:root {
  --bg: #14161b;
  --ink: #f4f1ea;
  --dim: #9aa0a8;
  --yellow: #ffd23f;
  --red: #e2382b;
  --display: "Russo One", "Arial Black", Impact, sans-serif;
  --text: "Onest", -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); }
body { font: 400 16px/1.45 var(--text); -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

/* ---------- экраны ---------- */
.screen { position: fixed; inset: 0; z-index: 10; }
.screen--menu {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-rows: 1fr auto;
  gap: 24px;
  padding: clamp(20px, 5vw, 64px);
  background:
    linear-gradient(90deg, rgba(20, 22, 27, .92) 0%, rgba(20, 22, 27, .55) 45%, rgba(20, 22, 27, .1) 75%),
    linear-gradient(0deg, rgba(20, 22, 27, .8), transparent 30%);
}
.menu { align-self: center; max-width: 620px; }
.logo {
  margin: 0; font: 400 clamp(84px, 15vw, 190px)/.82 var(--display);
  text-transform: uppercase; letter-spacing: -.02em; color: var(--yellow);
  transform: skewX(-9deg); transform-origin: left bottom;
}
.logo span { display: inline-block; position: relative; padding-right: .12em; }
.logo span::after {
  content: ""; position: absolute; left: .04em; right: 0; bottom: -.12em; height: .1em;
  background: repeating-linear-gradient(90deg, var(--ink) 0 .14em, transparent .14em .28em);
}
.tagline { margin: 34px 0 30px; font-size: clamp(17px, 1.6vw, 20px); color: #d6d2c8; max-width: 26em; }
.menu__buttons { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.btn {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-width: 280px; padding: 14px 22px 13px; cursor: pointer;
  background: rgba(255, 255, 255, .06); border: 2px solid rgba(255, 255, 255, .25);
  font: 400 20px/1.1 var(--display); text-transform: uppercase; letter-spacing: .02em; text-align: left;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  transition: background .15s, border-color .15s, transform .15s;
}
.btn small { font: 400 13px var(--text); text-transform: none; letter-spacing: 0; color: var(--dim); }
.btn:hover { background: rgba(255, 255, 255, .12); border-color: var(--ink); transform: translateX(4px); }
.btn--main { background: var(--yellow); border-color: var(--yellow); color: #16140e; }
.btn--main small { color: #55491a; }
.btn--main:hover { background: #ffe06e; border-color: #ffe06e; }
.menu__best { margin-top: 26px; color: var(--dim); font-size: 15px; }
.menu__best b { color: var(--ink); font: 500 15px var(--mono); }

.help {
  align-self: center; padding: 22px 24px; background: rgba(20, 22, 27, .72);
  border-left: 3px solid var(--yellow);
}
.help h2 { margin: 0 0 14px; font: 400 15px var(--display); text-transform: uppercase; letter-spacing: .08em; color: var(--yellow); }
.help dl { margin: 0; display: grid; gap: 9px; }
.help dl div { display: grid; grid-template-columns: 128px 1fr; gap: 12px; align-items: center; font-size: 14px; }
.help dt { display: flex; flex-wrap: wrap; gap: 4px; }
.help dd { margin: 0; color: #d6d2c8; }
kbd {
  display: inline-block; min-width: 24px; padding: 3px 6px; text-align: center;
  font: 500 12px var(--mono); color: var(--ink);
  border: 1px solid rgba(255, 255, 255, .35); border-bottom-width: 3px; border-radius: 4px;
}
.help__touch { margin: 14px 0 0; font-size: 13px; color: var(--dim); }
.menu__foot { grid-column: 1 / -1; display: flex; gap: 22px; flex-wrap: wrap; font-size: 13px; color: var(--dim); }
.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--dim); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--ink); }

.screen--modal { display: grid; place-items: center; background: rgba(12, 13, 16, .6); padding: 20px; }
.modal {
  display: flex; flex-direction: column; gap: 10px; align-items: stretch;
  padding: 28px; min-width: 300px; background: var(--bg); border: 2px solid rgba(255, 255, 255, .15);
}
.modal--wide { min-width: min(460px, 100%); }
.modal h2 { margin: 0 0 10px; font: 400 34px var(--display); text-transform: uppercase; color: var(--yellow); transform: skewX(-8deg); }
.modal .btn { min-width: 0; width: 100%; }
.modal__row { display: flex; gap: 10px; margin-top: 8px; }
.finish__place { margin: 0; font-size: 18px; }
.finish__best { margin: 4px 0 0; color: var(--yellow); min-height: 1.4em; }
.results { width: 100%; border-collapse: collapse; font-size: 15px; margin: 6px 0; }
.results th { text-align: left; font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--dim); padding: 6px 4px; }
.results td { padding: 8px 4px; border-top: 1px solid rgba(255, 255, 255, .1); }
.results td:last-child, .results th:last-child { text-align: right; font-family: var(--mono); }
.results tr.is-you td { color: var(--yellow); }
.results i { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 2px; vertical-align: 0; }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; font-family: var(--display); text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.hud__block { position: absolute; }
.hud__label { display: block; font: 500 12px var(--mono); text-shadow: none; letter-spacing: .1em; text-transform: uppercase; color: rgba(255, 255, 255, .7); }
.hud__big { font-size: 40px; line-height: 1; }
.hud__laps { top: 20px; left: 24px; }
.hud__times { top: 20px; left: 130px; display: grid; gap: 4px; font: 500 15px var(--mono); }
.hud__times div { display: grid; grid-template-columns: 76px auto; align-items: baseline; }
.hud__pos { top: 20px; right: 24px; text-align: right; }
.hud__pos .hud__big { color: var(--yellow); }
.hud__map { position: absolute; left: 20px; bottom: 20px; width: 160px; height: 160px; opacity: .92; }
.hud__speed { position: absolute; right: 26px; bottom: 18px; font-size: 64px; line-height: 1; text-align: right; font-variant-numeric: tabular-nums; }
.hud__speed small { display: block; font: 500 12px var(--mono); letter-spacing: .1em; color: rgba(255, 255, 255, .7); }
.hud__center {
  position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%);
  font-size: clamp(64px, 12vw, 150px); color: var(--yellow); text-transform: uppercase;
}
.hud__center.pop { animation: pop .9s ease-out; }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); } }
.hud__toast {
  position: absolute; left: 50%; top: 18%; transform: translateX(-50%);
  font-size: 22px; text-transform: uppercase; color: var(--ink); opacity: 0; transition: opacity .3s;
  white-space: nowrap;
}
.hud__toast.show { opacity: 1; }
.hud__wrong {
  position: absolute; left: 50%; top: 24%; transform: translateX(-50%);
  padding: 8px 18px; background: var(--red); font-size: 22px; text-transform: uppercase;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: .4; } }
