/* style.css — Spoji slovo. Brend Terminia (R6) + dnevni/noćni režim (R5) + bez preliva (R14).
   Deca ≤7 (R13): velike mete (≥44px), krupna dugmad, malo teksta. */
:root {
  --brand: #0F6E56; --brand-dark: #085041; --brand-light: #E1F5EE; --accent: #5DCAA5;
  --paper: #EFE9DA; --ink: #2A2622; --muted: #6B6358; --chrome: #F5F2EA; --chip: #D8CFBB;
  --tile-face: #FBF8F0; --board: #DCE8E2;
  --bg: var(--paper); --text: var(--ink); --panel: var(--chrome); --border: var(--ink);
  --border-soft: color-mix(in srgb, var(--ink) 16%, transparent);
  --shadow: rgba(42,38,34,.28);
  --danger: #D64545;
  --font: 'Instrument Sans', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-play: 'Fredoka', var(--font);
}
:root[data-theme="night"] {
  --paper: #1A1F26; --ink: #D8D1BD; --muted: #8A8473; --chrome: #0A0C10; --chip: #2A3037;
  --tile-face: #F1ECDD; --board: #12181C;
  --shadow: rgba(0,0,0,.5); --border-soft: color-mix(in srgb, var(--ink) 20%, transparent);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* R14: nikad horizontalni preliv — nijedna aplikacija ne sme biti šira od ekrana */
html, body { margin: 0; height: 100dvh; width: 100%; max-width: 100%; overflow-x: hidden; background: var(--bg); color: var(--text); font-family: var(--font); }
body { display: flex; flex-direction: column; user-select: none; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; flex-wrap: wrap; row-gap: 8px;
  background: var(--panel); border-bottom: 1px solid var(--border-soft); flex: 0 0 auto;
}
.back { color: var(--brand); font-weight: 600; text-decoration: none; white-space: nowrap; }
:root[data-theme="night"] .back { color: var(--accent); }
.title { flex: 1; min-width: 0; text-align: center; font-size: 18px; margin: 0; color: var(--ink); font-weight: 700; font-family: var(--font-play); }
.controls { display: flex; align-items: center; gap: 8px; }
.controls select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; cursor: pointer;
}
.btn { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; font: inherit; font-weight: 600; cursor: pointer; }
.btn-round { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; font-size: 18px; }

.stage { flex: 1 1 auto; display: flex; padding: 12px; min-height: 0; }
.game { flex: 1; display: flex; flex-direction: column; gap: 10px; min-height: 0; max-width: 640px; margin: 0 auto; width: 100%; }

.hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; row-gap: 6px; }
.hud-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; row-gap: 6px; }
.pill {
  display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border-soft); color: var(--text);
  font-weight: 700; font-size: 14px; white-space: nowrap;
}
.pill.mono { font-variant-numeric: tabular-nums; min-width: 52px; justify-content: center; }

/* Tabla: dve kolone pločica + SVG sloj za linije spajanja */
.board-wrap { position: relative; flex: 1 1 auto; min-height: 0; border-radius: 16px;
  background: var(--board); box-shadow: 0 8px 30px var(--shadow); overflow: hidden; }
.links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.link-line { stroke: var(--brand); stroke-width: 5; stroke-linecap: round; opacity: .85; }
:root[data-theme="night"] .link-line { stroke: var(--accent); }

.board {
  position: absolute; inset: 0; z-index: 1;
  display: flex; justify-content: space-between; gap: 12px;
  padding: 14px; overflow-y: auto;
}
.col { display: flex; flex-direction: column; justify-content: center; gap: 10px; flex: 1 1 0; min-width: 0; }

.tile {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 56px; flex: 1 1 0; max-height: 88px;
  border-radius: 16px; cursor: pointer;
  background: var(--tile-face); color: var(--ink);
  border: 3px solid var(--border-soft);
  font-family: var(--font-play); font-weight: 700; font-size: clamp(26px, 8vw, 44px);
  line-height: 1; padding: 6px; transition: transform .08s ease, border-color .12s ease, background .12s ease;
}
.tile-pic { font-family: "Segoe UI Emoji", "Noto Color Emoji", "Apple Color Emoji", var(--font-play); }
.tile:hover { border-color: var(--brand); }
.tile.sel { border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark); transform: scale(1.04); }
:root[data-theme="night"] .tile.sel { background: color-mix(in srgb, var(--brand) 30%, transparent); color: var(--accent); border-color: var(--accent); }
.tile.matched { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--tile-face)); cursor: default; }
.tile.matched:hover { border-color: var(--accent); }
.tile.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 18%, var(--tile-face)); animation: shake .4s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* Overlay (meni / rezultat) */
.overlay {
  position: absolute; inset: 0; z-index: 3; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(3px);
  border-radius: 16px; padding: 16px; text-align: center; overflow-y: auto;
}
.overlay[hidden] { display: none; }
.overlay-card {
  background: var(--panel); border: 1px solid var(--border-soft); border-radius: 18px;
  padding: 20px; max-width: 460px; width: 100%; box-shadow: 0 12px 40px var(--shadow);
  max-height: 100%; overflow-y: auto;
}
.ov-title { margin: 0 0 6px; font-family: var(--font-play); font-size: 26px; color: var(--brand); }
:root[data-theme="night"] .ov-title { color: var(--accent); }
.ov-text { margin: 0 0 16px; color: var(--muted); font-size: 15px; line-height: 1.45; }

/* Biraci (režim) */
.pickers { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.pickers[hidden] { display: none; }
.picker { display: flex; flex-direction: column; gap: 8px; }
.picker-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }

.opt-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.opt {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-width: 120px; min-height: 56px; padding: 10px 14px; border-radius: 14px; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 14px;
  color: var(--text); background: var(--bg); border: 2px solid var(--border-soft);
}
.opt-ico { font-size: 22px; line-height: 1; font-family: var(--font-play); }
.opt.sel { border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark); }
:root[data-theme="night"] .opt.sel {
  background: color-mix(in srgb, var(--brand) 28%, transparent); color: var(--accent); border-color: var(--accent);
}

.ov-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand-dark); padding: 12px 24px; font-weight: 700; }
.btn-primary:hover { background: var(--brand-dark); }

.footer { display: flex; align-items: center; justify-content: center; min-height: 22px; flex: 0 0 auto; }
.hint { color: var(--brand); font-size: 14px; font-weight: 700; text-align: center; padding: 0 8px; }
:root[data-theme="night"] .hint { color: var(--accent); }

@media (max-width: 420px) {
  .pill { font-size: 13px; padding: 5px 10px; }
  .ov-title { font-size: 23px; }
  .stage { padding: 8px; }
  .board { padding: 10px; gap: 8px; }
  .tile { border-radius: 14px; }
}
