/* ============================================================
   IMK TETRIS - Modern Minimal Arcade
   Vanilla CSS. Geometric sans + mono numerals, single lime accent.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500;700&display=swap');

/* ---------- Reset & base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Prevent selecting non-editable UI chrome with the mouse; inputs opt back in. */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

input, textarea {
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}

/* ---------- Accessibility ---------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:root {
  /* =========================================================
     Design tokens — dark (default). Semantic groups:
     primario · neutros · superficie · acento
     ========================================================= */

  /* Neutros (page background scale, always dark here) */
  --bg:            #0b0c10;
  --surface:       #14161c;
  --surface-2:     #1a1d25;
  --border:        #242832;
  --border-strong: #333845;

  /* Typography / text */
  --text:          #f2f3f5;
  --text-dim:      #a7afbd;
  --text-faint:    #8a92a3;

  /* Primary accent (brand) */
  --primary:       #bef264;
  --primary-strong:#d3ff7e;
  --accent:        #bef264;
  --accent-strong: #d3ff7e;
  --accent-soft:   rgba(190, 242, 100, 0.14);
  --accent-line:   rgba(190, 242, 100, 0.55);

  /* Type */
  --font-ui:   "Geist", system-ui, -apple-system, Segoe UI, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Shape scale (locked): cards 12px, controls 8px, toggle pill */
  --radius-card: 12px;
  --radius-btn:  8px;

  /* ---- Board-scoped tokens (dark defaults; light overrides below) ---- */
  --board-frame-surface:      var(--surface);
  --board-frame-surface-2:    var(--surface-2);
  --board-frame-border:       var(--border);
  --board-frame-shadow:       0 24px 60px rgba(0, 0, 0, 0.34);
  --board-frame-inner-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05),
                              inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  --board-frame-sheen:        rgba(255, 255, 255, 0.08);
  --board-frame-divider:      rgba(255, 255, 255, 0.06);
  --board-frame-ambient:      var(--accent-soft);
  --board-surface:            var(--bg);
  --board-border:             var(--border-strong);
  --board-canvas-grid:        rgba(255, 255, 255, 0.045);

  --board-overlay-bg:           rgba(9, 10, 14, 0.78);
  --board-overlay-card-bg:      rgba(20, 23, 30, 0.96);
  --board-overlay-card-shadow:  0 24px 60px rgba(0, 0, 0, 0.55),
                                inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --board-overlay-border:       #2d323d;
  --board-overlay-title:        var(--text);
  --board-overlay-heading:      var(--accent);
  --board-overlay-text:         var(--text);
  --board-overlay-muted:        var(--text-dim);

  /* Theme-toggle icons (masked) */
  --icon-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
  --icon-sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4.2'/%3E%3Cline x1='12' y1='1.5' x2='12' y2='4'/%3E%3Cline x1='12' y1='20' x2='12' y2='22.5'/%3E%3Cline x1='1.5' y1='12' x2='4' y2='12'/%3E%3Cline x1='20' y1='12' x2='22.5' y2='12'/%3E%3Cline x1='4.4' y1='4.4' x2='6.2' y2='6.2'/%3E%3Cline x1='17.8' y1='17.8' x2='19.6' y2='19.6'/%3E%3Cline x1='4.4' y1='19.6' x2='6.2' y2='17.8'/%3E%3Cline x1='17.8' y1='6.2' x2='19.6' y2='4.4'/%3E%3C/svg%3E");
  --icon-play: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M8 5.5L19 12 8 18.5z'/%3E%3C/svg%3E");
  --icon-freeze: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2V22M3.34 7L20.66 17M20.66 7L3.34 17M12 6L13.9 4.9M12 6L10.1 4.9M12 18L13.9 19.1M12 18L10.1 19.1M17.2 9L17.2 6.8M17.2 9L19.1 10.1M6.8 15L6.8 17.2M6.8 15L4.9 13.9M6.8 9L6.8 6.8M6.8 9L4.9 10.1M17.2 15L17.2 17.2M17.2 15L19.1 13.9'/%3E%3C/svg%3E");
  --icon-sound: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9z'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7'/%3E%3C/svg%3E");
  --icon-mute: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9z'/%3E%3Cpath d='M22 9l-5 6M17 9l5 6'/%3E%3C/svg%3E");
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Subtle accent bloom behind the playfield - identity, very low intensity */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(58% 46% at 50% 40%, rgba(190, 242, 100, 0.05), transparent 70%),
    radial-gradient(120% 120% at 50% 0%, rgba(255, 255, 255, 0.02), transparent 60%);
}

