/* Neon Driftline - interface in a flat enamel-signboard style (red / cream / ink / mustard / jade,
   double keylines, hard print shadows, system fonts). Copyright (c) 2026 Vipex Technology Co., Ltd. */
:root {
  --red: #c8231b;
  --cream: #f4ead2;
  --paper: #e8dcc0;
  --ink: #1b1a17;
  --mustard: #f2b705;
  --jade: #1f7a5a;
  --muted: #8c8577;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --display: "Helvetica Neue", "Arial Black", Arial, system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --keyline: inset 0 0 0 2px var(--cream), inset 0 0 0 4px var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; width: 100%;
  overflow: hidden; position: fixed; inset: 0;
  background: var(--ink); color: var(--ink);
  font-family: var(--body);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  touch-action: none; overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
body.frozen *, body.frozen *::before, body.frozen *::after { animation-play-state: paused !important; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; background: var(--ink); touch-action: none; }

button {
  font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0;
  cursor: pointer; touch-action: manipulation;
}
button:focus { outline: none; }
button:focus-visible { outline: 3px solid var(--mustard); outline-offset: 3px; }

/* ---------- enamel parts ---------- */
.logo {
  margin: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 22px 12px; background: var(--red); color: var(--cream);
  border: 3px solid var(--ink); border-radius: 8px;
  box-shadow: inset 0 0 0 3px var(--red), inset 0 0 0 5px var(--cream), 6px 6px 0 var(--ink);
  font-family: var(--display); font-weight: 900; text-transform: uppercase; line-height: 1;
}
.logo-top { font-size: 15px; letter-spacing: 0.6em; margin-right: -0.6em; color: var(--mustard); }
.logo-main { font-size: clamp(34px, 10.5vmin, 54px); letter-spacing: 0.04em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 6px;
  font-family: var(--display); font-weight: 900; font-size: 18px; letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--cream); color: var(--ink); border: 3px solid var(--ink);
  box-shadow: var(--keyline), 4px 4px 0 var(--ink);
  transition: transform 0.05s linear;
}
.btn:active { transform: translate(3px, 3px); box-shadow: var(--keyline), 1px 1px 0 var(--ink); }
.btn.primary {
  min-height: 60px; font-size: 26px; padding: 0 38px;
  background: var(--red); color: var(--cream);
  box-shadow: inset 0 0 0 2px var(--red), inset 0 0 0 4px var(--cream), 5px 5px 0 var(--ink);
}
.btn.primary:active { box-shadow: inset 0 0 0 2px var(--red), inset 0 0 0 4px var(--cream), 2px 2px 0 var(--ink); }
.btn em { font-style: normal; font-size: 12px; background: var(--jade); color: var(--cream); border: 2px solid var(--ink); border-radius: 4px; padding: 1px 6px; letter-spacing: 0.02em; }
.btn em:empty { display: none; }
.btn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.round-btn {
  width: 46px; height: 46px; border-radius: 6px; position: relative;
  display: grid; place-items: center;
  background: var(--cream); border: 3px solid var(--ink);
  box-shadow: var(--keyline), 3px 3px 0 var(--ink);
}
.round-btn:active { transform: translate(2px, 2px); box-shadow: var(--keyline), 1px 1px 0 var(--ink); }
.bars { width: 14px; height: 16px; border-left: 5px solid var(--ink); border-right: 5px solid var(--ink); }
.chev { width: 13px; height: 13px; border-left: 4px solid var(--ink); border-bottom: 4px solid var(--ink); transform: translateX(3px) rotate(45deg); }
.note { width: 20px; height: 20px; position: relative; }
.note::before { content: ""; position: absolute; left: 2px; bottom: 0; width: 9px; height: 8px; border-radius: 50%; background: var(--ink); }
.note::after { content: ""; position: absolute; left: 8px; top: 0; width: 8px; height: 16px; border-left: 3px solid var(--ink); border-top: 3px solid var(--ink); }
.sound.off .note { opacity: 0.35; }
.sound.off::after { content: ""; position: absolute; width: 30px; height: 4px; background: var(--red); transform: rotate(-40deg); }

/* ---------- boot ---------- */
.screen { position: fixed; inset: 0; z-index: 20; }
.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 30px; background: var(--ink); }
.bar { width: min(240px, 60vw); height: 14px; border: 3px solid var(--cream); background: var(--ink); }
.bar i { display: block; height: 100%; width: 0; background: var(--mustard); transition: width 0.15s linear; }

