[hidden] { display: none !important; }
/* Layout: portrait is one arcade cabinet column (HUD strip on top, 480x600 playfield below);
   landscape puts panels beside the playfield (see the end of this file). DOM overlays sit on the
   playfield. Single dark theme by design. */
:root {
  --bg: #0B0E24;
  --panel: #141A3A;
  --edge: #2A3370;
  --ink: #F3F0E6;
  --muted: #A3ACDD;
  --amber: #FFB238;
  --lime: #B6F24A;
  --cyan: #3FE0D0;
  --pink: #FF4F8B;
  --field: #05071A;
  --scan: rgba(0, 0, 0, 0.22);
  --veil: rgba(5, 7, 26, 0.88);
  --flash: #FF4F8B;
  --display: 'Press Start 2P', ui-monospace, Menlo, monospace;
  --body: 'VT323', ui-monospace, Menlo, monospace;
  --canvas-font: 'Press Start 2P', ui-monospace, monospace;
  --canvas-size: 10px;
  --fs: 1; /* multiplier for display-font sizes */
  color-scheme: dark;
}
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 20px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  overflow: hidden;
  display: flex;
  justify-content: center;
}
.app {
  width: 100%;
  max-width: 480px;
  height: 100%;
  box-sizing: border-box;
  padding-block: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hud { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.cell {
  background: var(--panel);
  border: 2px solid var(--edge);
  padding: 6px 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cell span:first-child { font-family: var(--display); font-size: calc(8px * var(--fs)); letter-spacing: 0.08em; color: var(--muted); }
.cell span:last-child { font-size: clamp(19px, 5.6vw, 28px); line-height: 26px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#hudLeft.hot { color: var(--pink); }
.stagewrap { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.screen { position: relative; border: 3px solid var(--edge); background: var(--field); box-sizing: content-box; }
.screen canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, var(--scan) 2px 3px);
}
.overlay {
  position: absolute;
  inset: 0;
  background: var(--veil);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  box-sizing: border-box;
  text-align: center;
  z-index: 2;
  overflow-y: auto;
}
.overlay { justify-content: flex-start; }
.overlay > :first-child { margin-top: auto; }
.overlay > :last-child { margin-bottom: auto; }
.overlay.clear-bg { background: transparent; }
.overlay[hidden], form[hidden] { display: none; }
h1, h2 { font-family: var(--display); font-weight: 400; margin: 0; text-wrap: balance; }
h1 { font-size: calc(26px * var(--fs)); line-height: 38px; color: var(--amber); text-shadow: 3px 3px 0 var(--pink); }
h2 { font-size: calc(18px * var(--fs)); line-height: 28px; }
.kicker { font-family: var(--display); font-size: calc(10px * var(--fs)); line-height: 1.6; letter-spacing: 0.12em; color: var(--muted); }
.big { font-family: var(--display); font-size: calc(30px * var(--fs)); line-height: 40px; }
p { margin: 0; line-height: 22px; max-width: 34ch; }
.muted { color: var(--muted); }
.btn {
  font-family: var(--display);
  font-size: calc(12px * var(--fs));
  color: var(--bg);
  background: var(--amber);
  border: none;
  box-shadow: 4px 4px 0 var(--pink);
  padding: 14px 18px;
  min-height: 44px;
  cursor: pointer;
}
.btn.alt { background: var(--cyan); box-shadow: 4px 4px 0 var(--edge); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: none; border: 2px solid var(--edge); }
.btn:focus-visible, input:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--pink); }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.board { width: 100%; max-width: 340px; border-collapse: collapse; font-size: 20px; font-variant-numeric: tabular-nums; }
.board th { font-family: var(--display); font-size: calc(8px * var(--fs)); color: var(--muted); font-weight: 400; padding: 4px; text-align: left; }
.board td { padding: 3px 4px; text-align: left; border-top: 1px solid var(--edge); }
.board td:first-child { color: var(--muted); }
.board tr.me td { color: var(--lime); }
.stages { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip { font-family: var(--display); font-size: calc(8px * var(--fs)); padding: 6px 8px; border: 2px solid var(--edge); }
.chip.a { color: var(--amber); } .chip.l { color: var(--lime); } .chip.c { color: var(--cyan); } .chip.p { color: var(--pink); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; max-width: 340px; }
.stats div { border: 2px solid var(--edge); padding: 6px; display: flex; flex-direction: column; }
.stats b { font-family: var(--display); font-size: calc(8px * var(--fs)); font-weight: 400; color: var(--muted); }
.stats span { font-size: 28px; font-variant-numeric: tabular-nums; }
.initials { display: flex; gap: 8px; align-items: center; }
.initials label { font-family: var(--display); font-size: calc(9px * var(--fs)); color: var(--muted); }
.initials input {
  width: 92px;
  font-family: var(--display);
  font-size: calc(18px * var(--fs));
  text-transform: uppercase;
  text-align: center;
  background: var(--field);
  color: var(--lime);
  border: 2px solid var(--edge);
  padding: 8px;
  min-height: 44px;
  box-sizing: border-box;
}
.foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 18px; color: var(--muted); }
.foot button { font-family: var(--display); font-size: calc(8px * var(--fs)); background: transparent; color: var(--muted); border: 2px solid var(--edge); padding: 8px 10px; min-height: 36px; cursor: pointer; }
.toast { font-family: var(--display); font-size: calc(9px * var(--fs)); color: var(--lime); min-height: 12px; }
.pick {
  font-family: var(--body);
  font-size: 20px;
  background: var(--field);
  color: var(--ink);
  border: 2px solid var(--edge);
  padding: 6px 8px;
  min-height: 44px;
  max-width: 220px;
}
.pick:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
#btnInsane[aria-pressed="true"] { color: var(--pink); border-color: var(--pink); }
.app.insane .cell { border-color: var(--pink); }
.app.insane .screen { border-color: var(--pink); }
@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }

/* ---------- portrait (default): one column; side panels collapse ---------- */
.side { display: contents; }
.wide-only { display: none !important; }
.card { background: var(--panel); border: 2px solid var(--edge); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card .board { max-width: none; }

/* ---------- landscape (16:9 portals, desktop): playfield centered at full height, panels beside it.
   The playfield stays 480x600; only the frame around it changes. Keep this query in sync with
   WIDE_QUERY in js/core.js, which sizes the playfield column. ---------- */
@media (min-aspect-ratio: 5/4) and (min-width: 600px) {
  .app {
    max-width: 1600px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--screen-w, 486px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 16px;
  }
  .side { display: flex; flex-direction: column; justify-content: center; gap: 12px; min-width: 0; min-height: 0; overflow: hidden; }
  .side-left { order: 1; }
  .stagewrap { order: 2; height: 100%; }
  .side-right { order: 3; }
  .wide-only { display: flex !important; }
  p.wide-only { display: block !important; }
  .narrow-only { display: none !important; }
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cell span:last-child { font-size: clamp(20px, 2.4vw, 34px); line-height: 1.2; }
  .card h2 { font-size: calc(clamp(12px, 1.4vw, 18px) * var(--fs)); line-height: 1.5; }
  .card p { max-width: none; }
  .foot { flex-wrap: wrap; }
}
/* Short landscape screens (phones turned sideways): trim the title screen and tighten panels. */
@media (min-aspect-ratio: 5/4) and (min-width: 600px) and (max-height: 520px) {
  .app { padding-block: 8px; gap: 10px; }
  .side { gap: 8px; }
  .card { padding: 8px; gap: 6px; }
  .cell { padding: 4px 6px 2px; }
  .cell span:last-child { font-size: 20px; line-height: 22px; }
  .card p, .keys { font-size: 16px; line-height: 18px; }
  .board { font-size: 16px; }
  .board td { padding: 1px 4px; }
  .side p.keys, .foot > span { display: none !important; }
  #ovTitle .stages, #ovTitle > p.muted, #ovTitle > .kicker:first-child { display: none; }
  .overlay { gap: 8px; padding: 10px; }
  h1 { font-size: calc(18px * var(--fs)); line-height: 26px; }
  .btn { padding: 10px 12px; font-size: calc(10px * var(--fs)); }
}

/* ---------- replay viewer: bar over the playfield while watching a ranked run ---------- */
.watchbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  background: var(--veil); border-bottom: 2px solid var(--cyan);
  font-family: var(--display); font-size: calc(8px * var(--fs)); line-height: 1.6; color: var(--cyan);
}
.watchbar[hidden] { display: none; }
.watchbar span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watchbar button { font-family: var(--display); font-size: calc(8px * var(--fs)); background: transparent; color: var(--ink); border: 2px solid var(--edge); padding: 6px 8px; min-height: 32px; cursor: pointer; }
.board button.watch { font-size: 14px; line-height: 1; background: transparent; color: var(--cyan); border: 2px solid var(--edge); min-width: 34px; min-height: 30px; padding: 2px 8px; cursor: pointer; }
.board button.watch:hover, .board button.watch:focus-visible { border-color: var(--cyan); }

/* ---------- phosphor look (default): one amber phosphor hue on a dark tube, glow instead of
   scanlines, terminal type. The picture runs hot as the clock drains (see draw() in js/loop.js).
   Colors keep their token names so stage code is untouched: "pink" is the hottest tint, used
   for danger; "cyan" and "lime" are cooler amber tints. ---------- */