/* State machine class read by game.js - keep display:none semantics */
.hidden { display: none !important; }

/* ---------- Container ---------- */
.container {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 680px;
  min-height: 600px;
}

/* Vertical game-toggle column (theme / sound / freeze) in right panel, below skins. */
.board-toggles {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: flex-start;
}

/* ---------- Panels ---------- */
.panel {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 170px;
}

.panel-left  {
  left: 0;
  justify-content: center;
  gap: 28px;
  padding: 0;
}

.panel-right {
  right: 0;
  justify-content: center;
  gap: 26px;
  padding: 0;
}

/* ---------- Brand ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
}

.brand-mark {
  flex: none;
  width: 40px;
  height: 26px;
}

.brand-mark rect { fill: var(--text-dim); }
.brand-mark .accent-cell { fill: var(--accent); }

.brand-word {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-word .b1 {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.34em;
  color: var(--text-faint);
}

.brand-word .b2 {
  font-size: 2.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

/* ---------- Stat console ---------- */
.stats {
  display: flex;
  flex-direction: column;
  gap: 0;
  align-self: flex-start;
  width: 142px;
  margin-right: 0;
}

.info-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px 13px;
}

.stats .info-block + .info-block {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.label {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--text-faint);
  text-transform: uppercase;
}

.value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.05;
  min-height: 1.05em;
}

.info-block:first-child .value { color: var(--accent); }

/* ---------- Board wrapper ---------- */
.board-wrapper {
  position: relative;
  align-self: center;
  isolation: isolate;
  padding: 10px;
  border: 1px solid var(--board-frame-border);
  border-radius: calc(var(--radius-card) + 6px);
  background: linear-gradient(180deg, var(--board-frame-surface), var(--board-frame-surface-2));
  box-shadow: var(--board-frame-shadow), var(--board-frame-inner-shadow);
  overflow: hidden;
}

.board-wrapper::before,
.board-wrapper::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.board-wrapper::before {
  z-index: 0;
  background:
    linear-gradient(180deg, var(--board-frame-sheen), transparent 22%),
    linear-gradient(90deg, transparent 0%, var(--board-frame-divider) 50%, transparent 100%);
  opacity: 0.9;
}

.board-wrapper::after {
  inset: auto;
  top: 12%;
  left: 16%;
  width: 68%;
  height: 42%;
  z-index: 0;
  border-radius: 999px;
  background: radial-gradient(circle at 50% 50%, var(--board-frame-ambient), transparent 72%);
  opacity: 0.75;
  transform: translate3d(0, 0, 0);
  animation: board-wrapper-drift 18s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

@keyframes board-wrapper-drift {
  0%, 100% {
    transform: translate3d(-2%, 0, 0) scale(0.98);
    opacity: 0.58;
  }
  50% {
    transform: translate3d(2%, 2%, 0) scale(1.03);
    opacity: 0.86;
  }
}

#board {
  position: relative;
  z-index: 1;
  display: block;
  border: 1px solid var(--board-border);
  border-radius: calc(var(--radius-card) - 2px);
  background-color: var(--board-surface);
  box-shadow: inset 0 0 0 1px var(--board-frame-divider);
}

/* Quick crossfade flash when switching skins (active piece + preview). */
@keyframes skin-swap {
  0%   { opacity: 0.35; filter: brightness(1.5) saturate(1.25); }
  100% { opacity: 1;    filter: none; }
}
#board.skin-swap,
#next.skin-swap {
  animation: skin-swap 0.28s ease-out;
}

/* ---------- Right-panel modules ---------- */
.module {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.next-block {
  position: static;
  align-items: flex-start;
  align-self: flex-start;
  margin-top: 0;
}

.next-block.info-block {
  padding: 0;
  gap: 0;
}

#next {
  display: block;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background-color: var(--surface-2);
}

