/* style.css — Leti, leti. Brend Terminia (R6) + dnevni/noćni režim (R5) + bez preliva (R14).
   Deca ≤7 (R13): velike mete (cela zona je meta), 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;
  --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);
  --good: #3FA34D; --danger: #D64545;
  --sky: #D8EEF6;
  --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: #232A31; --sky: #172733;
  --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; }
.pill.lives { color: var(--danger); letter-spacing: 2px; font-size: 16px; }

/* Igralište */
.play {
  position: relative; flex: 1 1 auto; min-height: 0; border-radius: 16px;
  background: linear-gradient(180deg, var(--sky), var(--card-face));
  box-shadow: 0 8px 30px var(--shadow); overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 12px; text-align: center;
}

/* Zona reakcije = cela sredina (velika meta za dete) */
.react-zone {
  appearance: none; -webkit-appearance: none; background: transparent; border: 0; cursor: pointer;
  flex: 1 1 auto; width: 100%; min-height: 0; padding: 8px; margin: 0; color: inherit; font: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border-radius: 14px; position: relative; touch-action: manipulation;
}
.react-zone:active { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.react-zone.flash-good { animation: flashGood .35s ease; }
.react-zone.flash-bad { animation: flashBad .4s ease; }
@keyframes flashGood { 0%,100% { background: transparent; } 40% { background: color-mix(in srgb, var(--good) 22%, transparent); } }
@keyframes flashBad { 0%,100% { transform: translateX(0); background: transparent; }
  20% { transform: translateX(-8px); background: color-mix(in srgb, var(--danger) 18%, transparent); }
  60% { transform: translateX(8px); } }

.chant { font-family: var(--font-play); font-weight: 700; color: var(--brand);
  font-size: clamp(18px, 5.5vw, 30px); min-height: 1.2em; }
:root[data-theme="night"] .chant { color: var(--accent); }

.stageItem { font-size: clamp(80px, 30vw, 190px); line-height: 1; display: block; will-change: transform; }
.stageItem.spawn { animation: pop .35s ease; }
.stageItem.fly-away { animation: flyAway .5s ease forwards; }
.stageItem.stay-put { animation: stayPut .5s ease; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
@keyframes flyAway { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(-120px) scale(.6) rotate(-12deg); opacity: 0; } }
@keyframes stayPut { 0%,100% { transform: translateY(0); } 30% { transform: translateY(6px); } 60% { transform: translateY(0); } }

.itemName { font-family: var(--font-play); font-weight: 600; color: var(--muted);
  font-size: clamp(14px, 4vw, 20px); min-height: 1.2em; text-transform: lowercase; }

/* Traka vremena (prozor reakcije) — nema teksta, jasna za decu */
.timebar { width: min(70%, 360px); height: 10px; border-radius: 999px; background: var(--chip); overflow: hidden; margin-top: 4px; }
.timebar-fill { display: block; height: 100%; width: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--accent)); transform-origin: left center; }

.feedback { min-height: 26px; font-family: var(--font-play); font-weight: 700; font-size: 18px; flex: 0 0 auto; }
.feedback.good { color: var(--good); }
.feedback.oops { color: var(--danger); }

/* Overlay (meni / rezultat) */
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 80%, 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: 22px 20px; max-width: 460px; width: 100%; box-shadow: 0 12px 40px var(--shadow);
  max-height: 100%; overflow-y: auto;
}
.ov-emoji { font-size: 56px; line-height: 1; margin-bottom: 6px; }
.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 18px; color: var(--muted); font-size: 15px; line-height: 1.45; }

.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; }
}
@media (prefers-reduced-motion: reduce) {
  .stageItem.spawn, .stageItem.fly-away, .stageItem.stay-put,
  .react-zone.flash-good, .react-zone.flash-bad { animation: none; }
}
