:root {
  color-scheme: dark;
  --ink: #10071c;
  --cream: #fff3d8;
  --gold: #ffdb8a;
  --muted: #ecdef8;
  font-family: system-ui, sans-serif;
  color: var(--cream);
  background: #100719;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: radial-gradient(ellipse at 70% 0%, #35104b, #100719 60%); min-height: 100vh; }
button, a { font: inherit; }
button, .primary {
  min-height: 40px; border: 1px solid #a97ac2; border-radius: 8px; color: var(--cream);
  background: #2e1544; padding: 8px 15px; cursor: pointer; text-decoration: none;
}
button:hover, .primary:hover { filter: brightness(1.2); }
:focus-visible { outline: 3px solid #89ebff; outline-offset: 3px; }
.arcade { width: min(96%, 1400px); margin: auto; padding: 12px 0; }
.masthead, .actions, .film-head, .game-controls, .counters, .end-actions { display: flex; gap: 9px; align-items: center; }
.masthead { justify-content: space-between; padding: 4px 3px 12px; }
.brand { font-family: Georgia, serif; font-size: clamp(14px, 2.2vw, 23px); }
.brand span { color: var(--gold); margin-right: 4px; }
.actions button { font-size: .83rem; white-space: nowrap; }
.progress { display: flex; gap: 4px; padding: 0 1px 12px; }
.progress i { flex: 1; height: 4px; background: #503361; border-radius: 4px; }
.progress .past { background: #c07bed; }
.progress .current { background: #ffe89d; box-shadow: 0 0 9px #ffd390; }
.stage {
  position: relative; overflow: hidden; border: 1px solid #cd9b5f; border-radius: 16px;
  box-shadow: 0 12px 45px #06030a, inset 0 0 0 3px #ffc67720;
  background: #130821 url('assets/command-centre.webp') center / cover;
}
.cover, .interlude, .film { position: relative; min-height: 470px; aspect-ratio: 16/9; }
.cover {
  display: grid; grid-template-columns: 1.15fr 1fr; align-items: center;
  background: linear-gradient(90deg,#120624f8 5%,#1a0a30e2 32%,#1a0a3045 67%,#10071c30), linear-gradient(0deg,#120624a0,transparent 55%);
}
.cover-copy { padding: clamp(22px, 5.7vw, 90px); position: relative; z-index: 1; }
.eyebrow { color: var(--gold); text-transform: uppercase; letter-spacing: .19em; font-size: .76rem; font-weight: 800; margin: 0; }
h1, h2 { font-family: Georgia, serif; font-weight: 700; }
h1 { margin: 12px 0 16px; font-size: clamp(48px, 8.4vw, 122px); line-height: .88; letter-spacing: -.055em; text-shadow: 0 5px 36px #10071c; }
.cover-copy p, .glass p { color: var(--muted); max-width: 36ch; line-height: 1.5; }
.cover-copy p { font-size: clamp(15px,1.45vw,21px); margin: 0 0 22px; }
.primary { display: inline-block; color: #26102d; background: linear-gradient(#fff0b9, #edb45e); border-color: #ffe6a4; font-weight: 800; }
.hero-crystal { width: min(92%, 540px); justify-self: center; filter: drop-shadow(0 0 24px #b84cffc0); }
.film { min-height: 0; background: #0a0512; }
.film video { position: absolute; width: 100%; height: 100%; object-fit: contain; }
.film-head { position: absolute; inset: 0 0 auto; padding: 10px 14px; justify-content: space-between; background: linear-gradient(#0d061aeb,transparent); }
.play-film { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); }
.game { position: relative; }
.round-head { display: flex; justify-content: space-between; gap: 12px; padding: 12px 18px; background: #1b0b2a; }
.round-head h2 { margin: 3px 0; font-size: clamp(20px,3vw,36px); }
.round-head p:last-child { margin: 0; color: var(--muted); font-size: .86rem; }
.counters { font-variant-numeric: tabular-nums; }
.counters > * { background: #34184c; border: 1px solid #80549d; border-radius: 8px; min-width: 48px; text-align: center; padding: 5px; }
canvas { display: block; width: 100%; aspect-ratio: 16/9; touch-action: none; background: #180d27; }
canvas:focus-visible { outline-offset: -4px; }
.game-controls { justify-content: space-between; flex-wrap: wrap; padding: 9px 13px; background: #1b0b2a; }
.game-controls span { color: var(--muted); font-size: .83rem; }
.dpad { display: flex; gap: 4px; }
.dpad button { min-width: 44px; min-height: 42px; padding: 4px; touch-action: none; font-size: 1.2rem; }
.interlude { display: grid; place-items: center; background: #0d051a91; padding: 18px; }
.glass { padding: clamp(18px, 3vw, 38px); text-align: center; border-radius: 18px; border: 1px solid #ffdc8d; background: #1b0a32ed; box-shadow: 0 0 38px #c752ff77; width: min(100%, 560px); }
.glass img { width: clamp(72px,13vw,145px); height: clamp(72px,13vw,145px); object-fit: contain; }
.glass h2 { margin: 4px 0; color: var(--gold); font-size: clamp(30px,5vw,59px); }
.glass p { margin: 9px auto 16px; }
.glass .eyebrow { color: var(--gold); }
.end-actions { justify-content: center; flex-wrap: wrap; }
.credits { padding: 10px 4px; font-size: .78rem; color: #d3bfdc; text-align: right; }
@media (max-width: 620px) {
  .cover { display: flex; align-items: end; min-height: 440px; background: linear-gradient(0deg,#13061dfb 8%,#13061dbc 58%,#13061d24); }
  .hero-crystal { position: absolute; width: 175px; right: 1%; top: 4%; }
  .cover-copy { padding: 24px 19px; }
  .round-head { padding: 9px; gap: 7px; }
  .round-head p:last-child { font-size: .78rem; }
  .counters { align-self: start; flex-direction: column; gap: 4px; font-size: .78rem; }
  .game-controls span { order: 3; flex-basis: 100%; min-height: 18px; }
  .film-head { padding: 4px 7px; font-size: .72rem; }
  .film-head button, .actions button { padding: 4px 8px; }
  .interlude { min-height: 360px; }
}


/* Reserve room for the game controls in short landscape viewports. */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 1100px) {
  .arcade {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    padding: 2px 0 5px;
  }

  .masthead { padding: 0 3px 3px; }
  .actions button { min-height: 30px; padding: 4px 8px; }
  .progress { padding: 0 1px 4px; }
  .credits { display: none; }
  .stage { min-height: 0; border-radius: 10px; }

  .cover, .film, .interlude { height: 100%; min-height: 0; aspect-ratio: auto; }
  .cover { display: grid; align-items: center; }
  .cover-copy { padding: 12px 16px; }
  .cover-copy h1 { font-size: clamp(30px, 12vh, 60px); margin: 5px 0; }
  .cover-copy p { margin: 0 0 7px; font-size: 13px; line-height: 1.25; }
  .hero-crystal { position: static; width: min(70%, 32vh); }
  .film-head { padding: 4px 8px; }
  .interlude { padding: 6px; overflow: auto; }
  .glass { padding: 8px 12px; }
  .glass img { width: 46px; height: 46px; }
  .glass h2 { font-size: 26px; }
  .glass p { margin: 4px auto 6px; line-height: 1.25; }

  .game {
    height: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .round-head { padding: 3px 8px; align-items: center; }
  .round-head h2 { margin: 1px 0; font-size: 17px; }
  .round-head p:last-child { font-size: 11px; }
  .counters { align-self: auto; flex-direction: row; gap: 4px; }
  .counters > * { min-width: 35px; padding: 2px 4px; }
  .game canvas {
    width: auto;
    height: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    justify-self: center;
  }

  .game-controls { flex-wrap: nowrap; gap: 6px; padding: 2px 8px; }
  .game-controls span { order: 0; flex-basis: auto; min-height: 0; font-size: 11px; text-align: center; }
  .game-controls #retry { padding: 3px 6px; font-size: 12px; }
}
