/* Optic World Exclusive – Miami Driving Game
   Game world = pixel/retro (canvas). Branding & UI = clean, premium (DOM). */

@import url('https://fonts.googleapis.com/css2?family=Epilogue:wght@400;500;600;700;800&family=Manrope:wght@400;500;600;700&family=Silkscreen:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Racing+Sans+One:wght@400&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  --navy: #141A3A;
  --deep: #3A1D5C;
  --pink: #FF3D8B;
  --coral: #FF6B5A;
  --orange: #FFA23D;
  --turq: #2EE6D6;
  --off: #FFF4E6;
  --ink: #0A0C1E;
  --scrim: rgba(20, 26, 58, 0.82);
  --font-brand: "Epilogue", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Epilogue", "Helvetica Neue", Arial, sans-serif;
  --font-pixel: "Press Start 2P", monospace;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}



/* The game uses one fixed night-time palette in both themes. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --navy: #141A3A; --off: #FFF4E6; } }
:root[data-theme="dark"] { --navy: #141A3A; --off: #FFF4E6; }

*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  height: 100%; margin: 0; overflow: hidden;
  background: radial-gradient(120% 80% at 50% 0%, #2a1650 0%, var(--navy) 60%);
  background-color: var(--navy);
  color: var(--off);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
#app { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }

/* ---------- Stage (always 9:16, sized by JS) ---------- */
.stage {
  position: relative; overflow: hidden;
  width: 360px; height: 640px;           /* overwritten by JS */
  font-size: 16px;                        /* overwritten by JS: scales all UI */
  background: var(--navy);
  box-shadow: 0 0 0 1px rgba(255,244,230,.06), 0 30px 80px rgba(0,0,0,.5);
  user-select: none; -webkit-user-select: none;
}
@media (max-width: 600px) { .stage { box-shadow: none; } }
#game {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated; image-rendering: crisp-edges;
  touch-action: none; display: block;
}

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0; display: none;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, rgba(20,26,58,.25) 0%, rgba(20,26,58,.55) 45%, var(--scrim) 100%);
}
.screen-dim { background: var(--scrim); backdrop-filter: blur(2px); }
.screen-inner { min-height: 100%; display: flex; flex-direction: column; padding: 1.6em 1.4em 1.8em; }
.start-inner { justify-content: flex-end; gap: 1em; padding-bottom: 2.4em; }
.center-inner { justify-content: center; align-items: stretch; gap: .9em; text-align: center; }
.glasses-inner { gap: .9em; }
.result-inner { gap: .55em; align-items: center; justify-content: center; height: 100%; padding-top: 1.2em; padding-bottom: 1em; }

[data-state="START"] #screenStart,
[data-state="GLASSES_SELECTION"] #screenGlasses,
[data-state="PAUSED"] #screenPaused,
[data-state="GAME_OVER"] #screenGameOver,
[data-state="RESULT"] #screenResult { display: block; }

