/* Two looks share one stylesheet: "grid" (default) and "synthwave",
   switched by data-theme on <html>. Theme tokens first, then components. */

:root {
  --accent: #3cf4ff;
  --accent-rgb: 60, 244, 255;
  --glow: #1a6bff;
  --glow-rgb: 26, 107, 255;
  --warn: #ff8a1a;
  --warn-2: #ff2d3d;
  --text: #e8f8ff;
  --panel-bg: rgba(0, 8, 20, 0.8);
  --board-bg: #00060f;
  --font-display: 'Orbitron', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Share Tech Mono', ui-monospace, Consolas, monospace;
  --page-bg:
    radial-gradient(ellipse 120% 30% at 50% 55%, rgba(26, 107, 255, 0.22), transparent 70%),
    linear-gradient(180deg, #000 0%, #00040a 55%, #000 100%);
  --horizon: 55%;
  --floor-line: rgba(60, 244, 255, 0.55);
  --floor-line-w: 1px;
  --floor-cell: 80px;
  --floor-tilt: 64deg;
}

[data-theme='synthwave'] {
  --accent: #00f0ff;
  --accent-rgb: 0, 240, 255;
  --glow: #ff2bd6;
  --glow-rgb: 255, 43, 214;
  --warn: #ff2bd6;
  --warn-2: #ff2bd6;
  --text: #fff;
  --panel-bg: rgba(10, 0, 30, 0.72);
  --board-bg: #08001a;
  --font-body: var(--font-display);
  --page-bg: linear-gradient(180deg, #07010f 0%, #160430 35%, #3a0b5c 59.5%, #07010f 60%);
  --horizon: 60%;
  --floor-line: rgba(255, 43, 214, 0.75);
  --floor-line-w: 2px;
  --floor-cell: 64px;
  --floor-tilt: 62deg;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* --- frames ------------------------------------------------------------------ */

/* Grid: thin frame with bright corner brackets. */
.frame {
  --c: var(--accent);
  --k: 12px;
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--k) 2px,
    linear-gradient(var(--c), var(--c)) top left / 2px var(--k),
    linear-gradient(var(--c), var(--c)) top right / var(--k) 2px,
    linear-gradient(var(--c), var(--c)) top right / 2px var(--k),
    linear-gradient(var(--c), var(--c)) bottom left / var(--k) 2px,
    linear-gradient(var(--c), var(--c)) bottom left / 2px var(--k),
    linear-gradient(var(--c), var(--c)) bottom right / var(--k) 2px,
    linear-gradient(var(--c), var(--c)) bottom right / 2px var(--k),
    var(--panel-bg);
  background-repeat: no-repeat;
  background-origin: border-box;
}

/* Synthwave: soft rounded neon panels. */
[data-theme='synthwave'] .frame {
  background: var(--panel-bg);
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  border-radius: 10px;
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.25), inset 0 0 12px rgba(var(--accent-rgb), 0.1);
}

/* --- backdrop: a perspective floor (and ceiling) meeting at the horizon ------ */

.backdrop { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }

.floor, .ceiling {
  position: absolute;
  left: -50%;
  right: -50%;
  height: 90%;
  background-image:
    linear-gradient(var(--floor-line) var(--floor-line-w), transparent var(--floor-line-w)),
    linear-gradient(90deg, var(--floor-line) var(--floor-line-w), transparent var(--floor-line-w));
  background-size: var(--floor-cell) var(--floor-cell);
  animation: grid-scroll 2.4s linear infinite;
}

.floor {
  top: var(--horizon);
  transform: perspective(260px) rotateX(var(--floor-tilt));
  transform-origin: 50% 0;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 35%);
  mask-image: linear-gradient(180deg, transparent, #000 35%);
}

.ceiling {
  bottom: calc(100% - var(--horizon));
  opacity: 0.3;
  transform: perspective(260px) rotateX(calc(-1 * var(--floor-tilt)));
  transform-origin: 50% 100%;
  -webkit-mask-image: linear-gradient(0deg, transparent, #000 35%);
  mask-image: linear-gradient(0deg, transparent, #000 35%);
  animation-direction: reverse;
}

.horizon {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--horizon);
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 24px 4px rgba(var(--glow-rgb), 0.8);
}

.sun, .stars { display: none; }

[data-theme='synthwave'] .ceiling { display: none; }
[data-theme='synthwave'] .horizon { height: 2px; background: var(--glow); box-shadow: 0 0 18px 2px var(--glow); }
[data-theme='synthwave'] .floor { background-color: #07010f; animation-duration: 1.2s; }
[data-theme='synthwave'] .sun {
  display: block;
  position: absolute;
  left: 50%;
  top: var(--horizon);
  width: min(72vmin, 540px);
  aspect-ratio: 1;
  transform: translate(-50%, -80%);
  border-radius: 50%;
  background: linear-gradient(180deg, #ffe600 0%, #ff8a00 35%, #ff2bd6 72%, #a855f7 100%);
  --stripes: linear-gradient(180deg, #000 50%, transparent 50% 53%, #000 53% 60%, transparent 60% 64%,
    #000 64% 70%, transparent 70% 75%, #000 75% 80%, transparent 80% 86%, #000 86%);
  -webkit-mask-image: var(--stripes);
  mask-image: var(--stripes);
  filter: drop-shadow(0 0 40px rgba(255, 43, 214, 0.6));
  opacity: 0.5;
}

@keyframes grid-scroll { to { background-position: 0 var(--floor-cell), 0 var(--floor-cell); } }

/* --- layout ---------------------------------------------------------------- */

.app {
  position: relative;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.hud {
  width: min(100%, 560px);
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.4fr auto;
  gap: 8px;
}

.stat { padding: 8px 6px; text-align: center; min-width: 0; }

.label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(var(--accent-rgb), 0.75);
}

.value {
  display: block;
  font-size: clamp(18px, 5.5vw, 28px);
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 0 6px var(--accent), 0 0 14px var(--glow);
}

[data-theme='synthwave'] .value {
  font-size: clamp(14px, 4.2vw, 24px); /* Orbitron digits are wide */
  font-weight: 700;
  letter-spacing: 0;
  text-shadow: 0 0 8px var(--accent);
}

.stat.low { --c: var(--warn); }
.stat.low .value { text-shadow: 0 0 6px var(--warn), 0 0 14px var(--warn-2); }

/* Survival's power bar, in place of the middle stat's number. */
.meter-row { display: flex; align-items: center; gap: 4px; margin: 9px 0 7px; }
.meter {
  flex: 1;
  min-width: 0;
  height: 10px;
  border: 1px solid rgba(var(--accent-rgb), 0.5);
}
.level { font-size: 11px; letter-spacing: 0; white-space: nowrap; color: rgba(var(--accent-rgb), 0.85); font-variant-numeric: tabular-nums; }
.stat.low .level { color: var(--warn); }
.meter-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  transition: width 0.25s ease-out;
}
.stat.low .meter-fill { background: var(--warn); box-shadow: 0 0 8px var(--warn-2); }
[data-theme='synthwave'] .meter, [data-theme='synthwave'] .meter-fill { border-radius: 999px; }

.bump { animation: bump 0.25s ease-out; }
@keyframes bump { 40% { transform: scale(1.15); } }

.icon-btn {
  width: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--accent);
  cursor: pointer;
  filter: drop-shadow(0 0 4px rgba(var(--accent-rgb), 0.6));
}

.board-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: grid;
  place-items: center; /* board centred in the space below the HUD */
  container-type: size;
}

/* Opaque on purpose: anything see-through lets the horizon line show through the board. */
/* --rows/--cols are set from the board shape; tiles top out at 70px */
#board {
  --rows: 8;
  --cols: 8;
  --cell: min(100cqw / var(--cols), 100cqh / var(--rows), 70px);
  display: block;
  width: calc(var(--cell) * var(--cols));
  height: calc(var(--cell) * var(--rows));
  border-radius: 2px;
  background: var(--board-bg);
  box-shadow: 0 0 24px rgba(var(--glow-rgb), 0.45), 0 0 80px rgba(var(--glow-rgb), 0.2);
  touch-action: none;
}

[data-theme='synthwave'] #board {
  border-radius: 14px;
  box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.75), 0 0 30px rgba(0, 240, 255, 0.35), 0 0 80px rgba(255, 43, 214, 0.25);
}

