/* style.css -- number-block-sim v1.1, shared by home, game, cinema and test.
   Darker, rawer, slightly arcade: near-black ground, sharp corners, hard
   lines, one loud thing at a time. Geometry and colour values that are tuning
   constants come in from config.js as inline styles set by the scripts. */

:root {
  --bg: #05070c;
  --bg-panel: #090d16;
  --bg-raised: #0d1220;
  --line: #1c2438;
  --line-hard: #2a3552;
  --text: #dfe6f3;
  --text-dim: #8b96ad;
  --accent: #d97e23;
  --accent-deep: #cf4e2a;
  --good: #2f9e77;
  --bad: #c93030;
  --tile: 76px;
  --gap: 6px;
  --radius: 4px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background:
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(28, 36, 56, 0.10) 39px 40px),
    radial-gradient(1100px 600px at 50% -20%, #0c1322 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.top {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 16px 26px 6px;
}
header.top h1 { font-size: 17px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; }
header.top h1 a { color: var(--text); }
header.top h1 a:hover { color: var(--accent); text-decoration: none; }
header.top .sub { color: var(--text-dim); font-size: 13px; }
header.top .links { margin-left: auto; font-size: 13px; }

.layout {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 26px;
  padding: 12px 20px 30px;
}

/* --- home ----------------------------------------------------------------- */

.home {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 20px 60px;
  text-align: center;
}
.home .big-title {
  font-size: clamp(34px, 7vw, 62px);
  font-weight: 850;
  letter-spacing: 6px;
  text-transform: uppercase;
  line-height: 1.05;
  text-shadow: 0 2px 0 #000, 0 0 34px rgba(217, 126, 35, 0.18);
}
.home .tagline { color: var(--text-dim); font-size: 15px; margin-bottom: 16px; }
.home .deco { display: flex; gap: 8px; margin: 10px 0 26px; }
.home .menu { display: flex; flex-direction: column; gap: 10px; width: min(86vw, 320px); }
.home .menu .btn, .home .menu button { font-size: 16px; padding: 13px 16px; letter-spacing: 1px; }
.home details {
  width: min(92vw, 560px);
  margin-top: 26px;
  text-align: left;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.home details summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--text-dim);
}
.home details[open] summary { color: var(--text); border-bottom: 1px solid var(--line); }
.home details .body { padding: 14px 18px 16px; font-size: 14px; line-height: 1.75; color: var(--text-dim); }
.home details .body b { color: var(--text); }
.home .foot { margin-top: 26px; font-size: 12.5px; color: var(--text-dim); }

/* --- board ---------------------------------------------------------------- */

.board-wrap { position: relative; }

.board {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--line-hard);
  border-radius: 8px;
  overflow: hidden;
}

.board.danger { border-color: rgba(201, 48, 48, 0.85); }
.board.danger::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 7px;
  box-shadow: inset 0 0 26px rgba(201, 48, 48, 0.28);
  animation: danger-pulse 1.6s ease-in-out infinite;
}
@keyframes danger-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

/* the overflow row (above legal height) is tinted so a clutch lock reads */
.board .overflow-zone {
  position: absolute;
  left: 0; right: 0; top: 0;
  border-bottom: 1px dashed var(--line);
  background: rgba(201, 48, 48, 0.05);
}

.tile {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tile);
  height: var(--tile);
  border-radius: var(--radius);
  font-weight: 800;
  color: #0a0c12;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), inset 0 -3px 0 rgba(0, 0, 0, 0.30);
  transition: top 130ms ease-in, left 80ms ease-out;
  will-change: top, left, transform;
}
.tile.no-anim { transition: none; }
.tile.heavy {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.20),
    inset 0 -4px 0 rgba(0, 0, 0, 0.42),
    0 0 16px var(--glow, rgba(179, 45, 60, 0.45));
}
.tile.flash { animation: flash 200ms ease-in-out; z-index: 3; }
/* The actively falling tile owns its own vertical position: ui.js rewrites
   style.top every animation frame, and a `top` transition therefore restarts
   on every write, so the rendered tile lags its true position by up to a cell
   and appears to hover above the stack (audit 0019, 2026-08-05, reproduced
   live). The sideways nudge still animates, which is the part a player wants
   to see; the fall does not, because the fall is already animated by the
   renderer. Settled tiles keep the shared transition, which is what makes
   gravity and merges read. */