/* ---------- Skin selector (segmented) ---------- */
.skin-btns {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.skin-selector {
  position: static;
  width: 122px;
  margin-top: 0;
}

.skin-btn {
  font-family: var(--font-ui);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--surface-2);
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 5px 6px;
  cursor: pointer;
  text-align: left;
  transition: color 0.18s, background 0.18s, box-shadow 0.18s;
}

.skin-btn:last-child { border-bottom: none; }

.skin-btn:hover { color: var(--text); background: #20242d; }

.skin-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

/* ---------- Board-theme toggle module ---------- */
.toggle-module {
  position: static;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  align-self: stretch;
  margin-top: 0;
}

.toggle-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 2px 5px;
  border: 1px solid var(--board-overlay-border);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
  white-space: nowrap;
}

/* ---------- Buttons (neutral base) ---------- */
.theme-btn {
  font-family: var(--font-ui);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-btn);
  padding: 10px 12px;
  cursor: pointer;
  width: 100%;
  transition: color 0.18s, border-color 0.18s, background 0.18s, transform 0.1s;
}

.theme-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-btn:active { transform: translateY(1px); }

.theme-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent-line);
}

/* ---------- Overlay (game over / high scores) ---------- */
.overlay {
  position: absolute;
  inset: 0;
  background: var(--board-overlay-bg);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
  z-index: 10;
  animation: fade-in 0.24s ease;
}

.overlay-card {
  width: min(290px, 100%);
  border: 1px solid var(--board-overlay-border);
  border-radius: var(--radius-card);
  background: var(--board-overlay-card-bg);
  box-shadow: var(--board-overlay-card-shadow);
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.overlay-title {
  font-family: var(--font-ui);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--board-overlay-title);
  text-align: center;
  line-height: 1.25;
  -webkit-user-select: none;
  user-select: none;
}

/* Focus is set programmatically for screen readers only (tabindex="-1");
   hide the visible focus box so the heading doesn't look selected. */
.overlay-title:focus,
.overlay-title:focus-visible {
  outline: none;
}

.overlay-sub {
  font-family: var(--font-ui);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--board-overlay-muted);
  text-align: center;
  line-height: 1.7;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.85; transform: scale(0.98); }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Start screen ---------- */
.start-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background:
    radial-gradient(70% 55% at 50% 38%, rgba(190, 242, 100, 0.06), transparent 70%),
    rgba(8, 9, 12, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 30px;
}

.start-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.start-brand .brand-mark {
  width: 54px;
  height: 36px;
}

.start-title {
  font-family: var(--font-ui);
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  text-align: center;
  line-height: 1;
}

.start-title .accent { color: var(--accent); }

.press-enter {
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  animation: pulse 1.8s ease-in-out infinite;
}

/* ---------- High-scores section ---------- */
.hs-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.hs-heading {
  font-family: var(--font-ui);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.hs-table {
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.hs-table th,
.hs-table td {
  padding: 7px 12px;
  text-align: center;
  border-bottom: 1px solid var(--board-overlay-border);
  letter-spacing: 0.02em;
}

.hs-table th {
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-size: 0.58rem;
}

.hs-table td { color: var(--board-overlay-text); }

.hs-table tbody tr:last-child td { border-bottom: none; }

.hs-table th:nth-child(1),
.hs-table td:nth-child(1) { width: 10%; color: var(--text-faint); }

.hs-table th:nth-child(2),
.hs-table td:nth-child(2) {
  width: 36%;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hs-table th:nth-child(3),
.hs-table td:nth-child(3),
.hs-table th:nth-child(4),
.hs-table td:nth-child(4),
.hs-table th:nth-child(5),
.hs-table td:nth-child(5) { width: 18%; }

.hs-table tr.hs-new td { color: var(--accent); }
.hs-table tr.hs-new td:nth-child(1) { color: var(--accent); }

#start-screen .hs-section { width: min(92vw, 460px); }

#start-screen .hs-table {
  width: 100%;
  min-width: 360px;
  table-layout: fixed;
}

#overlay .hs-section {
  width: 100%;
  max-width: 100%;
  gap: 10px;
}

#overlay .hs-heading {
  font-size: 0.58rem;
  letter-spacing: 0.2em;
}