/* ---------- title (the renderer paints a still frame of the road behind it) ---------- */
.title { background: rgba(27, 26, 23, 0.18); }
.title-card {
  position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%);
  width: min(360px, calc(100% - 28px));
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  padding: 20px 16px 12px; background: var(--cream);
  border: 3px solid var(--ink); border-radius: 10px;
  box-shadow: var(--keyline), 7px 7px 0 var(--ink);
}
.title-card .logo { margin-top: -2px; }
.tagline { margin: 0; padding: 4px 10px; background: var(--jade); color: var(--cream); border: 2px solid var(--ink); font-size: 12px; font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; }
.title-best { font-family: var(--display); font-weight: 900; letter-spacing: 0.14em; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.title-best b { font-size: 22px; background: var(--mustard); border: 2px solid var(--ink); padding: 0 10px; box-shadow: 3px 3px 0 var(--ink); }
.title-card .btn.primary { min-width: 220px; }
.sound { position: absolute; left: calc(12px + var(--safe-l)); top: calc(12px + var(--safe-t)); }
.made-by { margin: 2px 0 0; font-size: 10px; color: var(--muted); letter-spacing: 0.18em; text-transform: uppercase; font-weight: 700; }

@media (orientation: landscape) and (max-height: 620px), (min-aspect-ratio: 13/10) and (min-width: 900px) {
  .title-card { left: auto; right: calc(24px + var(--safe-r)); top: 50%; bottom: auto; transform: translateY(-50%); gap: 9px; padding-top: 16px; }
  .logo-main { font-size: clamp(30px, 9vh, 50px); }
}
@media (orientation: landscape) and (max-height: 420px) {
  .title-card { gap: 7px; padding: 12px 14px 8px; }
  .title-card .btn.primary { min-height: 50px; font-size: 22px; }
  .title-card .btn { min-height: 42px; }
  .made-by { display: none; }
}

/* ---------- panels (garage, help) ---------- */
.panel-screen {
  display: flex; flex-direction: column;
  padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) calc(12px + var(--safe-b)) calc(16px + var(--safe-l));
  background: var(--ink); color: var(--cream);
}
.panel-head { display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 12px; padding-right: 130px; }
.panel-head h2 {
  justify-self: start; margin: 0; padding: 6px 16px; background: var(--red); color: var(--cream);
  border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px var(--red), inset 0 0 0 4px var(--cream);
  font-family: var(--display); font-weight: 900; font-size: 22px; letter-spacing: 0.1em;
}
.count { font-family: var(--display); font-weight: 900; color: var(--ink); background: var(--mustard); padding: 3px 8px; border: 2px solid var(--cream); font-size: 15px; white-space: nowrap; }
.count:empty { display: none; }
.panel-note { margin: 12px 0; text-align: center; color: var(--paper); font-size: 13px; }
.garage-grid {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; align-content: start;
  padding: 4px 6px 14px 2px; scrollbar-width: none;
}
.garage-grid::-webkit-scrollbar { display: none; }
.car-card {
  position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: auto auto 1fr; column-gap: 10px;
  text-align: left; padding: 10px; min-height: 110px; min-width: 0; border-radius: 6px; color: var(--ink);
  background: var(--cream); border: 3px solid var(--ink); box-shadow: var(--keyline), 4px 4px 0 #000;
}
.car-card .thumb {
  grid-row: 1 / 4; width: 44px; height: 92px;
  background-image: url("assets/img/cars.webp"); background-size: 700% 200%; background-repeat: no-repeat;
}
.car-card .name { font-family: var(--display); font-weight: 900; font-size: 14px; line-height: 1.1; text-transform: uppercase; overflow-wrap: break-word; min-width: 0; }
.car-card .driver { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; font-weight: 700; }
.car-card .avatar { width: 28px; height: 28px; border-radius: 50%; background-image: url("assets/img/drivers.webp"); background-size: 700% 200%; border: 2px solid var(--ink); }
.car-card .tag { align-self: end; justify-self: start; max-width: 100%; font-size: 10px; font-weight: 900; letter-spacing: 0; white-space: nowrap; padding: 2px 5px; background: var(--jade); color: var(--cream); }
.car-card.selected { background: var(--mustard); }
.car-card.selected .tag { background: var(--ink); color: var(--mustard); }
.car-card.locked { background: var(--paper); }
.car-card.locked .thumb { filter: brightness(0); opacity: 0.55; }
.car-card.locked .avatar { filter: grayscale(1); opacity: 0.5; }
.car-card.locked .name, .car-card.locked .driver { color: var(--muted); }
.car-card.locked .tag { background: var(--red); }

