/* Copyright (c) 2026 Yoda Games. All rights reserved.
   Near Miss Highway — the play page. The 3D road fills the frame; the bank, what is at
   risk, speed and the buttons sit over it; the cards come up over the road. Nunito is the site's
   own font file (already cached by the shell page). */
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 800 900; font-display: swap; src: url(/fonts/nunito-v32-latin.woff2) format('woff2'); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #d5e8f2; overscroll-behavior: none; }
body { font: 800 16px/1.3 Nunito, system-ui, -apple-system, 'Segoe UI', sans-serif; color: #fff; -webkit-user-select: none; user-select: none; touch-action: none; }
#app { position: fixed; inset: 0; overflow: hidden; }
#app:focus { outline: none; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.hbtn:focus-visible { box-shadow: 0 0 0 7px rgba(8, 14, 28, .85); }

/* ── the bar at the top */
#hud { position: absolute; left: 0; right: 0; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); z-index: 3; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-c { pointer-events: none !important; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hud-l { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.nitro { display: inline-flex; align-items: center; gap: 7px; padding: 4px 9px; border-radius: 10px; background: rgba(9, 16, 32, .5); font-size: 12px; }
.nitro .lbl { letter-spacing: 1px; text-transform: uppercase; opacity: .82; }
.nitro .gauge { position: relative; display: block; width: 64px; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .16); overflow: hidden; }
.nitro .gauge i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 4px; background: linear-gradient(90deg, #3ab8ff, #8fe6ff); }
.nitro.full { box-shadow: inset 0 0 0 2px rgba(120, 220, 255, .8); }
.nitro.full .gauge i { animation: nfull .7s ease-in-out infinite alternate; }
.nitro.on .gauge i { background: linear-gradient(90deg, #ffffff, #8fe6ff); }
@keyframes nfull { to { filter: brightness(1.6); } }
.touch .nitro { display: none; }
.hud-r { display: flex; justify-content: flex-end; gap: 7px; }
.speed { display: inline-flex; align-items: baseline; gap: 5px; padding: 5px 12px 6px; border-radius: 14px; background: rgba(9, 16, 32, .62); font-variant-numeric: tabular-nums; }
.speed b { font-size: 26px; font-weight: 900; line-height: 1; min-width: 2.2em; text-align: right; }
.speed i { font-style: normal; font-size: 13px; opacity: .8; }
.dist { padding: 3px 10px; border-radius: 10px; background: rgba(9, 16, 32, .5); font-size: 13px; font-variant-numeric: tabular-nums; }
.bank { display: inline-flex; align-items: baseline; gap: 8px; padding: 6px 16px 7px; border-radius: 16px; background: rgba(9, 16, 32, .66); box-shadow: inset 0 0 0 2px rgba(61, 220, 132, .55); }
.bank .lbl, .pot .lbl { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; opacity: .82; }
.bank b { font-size: 30px; font-weight: 900; line-height: 1; color: #6ff0a6; font-variant-numeric: tabular-nums; }
.bank.gain { animation: gain .5s ease-out; }
@keyframes gain { 0% { transform: scale(1.18); } 100% { transform: scale(1); } }
.pot { display: inline-flex; align-items: center; gap: 8px; padding: 5px 8px 5px 12px; border-radius: 14px; background: rgba(9, 16, 32, .6); font-variant-numeric: tabular-nums; transition: box-shadow .2s; }
.pot b { font-size: 20px; font-weight: 900; line-height: 1; color: #ffd34d; min-width: 2.6em; }
.pot.hot { box-shadow: inset 0 0 0 2px rgba(255, 196, 46, .8); }
/* banking now would beat the best: a star on the pill and the button */
.pot.beat::before { content: '★'; color: #ffd60a; font-size: 15px; margin-right: -2px; text-shadow: 0 0 8px rgba(255, 214, 10, .8); animation: star 1.2s ease-in-out infinite; }
@keyframes star { 50% { transform: scale(1.25); } }
/* the edge of the screen glows for a close call, a long chain or a new best */
#edge { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; box-shadow: inset 0 0 120px 26px rgba(255, 214, 90, .5); }
#edge.flash { animation: edge .5s ease-out; }
#edge.gold { box-shadow: inset 0 0 150px 34px rgba(255, 200, 40, .65); animation: edge 1.1s ease-out; }
@keyframes edge { from { opacity: 1; } to { opacity: 0; } }
.mult { padding: 3px 8px; border-radius: 999px; background: #ff7a1a; color: #fff; font-size: 15px; font-weight: 900; line-height: 1.1; }
.mult.up { animation: up .35s ease-out; }
@keyframes up { 0% { transform: scale(1.5); background: #ffe14d; color: #3a2400; } 100% { transform: scale(1); } }
.key { padding: 2px 7px; border-radius: 7px; background: #fff; color: #17202f; font: inherit; font-size: 12px; box-shadow: 0 2px 0 #9aa4b5; }
.hbtn { width: 40px; height: 40px; border-radius: 12px; background: rgba(9, 16, 32, .6); display: grid; place-items: center; }
.hbtn svg { width: 22px; height: 22px; fill: currentColor; }
.hbtn:hover { background: rgba(9, 16, 32, .78); }
#btn-sound[aria-pressed='true'] .cross, #btn-sound[aria-pressed='false'] .wave { display: none; }

/* ── help and the floating words */
.tip { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); padding: 10px 18px; border-radius: 14px; background: rgba(9, 16, 32, .74); font-size: 18px; text-align: center; white-space: nowrap; z-index: 3; animation: bob 1.4s ease-in-out infinite; pointer-events: none; }
.tip kbd { display: inline-block; min-width: 26px; padding: 2px 6px; margin: 0 2px; border-radius: 7px; background: #fff; color: #17202f; font: inherit; font-size: 15px; box-shadow: 0 2px 0 #9aa4b5; }
.tip small { display: block; margin-top: 4px; font-size: 13px; opacity: .85; }
@keyframes bob { 50% { transform: translate(-50%, -5px); } }
.pops { position: absolute; left: 0; right: 0; top: 42%; height: 0; z-index: 3; pointer-events: none; }
.pop { position: absolute; left: 50%; top: 0; transform: translate(-50%, 0); white-space: nowrap; font-size: 26px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 rgba(9, 16, 32, .6), 0 0 14px rgba(9, 16, 32, .35); animation: pop 1s ease-out forwards; }
.pop small { display: block; text-align: center; font-size: 16px; color: #ffd34d; }
.pop.close { color: #ffe14d; font-size: 32px; }
.pop.nitro { color: #8fe6ff; font-size: 34px; letter-spacing: 2px; }
.pop.chain { color: #ff9a3c; font-size: 30px; letter-spacing: 1px; }
.pop.bank { color: #6ff0a6; font-size: 30px; }
.pop.far { color: #ffd60a; font-size: 30px; letter-spacing: 1px; }
.pop.best { color: #ffd60a; font-size: 34px; letter-spacing: 1px; }
.pop.bad { color: #ff6b5a; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, 14px) scale(.7); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 70% { opacity: 1; transform: translate(-50%, -26px) scale(1); } 100% { opacity: 0; transform: translate(-50%, -48px) scale(1); } }

/* ── touch controls */
.pad { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); z-index: 3; pointer-events: none; }
.pad-l, .pad-r { display: flex; gap: 12px; align-items: flex-end; pointer-events: auto; }
.pbtn { width: 74px; height: 74px; border-radius: 50%; background: rgba(9, 16, 32, .45); border: 2px solid rgba(255, 255, 255, .55); display: grid; place-items: center; font-size: 13px; letter-spacing: .5px; touch-action: none; }
.pbtn svg { width: 38px; height: 38px; }
.pbtn.small { width: 66px; height: 66px; background: rgba(215, 60, 60, .55); font-size: 12px; }
.bankbtn { width: 92px; height: 92px; background: rgba(40, 170, 96, .85); border-color: #b6ffd5; font-size: 19px; font-weight: 900; box-shadow: 0 0 0 0 rgba(111, 240, 166, .6); }
.bankbtn.hot { animation: ready 1.1s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 0 0 10px rgba(111, 240, 166, 0); } 0% { box-shadow: 0 0 0 0 rgba(111, 240, 166, .6); } }
.pad-col { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.nitrobtn { position: relative; width: 60px; height: 60px; font-size: 11px; font-weight: 900; color: #e6f8ff; background: rgba(9, 16, 32, .55); border-color: rgba(143, 216, 255, .55); }
.nitrobtn::before { content: ''; position: absolute; inset: -6px; border-radius: 50%; pointer-events: none; background: conic-gradient(#5fd2ff calc(var(--g, 0) * 1turn), rgba(255, 255, 255, .14) 0); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px)); mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px)); }
.nitrobtn.full { background: rgba(32, 140, 214, .85); border-color: #c9f1ff; animation: nready 1s ease-in-out infinite; }
.nitrobtn.on { background: rgba(160, 230, 255, .9); color: #0b2a3a; }
@keyframes nready { 50% { box-shadow: 0 0 0 9px rgba(95, 210, 255, 0); } 0% { box-shadow: 0 0 0 0 rgba(95, 210, 255, .65); } }
.pbtn.on { background: rgba(255, 255, 255, .5); transform: scale(.94); }
.pbtn.small.on { background: rgba(215, 60, 60, .9); }
.bankbtn.pressed { background: #2fd17a; }
.bankbtn.beat { position: relative; border-color: #ffd60a; }
.bankbtn.beat::after { content: '★'; position: absolute; top: -6px; right: -2px; color: #ffd60a; font-size: 20px; text-shadow: 0 0 8px rgba(255, 214, 10, .9); }
.nitrobtn.pressed { transform: scale(.94); }

/* ── cards */
.card { position: absolute; left: 50%; transform: translateX(-50%); width: min(400px, calc(100% - 28px)); padding: 20px 20px 18px; border-radius: 22px; background: rgba(12, 20, 38, .9); box-shadow: 0 14px 44px rgba(0, 0, 0, .4), inset 0 0 0 1px rgba(255, 255, 255, .08); text-align: center; z-index: 5; }
.card.dock { bottom: max(22px, env(safe-area-inset-bottom)); }
.card.mid { top: 50%; transform: translate(-50%, -50%); }
.card h1, .card h2 { margin: 0; font-weight: 900; }
.card h2 { font-size: 28px; }
.logo { font-size: 46px; line-height: 1; letter-spacing: 1px; text-transform: uppercase; font-style: italic; text-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.logo em { color: #ffd34d; font-style: inherit; }
.sub { margin: 10px 0 16px; font-size: 15px; opacity: .9; }
.hint { margin: 12px 0 0; font-size: 13px; opacity: .7; }
.best { margin: 10px 0 0; font-size: 15px; color: #6ff0a6; }
.btn-main { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 56px; padding: 0 34px 0 28px; border-radius: 999px; background: #12A870; color: #04210F; font-size: 20px; font-weight: 900; text-transform: uppercase; letter-spacing: .5px; box-shadow: 0 4px 0 #0E8C5C, 0 8px 22px rgba(18, 168, 112, .35); }
.btn-main svg { width: 16px; height: 20px; fill: #04210F; }
.btn-main:hover { transform: translateY(-1px); }
.btn-main:active { transform: translateY(2px); box-shadow: 0 2px 0 #0E8C5C; }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 12px; }
.btn-ghost { height: 42px; padding: 0 18px; border-radius: 999px; background: rgba(255, 255, 255, .12); font-size: 15px; }
.btn-ghost:hover { background: rgba(255, 255, 255, .2); }
.badge { position: absolute; top: -14px; left: 50%; transform: translateX(-50%) rotate(-3deg); padding: 5px 14px; border-radius: 999px; background: #ffd21f; color: #2a1c00; font-size: 14px; font-weight: 900; text-transform: uppercase; white-space: nowrap; }
.score-lbl { margin: 10px 0 0; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; opacity: .75; }
.score { font-size: 48px; font-weight: 900; line-height: 1.05; color: #6ff0a6; font-variant-numeric: tabular-nums; }
.lines { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 12px 0 16px; }
.lines div { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 8px 7px; border-radius: 11px; background: rgba(255, 255, 255, .08); }
.lines dt { font-size: 11.5px; letter-spacing: .6px; text-transform: uppercase; white-space: nowrap; opacity: .74; }
.lines dd { margin: 0; font-size: 17px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.boot-error { position: fixed; inset: auto 12px 12px 12px; padding: 12px 14px; border-radius: 12px; background: #b3261e; color: #fff; text-align: center; z-index: 9; }

/* ── phones and small frames */
@media (max-width: 640px), (max-height: 460px) {
  .hbtn { width: 36px; height: 36px; border-radius: 10px; }
  .hbtn svg { width: 20px; height: 20px; }
  .speed b { font-size: 21px; }
  .bank b { font-size: 24px; }
  .pot b { font-size: 17px; }
  .logo { font-size: 38px; }
  .tip { font-size: 15px; top: 24%; }
  .pop { font-size: 21px; } .pop.close { font-size: 25px; } .pop.bank { font-size: 24px; }
  .score { font-size: 40px; }
}
@media (max-width: 480px) {
  /* the middle may be narrower than the pot pill under the bank: that row has nothing else on it */
  #hud { grid-template-columns: auto minmax(0, 1fr) auto; }
  .bank b { font-size: clamp(18px, 6.4vw, 24px); }
  .hud-c { align-items: center; }
  .dist { display: none; }
  .speed { padding: 4px 9px 5px; }
  .speed i { display: none; }
  .bank { padding: 5px 12px 6px; }
  .bank .lbl { display: none; }
  .pot .lbl, .key { display: none; }
}
@media (max-height: 460px) {
  .card { padding: 12px 16px; }
  .card.dock { bottom: 10px; }
  .sub { margin: 4px 0 8px; }
  .hint { display: none; }
  .btn-main { height: 46px; font-size: 17px; }
  .score { font-size: 32px; }
  .lines { margin: 6px 0 10px; }
  .lines div { padding: 3px 8px 4px; }
  .pbtn { width: 62px; height: 62px; }
  .pbtn.small { width: 56px; height: 56px; }
  .bankbtn { width: 76px; height: 76px; }
}
@media (max-width: 380px) { .pbtn { width: 62px; height: 62px; } .pbtn.small { width: 56px; height: 56px; } .bankbtn { width: 78px; height: 78px; } .pad-l, .pad-r { gap: 8px; } .nitrobtn { width: 52px; height: 52px; } .pad-col { gap: 8px; } }
@media (max-height: 460px) { .nitrobtn { width: 52px; height: 52px; } .pad-col { gap: 8px; } }
@media (pointer: coarse) { .key { display: none; } .hud-r { gap: 10px; } .hbtn { position: relative; } .hbtn::after { content: ''; position: absolute; inset: -4px; } }
@media (max-width: 360px) { .hud-r { gap: 8px; } .hbtn { width: 34px; height: 34px; } }
@media (prefers-reduced-motion: reduce) { .tip, .mult.up, .bank.gain, .bankbtn.hot, .pot.beat::before { animation: none; } .pop { animation-duration: .01s; animation-delay: .9s; } #edge.flash, #edge.gold { animation-duration: .3s; } }
@media (forced-colors: active) { .mult { forced-color-adjust: none; } }
