:root {
  color-scheme: dark;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  background: #050407;
  color: #fff0b8;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 208, 90, 0.2), transparent 32%),
    linear-gradient(180deg, #160f22 0%, #050407 100%);
}

button {
  appearance: none;
  border: 0;
  border-radius: 2px;
  background: #ffd05a;
  color: #080506;
  cursor: pointer;
  font: 800 16px/1.1 inherit;
  min-width: 128px;
  min-height: 44px;
  padding: 12px 18px;
  box-shadow: 0 0 0 3px #000, 0 10px 0 rgba(0, 0, 0, 0.45);
}

button:hover {
  filter: brightness(1.07);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  background: #161a3a;
  color: #fff0b8;
  border: 2px solid #55d9ff;
  box-shadow: 0 0 0 3px #000;
}

#gameShell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(90deg, rgba(255, 208, 90, 0.08), transparent 14%, transparent 86%, rgba(255, 208, 90, 0.08)),
    #050407;
}

#gameCanvas {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  display: block;
  background: #060508;
  border: 8px solid #000;
  box-shadow:
    0 0 0 4px #ffd05a,
    0 0 0 14px #17111d,
    0 32px 80px rgba(0, 0, 0, 0.72);
  image-rendering: auto;
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 2px, rgba(0, 0, 0, 0) 2px 6px),
    linear-gradient(180deg, rgba(5, 4, 7, 0.52), rgba(5, 4, 7, 0.9));
}

.overlay--active {
  display: grid;
}

.title-panel,
.end-panel {
  width: min(720px, calc(100vw - 40px));
  border: 6px solid #000;
  border-radius: 2px;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(255, 208, 90, 0.18), transparent 32%),
    linear-gradient(180deg, rgba(22, 26, 58, 0.96), rgba(8, 5, 6, 0.96));
  box-shadow:
    0 0 0 4px #ffd05a,
    0 30px 80px rgba(0, 0, 0, 0.5);
}

.eyebrow {
  margin: 0 0 10px;
  color: #55d9ff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-size: clamp(40px, 7vw, 72px);
  line-height: 0.92;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(44px, 7vw, 72px);
  overflow-wrap: anywhere;
}

.tagline {
  max-width: 560px;
  margin: 18px 0 22px;
  color: rgba(255, 240, 184, 0.82);
  font-size: 18px;
  line-height: 1.45;
}

.control-grid,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.control-grid div,
.stats-grid div,
.asset-summary {
  min-height: 62px;
  border: 4px solid #000;
  border-radius: 2px;
  padding: 12px;
  background: rgba(8, 5, 6, 0.6);
  box-shadow: inset 0 0 0 2px rgba(255, 208, 90, 0.18);
}

.control-grid strong,
.stats-grid strong {
  display: block;
  margin-bottom: 6px;
}

.control-grid span,
.stats-grid span,
.asset-summary {
  color: rgba(255, 240, 184, 0.76);
  font-size: 14px;
}

.title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.debug-overlay {
  position: fixed;
  top: 12px;
  right: 12px;
  width: min(420px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  border: 1px solid rgba(138, 231, 255, 0.3);
  border-radius: 2px;
  padding: 12px;
  background: rgba(8, 5, 6, 0.9);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.debug-header button {
  min-width: 0;
  min-height: 34px;
  padding: 8px 10px;
  font-size: 12px;
}

#debugText {
  margin: 0;
  color: #fff0b8;
  white-space: pre-wrap;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 720px) {
  .title-panel,
  .end-panel {
    padding: 20px;
  }

  .control-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Arcade opening screen (full neon arcade-room illustration) ===== */
.arcade-overlay {
  padding: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(120, 60, 200, 0.16), transparent 42%),
    #050407;
  overflow: hidden;
}

.arcade-overlay.arcade--gated .arcade-scene {
  transform: scale(1.035);
  filter: blur(10px) brightness(0.58) saturate(0.88);
}

.arcade-overlay.arcade--gated .arcade-enter-prompt {
  display: none;
}

.arcade-gate {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 226, 122, 0.12), transparent 24%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.62));
  transition: opacity 0.34s ease, visibility 0.34s ease;
}

.arcade-overlay:not(.arcade--gated) .arcade-gate {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.arcade-gate-button {
  display: inline-grid;
  place-items: center;
  min-width: min(420px, 82vw);
  min-height: 74px;
  padding: 18px 28px;
  border: 2px solid #ffe27a;
  border-radius: 6px;
  color: #ffe27a;
  background:
    linear-gradient(180deg, rgba(35, 21, 57, 0.86), rgba(8, 5, 16, 0.94)),
    #090611;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.1),
    0 0 24px rgba(255, 226, 122, 0.36),
    0 18px 42px rgba(0, 0, 0, 0.72);
  font: inherit;
  font-size: clamp(18px, 3.8vw, 34px);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-shadow: 0 0 14px rgba(255, 210, 90, 0.78);
  cursor: pointer;
  animation: arcadeBlink 1.05s steps(1) infinite;
}

.arcade-gate-button:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 6px;
}