:root[data-look="phosphor"] {
  --bg: #060401;
  --panel: #0e0903;
  --edge: #3d2a0a;
  --ink: #ffdf9e;
  --muted: #a8781f;
  --amber: #ffb000;
  --lime: #ffcc4d;
  --cyan: #e39c00;
  --pink: #fff2d2;
  --field: #070502;
  --scan: transparent;
  --veil: rgba(6, 4, 1, 0.9);
  --flash: #ff4a14;
  --glow: rgba(255, 176, 0, 0.38);
  --display: 'Jersey 25', 'VT323', ui-monospace, monospace;
  --body: 'VT323', ui-monospace, Menlo, monospace;
  --canvas-font: 'VT323', ui-monospace, monospace;
  --canvas-size: 18px;
  --fs: 1.55;
}
[data-look="phosphor"] body { text-shadow: 0 0 7px var(--glow); }
[data-look="phosphor"] h1, [data-look="phosphor"] h2 { letter-spacing: 0.04em; }
[data-look="phosphor"] h1 { color: var(--amber); text-shadow: 0 0 10px var(--glow), 0 0 28px var(--glow); }
[data-look="phosphor"] .kicker, [data-look="phosphor"] .cell span:first-child, [data-look="phosphor"] .board th,
[data-look="phosphor"] .stats b, [data-look="phosphor"] .initials label { letter-spacing: 0.08em; }
[data-look="phosphor"] .screen {
  border-color: var(--edge);
  box-shadow: 0 0 36px rgba(255, 176, 0, 0.1), inset 0 0 0 1px rgba(255, 176, 0, 0.08);
}
[data-look="phosphor"] .screen::after { background: radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, 0.6) 100%); }
[data-look="phosphor"] .cell, [data-look="phosphor"] .card, [data-look="phosphor"] .stats div { box-shadow: inset 0 0 24px rgba(255, 176, 0, 0.05); }
[data-look="phosphor"] .btn {
  background: transparent; color: var(--amber); border: 2px solid var(--amber);
  box-shadow: 0 0 14px var(--glow), inset 0 0 14px rgba(255, 176, 0, 0.12);
  text-shadow: 0 0 8px var(--glow);
}
[data-look="phosphor"] .btn.alt { color: var(--ink); border-color: var(--ink); box-shadow: 0 0 14px rgba(255, 223, 158, 0.3), inset 0 0 14px rgba(255, 223, 158, 0.1); }
[data-look="phosphor"] .btn.ghost { color: var(--muted); border-color: var(--edge); box-shadow: none; }
[data-look="phosphor"] .btn:active { transform: none; background: var(--amber); color: var(--bg); text-shadow: none; }
[data-look="phosphor"] .chip { border-color: var(--edge); }
[data-look="phosphor"] .chip.a, [data-look="phosphor"] .chip.l, [data-look="phosphor"] .chip.c { color: var(--amber); }
[data-look="phosphor"] .chip.p { color: var(--ink); }
[data-look="phosphor"] .initials input { color: var(--amber); }
[data-look="phosphor"] .toast { color: var(--amber); }
[data-look="phosphor"] .board tr.me td { color: var(--pink); }
[data-look="phosphor"] .board button.watch { color: var(--amber); }
[data-look="phosphor"] .watchbar { border-bottom-color: var(--amber); color: var(--amber); }
[data-look="phosphor"] .app.insane .cell, [data-look="phosphor"] .app.insane .screen { border-color: var(--pink); }
[data-look="phosphor"] #btnInsane[aria-pressed="true"] { color: var(--pink); border-color: var(--pink); }
/* The clock runs hot: the LEFT readout pulses in the last ten seconds. */
@keyframes hot { 0%, 100% { color: var(--pink); text-shadow: 0 0 6px var(--glow); } 50% { color: #ff6a2a; text-shadow: 0 0 14px rgba(255, 90, 30, 0.7); } }
[data-look="phosphor"] #hudLeft.hot { animation: hot 0.5s steps(2, end) infinite; }
@media (prefers-reduced-motion: reduce) { [data-look="phosphor"] #hudLeft.hot { animation: none; color: #ff6a2a; } }
/* Title matches the logo (> INSERT RAGE█): RAGE and the cursor run white-hot. Phosphor only. */
.title .cursor { display: none; }
[data-look="phosphor"] .title .rage { color: var(--pink); text-shadow: 0 0 4px rgba(255, 242, 210, 0.9), 0 0 12px rgba(255, 140, 30, 0.8), 0 0 30px rgba(255, 74, 20, 0.5); }
[data-look="phosphor"] .title .cursor {
  display: inline-block; width: 0.42em; height: 0.72em; margin-left: 0.13em; background: var(--pink);
  box-shadow: 0 0 6px rgba(255, 140, 30, 0.9), 0 0 18px rgba(255, 74, 20, 0.6);
  animation: blink 1.06s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { [data-look="phosphor"] .title .cursor { animation: none; } }
.fine { font-size: 16px; line-height: 18px; max-width: 40ch; }