.help-steps {
  flex: 1; min-height: 0; overflow-y: auto; touch-action: pan-y; scrollbar-width: none;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; align-content: start; padding: 12px 6px 6px 2px;
}
.help-steps::-webkit-scrollbar { display: none; }
.step {
  display: grid; grid-template-columns: 52px 1fr; grid-template-rows: auto 1fr; column-gap: 12px; padding: 12px;
  background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 6px; box-shadow: var(--keyline), 4px 4px 0 #000;
}
.step b { font-family: var(--display); font-weight: 900; font-size: 18px; letter-spacing: 0.08em; }
.step span { font-size: 14px; line-height: 1.35; }
.step-art { grid-row: 1 / 3; width: 52px; height: 52px; border-radius: 50%; position: relative; background: var(--cream); border: 3px solid var(--ink); }
.step-art::before { content: ""; position: absolute; inset: 13px; border-radius: 50%; background: var(--red); border: 3px solid var(--ink); }
.step-art.hold::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; border: 3px dashed var(--jade); }
.step-art.release::after { content: ""; position: absolute; left: 30px; top: 6px; width: 20px; height: 5px; background: var(--jade); transform: rotate(-35deg); transform-origin: left; }
.step-art.perfect::before { background: var(--mustard); }
.step-art.world { background: linear-gradient(135deg, #2a2d34 0 25%, #6f8f4a 25% 50%, #5d6c45 50% 75%, #e8edf2 75%); }
.step-art.world::before { display: none; }
@media (orientation: landscape) and (max-height: 520px) {
  .step { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; row-gap: 6px; }
  .step-art { grid-row: auto; width: 40px; height: 40px; }
  .step-art::before { inset: 9px; }
  .step span { font-size: 13px; }
}

/* ---------- in-run HUD ---------- */
.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud > * { pointer-events: auto; }
#btn-pause { position: absolute; left: calc(12px + var(--safe-l)); top: calc(12px + var(--safe-t)); }
.best-mini {
  position: absolute; left: calc(12px + var(--safe-l)); top: calc(68px + var(--safe-t)); pointer-events: none;
  padding: 2px 7px; background: var(--ink); color: var(--cream); border: 2px solid var(--cream);
  font-family: var(--display); font-weight: 900; font-size: 12px; letter-spacing: 0.08em;
}
.speedo {
  position: absolute; left: calc(12px + var(--safe-l)); top: calc(96px + var(--safe-t)); pointer-events: none;
  width: 96px; padding: 4px 6px 6px; background: var(--cream); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
}
.speed-read { display: flex; align-items: baseline; gap: 4px; font-family: var(--display); font-weight: 900; line-height: 1; }
.speed-read b { font-size: 20px; min-width: 38px; }
.speed-read small { font-size: 9px; letter-spacing: 0.08em; }
.speed-read em { margin-left: auto; font-style: normal; font-size: 10px; padding: 1px 3px; background: var(--mustard); border: 1.5px solid var(--ink); }
.speed-read em:empty { display: none; }
.speed-bar { display: flex; height: 7px; margin-top: 4px; background: var(--ink); border: 1.5px solid var(--ink); }
.speed-bar i { display: block; height: 100%; width: 0; }
#speed-floor { background: var(--jade); }
#speed-boost { background: var(--mustard); }
.scorebox { position: absolute; left: 50%; top: calc(10px + var(--safe-t)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.score {
  min-width: 78px; padding: 4px 14px 2px; text-align: center;
  font-family: var(--display); font-weight: 900; font-size: 40px; line-height: 1; color: var(--ink);
  background: var(--cream); border: 3px solid var(--ink); border-radius: 6px; box-shadow: var(--keyline), 4px 4px 0 var(--ink);
}
.score.bump { animation: bump 0.22s ease-out; }
@keyframes bump { 40% { transform: scale(1.14); } }
.chain {
  padding: 2px 9px; font-family: var(--display); font-weight: 900; font-size: 15px; letter-spacing: 0.06em;
  color: var(--ink); background: var(--mustard); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
  opacity: 0; transform: scale(0.8); transition: opacity 0.15s, transform 0.15s;
}
.chain.on { opacity: 1; transform: scale(1); }
.banner {
  position: absolute; left: 50%; top: 24%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; text-align: center;
  animation: banner 2.6s steps(1, end) forwards; white-space: nowrap;
}
.banner small { font-size: 11px; font-weight: 900; letter-spacing: 0.4em; padding: 2px 8px 2px 12px; background: var(--mustard); color: var(--ink); border: 2px solid var(--ink); }
.banner b {
  padding: 6px 18px; font-family: var(--display); font-weight: 900; font-size: clamp(26px, 7vmin, 44px); letter-spacing: 0.06em;
  background: var(--red); color: var(--cream); border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--red), inset 0 0 0 4px var(--cream), 5px 5px 0 var(--ink);
}
.banner span { padding: 2px 10px; background: var(--ink); color: var(--cream); font-size: 12px; font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; }
@keyframes banner { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- overlays ---------- */
.veil { position: fixed; inset: 0; z-index: 30; }
.veil.center { display: grid; place-items: center; background: rgba(27, 26, 23, 0.55); padding: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l)); }
.card {
  width: min(360px, 100%); max-height: 100%; overflow: hidden;
  display: flex; flex-direction: column; align-items: stretch; gap: 12px; text-align: center;
  padding: 18px 16px; background: var(--cream); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 10px; box-shadow: var(--keyline), 7px 7px 0 var(--ink);
}
.card h2 {
  margin: 0 0 4px; padding: 6px; background: var(--red); color: var(--cream);
  border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px var(--red), inset 0 0 0 4px var(--cream);
  font-family: var(--display); font-weight: 900; font-size: 28px; letter-spacing: 0.12em;
}
.card .btn-row .btn { flex: 1; padding: 0 10px; white-space: nowrap; font-size: 16px; }
.kicker { margin: 0; padding: 5px; background: var(--red); color: var(--cream); border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px var(--red), inset 0 0 0 4px var(--cream); font-size: 14px; letter-spacing: 0.3em; font-weight: 900; font-family: var(--display); }
.result-score { font-family: var(--display); font-weight: 900; font-size: 80px; line-height: 0.95; color: var(--ink); text-shadow: 4px 4px 0 var(--mustard); }
.result-best { display: flex; gap: 10px; justify-content: center; align-items: center; font-family: var(--display); font-weight: 900; letter-spacing: 0.1em; }
.newbest { padding: 2px 8px; background: var(--mustard); border: 2px solid var(--ink); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 2px 0; }
.stats div { padding: 6px 4px; background: var(--paper); border: 2px solid var(--ink); }
.stats dt { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.stats dd { margin: 2px 0 0; font-family: var(--display); font-weight: 900; font-size: 22px; }
.unlock { margin: 0; padding: 7px; background: var(--jade); color: var(--cream); border: 2px solid var(--ink); font-weight: 800; font-size: 14px; }

@media (orientation: landscape) and (max-height: 520px) {
  .result-card { width: min(640px, 100%); display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; row-gap: 8px; padding: 14px 16px; }
  .result-card > * { grid-column: 1; }
  .result-card .stats, .result-card .unlock, .result-card #btn-again, .result-card .btn-row { grid-column: 2; }
  .result-card .kicker { grid-row: 1; }
  .result-card .result-score { grid-row: 2 / 4; align-self: center; font-size: 72px; }
  .result-card .result-best { grid-row: 4; }
  .result-card .stats { grid-row: 1 / 3; }
  .result-card .unlock { grid-row: 3; }
  .result-card #btn-again { grid-row: 4; }
  .result-card .btn-row { grid-row: 5; }
  .card h2 { font-size: 24px; }
}

.ready { display: flex; align-items: flex-end; justify-content: center; padding: 0 calc(16px + var(--safe-r)) calc(22px + var(--safe-b)) calc(16px + var(--safe-l)); pointer-events: none; }
.ready .back { position: absolute; left: calc(12px + var(--safe-l)); top: calc(12px + var(--safe-t)); pointer-events: auto; }
.ready-card { width: min(400px, 100%); padding: 14px 16px; background: var(--cream); border: 3px solid var(--ink); border-radius: 8px; box-shadow: var(--keyline), 5px 5px 0 var(--ink); }
.ready-title { margin: 0 0 8px; text-align: center; font-family: var(--display); font-weight: 900; font-size: 26px; letter-spacing: 0.12em; color: var(--red); animation: blink 1.2s steps(2, jump-none) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.ready-steps { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.5; }
.ready-steps b { color: var(--jade); }
.ready-steps .hot { color: var(--red); }
@media (orientation: landscape) and (max-height: 520px) {
  .ready { justify-content: flex-end; }
  .ready-card { width: min(360px, 48vw); padding: 10px 12px; }
  .ready-title { font-size: 21px; }
  .ready-steps { font-size: 13px; }
}

/* ---------- large screens: scale the interface with the viewport ---------- */
@media (min-width: 900px) and (min-height: 700px) {
  .title-card, .card, .panel-screen > *, .ready-card { zoom: 1.3; }
  .hud .round-btn, .best-mini, .scorebox, .banner, .speedo { zoom: 1.3; }
  .title .sound { zoom: 1.3; }
}