.tile.falling {
  z-index: 4;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16), inset 0 -3px 0 rgba(0,0,0,0.30), 0 8px 22px rgba(0, 0, 0, 0.55);
  transition: left 80ms ease-out;
}
.tile.ghost { opacity: 0.14; transition: none; box-shadow: none; }
.tile.last-locked { outline: 2px solid rgba(223, 230, 243, 0.85); outline-offset: 1px; }

@keyframes flash {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.10); filter: brightness(1.8); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* effect sprites (spawned and removed by fx.js) */
.fx-particle {
  position: absolute;
  width: 7px; height: 7px;
  border-radius: 1px;
  pointer-events: none;
  z-index: 6;
}
.fx-ring {
  position: absolute;
  border: 2px solid rgba(223, 230, 243, 0.9);
  border-radius: 50%;
  pointer-events: none;
  z-index: 6;
}
.chain-pop {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 850;
  letter-spacing: 2px;
  text-transform: uppercase;
  pointer-events: none;
  z-index: 7;
  text-shadow: 0 2px 0 #000;
  white-space: nowrap;
}

.banner {
  position: absolute;
  left: 50%; top: 38%;
  transform: translate(-50%, -50%);
  background: rgba(9, 13, 22, 0.94);
  border: 1px solid var(--line-hard);
  border-radius: 6px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 650;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
  z-index: 6;
  white-space: nowrap;
}
.banner.show { opacity: 1; }

/* --- side panel ----------------------------------------------------------- */

.panel {
  width: 264px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 13px 15px;
}
.card h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.score-big { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

/* NEXT is the one loud side element */
.card.next-card {
  border-color: var(--line-hard);
  background: linear-gradient(180deg, #101627 0%, var(--bg-raised) 100%);
}
.next-row { display: flex; align-items: center; gap: 16px; }
.next-tile-big {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 84px; height: 84px;
  border-radius: var(--radius);
  font-weight: 800;
  font-size: 30px;
  color: #0a0c12;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), inset 0 -3px 0 rgba(0, 0, 0, 0.30);
}
.next-note { color: var(--text-dim); font-size: 12.5px; line-height: 1.5; }

/* spawn possibilities: deliberately quiet */
.poss-rows { display: flex; flex-direction: column; gap: 5px; }
.poss-rows .row {
  display: grid;
  grid-template-columns: 34px 1fr 46px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.poss-rows .mini-tile { width: 30px; height: 30px; font-size: 11px; opacity: 0.85; }
.poss-rows .bar { height: 5px; background: var(--bg-panel); border-radius: 2px; overflow: hidden; }
.poss-rows .bar i { display: block; height: 100%; background: var(--line-hard); }
.poss-rows .pct { text-align: right; font-variant-numeric: tabular-nums; }

.mini-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px; height: 46px;
  border-radius: var(--radius);
  font-weight: 800;
  font-size: 15px;
  color: #0a0c12;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 -2px 0 rgba(0, 0, 0, 0.26);
}

.keys { font-size: 13px; color: var(--text-dim); line-height: 2.0; }
.keys b {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border: 1px solid var(--line-hard);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-panel);
  color: var(--text);
  font-size: 12px;
  text-align: center;
  margin-right: 2px;
}

button, .btn {
  appearance: none;
  display: inline-block;
  border: 1px solid var(--line-hard);
  background: var(--bg-raised);
  color: var(--text);
  border-radius: 5px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: background 110ms ease, border-color 110ms ease, transform 60ms ease;
}
button:hover, .btn:hover { background: #131a2c; border-color: #3a4a75; text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button.primary, .btn.primary { background: var(--accent-deep); border-color: var(--accent-deep); color: #fff; }
button.primary:hover, .btn.primary:hover { background: #b8431f; }
button:disabled { opacity: 0.4; cursor: default; }

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

/* The game-over screen covers the page rather than the board: v1.2's breakdown
   carries the performance grade as well as the game's own numbers, and that does
   not fit inside a 416px board. */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 11, 0.88);
  z-index: 10;
  padding: 16px;
}
.overlay.show { display: flex; }
.overlay .dialog {
  width: min(92%, 360px);
  background: var(--bg-raised);
  border: 1px solid var(--line-hard);
  border-radius: 8px;
  padding: 22px;
  text-align: center;
}
.overlay .dialog.breakdown {
  width: min(94vw, 540px);
  max-height: min(94vh, 880px);
  overflow-y: auto;
  padding: 24px 26px;
}
.overlay .dialog h2 {
  font-size: 18px;
  margin-bottom: 4px;
  color: var(--text);
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 850;
}
.overlay .dialog .final-score { font-size: 44px; font-weight: 850; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.overlay .dialog .best-note { color: var(--good); font-weight: 700; font-size: 14px; min-height: 18px; }
.metrics { margin: 14px 0; text-align: left; font-size: 13.5px; }
.metrics div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.metrics div:last-child { border-bottom: none; }
.metrics span:first-child { color: var(--text-dim); }
.metrics span:last-child { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-align: right; }
.overlay .actions { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.overlay .actions.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}
.overlay .actions.grid .primary { grid-column: 1 / -1; }

/* --- the v1.2 performance block ------------------------------------------- */

.section-label {
  margin: 18px 0 4px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-dim);
}

.perf {
  margin-top: 16px;
  border: 1px solid var(--line-hard);
  border-radius: 6px;
  background: linear-gradient(180deg, #101627 0%, var(--bg-panel) 100%);
  padding: 13px 15px 14px;
  text-align: left;
}
.perf-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.perf-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-dim);
}
.perf-sub { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; margin-top: 3px; }
.perf-total {
  font-size: 40px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--accent);
  white-space: nowrap;
}
.perf-total .of { font-size: 15px; font-weight: 700; color: var(--text-dim); margin-left: 3px; }
.perf-total.pending { color: var(--text-dim); font-size: 26px; }