#overlay .hs-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  font-size: 0.62rem;
}

#overlay .hs-table th,
#overlay .hs-table td { padding: 5px 5px; }

#overlay .hs-table th { font-size: 0.5rem; }

#overlay .hs-table tbody tr:nth-child(odd) td {
  background: rgba(255, 255, 255, 0.025);
}

#overlay .overlay-sub { line-height: 1.6; }

.board-wrapper .overlay .hs-heading { color: var(--board-overlay-heading); }

/* ---------- Reset button (quiet) ---------- */
.reset-btn {
  font-family: var(--font-ui);
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--board-overlay-muted);
  background: transparent;
  border: 1px solid var(--board-overlay-border);
  border-radius: var(--radius-btn);
  padding: 7px 12px;
  cursor: pointer;
  margin-top: 2px;
  transition: color 0.18s, border-color 0.18s;
}

.reset-btn:hover {
  color: var(--board-overlay-title);
  border-color: var(--board-overlay-muted);
}

/* ---------- Start screen controls (reset button + theme toggle) ---------- */
.start-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.start-theme-toggle-btn {
  flex: none;
  width: 48px;
  height: 26px;
  display: inline-block;
  position: relative;
  overflow: hidden;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--board-overlay-border);
  background: var(--board-surface-2);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.5);
  color: transparent;
  font-size: 0;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.start-theme-toggle-btn:hover {
  border-color: var(--board-overlay-border);
  color: transparent;
  background: var(--board-surface-2);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.03);
}

/* Knob */
.start-theme-toggle-btn::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #dfe3ec;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  transition:
    transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.3s ease;
  z-index: 2;
}

/* Icon */
.start-theme-toggle-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 7px;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  background-color: var(--board-overlay-muted);
  -webkit-mask: var(--icon-moon) center / contain no-repeat;
  mask: var(--icon-moon) center / contain no-repeat;
  pointer-events: none;
  transition: background-color 0.25s ease;
  z-index: 1;
}

.start-theme-toggle-btn:active::before { transform: scale(0.85); }

.start-theme-toggle-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--board-overlay-bg), 0 0 0 4px var(--board-overlay-accent-line),
              inset 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Light mode (board light) */
.start-theme-toggle-btn[data-mode="light"] {
  background: rgba(191, 242, 100, 0.15);
  border-color: rgba(191, 242, 100, 0.55);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.2);
}

.start-theme-toggle-btn[data-mode="light"]::before {
  transform: translateX(22px);
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35), 0 0 6px rgba(191, 242, 100, 0.15);
}

.start-theme-toggle-btn[data-mode="light"]::after {
  left: 7px;
  right: auto;
  background-color: rgba(191, 242, 100, 1);
  -webkit-mask: var(--icon-sun) center / contain no-repeat;
  mask: var(--icon-sun) center / contain no-repeat;
}

.start-theme-toggle-btn[data-mode="light"]:hover {
  border-color: rgba(191, 242, 100, 1);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.2), 0 0 0 3px rgba(191, 242, 100, 0.15);
}

.start-theme-toggle-btn[data-mode="light"]:active::before {
  transform: translateX(22px) scale(0.85);
}