.brand {
  margin: 0; font-family: var(--font-brand); font-weight: 700;
  font-size: .78em; letter-spacing: .02em; color: var(--off); opacity: .9;
}
.title-xl, .title-l, .title-m {
  margin: 0; font-family: var(--font-brand); font-weight: 800; line-height: 1em; letter-spacing: -.01em;
}
.title-xl { font-family: "Racing Sans One", sans-serif; font-size: 1.5em; }
.title-l { font-family: "Racing Sans One", sans-serif; font-size: 1.75em; }
.title-m { font-family: "Racing Sans One", sans-serif; font-size: 1.2em; text-align: center; line-height: 1.05; }
.start-inner .title-xl {
  font-size: 2.5em;
  background: linear-gradient(180deg, var(--off) 0%, var(--off) 45%, #ff8f00 70%, var(--coral) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: none; filter: drop-shadow(0 .08em 0 rgba(10,12,30,.55));
  padding-left: 3px;
  text-transform: uppercase;
}
.lead { margin: 0; font-size: .95em; line-height: 1.45; max-width: 22em; font-weight: 500; }
.hint { margin: 0; font-size: .75em; opacity: .75; text-align: center; }

.logo img{ width:150px; height:auto; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit;
  font-family: var(--font-brand); font-weight: 800; font-size: 1.2em; letter-spacing: .02em;
  min-height: 3.1em; padding: 1.1rem 1.1rem 0.7rem 1.1rem; border-radius: .25em;
  color: var(--ink); background: var(--off);
  transition: transform .08s ease, background-color .15s ease, opacity .15s;
  text-transform: uppercase;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--pink); color: var(--off); box-shadow: 0 .22em 0 #A3134F; }
.btn-primary:active { box-shadow: 0 .08em 0 #A3134F; transform: translateY(.14em); }
.btn-alt { background: var(--turq); color: var(--ink); box-shadow: 0 .22em 0 #12857C; }
.btn-ghost { background: transparent; color: var(--off); box-shadow: inset 0 0 0 2px rgba(255,244,230,.5); }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; transform: none; }
.btn:focus-visible, .icon-btn:focus-visible, .glass-tile:focus-visible {
  outline: 3px solid var(--turq); outline-offset: 3px;
}
.btn-row { display: flex; gap: .6em; width: 100%; }
.btn-row .btn { flex: 1; font-size: .85em; }
#btnSound img,
#btnPause img {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

/* ---------- Glasses grid ---------- */
.glasses-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .55em; }
.glass-tile {
  position: relative; appearance: none; cursor: pointer; font: inherit; color: var(--off);
  border: 2px solid rgba(255,244,230,.16); border-radius: .3em;
  background: rgba(255,244,230,.07);
  padding: .55em .5em .5em; display: flex; flex-direction: column; align-items: center; gap: .35em;
  transition: border-color .15s, background-color .15s;
  min-height: 9rem;
  justify-content: center;
}
.glass-tile img { width: 100%; aspect-ratio: 600 / 220; object-fit: contain; pointer-events: none; }
.glass-tile .gname { font-family: var(--font-brand); font-weight: 700; font-size: .72em; }
.glass-tile[aria-pressed="true"] { border-color: var(--pink); background: rgba(255,61,139,.7); }
.glass-tile .check {
  position: absolute; top: .3em; right: 2em; left:2em; display: none;
  font-size: .6em; font-weight: 800; padding: .15em .45em; border-radius: 1em;
  background: var(--turq); color: var(--pink);
}
.glass-tile[aria-pressed="true"] .check { display: block; }

.howto {
  margin: .2em 0 0; display: flex; flex-direction: column; align-items: center; gap: .15em;
  font-family: var(--font-pixel); font-size: .72em; text-align: center; color: var(--turq); line-height: 1.3em;
}
.howto .arrows { font-size: 1.6em; color: var(--off); line-height: 1; }

/* ---------- HUD ---------- */
.hud {
  position: absolute; left: 0; right: 0; top: 0; padding: .7em .8em 1.4em; display: none;
  background: linear-gradient(180deg, rgba(10,12,30,.55), rgba(10,12,30,0));
  pointer-events: none;
}
[data-state="PLAYING"] .hud, [data-state="COUNTDOWN"] .hud, [data-state="PAUSED"] .hud { display: block; }
.hud-brand { font-family: var(--font-brand); font-weight: 700; font-size: .62em; opacity: .85; margin-bottom: .35em; text-align: center; }
.hud-row { display: flex; align-items: flex-end; gap: .9em; }
.hud-stat { display: flex; flex-direction: column; gap: .1em; }
.hud-label { font-family: var(--font-pixel); font-size: .55em; color: var(--turq); }
.hud-value { font-family: var(--font-pixel); font-weight: 700; font-size: 1.15em; line-height: 1; }
.hud-police { flex: 1; }
.meter { display: flex; gap: 2px; height: .75em; }
.meter i { flex: 1; background: rgba(255,244,230,.18); }
.meter i.on { background: var(--off); }
.meter.hot i.on { background: var(--pink); }
.meter.hot { animation: pulse .5s steps(2) infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.hud-buttons { display: flex; gap: .35em; pointer-events: auto; }
.icon-btn {
  appearance: none; border: 0; cursor: pointer; font: inherit;
  width: 2.4em; height: 2.4em; border-radius: .25em; font-size: .85em;
  background: rgba(255,244,230,.14); color: var(--off);
}

/* ---------- Countdown ---------- */
.countdown {
  position: absolute; inset: 0; display: none; place-items: center; pointer-events: none;
  font-family: var(--font-brand); font-weight: 800; font-size: 5.5em; color: var(--off);
  text-shadow: .05em .05em 0 var(--pink), -.03em -.03em 0 var(--turq);
}
[data-state="COUNTDOWN"] .countdown { display: grid; }
.countdown.pop { animation: pop .38s ease-out; }
@keyframes pop { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Game over ---------- */
.over-title { font-size: 3.2em; color: var(--off); text-shadow: .06em .06em 0 var(--pink); }
.stats { display: flex; justify-content: center; gap: 1.6em; margin: .4em 0 .6em; }
.stats div { display: flex; flex-direction: column; gap: .2em; }
.stats dt { font-family: var(--font-pixel); font-size: .6em; color: var(--turq); }
.stats dd { margin: 0; font-family: var(--font-pixel); font-weight: 700; font-size: 1.1em; }

/* ---------- Result ---------- */
/* the card takes whatever height is left, so title + text + CTA + link always fit on screen */
.card-wrap { flex: 1 1 0; min-height: 0; width: 100%; display: flex; justify-content: center; align-items: center; }
.card-wrap img { width: auto; height: auto; max-width: 72%; max-height: 100%; display: block; border-radius: .3em; box-shadow: 0 1em 2.4em rgba(0,0,0,.5); }

/* ---------- Loading & rotate ---------- */
.loading {
  position: absolute; inset: 0; display: grid; place-items: center; background: var(--navy);
  font-family: var(--font-pixel); font-size: .9em; color: var(--turq);
}
.loading[hidden] { display: none; }
.rotate {
  position: fixed; inset: 0; display: none; place-items: center; text-align: center;
  background: var(--navy); z-index: 10; font-family: var(--font-brand); font-weight: 800; font-size: 1.3em;
}
.rotate-icon { display: inline-block; font-size: 2.5em; transform: rotate(90deg); }
@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
  .rotate { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  .countdown.pop, .meter.hot { animation: none; }
  .btn { transition: none; }
}

@media screen and (max-width: 768px) {
  .glass-tile { min-height: 7rem; height: auto;}
}

/* ---------- Milestone / zone toast ---------- */
.toast {
  position: absolute; left: 50%; top: 24%; transform: translateX(-50%);
  display: none; flex-direction: column; align-items: center; gap: .25em;
  width: 90%; text-align: center; pointer-events: none; z-index: 3;
}
[data-state="PLAYING"] .toast.show { display: flex; animation: toastIn 2.2s ease-out forwards; }
.toast strong {
  font-family: "Racing Sans One", "Arial Black", sans-serif; font-weight: 400; font-size: 2.1em; line-height: 1;
  color: var(--off); text-shadow: .06em .06em 0 var(--pink), -.03em -.03em 0 var(--turq);
}
.toast span { font-family: var(--font-pixel); font-size: .62em; color: var(--turq); background: rgba(10,12,30,.72); padding: .45em .7em; border-radius: .25em; }
@keyframes toastIn {
  0% { opacity: 0; transform: translateX(-50%) scale(1.5); }
  12% { opacity: 1; transform: translateX(-50%) scale(1); }
  80% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-1em); }
}
@media (prefers-reduced-motion: reduce) { [data-state="PLAYING"] .toast.show { animation: none; } }

/* ---------- Prize game CTA (result screen) ---------- */
.prize-text { margin: .2em 0 0; max-width: 20em; text-align: center; font-size: .9em; line-height: 1.4; }
.prize-text strong { display: block; font-family: "Racing Sans One", "Arial Black", sans-serif; font-weight: 400; font-size: 1.5em; line-height: 1.1; margin-bottom: .2em; color: var(--off); }
.btn-prize { width: 100%; font-size: 1.25em; min-height: 2.9em; flex-shrink: 0; }

/* "újra megpróbálom" – plain text link under the prize CTA */
.text-link {
  appearance: none; background: none; border: 0; cursor: pointer; padding: .6em 1em;
  font-family: var(--font-body); font-size: .8em; font-weight: 500;
  color: var(--off); opacity: .85; text-decoration: underline; text-underline-offset: .2em;
}
.text-link:hover { opacity: 1; }
.text-link:focus-visible { outline: 3px solid var(--turq); outline-offset: 2px; }