.hud__pause {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%); pointer-events: auto;
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .4);
  background: rgba(0, 0, 0, .25); font: 400 14px var(--display); cursor: pointer;
}

/* ---------- тач ---------- */
.touch {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 16px max(16px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.touch__side { display: flex; gap: 12px; pointer-events: auto; }
.touch button {
  width: 76px; height: 76px; border-radius: 50%; touch-action: none;
  background: rgba(255, 255, 255, .14); border: 2px solid rgba(255, 255, 255, .4);
  font: 400 20px var(--display); color: var(--ink);
}
.touch button.on { background: rgba(255, 210, 63, .5); border-color: var(--yellow); }
.touch .touch__gas { width: 92px; height: 92px; background: rgba(255, 210, 63, .25); border-color: var(--yellow); }
body.is-touch .hud__speed { bottom: 130px; font-size: 44px; }
body.is-touch .hud__map { bottom: 120px; width: 110px; height: 110px; }

.nojs, .nogl { position: fixed; inset: auto 20px 20px; z-index: 20; padding: 14px 18px; background: var(--red); color: #fff; }

@media (max-width: 760px) {
  .screen--menu { grid-template-columns: 1fr; grid-template-rows: auto auto auto; overflow-y: auto; align-content: start; }
  .menu { align-self: start; padding-top: 6vh; }
  .help { padding: 16px; }
  .help dl div { grid-template-columns: 110px 1fr; }
  .btn { min-width: 0; width: 100%; }
  .hud__times { left: 24px; top: 74px; font-size: 13px; }
  .hud__big { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .hud__center.pop, .hud__wrong { animation: none; }
}
