:root {
  color-scheme: dark;
  --ink: #f3f5f8;
  --muted: #b5bfcc;
  --glass: rgba(16, 21, 30, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --accent: #ffcf3f;
  --teal: #57e3c4;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #b9d3ea; color: var(--ink); }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

kbd {
  display: inline-block; min-width: 1.5em; padding: 0 .35em; margin: 0 .1em;
  border: 1px solid var(--line); border-radius: 5px; background: rgba(255, 255, 255, .08);
  font-family: inherit; font-size: .85em; font-weight: 600; line-height: 1.5; text-align: center;
}

.bar {
  position: fixed; top: 12px; left: 12px; right: 12px; display: flex; align-items: center; gap: 12px;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.back, .chip, .title {
  background: var(--glass); border: 1px solid var(--line); border-radius: 10px; color: var(--ink);
  backdrop-filter: blur(8px);
}
.back { padding: 8px 12px; text-decoration: none; font-size: 14px; }
.back:hover, .chip:hover { border-color: rgba(255, 255, 255, .4); }
.title { padding: 6px 14px; display: grid; }
.title strong { font-size: 15px; }
.title small { color: var(--muted); font-size: 12px; }
.chip { margin-left: auto; padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; }

.hud {
  position: fixed; top: 70px; left: 12px; display: grid; grid-auto-flow: column; gap: 6px;
}
.hud div {
  min-width: 92px; padding: 6px 12px; background: var(--glass); border: 1px solid var(--line); border-radius: 10px;
  display: grid;
}
.hud small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.hud strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.mini-map {
  position: fixed; top: 70px; right: 12px; width: 180px; height: 180px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 12px;
}

.countdown {
  position: fixed; top: 32%; left: 50%; transform: translate(-50%, -50%);
  font-family: inherit; font-size: clamp(56px, 12vw, 128px); font-weight: 900; font-style: italic; line-height: 1; color: var(--accent);
  text-shadow: 0 4px 24px rgba(0, 0, 0, .45); pointer-events: none;
}
.wrong-way {
  position: fixed; top: 22%; left: 50%; transform: translateX(-50%); padding: 10px 18px;
  background: #c8323a; border-radius: 10px; font-weight: 800; letter-spacing: .04em; pointer-events: none;
}
.notice { position: fixed; bottom: 64px; left: 50%; transform: translateX(-50%); margin: 0; color: var(--ink); text-shadow: 0 1px 4px #000; }

.finish {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(360px, calc(100% - 32px));
  padding: 22px; display: grid; gap: 10px; text-align: center;
  background: rgba(16, 21, 30, .9); border: 1px solid var(--line); border-radius: 16px;
}
.eyebrow { color: var(--teal); font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.finish strong { font-size: 40px; font-variant-numeric: tabular-nums; }
.finish span { color: var(--muted); }
.muted { color: var(--muted); }
.primary {
  margin-top: 6px; padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: #17130a;
  font-family: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
}
.primary kbd { border-color: rgba(0, 0, 0, .25); background: rgba(0, 0, 0, .08); }

.keys-help {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); margin: 0; padding: 6px 12px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; color: var(--muted);
  white-space: nowrap;
}
.credits { position: fixed; bottom: 12px; left: 12px; display: flex; gap: 10px; font-size: 11px; }
.credits a { color: #1d2733; background: rgba(255, 255, 255, .7); padding: 2px 6px; border-radius: 4px; text-decoration: none; }

.touch {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 0 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none;
}
.pad { display: flex; gap: 10px; pointer-events: auto; }
.pad button {
  width: 70px; height: 70px; border-radius: 18px; border: 1px solid var(--line); background: var(--glass);
  color: var(--ink); font-family: inherit; font-size: 22px; font-weight: 700; touch-action: none;
}
.pad button.gas { height: 96px; background: rgba(40, 120, 90, .75); }
.pad button.pressed { background: rgba(255, 207, 63, .85); color: #17130a; }
.touch ~ .credits { bottom: auto; top: 260px; }

.loading {
  position: fixed; inset: 0; display: grid; place-items: center; background: #19202e; color: var(--ink); font-size: 18px;
}

@media (max-width: 720px) {
  .hud { top: 64px; }
  .hud div { min-width: 0; padding: 4px 8px; }
  .hud strong { font-size: 16px; }
  .mini-map { width: 120px; height: 120px; top: 120px; }
  .title small { display: none; }
  .back { font-size: 12px; }
}
