:root {
  color-scheme: dark;
  --bg: #111024;
  --panel: rgb(12 14 31 / 72%);
  --panel-strong: rgb(12 14 31 / 88%);
  --text: #fff8ea;
  --muted: #b9c2df;
  --line: rgb(255 255 255 / 20%);
  --pink: #ff3f7f;
  --cyan: #37d7ff;
  --gold: #ffe263;
  --green: #56f08b;
  --shadow: 0 22px 80px rgb(0 0 0 / 44%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--text);
  background:
    linear-gradient(180deg, rgb(3 7 23 / 80%), rgb(3 7 23 / 18)),
    #15112d;
  overflow-x: hidden;
}

button {
  font: inherit;
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 20;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  background: var(--text);
  color: #0c0e1f;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.game-shell {
  min-height: 100vh;
  padding: clamp(0.5rem, 2vw, 1.25rem);
}

.game-stage {
  position: relative;
  min-height: calc(100vh - clamp(1rem, 4vw, 2.5rem));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090b1a;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: calc(100vh - clamp(1rem, 4vw, 2.5rem));
  min-height: 520px;
  background: #090b1a;
  touch-action: none;
}

.hud,
.title-lockup,
.game-actions,
.touch-controls {
  position: absolute;
  z-index: 2;
}

.hud {
  top: 0.85rem;
  right: 0.85rem;
  left: 0.85rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  pointer-events: none;
}

.hud div,
.game-actions,
.touch-controls button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.hud div {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  padding: 0.65rem 0.75rem;
}

.hud span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hud strong {
  overflow: hidden;
  color: var(--gold);
  font-size: clamp(1rem, 2vw, 1.35rem);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-lockup {
  top: clamp(5.6rem, 11vw, 7.5rem);
  left: clamp(1rem, 3vw, 2rem);
  pointer-events: none;
  text-shadow: 0 4px 22px rgb(0 0 0 / 52%);
}

.title-lockup p {
  margin: 0 0 0.25rem;
  color: var(--cyan);
  font-size: clamp(0.72rem, 1.3vw, 0.85rem);
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.title-lockup h1 {
  max-width: 9ch;
  margin: 0;
  color: var(--text);
  font-size: clamp(2.4rem, 8vw, 6.2rem);
  line-height: 0.88;
  letter-spacing: 0;
  text-transform: uppercase;
}

.game-actions {
  right: 0.85rem;
  bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  max-width: min(620px, calc(100% - 1.7rem));
  padding: 0.6rem;
}

.button,
.touch-controls button {
  min-height: 2.75rem;
  border-radius: 8px;
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
}

.button {
  min-width: 6rem;
  border: 1px solid transparent;
  padding: 0.7rem 1rem;
}

.button.primary {
  background: var(--pink);
  box-shadow: 0 0 0 2px rgb(255 63 127 / 20%);
}

.button.secondary {
  border-color: var(--line);
  background: var(--panel-strong);
}

.button:hover,
.button:focus-visible,
.touch-controls button:hover,
.touch-controls button:focus-visible {
  outline: 3px solid rgb(55 215 255 / 34%);
  outline-offset: 2px;
}

#game-message {
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 800;
}

.touch-controls {
  bottom: 0.85rem;
  left: 0.85rem;
  display: grid;
  grid-template-columns: repeat(2, 4.5rem);
  gap: 0.5rem;
}

.touch-controls button {
  border-color: var(--line);
  color: var(--text);
}

.touch-controls button[data-control="accelerate"] {
  background: rgb(86 240 139 / 30%);
}

.touch-controls button[data-control="brake"] {
  background: rgb(255 63 127 / 28%);
}

@media (max-width: 760px) {
  .game-shell {
    padding: 0;
  }

  .game-stage,
  #game-canvas {
    min-height: 100vh;
    height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .title-lockup {
    top: 9.5rem;
  }

  .game-actions {
    right: 0.6rem;
    bottom: 6.2rem;
    left: 0.6rem;
    flex-wrap: wrap;
  }

  .touch-controls {
    right: 0.6rem;
    bottom: 0.6rem;
    left: 0.6rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .touch-controls button {
    min-width: 0;
  }
}
