/* FALL LINE — crisp alpine morning UI */
@font-face {
  font-family: 'Russo One';
  src: url('../assets/russo-one.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
:root {
  --sky: #1d5fd0;
  --ink: #0b1e3a;
  --red: #e63946;
  --blue: #1d4ed8;
  --snow: #f6faff;
  --gold: #ffc53d;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b1e3a; }
body {
  font-family: 'Russo One', 'Arial Black', system-ui, sans-serif;
  color: var(--snow);
  -webkit-user-select: none; user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
kbd {
  font-family: inherit; font-size: .72em; background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.25); border-radius: 4px; padding: 1px 6px;
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud-tl {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: max(18px, env(safe-area-inset-left));
  text-shadow: 0 2px 0 rgba(8,24,52,.55), 0 0 18px rgba(30,80,180,.35);
}
#score { font-size: clamp(26px, 4.2vw, 44px); letter-spacing: .02em; line-height: 1; }
#mult {
  margin-top: 4px; font-size: clamp(12px, 1.6vw, 17px); color: var(--gold);
  letter-spacing: .08em; transition: transform .12s;
}
#mult.pump { transform: scale(1.25); }
#hud-tr {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: max(18px, env(safe-area-inset-right));
  text-align: right; text-shadow: 0 2px 0 rgba(8,24,52,.55);
}
#speed { font-size: clamp(30px, 5vw, 52px); line-height: .95; }
#hud-tr .unit { font-size: 12px; letter-spacing: .3em; opacity: .75; }
#alt { margin-top: 6px; font-size: clamp(12px, 1.6vw, 16px); color: #bcd7ff; letter-spacing: .06em; }

#toasts {
  position: absolute; top: 22%; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.toast {
  font-size: clamp(15px, 2.2vw, 24px); letter-spacing: .06em; white-space: nowrap;
  color: #fff; text-shadow: 0 2px 0 rgba(8,24,52,.6), 0 0 16px rgba(60,140,255,.5);
  animation: toast-pop 1.5s ease-out forwards;
}
.toast.gold { color: var(--gold); }
.toast.red { color: #ffb3ba; }
@keyframes toast-pop {
  0% { opacity: 0; transform: translateY(14px) scale(.8); }
  12% { opacity: 1; transform: translateY(0) scale(1.06); }
  20% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-18px); }
}

#zone-banner {
  position: absolute; top: 12%; left: 50%; transform: translateX(-50%);
  font-size: clamp(20px, 3.4vw, 38px); letter-spacing: .28em; white-space: nowrap;
  color: #fff; text-shadow: 0 3px 0 rgba(8,24,52,.6), 0 0 26px rgba(80,160,255,.6);
  opacity: 0; transition: opacity .5s;
}
#zone-banner.show { opacity: 1; }
#zone-banner small { display:block; text-align:center; font-size:.42em; letter-spacing:.5em; color:#bcd7ff; }

#hint {
  position: absolute; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  font-size: clamp(12px, 1.7vw, 16px); letter-spacing: .12em; color: #dceaff;
  text-shadow: 0 2px 0 rgba(8,24,52,.6); opacity: 0; transition: opacity .6s; text-align:center;
}
#hint.show { opacity: .95; }