.start-theme-toggle-btn[data-mode="light"]:focus-visible {
  box-shadow: 0 0 0 2px var(--board-overlay-bg), 0 0 0 4px rgba(191, 242, 100, 0.55),
              inset 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* Light hub theme — start-theme-toggle colors should match light palette */
html[data-theme="light"] .start-theme-toggle-btn {
  border-color: var(--border-strong);
  background: #e7e5dd;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .start-theme-toggle-btn::before,
html[data-theme="light"] .start-theme-toggle-btn[data-mode="light"]::before {
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.30), 0 0 0 1px rgba(0, 0, 0, 0.55);
}

html[data-theme="light"] .start-theme-toggle-btn::after {
  background-color: #54524c;
}

html[data-theme="light"] .start-theme-toggle-btn[data-mode="light"] {
  background: rgba(63, 98, 18, 0.20);
  border-color: var(--accent-line);
}

/* ---------- Name entry ---------- */
.name-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.name-label {
  font-family: var(--font-ui);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.name-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.name-input {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--board-overlay-text);
  background: var(--board-surface);
  border: 1px solid var(--board-overlay-border);
  border-radius: var(--radius-btn);
  padding: 8px 10px;
  width: calc(10ch + 1.2em + 20px);
  text-align: center;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.name-input::placeholder { color: var(--board-overlay-muted); }

.name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.name-save-btn {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #0c1106;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-btn);
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.18s, transform 0.1s;
}

.name-save-btn:hover { background: var(--accent-strong); }
.name-save-btn:active { transform: translateY(1px); }

#overlay-hs-section.hidden { display: none; }

/* ---------- Pause menu ---------- */
.pause-menu {
  position: absolute;
  inset: 0;
  background: var(--board-overlay-bg);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  padding: 22px 20px;
  z-index: 20;
  overflow-y: auto;
  animation: fade-in 0.24s ease;
}

.pause-menu-title {
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--board-overlay-title);
  text-align: center;
}

.pause-menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 84%;
}

.pause-btn {
  width: 100%;
  padding: 11px;
  font-size: 0.66rem;
}

.pause-volume {
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: center;
  width: 84%;
}

.pause-volume .volume-control {
  width: 100%;
  flex: none;
}

/* Board-scoped colors so pause UI reads in light board theme */
.pause-menu .theme-btn {
  color: var(--board-overlay-text);
  background: transparent;
  border-color: var(--board-overlay-border);
}

.pause-menu .theme-btn:hover {
  color: var(--board-overlay-heading);
  border-color: var(--board-overlay-heading);
}

.pause-menu .label { color: var(--board-overlay-muted); }

.pause-menu kbd {
  color: var(--board-overlay-text);
  border-color: var(--board-overlay-border);
  background: transparent;
}

.pause-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 84%;
  border: 1px solid var(--board-overlay-border);
  border-radius: var(--radius-card);
  padding: 12px 14px;
}

.pause-controls-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  margin-top: 4px;
}

.pause-controls-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--board-overlay-border);
}

.pause-controls-list li:last-child { border-bottom: none; }

.pc-keys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.pc-action {
  font-family: var(--font-ui);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--board-overlay-text);
  text-align: right;
  white-space: nowrap;
}

.pc-note {
  font-weight: 400;
  color: var(--board-overlay-muted);
}

.pc-mouse {
  font-family: var(--font-ui);
  font-size: 0.56rem;
  letter-spacing: 0.03em;
  color: var(--board-overlay-muted);
  padding-left: 2px;
}

.pause-level-select {
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: center;
  width: 84%;
}

.level-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 2px;
}

.level-btn {
  width: 38px;
  padding: 7px 0;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
}

.level-value {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--board-overlay-heading);
  min-width: 2ch;
  text-align: center;
}

/* ============================================================
   Light hub theme — page, panels, start screen, and board shell all follow
   same warm-monochrome token system. Editorial palette, WCAG AA pairs.
   ============================================================ */