/* The scene IS the arcade-room art (4:3). The live marquee + CRT are positioned
   over the illustration's blank marquee and magenta screen placeholders. */
.arcade-scene {
  position: relative;
  width: min(100vw, calc(100vh * 1448 / 1086));
  height: min(100vh, calc(100vw * 1086 / 1448));
  overflow: hidden;
  background:
    url("assets/arcade_opening_flappers.png?v=gameplay-hp-20260609-1") center / cover no-repeat,
    #07040b;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7);
  transform-origin: 50% 38%;
  transition:
    transform 0.62s cubic-bezier(0.6, 0, 0.82, 0.34),
    opacity 0.42s ease 0.2s,
    filter 0.5s ease;
  will-change: transform, opacity;
}

/* Intro stage 1: short push-in that frames the upper cabinet — marquee, the
   song-select screen, and the joystick/buttons below it (not so tight it crops
   the controls off). */
.arcade-overlay.arcade--focus .arcade-scene {
  transform: scale(2.5);
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Wide/landscape viewports are height-limited, so the same scale crops the
   marquee/controls — ease the push-in there to keep the whole face in frame. */
@media (min-aspect-ratio: 4 / 3) {
  .arcade-overlay.arcade--focus .arcade-scene {
    transform: scale(2);
  }
}

/* Stage 2: on play, dive the rest of the way in and reveal full-screen gameplay */
.arcade-overlay.arcade--launch .arcade-scene {
  transform: scale(9);
  opacity: 0;
  filter: brightness(2.1);
}

/* "Click to enter" prompt over the wide room — first click starts the muffled
   title music (browser audio needs a gesture) and triggers the push-in. */
.arcade-enter-prompt {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8.5%;
  display: block;
  width: 100%;
  padding: 0.25em 0;
  border: 0;
  background: transparent;
  text-align: center;
  color: #ffe27a;
  font: inherit;
  font-weight: 900;
  font-size: clamp(14px, 3vh, 26px);
  letter-spacing: 0.14em;
  text-shadow: 0 0 14px rgba(255, 210, 90, 0.85), 0 3px 8px rgba(0, 0, 0, 0.9);
  animation: arcadeBlink 1s steps(1) infinite;
  cursor: pointer;
  z-index: 5;
}

.arcade-enter-prompt.is-hidden {
  display: none;
}

.arcade-enter-prompt:focus-visible {
  outline: 2px solid #ffe27a;
  outline-offset: 6px;
}

/* Title across the blank cream marquee (positioned over the art) */
.cab-marquee-mount {
  position: absolute;
  left: 35.2%;
  top: 17.1%;
  width: 27.8%;
  height: 10.4%;
  display: grid;
  place-items: center;
  text-align: center;
  pointer-events: none;
  container-type: size;
  display: none;
}

.marquee-title {
  color: #2a1338;
  font-weight: 900;
  line-height: 0.96;
  letter-spacing: 0.01em;
  font-size: 25cqh;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

/* Live CRT screen mounted into the magenta placeholder hole (sits ABOVE the
   joystick/buttons control panel — keep height short so it doesn't cover them) */
.cab-screen-mount {
  position: absolute;
  left: 39.8%;
  top: 33.9%;
  width: 20.0%;
  height: 19.2%;
  padding: 0;
  margin: 0;
  border: 0;
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
  cursor: pointer;
  border-radius: 2.5% / 4.5%;
  container-type: size;
  background: radial-gradient(120% 130% at 50% 26%, #0b3022, #04150e 68%, #020a07);
  box-shadow: inset 0 0 6cqh rgba(0, 0, 0, 0.85), inset 0 0 0 1px rgba(120, 255, 200, 0.14);
  transition: filter 0.18s ease, transform 0.18s ease;
}

.cab-screen-mount:hover { filter: brightness(1.1); }
.cab-screen-mount:focus-visible { outline: 2px solid #ffe27a; outline-offset: 2px; }

/* Real start control kept for ui.js bindings; visually hidden, screen forwards clicks to it */
.cab-start-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.crt {
  position: absolute;
  inset: 0;
  color: #8fffd0;
  text-shadow: 0 0 0.8cqh rgba(80, 255, 180, 0.75);
}

.crt-selector,
.crt-result-panel {
  position: absolute;
  inset: 0;
}

.crt-selector {
  padding: 3.1cqh 4.4cqw;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 1.15cqh;
}

.crt-result-panel {
  display: none;
  padding: 2.8cqh 4.2cqw;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 0.85cqh;
}

.arcade-overlay.arcade--result .crt-selector {
  display: none;
}

.arcade-overlay.arcade--result .crt-result-panel {
  display: grid;
}

.crt-header { text-align: center; color: #ffe27a; text-shadow: 0 0 1.2cqh rgba(255, 210, 90, 0.85); font-weight: 900; letter-spacing: 0.03em; font-size: 5.8cqh; white-space: nowrap; }
.song-list { min-height: 0; list-style: none; margin: 0; padding: 0; display: grid; gap: 0.65cqh; align-content: stretch; }
.song-row { display: grid; grid-template-columns: 4cqw minmax(0, 1fr); align-items: center; gap: 0.18cqh 1.1cqw; padding: 0.72cqh 1.6cqw; border: 1px solid rgba(120, 255, 200, 0.2); border-radius: 1cqh; font-size: 3.9cqh; cursor: pointer; user-select: none; transition: border-color 120ms ease, background 120ms ease, color 120ms ease; }
.song-row .song-name { min-width: 0; font-weight: 800; letter-spacing: 0; line-height: 0.96; white-space: normal; }
.song-row .song-meta { grid-column: 2; min-width: 0; color: rgba(143, 255, 208, 0.72); font-size: 2.55cqh; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-row:hover,
.song-row:focus-visible { outline: none; background: rgba(120, 255, 200, 0.1); border-color: rgba(143, 255, 208, 0.72); }
.song-row.is-selected { background: rgba(255, 226, 122, 0.16); border-color: #ffe27a; color: #fff; }
.song-row.is-selected .song-name { color: #fff; }
.song-row.is-selected .song-arrow { color: #ffe27a; animation: arcadeBlink 0.7s steps(1) infinite; }
.song-row.is-locked { color: rgba(143, 255, 208, 0.4); border-color: rgba(120, 255, 200, 0.08); cursor: default; }
.crt-hint { text-align: center; color: #fff; font-size: 5.2cqh; letter-spacing: 0.03em; white-space: nowrap; }
.crt-hint b { color: #ffe27a; animation: arcadeBlink 0.9s steps(1) infinite; }
@keyframes arcadeBlink { 50% { opacity: 0.22; } }

.crt-result-eyebrow {
  color: #ffe27a;
  font-size: 3.6cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
}

.crt-result-title {
  color: #fff;
  font-size: 7.8cqh;
  font-weight: 900;
  line-height: 0.92;
  text-align: center;
  text-shadow: 0 0 1.4cqh rgba(255, 226, 122, 0.72);
}

.crt-result-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55cqh 1.4cqw;
}

.crt-result-stats div {
  min-width: 0;
  border: 1px solid rgba(120, 255, 200, 0.2);
  border-radius: 0.9cqh;
  padding: 0.5cqh 1.4cqw;
  background: rgba(255, 226, 122, 0.08);
}

.crt-result-stats strong,
.crt-result-stats span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crt-result-stats strong {
  color: rgba(143, 255, 208, 0.72);
  font-size: 2.45cqh;
}

.crt-result-stats span {
  color: #fff;
  font-size: 3.65cqh;
  font-weight: 900;
}

.crt-next-song {
  align-self: end;
  display: grid;
  gap: 0.42cqh;
}

.crt-mini-label {
  color: #ffe27a;
  font-size: 2.55cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.crt-song-choice {
  display: grid;
  grid-template-columns: 3.4cqw minmax(0, 1fr) minmax(0, auto);
  align-items: center;
  gap: 1cqw;
  border: 1px solid rgba(120, 255, 200, 0.14);
  border-radius: 0.9cqh;
  padding: 0.42cqh 1.35cqw;
  font-size: 2.8cqh;
  cursor: pointer;
  user-select: none;
  transition: border-color 120ms ease, background 120ms ease;
}

.crt-song-choice strong,
.crt-song-choice em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crt-song-choice strong {
  color: #fff;
  line-height: 0.98;
  white-space: normal;
}

.crt-song-choice em {
  color: rgba(143, 255, 208, 0.72);
  font-style: normal;
  font-size: 2.15cqh;
}

.crt-song-choice.is-selected {
  border-color: #ffe27a;
  background: rgba(255, 226, 122, 0.12);
}

.crt-song-choice:not(.is-selected):hover,
.crt-song-choice:not(.is-selected):focus-visible {
  outline: none;
  border-color: rgba(143, 255, 208, 0.72);
  background: rgba(120, 255, 200, 0.09);
}

.crt-song-choice.is-selected span {
  color: #ffe27a;
  animation: arcadeBlink 0.7s steps(1) infinite;
}

.crt-song-choice.is-locked {
  opacity: 0.46;
  cursor: default;
}

.crt-play-button {
  justify-self: center;
  min-width: 0;
  min-height: 0;
  padding: 0.9cqh 4cqw;
  border-radius: 1.1cqh;
  font-size: 3.7cqh;
  line-height: 1;
  box-shadow: 0 0 0 1px #000, 0 0 2cqh rgba(255, 226, 122, 0.42);
}

.crt-scanlines { position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.32) 0 1px, rgba(0, 0, 0, 0) 1px 3px); mix-blend-mode: multiply; }
.crt-glass { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(130% 90% at 50% -4%, rgba(255, 255, 255, 0.14), transparent 44%); }

.arcade-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2.2%;
  margin: 0;
  color: rgba(255, 244, 214, 0.82);
  font-size: clamp(9px, 1.5vh, 13px);
  letter-spacing: 0.04em;
  text-align: center;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}
