:root {
  --cream: #fff3d6;
  --ember: #ff663d;
  --gold: #ffc857;
  --mint: #65e6c4;
  --night: #090914;
  --panel: #111223;
  --line: rgba(255, 243, 214, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--night);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--cream);
  background:
    radial-gradient(circle at 50% 10%, #292044 0, transparent 36%),
    linear-gradient(#090914, #100b18);
  font-family: "Courier New", monospace;
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  text-decoration-color: rgba(255, 243, 214, 0.5);
  text-underline-offset: 4px;
}

.game-page {
  width: min(1420px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 38px;
}

.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 18px;
}

.back-link,
.header-actions button {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.wordmark {
  text-align: center;
}

.wordmark-kicker {
  display: block;
  margin-bottom: 2px;
  color: var(--ember);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.wordmark h1 {
  margin: 0;
  color: var(--cream);
  font-size: clamp(25px, 4vw, 42px);
  letter-spacing: 0.16em;
  line-height: 1;
  text-shadow: 4px 4px 0 #6a2133;
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.header-actions button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(17, 18, 35, 0.75);
}

.header-actions button:hover,
.header-actions button:focus-visible {
  border-color: var(--mint);
}

.game-shell {
  position: relative;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(17, 18, 35, 0.84);
  box-shadow: 14px 14px 0 rgba(255, 102, 61, 0.09);
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 10px;
  border: 1px solid var(--line);
  background: #0b0c18;
}

.hud > div {
  display: flex;
  min-height: 48px;
  padding: 7px 14px;
  align-items: center;
  justify-content: space-between;
  border-right: 1px solid var(--line);
}

.hud > div:last-child {
  border-right: 0;
}

.hud span {
  color: #a4a0b8;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hud strong {
  color: var(--gold);
  font-size: 18px;
}

.canvas-wrap {
  position: relative;
  aspect-ratio: 2 / 1;
  border: 1px solid #372541;
  background: #111126;
  overflow: hidden;
  touch-action: none;
}

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

.screen {
  position: absolute;
  inset: 0;
  display: none;
  padding: 30px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  background: rgba(7, 7, 17, 0.78);
  backdrop-filter: blur(4px);
}

.screen.active {
  display: flex;
}

.screen h2 {
  max-width: 760px;
  margin: 8px 0 14px;
  font-family: Arial, sans-serif;
  font-size: clamp(34px, 7vw, 74px);
  letter-spacing: -0.06em;
  line-height: 0.95;
}

.screen p:not(.screen-kicker) {
  max-width: 620px;
  color: #c1bed0;
  font-family: Arial, sans-serif;
  font-size: clamp(14px, 2vw, 18px);
}

.screen-kicker {
  margin: 0;
  color: var(--ember);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.screen small {
  margin-top: 18px;
  color: #9894ab;
  font-size: 10px;
}

.pilot-select {
  display: flex;
  margin: 10px 0 0;
  padding: 0;
  gap: 8px;
  border: 0;
}

.pilot-select legend {
  width: 100%;
  margin-bottom: 8px;
  color: #aaa6b8;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

.pilot-option {
  display: grid;
  width: 128px;
  min-height: 82px;
  padding: 4px 8px 8px;
  place-items: center;
  color: var(--cream);
  border: 1px solid var(--line);
  background: rgba(17, 18, 35, 0.8);
  font-size: 11px;
  text-transform: uppercase;
}

.pilot-option img {
  width: 108px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.38));
  pointer-events: none;
}

.pilot-option span {
  pointer-events: none;
}

.pilot-option.active {
  color: #090914;
  border-color: var(--mint);
  background: rgba(113, 227, 202, 0.92);
}

.primary-action {
  min-height: 48px;
  margin-top: 12px;
  padding: 0 22px;
  color: #120d18;
  border: 0;
  background: var(--gold);
  box-shadow: 5px 5px 0 #8f342f;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.primary-action:hover,
.primary-action:focus-visible {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 #8f342f;
}

#countdown {
  color: var(--gold);
  font-size: clamp(72px, 18vw, 180px);
  line-height: 1;
  text-shadow: 8px 8px 0 #7b2634;
}

.pause-label {
  position: absolute;
  top: 50%;
  left: 50%;
  display: none;
  padding: 14px 22px;
  color: #090914;
  background: var(--mint);
  transform: translate(-50%, -50%);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.pause-label.active {
  display: block;
}

.level-banner {
  position: absolute;
  top: 20px;
  left: 50%;
  display: flex;
  min-width: 280px;
  padding: 12px 20px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--cream);
  border: 1px solid rgba(255, 200, 87, 0.5);
  background: rgba(9, 9, 20, 0.88);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translate(-50%, -150%);
  transition:
    opacity 250ms ease,
    transform 350ms ease;
  pointer-events: none;
}

.level-banner.active {
  opacity: 1;
  transform: translate(-50%, 0);
}

.level-banner span {
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.level-banner strong {
  font-family: Arial, sans-serif;
  font-size: 14px;
}

.mobile-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.mobile-controls button {
  min-height: 58px;
  color: var(--cream);
  border: 1px solid var(--line);
  background: #19172c;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  touch-action: manipulation;
  user-select: none;
}

.mobile-controls button span {
  color: var(--mint);
  font-size: 20px;
  vertical-align: -2px;
}

.mobile-controls button.active {
  color: #090914;
  background: var(--mint);
}

.mobile-controls button.active span {
  color: #090914;
}

.game-footer {
  display: flex;
  padding: 22px 4px 0;
  justify-content: space-between;
  gap: 40px;
  color: #8e8a9d;
  font-family: Arial, sans-serif;
  font-size: 12px;
}

.game-footer p {
  max-width: 560px;
  margin: 0;
}

.game-footer strong {
  color: var(--cream);
}

.game-footer a {
  color: var(--mint);
}

@media (min-width: 900px) and (pointer: fine) {
  .mobile-controls {
    display: none;
  }
}

@media (max-width: 700px) {
  .game-page {
    width: min(100% - 16px, 1420px);
    padding-top: 10px;
  }

  .game-header {
    grid-template-columns: 1fr auto;
  }

  .wordmark {
    grid-column: 1 / -1;
    grid-row: 1;
    margin-bottom: 16px;
  }

  .back-link {
    grid-column: 1;
    grid-row: 2;
  }

  .header-actions {
    grid-column: 2;
    grid-row: 2;
  }

  .game-shell {
    padding: 7px;
    box-shadow: 7px 7px 0 rgba(255, 102, 61, 0.09);
  }

  .hud > div {
    min-height: 40px;
    padding: 5px 8px;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
  }

  .hud strong {
    font-size: 14px;
  }

  .screen {
    padding: 14px;
  }

  .screen p:not(.screen-kicker) {
    display: none;
  }

  .primary-action {
    min-height: 40px;
  }

  .game-footer {
    flex-direction: column;
    gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
