:root {
  color-scheme: dark;
  --ink: #090c0c;
  --panel: #111716;
  --line: #34403c;
  --paper: #e8eee8;
  --muted: #91a099;
  --amber: #ff9e2c;
  --mint: #86ffd4;
  --red: #ff4e35;
  --display: "Bahnschrift Condensed", "Aptos Display", "Franklin Gothic Condensed", sans-serif;
  --body: "Trebuchet MS", "Gill Sans", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--ink); }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  font-family: var(--body);
  background:
    radial-gradient(circle at 72% -10%, rgba(255,158,44,.13), transparent 34rem),
    linear-gradient(135deg, rgba(134,255,212,.025) 25%, transparent 25%) 0 0/20px 20px,
    #080b0b;
}
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; }
.skip { position: fixed; z-index: 100; top: .75rem; left: .75rem; padding: .7rem 1rem; color: var(--ink); background: var(--mint); transform: translateY(-180%); }
.skip:focus { transform: none; }
.shell { width: min(100%, 1536px); min-height: 100vh; margin: 0 auto; padding: clamp(.6rem, 2vw, 1.6rem); display: grid; align-content: center; }
.masthead { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding: 0 .2rem .8rem; }
.brand { display: flex; gap: .85rem; align-items: baseline; }
.brand h1 { margin: 0; font: 900 clamp(1.45rem, 3.4vw, 3rem)/.9 var(--display); letter-spacing: -.035em; text-transform: uppercase; }
.brand-mark, .eyebrow { color: var(--amber); font: 700 .68rem/1 var(--body); letter-spacing: .17em; text-transform: uppercase; }
.header-actions { display: flex; gap: .5rem; }
.utility, .secondary { border: 1px solid var(--line); color: var(--paper); background: #111716; padding: .62rem .85rem; cursor: pointer; text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; }
.utility:hover, .secondary:hover { border-color: var(--amber); }
.stage-frame { position: relative; overflow: hidden; border: 1px solid #3e4844; background: #020404; box-shadow: 0 1.5rem 5rem #000; aspect-ratio: 16/9; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.scanlines { position: absolute; inset: 0; pointer-events: none; opacity: .13; background: repeating-linear-gradient(0deg, transparent 0 3px, #000 3px 4px); mix-blend-mode: multiply; }
.overlay { position: absolute; inset: 0; z-index: 4; padding: clamp(1.1rem, 5vw, 5rem); display: flex; flex-direction: column; justify-content: center; align-items: flex-start; background: linear-gradient(90deg, rgba(5,8,8,.97) 0 46%, rgba(5,8,8,.65) 72%, rgba(5,8,8,.1)); }
.overlay.hidden { display: none; }
.overlay h2 { max-width: 18ch; margin: .8rem 0; font: 900 clamp(2.2rem, 5.7vw, 5.8rem)/.82 var(--display); letter-spacing: -.05em; text-transform: uppercase; }
.overlay .lede { max-width: 43rem; color: #b7c2bc; font-size: clamp(.85rem, 1.35vw, 1.08rem); line-height: 1.55; }
.briefing { display: grid; grid-template-columns: repeat(4, minmax(8rem, 1fr)); width: min(100%, 48rem); margin: 1.1rem 0; border-block: 1px solid var(--line); }
.briefing div { padding: .75rem; border-right: 1px solid var(--line); }
.briefing div:last-child { border: 0; }
.briefing span, .briefing strong { display: block; }
.briefing span { color: var(--muted); margin-bottom: .25rem; font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; }
.briefing strong { font-size: .78rem; }
.primary { min-width: 13rem; padding: .9rem 1.1rem; border: 0; color: #16100a; background: var(--amber); cursor: pointer; font-weight: 900; text-align: left; text-transform: uppercase; letter-spacing: .07em; box-shadow: .3rem .3rem 0 rgba(255,158,44,.23); }
.primary span { float: right; }
.primary:hover { background: #ffba65; transform: translate(-1px,-1px); }
.menu-note { margin: .7rem 0 0; color: var(--muted); font-size: .65rem; }
.compact { align-items: center; text-align: center; background: rgba(5,8,8,.9); }
.compact h2 { font-size: clamp(3rem, 8vw, 7rem); }
.compact .primary, .compact .secondary { margin-top: .7rem; text-align: center; }
.power-deck { display: grid; grid-template-columns: 8rem 1fr 10rem; gap: .75rem; align-items: stretch; padding-top: .75rem; }
.readout { padding: .55rem .7rem; border: 1px solid var(--line); background: linear-gradient(90deg, rgba(255,158,44,.14), transparent 45%), var(--panel); }
.readout span, .readout strong { display: block; }
.readout span { color: var(--muted); font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; }
.readout strong { margin-top: .18rem; font: 900 1.05rem var(--display); }
.power-bar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; margin: 0; padding: 0; list-style: none; }
.power-bar li { position: relative; overflow: hidden; min-width: 0; padding: .48rem .6rem; color: #76817c; border: 1px solid #2b3431; background: #111615; transition: color .16s, border-color .16s, background .16s; }
.power-bar li::after { position: absolute; content: ""; inset: auto 0 0; height: 2px; background: var(--amber); transform: scaleX(0); transform-origin: left; transition: transform .18s; }
.power-bar li.selected { color: #1b1107; border-color: var(--amber); background: var(--amber); }
.power-bar li.selected::after { transform: scaleX(1); }
.power-bar li.owned { color: var(--mint); border-color: #416a5c; }
.power-bar li.owned:not(.selected) { background: linear-gradient(180deg, #14201d, #0d1412); }
.power-bar span { display: block; opacity: .65; font-size: .54rem; }
.power-bar strong { display: block; overflow: hidden; font: 800 clamp(.58rem, 1vw, .82rem) var(--display); letter-spacing: .05em; text-overflow: ellipsis; text-transform: uppercase; }
.power-bar em { position: absolute; top: .3rem; right: .35rem; min-width: 1.45rem; color: var(--mint); font: 800 .5rem var(--body); letter-spacing: .08em; text-align: right; }
.power-bar li.selected em { color: #3b250b; }
.activate-hint { display: flex; align-items: center; gap: .6rem; margin: 0; padding: .55rem .7rem; border: 1px solid var(--line); color: var(--muted); font-size: .62rem; line-height: 1.2; text-transform: uppercase; letter-spacing: .06em; }
kbd { display: inline-grid; min-width: 1.8rem; height: 1.8rem; place-items: center; color: var(--paper); border: 1px solid #66736d; background: #1b211f; font: 700 .75rem var(--body); }
.touch-controls { position: absolute; z-index: 3; inset: auto 0 0; display: none; justify-content: space-between; align-items: end; padding: 1rem; pointer-events: none; }
.touch-stick, .touch-actions button { pointer-events: auto; touch-action: none; }
.touch-stick { position: relative; width: 5.2rem; height: 5.2rem; border: 1px solid rgba(232,238,232,.35); border-radius: 50%; background: rgba(8,12,12,.45); }
.touch-stick span { position: absolute; left: 50%; top: 50%; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: rgba(134,255,212,.7); transform: translate(-50%,-50%); }
.touch-actions { display: flex; gap: .65rem; align-items: end; }
.touch-actions button { width: 4.3rem; height: 4.3rem; border: 1px solid rgba(255,158,44,.7); border-radius: 50%; color: var(--paper); background: rgba(25,17,8,.72); text-transform: uppercase; font-size: .58rem; font-weight: 900; }
.touch-actions button:last-child { width: 5rem; height: 5rem; background: rgba(255,158,44,.75); color: #140e08; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---- Mobile / touch: fill the viewport, kill the dead space ---- */
@media (pointer: coarse), (max-width: 820px) {
  html, body { height: 100%; overflow: hidden; }
  .shell { width: 100%; height: 100dvh; min-height: 100dvh; margin: 0; padding: 0;
    grid-template-rows: auto minmax(0, 1fr) auto; align-content: stretch; gap: 0; }
  .masthead { padding: .3rem .7rem; }
  .brand-mark { display: none; }
  .brand h1 { font-size: clamp(1.05rem, 5.4vw, 1.7rem); }
  .header-actions { gap: .4rem; }
  .utility { padding: .44rem .55rem; font-size: .56rem; }

  .stage-frame { aspect-ratio: auto; height: auto; min-height: 0; border-inline: 0; box-shadow: none; }

  .power-deck { grid-template-columns: 1fr; gap: .3rem; padding: .3rem .5rem calc(.3rem + env(safe-area-inset-bottom)); }
  .readout, .activate-hint { display: none; }
  .power-bar { gap: 2px; }
  .power-bar li { padding: .36rem .18rem; text-align: center; }
  .power-bar span { display: none; }
  .power-bar strong { font-size: clamp(.5rem, 2.7vw, .74rem); }

  .overlay { padding: 1.1rem 1.2rem; justify-content: center; overflow: auto;
    background: linear-gradient(rgba(5,8,8,.95), rgba(5,8,8,.82)); }
  .overlay h2 { font-size: clamp(1.7rem, 7.4vw, 3rem); margin: .5rem 0; max-width: none; }
  .overlay .lede { font-size: clamp(.82rem, 3.4vw, 1rem); max-width: none; }
  .briefing { grid-template-columns: 1fr 1fr; width: 100%; margin: .7rem 0; }
  .briefing div { padding: .5rem; }
  .briefing div:nth-child(2) { border-right: 0; }
  .primary { min-width: 0; width: 100%; text-align: center; }
  .primary span { float: none; }
  .menu-note { display: none; }

  /* Touch controls appear ONLY while flying — never over the menu/pause/end */
  .touch-controls { display: none;
    padding: calc(.7rem + env(safe-area-inset-top)) calc(.9rem + env(safe-area-inset-right)) calc(.9rem + env(safe-area-inset-bottom)) calc(.9rem + env(safe-area-inset-left)); }
  .stage-frame:not(:has(.overlay:not(.hidden))) .touch-controls { display: flex; }
}

/* Short landscape phones: drop the masthead so the play field owns the screen */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
  .masthead { display: none; }
  .shell { grid-template-rows: minmax(0, 1fr) auto; }
}

/* A horizontal shooter wants landscape — gently nudge in portrait */
.rotate-note { display: none; }
@media (pointer: coarse) and (orientation: portrait) {
  .rotate-note { display: flex; align-items: center; gap: .4rem; position: fixed; z-index: 60;
    left: 50%; bottom: calc(env(safe-area-inset-bottom) + .55rem); transform: translateX(-50%);
    padding: .5rem .85rem; border: 1px solid var(--line); border-radius: 2px;
    background: rgba(9,12,12,.9); color: var(--muted); font-size: .66rem; letter-spacing: .04em;
    white-space: nowrap; pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .scanlines { display: none; }
}