.perf-parts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.perf-parts .part {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px 10px;
}
.perf-parts .part .name {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 700;
}
.perf-parts .part .val { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.perf-parts .part .wt { font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.perf-parts .part .meter { height: 4px; background: var(--bg-raised); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.perf-parts .part .meter i { display: block; height: 100%; background: var(--accent); }
.perf-parts .part.absent .val { color: var(--text-dim); }

/* --- cinema --------------------------------------------------------------- */

.cinema-layout {
  display: flex;
  gap: 0;
  padding: 10px 20px 26px;
  align-items: stretch;
  justify-content: center;
}
.cinema-board {
  flex: 0 1 65%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.cinema-side {
  flex: 0 1 35%;
  max-width: 460px;
  min-width: 300px;
  padding-left: 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.4px;
}
.badge.ok { background: rgba(47, 158, 119, 0.14); color: var(--good); border: 1px solid rgba(47, 158, 119, 0.45); }
.badge.fail { background: rgba(201, 48, 48, 0.14); color: var(--bad); border: 1px solid rgba(201, 48, 48, 0.45); }
.badge.neutral { background: rgba(139, 150, 173, 0.10); color: var(--text-dim); border: 1px solid var(--line); }

.transport { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.transport .counter { font-variant-numeric: tabular-nums; color: var(--text-dim); font-size: 14px; min-width: 110px; text-align: center; }

.reason-line {
  font-size: 19px;
  line-height: 1.45;
  font-weight: 600;
  min-height: 56px;
}
.reason-empty { color: var(--text-dim); font-size: 14.5px; line-height: 1.6; }

.feature-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.feature-bars .row { display: grid; grid-template-columns: 110px 1fr 44px; align-items: center; gap: 8px; font-size: 12.5px; }
.feature-bars .name { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feature-bars .bar { height: 8px; background: var(--bg-panel); border-radius: 2px; overflow: hidden; }
.feature-bars .bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.feature-bars .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-dim); }

.drop-hint {
  border: 1.5px dashed var(--line-hard);
  border-radius: 6px;
  padding: 26px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.7;
}
.drop-hint.drag { border-color: var(--accent); color: var(--text); }

.small { font-size: 12.5px; color: var(--text-dim); line-height: 1.65; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; overflow-wrap: anywhere; }

/* --- reduced motion ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
  .tile.flash { animation: none; filter: brightness(1.6); }
  .board.danger::after { animation: none; opacity: 0.9; }
  .banner { transition: none; }
}

@media (max-width: 900px) {
  .layout { flex-direction: column; align-items: center; }
  .panel { width: min(92vw, 400px); }
  .cinema-layout { flex-direction: column; align-items: center; }
  .cinema-side { padding-left: 0; max-width: 480px; width: 100%; }
}