/* ---------- vignette / flash ---------- */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 4;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(6,18,44,.42) 100%);
}
#flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 6;
  background: #fff; opacity: 0; transition: opacity .09s;
}
#flash.on { opacity: .28; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(8,22,52,.25) 0%, rgba(8,22,52,.62) 100%);
  backdrop-filter: blur(1.5px);
}
.title-wrap { text-align: center; padding: 20px; }
#logo {
  font-size: clamp(52px, 11vw, 128px); line-height: .9; letter-spacing: .02em;
  color: #fff; font-style: italic;
  text-shadow:
    0 4px 0 var(--blue), 0 8px 0 rgba(9,26,60,.9),
    0 12px 30px rgba(10,40,120,.55);
  transform: skewX(-6deg);
}
#logo span { color: var(--red); text-shadow: 0 4px 0 #7d1420, 0 8px 0 rgba(9,26,60,.9); }
.tagline {
  margin-top: 10px; font-size: clamp(13px, 2vw, 19px); letter-spacing: .5em;
  color: #cfe4ff; text-transform: uppercase;
}
.press {
  margin-top: 34px; font-size: clamp(15px, 2.4vw, 24px); letter-spacing: .14em;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.controls-grid {
  margin: 30px auto 0; display: grid; grid-template-columns: repeat(3, auto);
  gap: 10px 26px; justify-content: center; font-size: clamp(11px, 1.5vw, 15px);
}
.controls-grid div { display: flex; flex-direction: column; gap: 3px; }
.controls-grid b { color: #fff; letter-spacing: .06em; }
.controls-grid i { font-style: normal; color: #9db9e8; font-size: .85em; letter-spacing: .1em; }
.bests {
  margin-top: 26px; display: flex; gap: 22px; justify-content: center; flex-wrap: wrap;
  font-size: clamp(11px, 1.5vw, 14px); color: #9db9e8; letter-spacing: .08em;
}
.bests b { color: var(--gold); }

.panel {
  text-align: center; padding: 34px 44px; border-radius: 14px;
  background: rgba(8,22,52,.72); border: 1px solid rgba(140,190,255,.25);
  box-shadow: 0 20px 60px rgba(4,12,32,.6); min-width: min(420px, 92vw);
}
.panel h2 { font-size: clamp(26px, 4vw, 42px); letter-spacing: .18em; font-style: italic; }
.menu { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }
.mbtn {
  font-family: inherit; font-size: clamp(14px, 2vw, 18px); letter-spacing: .1em;
  padding: 12px 18px; border-radius: 8px; cursor: pointer;
  color: var(--snow); background: rgba(255,255,255,.08);
  border: 1px solid rgba(150,200,255,.3);
  transition: background .12s, transform .12s;
}
.mbtn:hover, .mbtn:focus-visible { background: rgba(90,160,255,.3); transform: translateY(-1px); outline: none; }
.mbtn.primary { background: var(--blue); border-color: #6ea8ff; }
.mbtn.primary:hover { background: #2f63e8; }
.pause-controls { margin-top: 22px; font-size: 12px; color: #9db9e8; letter-spacing: .1em; }

.newbest { color: var(--gold); letter-spacing: .2em; margin-top: 10px; font-size: 15px; animation: pulse 1.2s infinite; }
.sum-grid { margin-top: 20px; display: flex; flex-direction: column; gap: 7px; }
.sum-row {
  display: flex; justify-content: space-between; gap: 40px;
  font-size: clamp(13px, 2vw, 17px); letter-spacing: .08em;
}
.sum-row span { color: #9db9e8; }
.sum-row b { color: #fff; }

/* ---------- touch UI ---------- */
#touch-ui { position: fixed; inset: 0; z-index: 8; pointer-events: none; }
.tzone {
  position: absolute; bottom: 0; width: 34%; height: 42%;
  pointer-events: auto; opacity: .9;
}
#t-left { left: 0; } #t-right { left: 34%; width: 34%; }
.tzone .tlabel {
  position: absolute; bottom: calc(24px + env(safe-area-inset-bottom)); font-size: 34px;
  color: rgba(255,255,255,.5);
}
#t-left .tlabel { left: 26px; } #t-right .tlabel { right: 26px; }
.tbtn {
  position: absolute; pointer-events: auto;
  min-width: 76px; padding: 16px 12px; text-align: center; border-radius: 12px;
  font-size: 15px; letter-spacing: .12em;
  color: #fff; background: rgba(10,30,70,.45); border: 1px solid rgba(150,200,255,.35);
}
.tbtn.on { background: rgba(90,160,255,.55); }
#t-tuck { right: calc(16px + env(safe-area-inset-right)); bottom: calc(118px + env(safe-area-inset-bottom)); }
#t-hop { right: calc(16px + env(safe-area-inset-right)); bottom: calc(36px + env(safe-area-inset-bottom)); }
#t-brake { left: 50%; transform: translateX(-50%); bottom: calc(36px + env(safe-area-inset-bottom)); }
#t-pause { top: calc(60px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); min-width: 44px; padding: 8px 10px; font-size: 12px; }

#fatal {
  position: fixed; inset: 0; z-index: 99; display: flex; align-items: center; justify-content: center;
  background: #0b1e3a; color: #fff; font-size: 16px; text-align: center; padding: 30px;
}

@media (max-width: 640px) {
  .controls-grid { grid-template-columns: repeat(2, auto); }
  .panel { padding: 24px 20px; }
  #toasts { top: 18%; }
}
@media (pointer: coarse) {
  #hint { bottom: calc(200px + env(safe-area-inset-bottom)); }
}