/* --- overlays ---------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  display: flex; /* with the panel's auto margin: centred, but scrollable from the top when too tall */
  padding: 24px;
  background: rgba(0, 2, 8, 0.65);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  overflow-y: auto;
}

.panel {
  --k: 18px;
  width: 100%;
  max-width: 420px;
  margin: auto;
  padding: 36px 24px 28px;
  text-align: center;
  box-shadow: 0 0 40px rgba(var(--glow-rgb), 0.35);
}

[data-theme='synthwave'] .panel { border-color: rgba(255, 43, 214, 0.6); border-radius: 18px; box-shadow: 0 0 40px rgba(255, 43, 214, 0.35); }

.title {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: clamp(34px, 11vw, 52px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  /* chrome with a hard horizon line through the middle */
  background: linear-gradient(180deg, #fff 0%, #c8f6ff 45%, #1a6bff 50%, #7fe6ff 58%, #fff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 10px rgba(60, 244, 255, 0.55));
}

[data-theme='synthwave'] .title {
  font-size: clamp(40px, 13vw, 64px);
  font-style: italic;
  line-height: 0.95;
  letter-spacing: 0.04em;
  background-image: linear-gradient(180deg, #fff 0%, #00f0ff 45%, #ff2bd6 55%, #ffe600 100%);
  filter: drop-shadow(0 0 12px rgba(255, 43, 214, 0.6));
}

.result {
  margin: 0;
  font-size: 44px;
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow: 0 0 8px var(--warn), 0 0 20px var(--warn-2);
}

[data-theme='synthwave'] .result { font-weight: 900; color: #ffe600; text-shadow: 0 0 14px #ffe600; letter-spacing: 0; }

.over-mode {
  margin: -4px 0 12px;
  font-size: 12px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(var(--accent-rgb), 0.75);
}

/* --- mode picker ----------------------------------------------------------- */

.mode-list { display: grid; gap: 10px; text-align: left; }

.mode {
  --k: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 12px;
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}
.mode-name {
  font: 700 15px var(--font-display);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.6);
}
.mode-best { font-size: 12px; letter-spacing: 0.08em; color: rgba(232, 248, 255, 0.6); font-variant-numeric: tabular-nums; }
.mode-blurb { grid-column: 1 / -1; font-size: 12px; letter-spacing: 0.04em; line-height: 1.4; color: rgba(232, 248, 255, 0.7); }

.mode:hover, .mode:focus-visible { outline: none; box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.4); }
.mode:hover .mode-name, .mode:focus-visible .mode-name { color: #fff; }
.mode:active { transform: scale(0.98); }

[data-theme='synthwave'] .mode { border-radius: 12px; }
[data-theme='synthwave'] .mode-name { font-size: 16px; letter-spacing: 0.08em; font-style: italic; }

/* The title shrinks a little so the mode list fits on a phone. */
#title .title { font-size: clamp(28px, 9vw, 44px); margin-bottom: 20px; }
[data-theme='synthwave'] #title .title { font-size: clamp(32px, 11vw, 52px); }
#title .panel { padding-top: 28px; }

.menu .btn { display: block; margin: 8px auto 6px; }
.menu .link-btn { margin-top: 4px; }

.blurb {
  margin: 10px 0 24px;
  color: rgba(232, 248, 255, 0.75);
  letter-spacing: 0.06em;
  line-height: 1.6;
}

.btn {
  padding: 14px 44px;
  font: 700 16px var(--font-display);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent);
  cursor: pointer;
}

[data-theme='synthwave'] .btn { border: 2px solid var(--accent); border-radius: 999px; font-size: 18px; }

.btn:hover, .btn:focus-visible, .icon-btn:hover, .icon-btn:focus-visible {
  outline: none;
  color: #fff;
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.45);
}
.btn:active, .icon-btn:active { transform: scale(0.97); }

.link-btn {
  display: block;
  margin: 14px auto 0;
  padding: 8px 12px;
  background: none;
  border: 0;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(var(--accent-rgb), 0.75);
  cursor: pointer;
}
.title-links { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.title-links .link-btn { margin: 0; }

.link-btn:hover, .link-btn:focus-visible { color: var(--accent); outline: none; text-shadow: 0 0 8px var(--accent); }

/* --- settings ---------------------------------------------------------------- */

.settings { max-width: 380px; text-align: left; }

.panel-title {
  margin: 0 0 12px;
  text-align: center;
  font: 700 18px var(--font-display);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.15);
  letter-spacing: 0.08em;
}

.row input[type='range'] { width: 55%; accent-color: var(--accent); cursor: pointer; }

.toggle {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 48px;
  height: 26px;
  margin: 0;
  border: 1px solid rgba(var(--accent-rgb), 0.6);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s;
}
.toggle::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: rgba(var(--accent-rgb), 0.45);
  transition: transform 0.15s;
}
.toggle:checked { background: rgba(var(--accent-rgb), 0.18); box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.4); }
.toggle:checked::before { transform: translateX(22px); background: var(--accent); box-shadow: 0 0 8px var(--accent); }