html[data-theme="light"] {
  /* Neutros */
  --bg:            #f5f4f0;
  --surface:       #ffffff;
  --surface-2:     #ecebe5;
  --border:        #dcdbd4;
  --border-strong: #c4c2b8;

  /* Text (charcoal on bone) */
  --text:          #1f2328;
  --text-dim:      #54524c;
  --text-faint:    #5f5d56;

  /* Accent (lime lacks contrast on light → accessible olive) */
  --primary:       #3f6212;
  --primary-strong:#4d7c0f;
  --accent:        #3f6212;
  --accent-strong: #4d7c0f;
  --accent-soft:   rgba(63, 98, 18, 0.12);
  --accent-line:   rgba(63, 98, 18, 0.55);

  /* Board shell */
  --board-frame-shadow:       0 20px 38px rgba(31, 35, 40, 0.08);
  --board-frame-inner-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92),
                              inset 0 0 0 1px rgba(255, 255, 255, 0.56);
  --board-frame-sheen:        rgba(255, 255, 255, 0.84);
  --board-frame-divider:      rgba(63, 98, 18, 0.10);
  --board-frame-ambient:      var(--accent-soft);
  --board-canvas-grid:        rgba(31, 35, 40, 0.065);

  /* Tokens shared by the start screen (outside the board) */
  --board-overlay-bg:         rgba(245, 244, 240, 0.78);
  --board-overlay-card-bg:    rgba(255, 255, 255, 0.94);
  --board-overlay-card-shadow:0 20px 38px rgba(31, 35, 40, 0.12),
                              inset 0 1px 0 rgba(255, 255, 255, 0.72);
  --board-overlay-border:  #dcdbd4;
  --board-overlay-title:   #1f2328;
  --board-overlay-heading: #3f6212;
  --board-overlay-text:    #2f3437;
  --board-overlay-muted:   #5f5d56;
}

/* Quiet warm light-spot instead of the dark bloom */
html[data-theme="light"] body::before {
  background:
    radial-gradient(58% 46% at 50% 36%, rgba(63, 98, 18, 0.05), transparent 70%),
    radial-gradient(120% 120% at 50% 0%, rgba(0, 0, 0, 0.015), transparent 60%);
}

/* Hardcoded dark surfaces that need a light counterpart */
html[data-theme="light"] .stats .info-block + .info-block {
  border-top-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .skin-btn:hover {
  background: #e3e1d9;
}

html[data-theme="light"] .start-screen {
  background:
    radial-gradient(70% 55% at 50% 38%, rgba(63, 98, 18, 0.05), transparent 70%),
    rgba(245, 244, 240, 0.94);
}

/* Theme/freeze toggles live in the hub — retune the track/knob for light.
   A hairline dark ring keeps the knob boundary visible (WCAG 1.4.11) on the
   pale track in both the off and on (data-mode="light") states. */
html[data-theme="light"] .theme-toggle-btn {
  border-color: var(--border-strong);
  background: #e7e5dd;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .theme-toggle-btn::before,
html[data-theme="light"] .theme-toggle-btn[data-mode="light"]::before,
html[data-theme="light"] .freeze-toggle-btn[data-mode="on"]::before {
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.30), 0 0 0 1px rgba(0, 0, 0, 0.55);
}

html[data-theme="light"] .theme-toggle-btn::after {
  background-color: #54524c;
}

html[data-theme="light"] .theme-toggle-btn[data-mode="light"] {
  background: rgba(63, 98, 18, 0.20);
  border-color: var(--accent-line);
}

/* ============================================================
   Theme toggle switch - knob/icon contract driven by data-mode
   ============================================================ */
.theme-toggle-btn {
  flex: none;
  width: 48px;
  height: 26px;
  display: inline-block;
  position: relative;
  overflow: hidden;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.5);
  color: transparent;
  font-size: 0;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.theme-toggle-btn:hover {
  border-color: var(--border-strong);
  color: transparent;
  background: var(--surface-2);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.03);
}

/* Knob */
.theme-toggle-btn::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #dfe3ec;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  transition:
    transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.3s ease;
  z-index: 2;
}

/* Icon */
.theme-toggle-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 7px;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  background-color: var(--text-dim);
  -webkit-mask: var(--icon-moon) center / contain no-repeat;
  mask: var(--icon-moon) center / contain no-repeat;
  pointer-events: none;
  transition: background-color 0.25s ease;
  z-index: 1;
}

.theme-toggle-btn:active::before { transform: scale(0.85); }

.theme-toggle-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent-line),
              inset 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Light mode (board light) */
.theme-toggle-btn[data-mode="light"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle-btn[data-mode="light"]::before {
  transform: translateX(22px);
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35), 0 0 6px var(--accent-soft);
}

.theme-toggle-btn[data-mode="light"]::after {
  left: 7px;
  right: auto;
  background-color: var(--accent);
  -webkit-mask: var(--icon-sun) center / contain no-repeat;
  mask: var(--icon-sun) center / contain no-repeat;
}

