:root {
  color-scheme: dark;
  --bg: #0a1d2b;
  --ink: #f4f8f9;
  --muted: #b6c9cd;
  --accent: #a9e5e5;
  --edge: clamp(12px, 3vw, 36px);
  font: 16px/1.4 system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
[hidden] { display: none !important; }
.game-shell {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #163d4b, var(--bg) 75%);
}
.game-shell:fullscreen { width: 100%; height: 100%; }
.arena { position: absolute; inset: 0; display: grid; place-items: center; }
canvas { display: block; outline: 0; touch-action: none; }
canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.game-top {
  position: absolute;
  top: max(var(--edge), env(safe-area-inset-top));
  left: max(var(--edge), env(safe-area-inset-left));
  right: max(var(--edge), env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.game-identity {
  border-radius: 12px;
  padding: 7px 12px;
  background: #092338e0;
  border: 1px solid #e2f7ff35;
}
h1 { margin: 0; font-size: clamp(19px, 3vw, 28px); line-height: 1.06; }
.game-identity span { display: block; margin-top: 2px; color: var(--accent); font-size: .72rem; }
.nav, .run-actions, .directions { display: flex; align-items: center; gap: 7px; }
.glass, .primary, .credit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
  cursor: pointer;
  font: 700 .86rem/1.18 system-ui, sans-serif;
  min-height: 44px;
  padding: 9px 13px;
  text-decoration: none;
}
.glass, .credit-button {
  color: var(--ink);
  background: #102e43ee;
  border: 1px solid #e2f7ff50;
}
.primary { color: #102938; background: var(--accent); border: 1px solid var(--accent); }
button:disabled { cursor: default; opacity: .59; }
button:focus-visible, a:focus-visible { outline: 2px solid white; outline-offset: 3px; }
.race-hud {
  position: absolute;
  top: calc(max(var(--edge), env(safe-area-inset-top)) + 67px);
  left: max(var(--edge), env(safe-area-inset-left));
  padding: 8px 11px;
  width: min(280px, calc(100% - 110px));
  border: 1px solid #d8f5ff30;
  border-radius: 12px;
  background: #0b2538e8;
}
.stats { display: grid; grid-template-columns: 1.2fr .9fr .9fr; gap: 7px; }
.stats span, .stats strong { display: block; }
.stats span { color: var(--muted); font-size: .68rem; }
.stats strong { font-size: .86rem; font-variant-numeric: tabular-nums; }
progress {
  display: block;
  width: 100%;
  height: 4px;
  margin: 6px 0 0;
  accent-color: var(--accent);
}
.pause { position: absolute; top: calc(max(var(--edge), env(safe-area-inset-top)) + 67px); right: max(var(--edge), env(safe-area-inset-right)); }
.run-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 38px));
  padding: clamp(17px, 3vw, 29px);
  border-radius: 19px;
  border: 1px solid #d8f5ff5c;
  background: #0a2132f0;
  box-shadow: 0 20px 68px #04101d66;
  text-align: center;
}
.run-card h2, .credits h2 { margin: 0; font-size: clamp(23px, 4vw, 33px); line-height: 1.07; }
.run-card p, .credits p { margin: 8px 0 14px; color: var(--muted); font-size: .9rem; }
.run-actions { justify-content: center; }
.touch {
  position: absolute;
  bottom: calc(max(var(--edge), env(safe-area-inset-bottom)) + 44px);
  left: max(var(--edge), env(safe-area-inset-left));
  right: max(var(--edge), env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.touch button {
  min-width: 57px;
  min-height: 51px;
  font-size: 1.32rem;
  user-select: none;
  touch-action: none;
  pointer-events: auto;
}
.touch .jump { padding-inline: 16px; font-size: .95rem; }
.bottom {
  position: absolute;
  bottom: max(var(--edge), env(safe-area-inset-bottom));
  left: max(var(--edge), env(safe-area-inset-left));
  right: max(var(--edge), env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.key-guide, .rotate-guide, .display-status {
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--muted);
  background: #092338ed;
  font-size: .72rem;
}
.rotate-guide { display: none; }
.credit-button { min-height: 36px; padding: 5px 10px; font-size: .72rem; pointer-events: auto; }
.display-status {
  position: absolute;
  z-index: 3;
  max-width: calc(100% - 24px);
  top: 142px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
}
.credits {
  width: min(370px, calc(100% - 34px));
  padding: 22px;
  color: var(--ink);
  background: #0d2b3f;
  border: 1px solid #d8f5ff5c;
  border-radius: 14px;
}
.credits::backdrop { background: #0410189c; }
.credits a { color: var(--accent); }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (max-width: 540px) {
  .full-label { display: none; }
  .nav .glass { min-width: 44px; }
}
@media (pointer: coarse) {
  .key-guide { display: none; }
  .bottom { justify-content: flex-end; }
}
@media (pointer: coarse) and (orientation: portrait) {
  .rotate-guide { display: block; }
  .bottom { justify-content: space-between; }
}
@media (orientation: landscape) and (max-height: 450px) {
  .touch { bottom: max(var(--edge), env(safe-area-inset-bottom)); }
  .bottom { justify-content: center; }
  .key-guide { display: none; }
  .race-hud, .pause { top: calc(max(var(--edge), env(safe-area-inset-top)) + 56px); }
  .run-card { padding: 13px; }
}