[data-theme='synthwave'] .toggle, [data-theme='synthwave'] .toggle::before { border-radius: 999px; }

/* ◀ name ▶ pickers for the look and the song */
.row.stacked { flex-direction: column; align-items: stretch; gap: 8px; }
.picker { display: flex; align-items: center; gap: 8px; }
.picker button {
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
}
.picker button:hover { background: rgba(var(--accent-rgb), 0.15); }
.pick-body { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.pick-preview { width: 180px; max-width: 100%; height: 30px; }
.pick-name { letter-spacing: 0.12em; text-transform: uppercase; color: #fff; text-shadow: 0 0 6px var(--accent); }
.pick-blurb { font-size: 12px; color: rgba(232, 248, 255, 0.6); }
[data-theme='synthwave'] .picker button { border-radius: 999px; }

.toggle:focus-visible, .picker button:focus-visible, .row input[type='range']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#settings-done { display: block; margin: 24px auto 0; }

/* --- reduced effects --------------------------------------------------------- */

/* Anything moving in the page background stops. */
.reduce-effects .backdrop *, .still-background .backdrop * { animation: none !important; }

@media (prefers-reduced-motion: reduce) {
  .backdrop * { animation: none !important; }
}

/* === Arcade: 8-bit cabinet ==================================================== */

[data-theme='arcade'] {
  --accent: #22e4ff;
  --accent-rgb: 34, 228, 255;
  --glow: #3a5bff;
  --glow-rgb: 58, 91, 255;
  --warn: #ff3b3b;
  --warn-2: #ff3b3b;
  --text: #ffffff;
  --panel-bg: #000;
  --board-bg: #000;
  --font-display: 'Press Start 2P', ui-monospace, monospace;
  --font-body: 'VT323', ui-monospace, monospace;
  --page-bg: #000;
}

[data-theme='arcade'] .floor,
[data-theme='arcade'] .ceiling,
[data-theme='arcade'] .horizon { display: none; }

/* Scrolling starfield: each layer moves a whole number of its tiles per loop,
   at different speeds for depth. */
[data-theme='arcade'] .stars {
  display: block;
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 20%, #fff 0 1px, transparent 1.5px),
    radial-gradient(circle at 70% 60%, #fff 0 1px, transparent 1.5px),
    radial-gradient(circle at 40% 85%, #9cf 0 1px, transparent 1.5px),
    radial-gradient(circle at 85% 10%, #ffd31a 0 1.5px, transparent 2px),
    radial-gradient(circle at 25% 55%, #ff4fe1 0 1px, transparent 1.5px);
  background-size: 120px 120px, 170px 170px, 210px 210px, 260px 260px, 150px 150px;
  animation: star-fall 30s linear infinite;
}
@keyframes star-fall { to { background-position: 0 480px, 0 510px, 0 420px, 0 520px, 0 450px; } }

[data-theme='arcade'] .frame { background: #000; border: 3px solid var(--glow); border-radius: 0; box-shadow: none; }
[data-theme='arcade'] .stat.low { border-color: var(--warn); }
[data-theme='arcade'] #board { border-radius: 0; box-shadow: 0 0 0 3px var(--glow); }

[data-theme='arcade'] .label { font-family: var(--font-display); font-size: 8px; letter-spacing: 0.1em; color: var(--warn); margin-bottom: 4px; }
[data-theme='arcade'] .value { font-family: var(--font-display); font-size: clamp(10px, 3.3vw, 18px); letter-spacing: 0; color: #fff; text-shadow: none; }
[data-theme='arcade'] .stat.low .value { color: var(--warn); text-shadow: none; }
[data-theme='arcade'] .title,
[data-theme='arcade'] #title .title {
  font-size: clamp(20px, 7vw, 32px);
  line-height: 1.35;
  letter-spacing: 0.05em;
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: #ffd31a;
  filter: none;
  text-shadow: 4px 4px 0 #ff3b3b;
}
[data-theme='arcade'] .panel { box-shadow: none; }
[data-theme='arcade'] .panel-title { font-size: 14px; letter-spacing: 0.1em; text-shadow: none; }
[data-theme='arcade'] .mode-name { font-size: 11px; letter-spacing: 0.05em; text-shadow: none; }
[data-theme='arcade'] .mode-blurb { font-size: 18px; letter-spacing: 0.02em; }
[data-theme='arcade'] .mode-best { font-size: 16px; }
[data-theme='arcade'] .btn { font-size: 12px; letter-spacing: 0.1em; text-shadow: none; }
[data-theme='arcade'] .link-btn { font-family: var(--font-display); font-size: 9px; letter-spacing: 0.1em; }
[data-theme='arcade'] .over-mode { font-size: 17px; }
[data-theme='arcade'] .result { font-family: var(--font-display); font-size: 26px; letter-spacing: 0; color: #ffd31a; text-shadow: 3px 3px 0 #ff3b3b; }
[data-theme='arcade'] .blurb { font-size: 21px; }
[data-theme='arcade'] .row { font-size: 20px; }
[data-theme='arcade'] .pick-name { font-family: var(--font-display); font-size: 10px; letter-spacing: 0.05em; text-shadow: none; }
[data-theme='arcade'] .pick-blurb { font-size: 16px; }
[data-theme='arcade'] .level { font-size: 16px; }
[data-theme='arcade'] .picker button, [data-theme='arcade'] .toggle { border-width: 2px; }

/* === CGA: 16-colour DOS text mode (id 'terminal') ============================= */

[data-theme='terminal'] {
  --accent: #55ffff;
  --accent-rgb: 85, 255, 255;
  --glow: #5555ff;
  --glow-rgb: 85, 85, 255;
  --warn: #ffff55;
  --warn-2: #ff5555;
  --text: #ffffff;
  --panel-bg: #0000aa;
  --board-bg: #000000;
  --font-display: 'VT323', ui-monospace, Consolas, monospace;
  --font-body: 'VT323', ui-monospace, Consolas, monospace;
  --page-bg: #0000aa;
}

[data-theme='terminal'] .floor,
[data-theme='terminal'] .ceiling,
[data-theme='terminal'] .horizon { display: none; }

/* DOS windows: blue with a double-line border */
[data-theme='terminal'] .frame {
  background: var(--panel-bg);
  border: 4px double #aaaaaa;
  border-radius: 0;
  box-shadow: none;
}
[data-theme='terminal'] .stat.low { border-color: var(--warn); }
[data-theme='terminal'] #board { border-radius: 0; box-shadow: 8px 8px 0 #000; }
[data-theme='terminal'] .panel { box-shadow: 10px 10px 0 #000; }
[data-theme='terminal'] .overlay { background: rgba(0, 0, 40, 0.55); }

[data-theme='terminal'] .label { font-size: 17px; letter-spacing: 0.1em; color: var(--accent); }
[data-theme='terminal'] .value { font-size: clamp(26px, 8vw, 40px); letter-spacing: 0.02em; color: #fff; text-shadow: none; }
[data-theme='terminal'] .stat.low .value { color: var(--warn); text-shadow: none; }
[data-theme='terminal'] .title,
[data-theme='terminal'] #title .title {
  font-size: clamp(48px, 15vw, 76px);
  line-height: 0.9;
  letter-spacing: 0.05em;
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: #ffff55;
  filter: none;
  text-shadow: 4px 4px 0 #000;
}
[data-theme='terminal'] .panel-title { font-size: 30px; letter-spacing: 0.12em; color: #ffff55; text-shadow: 3px 3px 0 #000; }
[data-theme='terminal'] .mode-name { font-size: 25px; letter-spacing: 0.08em; color: var(--accent); text-shadow: none; }
[data-theme='terminal'] .mode-blurb,
[data-theme='terminal'] .blurb,
[data-theme='terminal'] .pick-blurb,
[data-theme='terminal'] .mode-best { color: #aaaaaa; }
[data-theme='terminal'] .mode-blurb { font-size: 19px; }
[data-theme='terminal'] .mode-best { font-size: 18px; }
/* grey dialog buttons with a hard shadow */
[data-theme='terminal'] .btn {
  font-size: 26px;
  letter-spacing: 0.15em;
  color: #000;
  text-shadow: none;
  background: #aaaaaa;
  border: 0;
  box-shadow: 6px 6px 0 #000;
}
[data-theme='terminal'] .btn:hover, [data-theme='terminal'] .btn:focus-visible { background: #55ffff; color: #000; box-shadow: 6px 6px 0 #000; }
[data-theme='terminal'] .link-btn { font-size: 20px; letter-spacing: 0.12em; color: var(--accent); }
[data-theme='terminal'] .over-mode { font-size: 19px; color: var(--accent); }
[data-theme='terminal'] .result { font-size: 60px; color: #ffff55; text-shadow: 4px 4px 0 #000; }
[data-theme='terminal'] .blurb { font-size: 21px; }
[data-theme='terminal'] .row { font-size: 21px; border-bottom-color: rgba(170, 170, 170, 0.3); }
[data-theme='terminal'] .pick-name { font-size: 24px; color: #fff; text-shadow: none; }
[data-theme='terminal'] .pick-blurb { font-size: 18px; }
[data-theme='terminal'] .level { font-size: 17px; }
[data-theme='terminal'] .meter-fill { box-shadow: none; }

/* CRT scanlines over everything (pointer-events off, so taps pass through). */
[data-theme='terminal'] body::after,
[data-theme='arcade'] body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.28) 2px 3px);
}
[data-theme='arcade'] body::after,
[data-theme='terminal'] body::after { background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.16) 2px 3px); }

/* The pixel fonts are tall for their size: tighter lines keep the mode list on one screen. */
[data-theme='arcade'] .mode-blurb,
[data-theme='terminal'] .mode-blurb { line-height: 1.1; }
[data-theme='terminal'] #title .title { font-size: clamp(42px, 13vw, 64px); margin-bottom: 14px; }

/* === Stained glass ============================================================= */

[data-theme='glass'] {
  --accent: #ffcf6b;
  --accent-rgb: 255, 207, 107;
  --glow: #ffaa3c;
  --glow-rgb: 255, 170, 60;
  --warn: #e8284e;
  --warn-2: #ff5f7e;
  --text: #f3e6cf;
  --panel-bg: rgba(24, 18, 13, 0.94);
  --board-bg: #140f0b;
  --font-display: 'Cinzel', Georgia, 'Times New Roman', serif;
  --font-body: Georgia, 'Times New Roman', serif;
  /* stone blocks, warmly lit from above */
  --page-bg:
    radial-gradient(ellipse 80% 45% at 50% 0%, rgba(255, 190, 90, 0.14), transparent 70%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.28) 0 2px, transparent 2px 56px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.18) 0 2px, transparent 2px 112px),
    linear-gradient(180deg, #221b15, #0d0a08);
}

[data-theme='glass'] .floor,
[data-theme='glass'] .horizon { display: none; }

/* soft beams of coloured light falling across the wall */
[data-theme='glass'] .ceiling {
  top: 0;
  bottom: auto;
  left: -20%;
  right: -20%;
  height: 100%;
  opacity: 1;
  transform: none;
  background-image:
    repeating-linear-gradient(105deg, rgba(255, 210, 140, 0.07) 0 40px, transparent 40px 130px),
    repeating-linear-gradient(105deg, transparent 0 70px, rgba(155, 77, 255, 0.05) 70px 95px, transparent 95px 210px);
  background-size: auto;
  -webkit-mask-image: linear-gradient(180deg, #000 20%, transparent 90%);
  mask-image: linear-gradient(180deg, #000 20%, transparent 90%);
  animation: beams 9s ease-in-out infinite alternate;
}
@keyframes beams { from { opacity: 0.55; } to { opacity: 1; } }

/* a rose window glowing high on the wall */
[data-theme='glass'] .sun {
  display: block;
  position: absolute;
  left: 50%;
  top: 0;
  width: min(80vmin, 560px);
  aspect-ratio: 1;
  transform: translate(-50%, -45%);
  border-radius: 50%;
  background: conic-gradient(#e8284e, #ffb21f, #1fbf5f, #22d3d3, #2f6bff, #9b4dff, #e8284e);
  -webkit-mask-image: none;
  mask-image: none;
  filter: blur(40px);
  opacity: 0.28;
}

[data-theme='glass'] .frame {
  background: var(--panel-bg);
  border: 3px solid #3a2c20;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.35);
}
/* panels arch at the top like a church window */
[data-theme='glass'] .panel {
  border-radius: 50% 50% 8px 8px / 64px 64px 8px 8px;
  padding-top: 48px;
  box-shadow: 0 0 40px rgba(var(--glow-rgb), 0.18), inset 0 0 0 1px rgba(var(--accent-rgb), 0.35);
}
[data-theme='glass'] .stat.low { border-color: var(--warn); }
[data-theme='glass'] #board {
  border-radius: 4px;
  box-shadow: 0 0 0 4px #2a1f16, 0 0 0 6px #6b5232, 0 0 40px rgba(var(--glow-rgb), 0.25);
}

[data-theme='glass'] .title,
[data-theme='glass'] #title .title {
  font-size: clamp(28px, 9vw, 42px);
  font-weight: 700;
  letter-spacing: 0.06em;
  background-image: linear-gradient(180deg, #fff3d1 0%, #ffcf6b 55%, #b8862e 100%);
  filter: drop-shadow(0 0 10px rgba(255, 190, 90, 0.4));
}
[data-theme='glass'] .label { color: rgba(var(--accent-rgb), 0.8); }
[data-theme='glass'] .value { font-family: var(--font-display); font-size: clamp(16px, 4.8vw, 24px); letter-spacing: 0.04em; color: #fff3d1; text-shadow: 0 0 8px rgba(255, 190, 90, 0.6); }
[data-theme='glass'] .mode-name { letter-spacing: 0.1em; color: var(--accent); }
[data-theme='glass'] .mode-blurb, [data-theme='glass'] .blurb, [data-theme='glass'] .pick-blurb { color: rgba(243, 230, 207, 0.75); }
[data-theme='glass'] .result { font-family: var(--font-display); color: #fff3d1; text-shadow: 0 0 14px rgba(255, 190, 90, 0.7); }
[data-theme='glass'] .btn { border-radius: 4px; }

/* === Deep sea ================================================================== */
/* Deep, dark water; the moving specks and particle creatures are drawn on the
   #deep canvas (src/looks/deep-backdrop.js). */

.deep { display: none; }

[data-theme='sea'] {
  --accent: #4fb8ff;
  --accent-rgb: 79, 184, 255;
  --glow: #2a6bff;
  --glow-rgb: 42, 107, 255;
  --warn: #ffe7a3;
  --warn-2: #ffb35c;
  --text: #f2f8ff;
  --panel-bg: rgba(1, 6, 22, 0.62);
  --board-bg: #010616;
  --font-display: 'Montserrat', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Montserrat', 'Segoe UI', system-ui, sans-serif;
  --page-bg: radial-gradient(ellipse 120% 80% at 50% 40%, #04143d 0%, #010518 55%, #000208 100%);
}

[data-theme='sea'] .floor,
[data-theme='sea'] .ceiling,
[data-theme='sea'] .horizon { display: none; }
[data-theme='sea'] .deep { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }

[data-theme='sea'] .frame {
  background: var(--panel-bg);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-radius: 4px;
  box-shadow: none;
}
[data-theme='sea'] .panel { box-shadow: 0 0 60px rgba(var(--glow-rgb), 0.15); }
[data-theme='sea'] .overlay { background: rgba(0, 2, 10, 0.5); }
[data-theme='sea'] .stat.low { border-color: var(--warn); }
/* a thin glowing edge, like the walls of a well */
[data-theme='sea'] #board {
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.55), 0 0 24px rgba(var(--glow-rgb), 0.3);
}

[data-theme='sea'] .label { font-weight: 600; letter-spacing: 0.18em; color: rgba(242, 248, 255, 0.7); }
[data-theme='sea'] .value { font-weight: 800; font-size: clamp(16px, 5vw, 26px); letter-spacing: 0.02em; color: #fff; text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.6); }
[data-theme='sea'] .title,
[data-theme='sea'] #title .title {
  font-size: clamp(28px, 9vw, 42px);
  font-weight: 800;
  letter-spacing: 0.1em;
  background-image: linear-gradient(180deg, #ffffff 0%, #cfeeff 50%, #4fb8ff 100%);
  filter: drop-shadow(0 0 14px rgba(79, 184, 255, 0.55));
}
[data-theme='sea'] .mode-name { font-weight: 800; letter-spacing: 0.14em; color: #fff; text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.6); }
[data-theme='sea'] .mode-blurb, [data-theme='sea'] .blurb, [data-theme='sea'] .pick-blurb { color: rgba(242, 248, 255, 0.65); }
[data-theme='sea'] .result { font-weight: 800; color: #fff; text-shadow: 0 0 16px var(--accent); }
[data-theme='sea'] .btn { font-family: var(--font-display); font-weight: 800; color: #fff; text-shadow: 0 0 8px var(--accent); }
