:root {
  color-scheme: dark;
  --ink: #f4f7fb;
  --muted: #aab6c8;
  --panel: rgba(10, 17, 26, 0.86);
  --panel-strong: rgba(13, 26, 36, 0.96);
  --line: rgba(170, 190, 210, 0.22);
  --cyan: #39d8ff;
  --green: #72f2a0;
  --amber: #ffd166;
  --red: #ff5f7e;
  --space: #05070d;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(57, 216, 255, 0.16), transparent 28rem),
    radial-gradient(circle at 82% 78%, rgba(255, 209, 102, 0.12), transparent 30rem),
    linear-gradient(135deg, #05070d 0%, #111827 48%, #07131a 100%);
  color: var(--ink);
}

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-x: hidden;
}

button,
kbd {
  font: inherit;
}

.game-shell {
  width: min(1180px, 100%);
  display: grid;
  gap: 12px;
}

.hud,
.console {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
}

.console {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.3fr) auto;
}

.hud > div,
.console > div {
  min-width: 0;
}

.label {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0;
}

strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1rem, 2vw, 1.4rem);
  line-height: 1.1;
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 320px;
  overflow: hidden;
  border: 1px solid rgba(57, 216, 255, 0.34);
  background: var(--space);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(5, 7, 13, 0.52);
}

.overlay[hidden] {
  display: none;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2.4rem, 8vw, 6.2rem);
  line-height: 0.95;
  letter-spacing: 0;
  text-transform: uppercase;
}

.overlay p {
  max-width: 560px;
  margin: 0;
  color: #d7e2ee;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  line-height: 1.45;
}

.upgrade-grid {
  width: min(680px, 100%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.upgrade-grid[hidden] {
  display: none;
}

.achievement-list {
  width: min(720px, 100%);
  max-height: 260px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  overflow: auto;
}

.achievement-list[hidden] {
  display: none;
}

.achievement-item {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(170, 190, 210, 0.22);
  border-radius: 8px;
  background: rgba(8, 22, 30, 0.88);
  text-align: left;
}

.achievement-item.is-unlocked {
  border-color: rgba(114, 242, 160, 0.48);
}

.run-history-item {
  border-color: rgba(255, 209, 102, 0.34);
}

.achievement-item span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.achievement-item strong {
  margin-top: 3px;
  font-size: 0.94rem;
}

.achievement-item small {
  display: block;
  margin-top: 6px;
  color: #d7e2ee;
  font-size: 0.8rem;
  line-height: 1.35;
}

.upgrade-choice {
  min-width: 0;
  min-height: 118px;
  padding: 12px;
  border: 1px solid rgba(234, 252, 255, 0.28);
  border-radius: 8px;
  background: rgba(8, 22, 30, 0.88);
  color: var(--ink);
  text-align: left;
  box-shadow: inset 0 0 0 1px transparent;
}

.upgrade-choice:hover,
.upgrade-choice:focus-visible {
  border-color: var(--amber);
}

.upgrade-choice--green {
  border-color: rgba(114, 242, 160, 0.42);
  box-shadow: inset 0 0 0 1px rgba(114, 242, 160, 0.1);
}

.upgrade-choice--amber {
  border-color: rgba(255, 209, 102, 0.46);
  box-shadow: inset 0 0 0 1px rgba(255, 209, 102, 0.12);
}

.upgrade-choice--cyan {
  border-color: rgba(57, 216, 255, 0.46);
  box-shadow: inset 0 0 0 1px rgba(57, 216, 255, 0.12);
}

.upgrade-choice--green:hover,
.upgrade-choice--green:focus-visible {
  border-color: var(--green);
}

.upgrade-choice--amber:hover,
.upgrade-choice--amber:focus-visible {
  border-color: var(--amber);
}

.upgrade-choice--cyan:hover,
.upgrade-choice--cyan:focus-visible {
  border-color: var(--cyan);
}

.upgrade-choice span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.2;
}

.upgrade-choice strong {
  margin: 4px 0 8px;
  font-size: 1rem;
}

.upgrade-choice small {
  display: block;
  color: #d7e2ee;
  font-size: 0.82rem;
  line-height: 1.35;
}

button {
  min-width: 148px;
  min-height: 44px;
  border: 1px solid rgba(57, 216, 255, 0.55);
  border-radius: 6px;
  background: #eafcff;
  color: #07131a;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 150ms ease,
    filter 150ms ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.achievements-button,
.audio-button,
.dash-button {
  min-width: 68px;
  min-height: 30px;
  padding: 4px 10px;
  color: var(--ink);
  font-size: 0.78rem;
}

.achievements-button:disabled,
.audio-button:disabled,
.dash-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  filter: none;
}

.achievements-button {
  min-width: 108px;
  border-color: rgba(57, 216, 255, 0.38);
  background: rgba(57, 216, 255, 0.1);
}

.audio-button {
  border-color: rgba(114, 242, 160, 0.48);
  background: rgba(114, 242, 160, 0.12);
}

.audio-button[aria-pressed="false"] {
  border-color: rgba(170, 190, 210, 0.28);
  background: rgba(244, 247, 251, 0.07);
  color: var(--muted);
}

.dash-button {
  border-color: rgba(255, 209, 102, 0.55);
  background: rgba(255, 209, 102, 0.14);
}

kbd {
  display: inline-grid;
  min-width: 38px;
  min-height: 30px;
  place-items: center;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(244, 247, 251, 0.08);
  color: #dce8f5;
  font-size: 0.78rem;
  line-height: 1;
}

@media (max-width: 760px) {
  body {
    padding: 10px;
  }

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

  .console {
    grid-template-columns: 1fr;
  }

  .controls {
    justify-content: flex-start;
  }

  .upgrade-grid {
    grid-template-columns: 1fr;
  }

  .achievement-list {
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: 420px;
    aspect-ratio: 9 / 12;
  }
}
