/* style.css — Memorija. 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;
  --card-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;
  --card-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: 720px; 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; }
#timerPill.warn { background: var(--danger); color: #fff; border-color: var(--danger); }

.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; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* Overlay (meni / rezultat) */
.overlay {
  position: absolute; inset: 0; 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 (težina / simboli / vreme) */
.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; align-items: center; justify-content: center; gap: 6px; min-width: 72px;
  min-height: 44px; padding: 8px 14px; border-radius: 12px; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 14px;
  color: var(--text); background: var(--bg); border: 2px solid var(--border-soft);
}
.opt.sym { flex-direction: column; gap: 3px; min-width: 76px; }
.sym-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); }
.hint.flash { color: var(--danger); animation: hintflash .3s ease; }
@keyframes hintflash { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

@media (max-width: 420px) {
  .pill { font-size: 13px; padding: 5px 10px; }
  .ov-title { font-size: 23px; }
  .stage { padding: 8px; }
  .opt { min-width: 64px; padding: 8px 10px; }
}