.theme-toggle-btn[data-mode="light"]:hover {
  border-color: var(--accent);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.2), 0 0 0 3px var(--accent-soft);
}

.theme-toggle-btn[data-mode="light"]:active::before {
  transform: translateX(22px) scale(0.85);
}

.theme-toggle-btn[data-mode="light"]:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent-line),
              inset 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* Freeze mode (testing hold) */
.freeze-toggle-btn::after {
  left: auto;
  right: 7px;
  background-color: var(--text-dim);
  -webkit-mask: var(--icon-play) center / contain no-repeat;
  mask: var(--icon-play) center / contain no-repeat;
}

.freeze-toggle-btn[data-mode="on"] {
  background: #e1f3fe;
  border-color: rgba(31, 108, 159, 0.45);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.14);
}

.freeze-toggle-btn[data-mode="on"]::before {
  transform: translateX(22px);
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.30), 0 0 6px rgba(31, 108, 159, 0.24);
}

.freeze-toggle-btn[data-mode="on"]::after {
  left: 7px;
  right: auto;
  background-color: #1f6c9f;
  -webkit-mask: var(--icon-freeze) center / contain no-repeat;
  mask: var(--icon-freeze) center / contain no-repeat;
}

.freeze-toggle-btn[data-mode="on"]:hover {
  border-color: #1f6c9f;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.14), 0 0 0 3px rgba(31, 108, 159, 0.16);
}

.freeze-toggle-btn[data-mode="on"]:active::before {
  transform: translateX(22px) scale(0.85);
}

.freeze-toggle-btn[data-mode="on"]:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px rgba(31, 108, 159, 0.45),
              inset 0 1px 4px rgba(0, 0, 0, 0.14);
}

/* Sound toggle — base (muted) shows a dim mute icon; data-mode="on" is the
   active/enabled state (accent fill, knob right, speaker icon). */
.sound-toggle-btn::after {
  left: auto;
  right: 7px;
  background-color: var(--text-dim);
  -webkit-mask: var(--icon-mute) center / contain no-repeat;
  mask: var(--icon-mute) center / contain no-repeat;
}

.sound-toggle-btn[data-mode="on"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.2);
}

.sound-toggle-btn[data-mode="on"]::before {
  transform: translateX(22px);
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35), 0 0 6px var(--accent-soft);
}

.sound-toggle-btn[data-mode="on"]::after {
  left: 7px;
  right: auto;
  background-color: var(--accent);
  -webkit-mask: var(--icon-sound) center / contain no-repeat;
  mask: var(--icon-sound) center / contain no-repeat;
}

.sound-toggle-btn[data-mode="on"]:hover {
  border-color: var(--accent);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.2), 0 0 0 3px var(--accent-soft);
}

.sound-toggle-btn[data-mode="on"]:active::before {
  transform: translateX(22px) scale(0.85);
}

.sound-toggle-btn[data-mode="on"]:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent-line),
              inset 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* Master volume slider */
.volume-control {
  display: flex;
  align-items: center;
  flex: 1 1 90px;
  min-width: 80px;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #dfe3ec;
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  transition: background 0.2s ease, transform 0.1s ease;
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: #dfe3ec;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.volume-slider:hover::-webkit-slider-thumb { background: var(--accent); }
.volume-slider:hover::-moz-range-thumb { background: var(--accent); }
.volume-slider:active::-webkit-slider-thumb { transform: scale(0.9); }

.volume-slider:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent-line);
}

/* ---------- Pre-game countdown ---------- */
.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
  pointer-events: none;
  background: var(--board-overlay-bg);
  backdrop-filter: blur(2px);
}

.countdown-number {
  font-family: var(--font-mono);
  font-size: 8rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 26px var(--accent-soft), 0 6px 30px rgba(0, 0, 0, 0.5);
  animation: countdown-pop 0.92s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes countdown-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  18%  { transform: scale(1.08); opacity: 1; }
  42%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.84); opacity: 0; }
}

/* ---------- Responsive (modest down-scale) ---------- */
@media (max-width: 700px) {
  .container { gap: 12px; }
  .panel { width: 124px; gap: 11px; }
  .value { font-size: 1.25rem; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
