.nav-icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.nav-icon-btn:hover,
.nav-icon-btn.open {
  background: var(--panel);
  border-color: var(--ink);
  color: var(--ink);
}
/* Main dropdown panel */
.nav-dropdown {
  display: none;
  position: fixed;
  top: 52px;
  right: 12px;
  width: 280px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  z-index: 9999;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  overflow-x: visible;
}
.nav-dropdown.open {
  display: block;
}
/* Fly-out side panel (opens to the left, positioned in JS via ddShowFlyout —
   must be `fixed` not `absolute`: .nav-dropdown pairs overflow-y:auto with
   overflow-x:visible, and per spec that makes the "visible" axis compute to
   auto too, so an absolutely-positioned child gets clipped by the parent's
   scrollport instead of extending outside it. `fixed` escapes that clip. */
.dd-flyout-wrap {
  position: relative;
}
.dd-flyout {
  display: none;
  position: fixed;
  width: 236px;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: -6px 8px 28px rgba(0, 0, 0, 0.14);
  z-index: 10000;
  padding: 10px 14px;
  min-height: 40px;
}
.dd-flyout.open {
  display: block;
}
/* Profile row */
.dd-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.dd-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #555, #1a1510);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
  font-family: "IM Fell English", "Noto Serif SC", Georgia, serif;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}
.dd-profile-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}
.dd-profile-name {
  font-size: 14px;
  font-weight: 700;
}
.dd-profile-sub {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  color: var(--muted);
}
.dd-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3a3;
  flex-shrink: 0;
}
/* Nav rows */
.dd-nav-section {
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
}
.dd-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
}
.dd-row:hover {
  background: var(--panel);
}
.dd-row svg {
  color: var(--muted);
  flex-shrink: 0;
}
.dd-row.danger {
  color: var(--accent);
}
/* Section labels */
.dd-section-lbl {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 16px 4px;
}
.dd-section {
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.dd-section:last-child {
  border-bottom: none;
}
/* Setting rows */
.dd-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--ink);
}
.dd-setting-lbl {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.dd-setting-sub {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  color: var(--muted);
}
/* Chevron rows — now open a flyout, not an inline expand */
.dd-chevron-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}
.dd-chevron-row:hover,
.dd-chevron-row.active {
  background: var(--panel);
}
.dd-chevron {
  font-size: 11px;
  color: var(--muted);
}
/* old dd-sub hidden — flyout replaces it */
.dd-sub {
  display: none !important;
}
/* Chips */
.dd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.dd-chip {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s;
}
.dd-chip:hover {
  background: var(--panel);
  color: var(--ink);
}
.dd-chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
/* Preview cards (Board theme / Stone set flyouts) — small rendered swatches
   so picking an option shows what it actually looks like. Colours here are
   a CSS approximation of the canvas gradients in duk-render.js
   (BOARD_THEMES / STONE_SETS) — keep both in sync if those change. */
.dd-theme-cards,
.dd-stone-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.dd-theme-card,
.dd-stone-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 7px 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  transition: all 0.12s;
}
.dd-theme-card:hover,
.dd-stone-card:hover {
  background: var(--panel);
  color: var(--ink);
}
.dd-theme-card.active,
.dd-stone-card.active {
  border-color: var(--ink);
  background: var(--panel);
  color: var(--ink);
}
.dd-theme-swatch {
  width: 100%;
  height: 40px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.25);
}
.dd-theme-swatch.swatch-classic {
  background-color: #d4a843;
  background-image:
    repeating-linear-gradient(to right, rgba(122, 80, 16, 0.55) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(to bottom, rgba(122, 80, 16, 0.55) 0 1px, transparent 1px 9px);
}
.dd-theme-swatch.swatch-walnut {
  background-color: #8a5a30;
  background-image:
    repeating-linear-gradient(to right, rgba(58, 30, 10, 0.6) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(to bottom, rgba(58, 30, 10, 0.6) 0 1px, transparent 1px 9px);
}
.dd-theme-swatch.swatch-mahogany {
  background-color: #5c2a1e;
  background-image:
    repeating-linear-gradient(to right, rgba(58, 20, 13, 0.7) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(to bottom, rgba(58, 20, 13, 0.7) 0 1px, transparent 1px 9px);
}
.dd-theme-swatch.swatch-metal {
  background-image:
    repeating-linear-gradient(to right, rgba(40, 44, 48, 0.5) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(to bottom, rgba(40, 44, 48, 0.5) 0 1px, transparent 1px 9px),
    linear-gradient(135deg, #b0b6bc, #6b7178);
}
.dd-theme-swatch.swatch-glass {
  background-image:
    repeating-linear-gradient(to right, rgba(40, 80, 110, 0.4) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(to bottom, rgba(40, 80, 110, 0.4) 0 1px, transparent 1px 9px),
    linear-gradient(135deg, #e4f3fc, #8fbdd8);
}
.dd-theme-swatch.swatch-marble {
  background-image:
    repeating-linear-gradient(to right, rgba(60, 60, 65, 0.35) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(to bottom, rgba(60, 60, 65, 0.35) 0 1px, transparent 1px 9px),
    linear-gradient(135deg, #f2f2f4, #a8a8ae);
}
.dd-theme-swatch.swatch-neon {
  background-color: #150a24;
  background-image:
    repeating-linear-gradient(to right, rgba(255, 46, 196, 0.6) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(to bottom, rgba(0, 229, 255, 0.5) 0 1px, transparent 1px 9px);
}
.dd-theme-swatch.swatch-chalkboard {
  background-color: #1e4530;
  background-image:
    repeating-linear-gradient(to right, rgba(232, 232, 224, 0.55) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(to bottom, rgba(232, 232, 224, 0.55) 0 1px, transparent 1px 9px);
}
.dd-theme-swatch.swatch-sunset {
  background-image:
    repeating-linear-gradient(to right, rgba(255, 240, 224, 0.3) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(to bottom, rgba(255, 240, 224, 0.3) 0 1px, transparent 1px 9px),
    linear-gradient(135deg, #e88050, #a03a5a);
}
.dd-stone-swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
}
.dd-stone-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.35);
}
.dd-stone-dot.classic-black {
  background: radial-gradient(circle at 34% 32%, #6b6058, #1c1815 62%, #050403);
}
.dd-stone-dot.classic-white {
  background: radial-gradient(circle at 34% 32%, #fffdf8, #d8c9a8 62%, #b8a888);
  border: 1px solid rgba(90, 70, 40, 0.35);
}
.dd-stone-dot.cream-black {
  background: radial-gradient(circle at 34% 32%, #8a8a86, #302e2b 62%, #141311);
}
.dd-stone-dot.cream-white {
  background: radial-gradient(circle at 34% 32%, #fffaf0, #e0cca0 62%, #c4ab7c);
  border: 1px solid rgba(120, 90, 50, 0.3);
}
.dd-stone-dot.contrast-black {
  background: radial-gradient(circle at 34% 32%, #8c8c90, #343436 62%, #141416);
}
.dd-stone-dot.contrast-white {
  background: radial-gradient(circle at 34% 32%, #b5453f, #4a1015 62%, #20060a);
  border: 1px solid rgba(0, 0, 0, 0.3);
}
.dd-stone-dot.jade-black {
  background: radial-gradient(circle at 34% 32%, #7fae8a, #234a30 62%, #0e2417);
}
.dd-stone-dot.jade-white {
  background: radial-gradient(circle at 34% 32%, #fffaf0, #dcc99e 62%, #bfa579);
  border: 1px solid rgba(90, 70, 40, 0.3);
}
.dd-stone-dot.sapphire-black {
  background: radial-gradient(circle at 34% 32%, #6a8fd0, #183064 62%, #0a1836);
}
.dd-stone-dot.sapphire-white {
  background: radial-gradient(circle at 34% 32%, #fffdfa, #d8d8d2 62%, #b8b8b0);
  border: 1px solid rgba(60, 60, 70, 0.25);
}
.dd-stone-dot.amber-black {
  background: radial-gradient(circle at 34% 32%, #4a4642, #120f0c 62%, #050403);
}
.dd-stone-dot.amber-white {
  background: radial-gradient(circle at 34% 32%, #ffd485, #a8631c 62%, #6b3a0c);
  border: 1px solid rgba(80, 40, 0, 0.3);
}
/* Board size buttons */
.dd-board-btns {
  display: flex;
  gap: 4px;
}
.dd-board-btns button {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s;
}
.dd-board-btns button:hover {
  background: var(--panel);
}
.dd-board-btns button.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
/* Toggle rows inside flyout */
.dd-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.dd-toggle-row:last-child {
  border-bottom: none;
}
/* Master volume slider inside Sound flyout */
.dd-volume-row {
  padding: 6px 0 8px;
  border-bottom: 1px solid var(--border);
}
.dd-volume-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink);
  margin-bottom: 6px;
}
.dd-volume-val {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
}
.dd-vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  accent-color: var(--ink);
  cursor: pointer;
  display: block;
}
.dd-vol-slider:disabled {
  opacity: 0.4;
  cursor: default;
}
.dd-vol-slider::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: var(--border);
}
.dd-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
}
.dd-vol-slider::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: var(--border);
}
.dd-vol-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
}
/* Danger button */
.dd-danger-btn {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  padding: 4px 10px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: none;
  color: var(--accent);
  cursor: pointer;
}
.dd-danger-btn:hover {
  background: #fdecea;
}
/* Toggle switch */
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle input:checked + .toggle-track {
  background: var(--ink);
}
.toggle-track::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-track::after {
  transform: translateX(18px);
}
/* Account stats */
.acc-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 12px 16px;
}
.acc-stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 6px;
  text-align: center;
}
.acc-stat-val {
  font-family: "IM Fell English", "Noto Serif SC", Georgia, serif;
  font-size: 20px;
  font-weight: 700;
}
.acc-stat-lbl {
  font-family: "DM Mono", monospace;
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}
.acc-name-input {
  font-family: "IM Fell English", "Noto Serif SC", Georgia, serif;
  font-size: 14px;
  font-weight: 700;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  padding: 2px 0;
  outline: none;
  width: 100%;
}
.acc-name-input:focus {
  border-bottom-color: var(--ink);
}
/* Flyout label header */
.flyout-lbl {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
@media (max-width: 900px) {
}
.logo {
  font-family: "IM Fell English", "Noto Serif SC", Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.logo-stone {
  width: 20px;
  height: 20px;
  background: radial-gradient(circle at 35% 35%, #555, #1a1510);
  border-radius: 50%;
  box-shadow:
    2px 2px 4px rgba(0, 0, 0, 0.4),
    inset -1px -1px 2px rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}
:root {
  --ink: #1a1510;
  --paper: #f5efe4;
  --board: #d4a843;
  --board-dark: #b8892a;
  --stone-b: #1a1510;
  --stone-w: #f8f4ed;
  --accent: #8b1a1a;
  --muted: #7a6e5f;
  --line: #8b6914;
  --star: #5a3d0a;
  --panel: #ede5d3;
  --border: #c4a96a;
}
body.dark-mode,
html.dark-mode body {
  --ink: #e8e0d0;
  --paper: #1a1714;
  --board: #8c6a28;
  --board-dark: #6b4f1c;
  --stone-b: #e8e0d0;
  --stone-w: #1a1714;
  --accent: #c0504a;
  --muted: #8a8070;
  --line: #7a5c1e;
  --star: #c4a96a;
  --panel: #24201c;
  --border: #3a3228;
}
/* Dark "mahogany" board theme — independent of light/dark UI mode.
   Overrides only the board-wrapper frame; canvas fill (grain/grid/stars/coords)
   is themed separately in duk-render.js via BOARD_THEMES. */
body.board-theme-espresso {
  --board: #5c2a1e;
  --board-dark: #35130c;
}
body.board-theme-espresso.dark-mode,
html.dark-mode body.board-theme-espresso {
  --board: #452016;
  --board-dark: #240d09;
}
/* Remaining board themes — same pattern: frame colours only, canvas texture
   comes from BOARD_THEMES in duk-render.js. */
body.board-theme-walnut {
  --board: #8a5a30;
  --board-dark: #5a3a1a;
}
body.board-theme-walnut.dark-mode,
html.dark-mode body.board-theme-walnut {
  --board: #6e4526;
  --board-dark: #402612;
}
body.board-theme-metal {
  --board: #8a9096;
  --board-dark: #4a4f55;
}
body.board-theme-metal.dark-mode,
html.dark-mode body.board-theme-metal {
  --board: #6b7076;
  --board-dark: #33363a;
}
body.board-theme-glass {
  --board: #cfe8f7;
  --board-dark: #8fbdd8;
}
body.board-theme-glass.dark-mode,
html.dark-mode body.board-theme-glass {
  --board: #3a5a70;
  --board-dark: #1c303f;
}
body.board-theme-marble {
  --board: #e2e2e6;
  --board-dark: #a8a8ae;
}
body.board-theme-marble.dark-mode,
html.dark-mode body.board-theme-marble {
  --board: #5c5c62;
  --board-dark: #2c2c30;
}
body.board-theme-neon {
  --board: #150a24;
  --board-dark: #08040f;
}
body.board-theme-neon.dark-mode,
html.dark-mode body.board-theme-neon {
  --board: #150a24;
  --board-dark: #08040f;
}
body.board-theme-chalkboard {
  --board: #1e4530;
  --board-dark: #0e2418;
}
body.board-theme-chalkboard.dark-mode,
html.dark-mode body.board-theme-chalkboard {
  --board: #163420;
  --board-dark: #081810;
}
body.board-theme-sunset {
  --board: #e88050;
  --board-dark: #a03a5a;
}
body.board-theme-sunset.dark-mode,
html.dark-mode body.board-theme-sunset {
  --board: #a85838;
  --board-dark: #5c1e3a;
}
/* In dark mode, multiply blend makes noise invisible on dark backgrounds — use screen instead */
body.dark-mode::before,
html.dark-mode body::before {
  mix-blend-mode: screen;
  opacity: 0.12;
}
body.dark-mode .logo-stone {
  background: radial-gradient(circle at 35% 35%, #ccc, #e8e0d0);
  box-shadow:
    2px 2px 4px rgba(0, 0, 0, 0.6),
    inset -1px -1px 2px rgba(0, 0, 0, 0.2);
}
body.dark-mode .stone-indicator.white {
  background: radial-gradient(circle at 35% 35%, #333, #1a1714);
  box-shadow:
    1px 2px 4px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
body.dark-mode .stone-indicator.black {
  background: radial-gradient(circle at 35% 35%, #ccc, #e8e0d0);
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.5);
}
body.dark-mode .dd-avatar {
  background: radial-gradient(circle at 35% 35%, #ccc, #e8e0d0);
}
body.dark-mode .account-avatar {
  background: radial-gradient(circle at 35% 35%, #ccc, #e8e0d0);
}
body.dark-mode .replay-row:hover {
  background: #2e2a26;
}
body.dark-mode .dd-danger-btn:hover {
  background: #3a1e1e;
}
body.dark-mode .control-btn.primary:hover {
  background: #c0b8a8;
}
html,
body {
  height: 100%;
  overflow: hidden;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: "IM Fell English", "Noto Serif SC", Georgia, serif;
  background: var(--paper);
  color: var(--ink);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/png;base64,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");
  background-repeat: repeat;
  background-size: 128px 128px;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.08;
  mix-blend-mode: multiply;
}
.container {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  position: relative;
}
.setup-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  overflow-y: auto;
  padding: 24px 16px;
}
.setup-inner {
  width: 100%;
  max-width: 520px;
}
.setup-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.setup-tagline {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 24px;
  padding-left: 38px;
}
.setup-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.setup-inner .gsm-panel {
  padding: 0;
  border: 1px solid var(--border);
  border-top: none;
  border-bottom: none;
}
.setup-inner #gsmPanelPlayer {
  border-bottom: 1px solid var(--border);
}
.setup-inner .gsm-row {
  padding: 10px 14px;
}
.setup-inner .gsm-time-section {
  margin-top: 14px;
}
.setup-time-grid {
  grid-template-columns: repeat(5, 1fr) !important;
}
.setup-start-btn {
  width: 100%;
  margin-top: 18px;
  padding: 12px;
  font-size: 14px;
  letter-spacing: 0.05em;
}
.game-view {
  display: flex;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  align-items: center;
  justify-content: center;
}
.sidebar-left {
  display: none;
}
.sidebar-section h3 {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.opponent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.opponent-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-family: "IM Fell English", Georgia, serif;
  font-size: 13px;
  color: var(--ink);
  text-align: left;
  transition: all 0.15s;
  width: 100%;
}
.opponent-btn:hover {
  background: var(--panel);
  border-color: var(--border);
}
.opponent-btn.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.opponent-btn .rank-badge {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  opacity: 0.6;
}
.difficulty-dots {
  display: flex;
  gap: 2px;
}
.difficulty-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.3;
}
.difficulty-dots span.filled {
  opacity: 1;
}
.control-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: "IM Fell English", Georgia, serif;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  margin-bottom: 6px;
  transition: all 0.15s;
}
.control-btn:hover {
  background: var(--panel);
}
.control-btn.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  font-weight: 700;
}
.control-btn.primary:hover {
  background: #2d2520;
}
.control-btn.danger {
  border-color: var(--accent);
  color: var(--accent);
}
.control-btn.danger:hover {
  background: #f9eded;
}
.board-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  background: var(--paper);
  overflow: hidden;
  min-width: 0;
  height: 100%;
  box-sizing: border-box;
}
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 580px;
  margin-bottom: 16px;
}
.player-label {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stone-indicator {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
}
.stone-indicator.black {
  background: radial-gradient(circle at 35% 35%, #555, #1a1510);
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.5);
}
.stone-indicator.white {
  background: radial-gradient(circle at 35% 35%, #fff, #d0c8bc);
  box-shadow:
    1px 2px 4px rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}
.player-name {
  font-size: 14px;
  font-weight: 700;
}
.player-captures {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted);
}
.turn-indicator {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.board-area {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 1;
  overflow: auto;
  padding: 24px !important;
}
.board-unit {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 20px;
  flex: 0 0 auto;
}
.board-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
}
.game-panel {
  display: flex;
  flex-direction: column;
  width: 220px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  overflow: hidden;
  align-self: flex-start;
}
.panel-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}
.panel-section:last-child {
  border-bottom: none;
}
.panel-section.panel-grow {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.panel-label {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.board-wrapper {
  position: relative;
  background: var(--board);
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.25),
    inset 0 0 0 8px var(--board-dark),
    inset 0 0 0 9px var(--board);
  border-radius: 3px;
}
canvas {
  display: block;
  cursor: crosshair;
  max-width: 100%;
  max-height: calc(100vh - 140px);
  width: auto;
  height: auto;
  flex-shrink: 1;
}
.sidebar-right {
  display: none;
}
.score-display {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.score-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 14px 12px;
  text-align: center;
}
.score-box .score-label {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.score-box .score-val {
  font-family: "IM Fell English", "Noto Serif SC", Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
}
.move-log {
  flex: 1;
  overflow-y: auto;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.4;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
  gap: 0 2px;
  min-height: 60px;
}
.move-log .move-entry {
  display: flex;
  gap: 4px;
  padding: 1px 2px;
}
.move-log .move-num {
  color: var(--border);
}
.move-log .move-coord {
  color: var(--ink);
}
.status-bar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
  min-height: 50px;
}
.komi-note {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 21, 16, 0.55);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.show {
  display: flex;
}
.modal {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0;
  max-width: 320px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
}
.modal-header {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
  font-weight: 400;
}
.modal-body {
  padding: 16px;
}
.modal p {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 14px;
}
.modal-scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
}
.modal-score-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 10px 8px;
  text-align: center;
}
.modal-score-item .ms-label {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}
.modal-score-item .ms-val {
  font-family: "IM Fell English", "Noto Serif SC", Georgia, serif;
  font-size: 24px;
  font-weight: 700;
}
.thinking-indicator {
  display: none;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
}
.thinking-indicator.show {
  display: block;
}
.thinking-indicator::after {
  content: "...";
  animation: dots 1.2s steps(3, end) infinite;
}
@keyframes dots {
  0%,
  100% {
    content: ".";
  }
  33% {
    content: "..";
  }
  66% {
    content: "...";
  }
}
.territory-note {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  margin-top: 8px;
}
.page-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--paper);
  z-index: 10000;
  flex-direction: column;
  overflow: hidden;
}
.page-overlay.show {
  display: flex;
}
.page-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.page-nav-title {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 1;
}
.page-close-btn {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s;
}
.page-close-btn:hover {
  background: var(--panel);
  color: var(--ink);
}
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 40px 48px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}
.page-section-title {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.account-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #555, #1a1510);
  box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
  font-family: "IM Fell English", "Noto Serif SC", Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  flex-shrink: 0;
}
.account-name-input {
  font-family: "IM Fell English", "Noto Serif SC", Georgia, serif;
  font-size: 24px;
  font-weight: 700;
  background: none;
  border: none;
  border-bottom: 2px solid var(--border);
  color: var(--ink);
  padding: 4px 0;
  outline: none;
  width: 260px;
  transition: border-color 0.2s;
}
.account-name-input:focus {
  border-bottom-color: var(--ink);
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.stat-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px 12px;
  text-align: center;
}
.stat-box .stat-val {
  font-family: "IM Fell English", "Noto Serif SC", Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
}
.stat-box .stat-lbl {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}
.replay-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.replay-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.replay-row:hover {
  background: #e4d9c4;
}
.replay-row-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.replay-row-title {
  font-size: 14px;
  font-weight: 700;
}
.replay-row-meta {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
}
.replay-row-result {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 500;
}
.replay-row-result.win {
  color: #1a6b1a;
}
.replay-row-result.loss {
  color: var(--accent);
}
.replay-empty {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 48px 0;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child {
  border-bottom: none;
}
.settings-label {
  font-size: 14px;
}
.settings-desc {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle input:checked + .toggle-track {
  background: var(--ink);
}
.toggle-track::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-track::after {
  transform: translateX(18px);
}
.control-btn.replay {
  display: none;
}
.control-btn.replay.show {
  display: block;
}
.replay-controls {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px 0 2px;
  width: 100%;
}
.replay-controls.show {
  display: flex;
}
.move-entry.kill .move-coord {
  color: var(--accent);
  font-weight: 700;
}
.move-entry.active-replay {
  background: var(--panel);
  border-radius: 2px;
}
.move-entry {
  cursor: default;
}
.move-entry.clickable {
  cursor: pointer;
}
.move-entry.clickable:hover {
  background: var(--panel);
}
.replay-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 4px 8px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.1s;
}
.replay-btn:hover {
  background: var(--panel);
}
.replay-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.replay-counter {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  min-width: 50px;
  text-align: center;
}
@media (max-width: 900px) {
  .container {
    grid-template-columns: 1fr;
  }
  .sidebar-left,
  .sidebar-right {
    border: none;
    border-bottom: 1px solid var(--border);
  }
}
.game-setup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 21, 16, 0.55);
  z-index: 300;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.game-setup-overlay.show {
  display: flex;
}
.game-setup-modal {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 400px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.28);
}
.gsm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px 11px;
  border-bottom: 1px solid var(--border);
}
.gsm-title {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.gsm-close {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 2px 5px;
  border-radius: 3px;
  transition: background 0.12s;
}
.gsm-close:hover {
  background: var(--panel);
  color: var(--ink);
}
.gsm-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.gsm-tab {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: none;
  font-family: "DM Mono", monospace;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.gsm-tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}
.gsm-tab:hover:not(.active) {
  color: var(--ink);
  background: var(--panel);
}
.gsm-body {
  padding: 0;
}
.gsm-panel {
  display: none;
  padding: 14px 18px;
}
.gsm-panel.active {
  display: block;
}
.gsm-row {
  display: flex;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.gsm-row:last-child {
  border-bottom: none;
}
.gsm-row-label {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  width: 150px;
  flex-shrink: 0;
}
.gsm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}
.gsm-chip {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  padding: 4px 11px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  color: var(--ink);
  transition: all 0.12s;
  white-space: nowrap;
}
.gsm-chip:hover {
  background: var(--panel);
}
.gsm-chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.gsm-time-section {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.gsm-time-header {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 7px 12px 6px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.gsm-time-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}
.gsm-time-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 9px 4px;
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  color: var(--ink);
  transition: background 0.12s;
}
.gsm-time-chip:nth-child(4n) {
  border-right: none;
}
.gsm-time-chip:nth-last-child(-n + 4) {
  border-bottom: none;
}
.gsm-time-chip:hover {
  background: var(--panel);
}
.gsm-time-chip.active {
  background: var(--ink);
  color: var(--paper);
}
.gsm-time-chip-name {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.65;
  margin-bottom: 2px;
}
.gsm-time-chip-val {
  font-size: 13px;
  font-weight: 700;
  font-family: "DM Mono", monospace;
}
.gsm-time-chip.active .gsm-time-chip-name {
  opacity: 0.8;
}
.gsm-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}
.gsm-footer-info {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  color: var(--muted);
  flex: 1;
}
#clockRow {
  display: flex;
  gap: 6px;
}
.clock-cell {
  flex: 1;
  padding: 5px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.clock-cell.clock-active {
  background: var(--ink);
  border-color: var(--ink);
}
.clock-cell.clock-low {
  border-color: var(--accent);
}
.clock-label {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.clock-cell.clock-active .clock-label {
  color: rgba(245, 239, 228, 0.6);
}
.clock-cell.clock-low .clock-label {
  color: var(--accent);
}
.clock-time {
  font-family: "DM Mono", monospace;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.03em;
}
.clock-cell.clock-active .clock-time {
  color: var(--paper);
}
.clock-cell.clock-low .clock-time {
  color: var(--accent);
}
.active-game-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 5px;
  gap: 8px;
}
.active-game-card:hover {
  background: #e4d9c4;
  border-color: var(--ink);
}
.active-game-card-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}
.active-game-card-title {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.active-game-card-meta {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  color: var(--muted);
}
@keyframes badge-pulse {
  0%,
  100% {
    background: #2a6e2a;
    box-shadow: 0 0 0 0 rgba(42, 110, 42, 0.55);
  }
  50% {
    background: #3a8e3a;
    box-shadow: 0 0 0 5px rgba(42, 110, 42, 0);
  }
}
@keyframes badge-warn {
  0%,
  100% {
    background: #b06000;
    box-shadow: 0 0 0 0 rgba(176, 96, 0, 0.7);
  }
  50% {
    background: #d07800;
    box-shadow: 0 0 0 5px rgba(176, 96, 0, 0);
  }
}
.active-game-badge {
  font-family: "DM Mono", monospace;
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: #2a6e2a;
  color: #fff;
  padding: 2px 6px;
  border-radius: 10px;
  flex-shrink: 0;
  animation: badge-pulse 2.2s ease-in-out infinite;
}
.active-game-badge.ar-warn {
  background: #b06000;
  animation: badge-warn 0.9s ease-in-out infinite;
  letter-spacing: 0.04em;
  font-size: 8px;
}
.dd-active-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2a6e2a;
  flex-shrink: 0;
  animation: badge-pulse 2.2s ease-in-out infinite;
}
.dd-active-dot.ar-warn {
  background: #b06000;
  animation: badge-warn 0.9s ease-in-out infinite;
}
.setup-active-section {
  margin-bottom: 14px;
}
.setup-active-title {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.dd-active-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}
.dd-active-row:hover {
  background: var(--panel);
}
.dd-active-row-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}
.dd-active-row-title {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dd-active-row-meta {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  color: var(--muted);
}
/* dd-active-dot defined above */

/* ── Tournament ticker bar ── */
#tournament-ticker-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  height: 32px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  overflow: hidden;
  pointer-events: auto;
}
#tournament-ticker-bar .ticker-label {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 10px 0 12px;
  white-space: nowrap;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}
#tournament-ticker-bar .ticker-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 10px;
  min-width: 0;
}
#tournament-ticker-bar #tournamentCodeInput {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  outline: none;
  width: 160px;
  transition:
    border-color 0.15s,
    background 0.15s;
}
#tournament-ticker-bar #tournamentCodeInput:focus {
  border-color: var(--border);
  background: var(--paper);
}
#tournament-ticker-bar #tournamentCodeInput::placeholder {
  color: var(--muted);
  opacity: 0.6;
}
/* Push setup screen up so it doesn't hide behind ticker */
.setup-screen {
  padding-bottom: 40px !important;
}
/* ── Auth panel (duk-auth.js) ─────────────────────────────────────────────── */
.auth-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  padding: 8px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.auth-tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}
.auth-label {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
  margin-top: 14px;
}
.auth-label:first-child { margin-top: 0; }
.auth-hint {
  font-size: 9px;
  color: var(--muted);
  opacity: 0.7;
  text-transform: none;
  letter-spacing: 0;
}
.auth-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.auth-input:focus {
  border-color: var(--ink);
}
.auth-error {
  min-height: 18px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: #c0392b;
  margin-top: 6px;
}
.dark-mode .auth-error { color: #e07070; }
.auth-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 9px 0;
  border-radius: 4px;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  border: 1px solid var(--border);
}
.auth-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.auth-btn-primary:hover:not(:disabled) { opacity: 0.85; }
.auth-btn-outline {
  background: none;
  color: var(--muted);
}
.auth-btn-outline:hover:not(:disabled) {
  border-color: var(--ink);
  color: var(--ink);
}
.auth-fine-print {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.5;
}
.auth-section-divider {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 7px 14px;
  margin-top: 8px;
  width: 100%;
  box-sizing: border-box;
}
/* Logged-in state */
.auth-logged-in {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 0 4px;
  text-align: center;
}
.auth-avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'IM Fell English', 'Noto Serif SC', Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
}
.auth-username {
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}
.auth-email {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}
/* ── Gate modals (welcome & VS Player auth gate) ────────────────────────── */
.duk-gate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 21, 16, 0.62);
  z-index: 20000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
  padding: 20px;
}
.duk-gate-overlay.show {
  display: flex;
  animation: gateOverlayIn 0.22s ease;
}
@keyframes gateOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.duk-gate-modal {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 32px 28px 28px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  animation: gateModalIn 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  text-align: center;
}
@keyframes gateModalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.duk-gate-stone {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.duk-gate-eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.duk-gate-title {
  font-family: 'IM Fell English', 'Noto Serif SC', Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 16px;
  letter-spacing: 0.04em;
}
.duk-gate-body {
  font-family: 'IM Fell English', 'Noto Serif SC', Georgia, serif;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
  margin-bottom: 14px;
  text-align: left;
}
.duk-gate-body strong {
  font-weight: 700;
}
.duk-gate-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}
.duk-gate-btn-primary {
  padding: 10px 20px;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 3px;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.duk-gate-btn-primary:hover { opacity: 0.82; }
.duk-gate-btn-secondary {
  padding: 10px 20px;
  background: none;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.duk-gate-btn-secondary:hover { border-color: var(--ink); }
.duk-gate-btn-ghost {
  padding: 8px 20px;
  background: none;
  color: var(--muted);
  border: none;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: color 0.15s;
}
.duk-gate-btn-ghost:hover { color: var(--ink); }

/* ── Inline auth form inside account dropdown ───────────────────────────── */
.dd-auth-inline {
  padding: 12px 14px 14px;
  border-bottom: 1px solid var(--border);
}
.dd-auth-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.dd-auth-tab {
  flex: 1;
  padding: 6px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.dd-auth-tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}
.dd-auth-form .auth-input {
  font-size: 12px;
  padding: 6px 8px;
}
.dd-auth-form .auth-btn {
  margin-top: 8px;
  padding: 7px 0;
  font-size: 12px;
}
.dd-auth-form .auth-error {
  font-size: 10px;
  min-height: 14px;
  margin-top: 4px;
}
/* ── Ratings display ─────────────────────────────────────────────────────── */
.rat-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.rat-section-title {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.rat-mode-block {
  margin-bottom: 18px;
}
.rat-mode-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
}
.rat-mode-icon {
  font-size: 13px;
  opacity: 0.7;
}
.rat-mode-title {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.06em;
}
.rat-mode-desc {
  font-size: 10px;
  color: var(--muted);
  margin-left: auto;
}
.rat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.rat-cell {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 7px 5px 6px;
  text-align: center;
  position: relative;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.rat-cell.empty {
  opacity: 0.4;
}
.rat-cat-lbl {
  font-family: 'DM Mono', monospace;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 3px;
}
.rat-val {
  font-family: 'DM Mono', monospace;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.1;
  position: relative;
}
.rat-sub {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  color: var(--muted);
  margin-top: 2px;
}
.rat-promo-badge {
  position: absolute;
  top: -1px;
  right: -22px;
  background: #c0392b;
  color: #fff;
  font-size: 7px;
  padding: 1px 3px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.rat-note {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
  line-height: 1.5;
}

/* Auth actions row */
.auth-actions-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}
.auth-btn-sm {
  font-size: 11px !important;
  padding: 6px 12px !important;
}
.auth-btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
}
.auth-btn-ghost:hover {
  border-color: var(--ink);
  color: var(--ink);
}

/* Dropdown rating chip */
.dd-rating-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 6px 12px 2px;
  padding: 5px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--ink);
}
.dd-rating-chip.placement {
  color: var(--muted);
}
.dd-rat-icon {
  font-size: 11px;
  opacity: 0.7;
}
.dd-rat-promo {
  font-size: 10px;
  color: #c0392b;
  margin-left: 4px;
}

/* dd-row link */
.dd-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}
.dd-row:hover { background: var(--panel); }
.dd-row.danger { color: #c0392b; }
.dd-nav-section {
  border-top: 1px solid var(--border);
  padding: 4px 0;
  margin-top: 4px;
}

/* ── Inline auth inside modals (welcome / player gate) ───────────────────── */
.gate-inline-auth {
  width: 100%;
  text-align: left;
}
.gate-auth-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.gate-auth-form .auth-input {
  font-size: 13px;
  padding: 8px 10px;
  width: 100%;
  box-sizing: border-box;
}
.gate-auth-form .auth-error {
  font-size: 11px;
  min-height: 16px;
  margin-top: 5px;
}
.gate-auth-form .auth-fine-print {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  margin-top: 8px;
}
/* ── Account page — home-screen style redesign ──────────────────────────── */

/* Override page-content for account page to center like the setup screen */
#accountPage .page-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 48px 24px 48px;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

/* Inner card — matches .setup-inner width */
#accountPage .acc-card {
  width: 100%;
  max-width: 520px;
}

/* Logo header on account page — clone of setup-logo style */
.acc-page-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.acc-page-logo .logo-stone {
  width: 28px;
  height: 28px;
}
.acc-page-logo-text {
  font-family: 'IM Fell English', 'Noto Serif SC', Georgia, serif;
  font-size: 28px;
  font-weight: bold;
  letter-spacing: 0.08em;
  color: var(--ink);
}
.acc-page-logo-cjk {
  font-size: 26px;
  font-weight: normal;
  font-family: 'Noto Serif JP', 'Noto Serif SC', 'Noto Serif CJK JP', serif;
  margin-left: 6px;
}
.acc-page-tagline {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 28px;
  padding-left: 38px;
}

/* Auth panel inside account page — same card border as setup panels */
#accountPage #authPanel {
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--paper);
}

/* Logged-in state inside account page: less padding, more coherent */
#accountPage .auth-logged-in {
  padding: 20px 20px 4px;
  gap: 4px;
}
#accountPage .auth-avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 20px;
  margin-bottom: 4px;
}
#accountPage .auth-username {
  font-size: 22px;
}
#accountPage .auth-actions-row {
  margin-top: 14px;
  padding-bottom: 14px;
}
/* Ratings section inside account page */
#accountPage .rat-section {
  text-align: left;
  width: 100%;
  padding: 0 20px 0;
}

/* Login form inside account page */
#accountPage .auth-tabs {
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  margin-bottom: 0;
}
#accountPage .auth-tab {
  padding: 12px 0 10px;
}
#accountPage .auth-form {
  padding: 16px 20px 20px;
}

/* Stats section — bordered card like the panel sections on setup screen */
#accountPage .acc-stats-section {
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}
#accountPage .acc-stats-header {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 9px 14px 7px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
#accountPage .stats-grid {
  margin-bottom: 0;
  gap: 0;
  grid-template-columns: repeat(4, 1fr);
  border-top: none;
}
#accountPage .stat-box {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border);
  padding: 14px 10px;
}
#accountPage .stat-box:last-child {
  border-right: none;
}

/* Replays section — bordered card */
#accountPage .acc-replays-section {
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
#accountPage .acc-replays-header {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 9px 14px 7px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
#accountPage .replay-list {
  padding: 8px;
  gap: 6px;
}
#accountPage .replay-row {
  border-radius: 3px;
}
#accountPage .replay-empty {
  padding: 32px 0;
}

/* page-section-title override for account page — hidden since we use new headers */
#accountPage .page-section-title {
  display: none;
}
/* ── Profile avatar — shared across all contexts ───────────────────────── */

/* Image variant of the large avatar on account page */
.auth-avatar-img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin-bottom: 8px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--border);
}

/* Wrap that holds avatar + camera-button overlay */
.auth-avatar-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}
.auth-avatar-wrap .auth-avatar-lg,
.auth-avatar-wrap .auth-avatar-img {
  margin-bottom: 0;
}

/* Camera upload button — hovers bottom-right of avatar */
.auth-avatar-upload-btn {
  position: absolute;
  bottom: -2px;
  right: -6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid var(--paper);
  transition: background 0.12s;
  flex-shrink: 0;
}
.auth-avatar-upload-btn:hover { background: var(--accent); }
.auth-avatar-upload-btn svg { pointer-events: none; }

/* Status line under avatar */
.auth-avatar-status {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  min-height: 14px;
  margin-bottom: 4px;
}
.auth-avatar-status.success { color: #4caf50; }
.auth-avatar-status.error   { color: var(--accent); }

/* Stone indicator with avatar overlay on game header */
.stone-indicator.has-avatar {
  background: none !important;
  box-shadow: 0 0 0 2px var(--border);
  overflow: hidden;
  border-radius: 50%;
}
.stone-indicator.has-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}
/* ══════════════════════════════════════════════════════════════════════
   MOBILE — responsive layout for phones / small tablets.
   Everything below is additive: it only changes layout/sizing, never game
   logic, so AI games and multiplayer (duk-online.js / duk-ai.js) are
   unaffected — this is presentation only.
   ══════════════════════════════════════════════════════════════════════ */

/* Dynamic viewport height: 100vh is wrong on mobile once the browser's
   address bar collapses/expands. 100dvh tracks the real visible area.
   Declared outside the media query so it also fixes desktop browser UI
   chrome quirks; dvh support is ignored (falls back to the 100vh line
   above it) on browsers that don't understand it. */
.container {
  height: 100dvh;
  max-height: 100dvh;
}

@media (max-width: 900px) {
  /* ── Board + side panel: stack instead of sitting side-by-side ───────── */
  .board-area {
    padding: 12px 10px 64px !important; /* bottom clears the ticker bar */
    align-items: flex-start !important; /* NOT center — centering a flex
      cross-axis together with overflow:auto clips the top of scrollable
      content in most browsers. flex-start keeps the whole stack reachable
      when it's taller than the viewport. */
  }
  .board-unit {
    flex-direction: column;
    width: 100%;
    gap: 14px;
  }
  .board-column {
    width: 100%;
  }
  canvas {
    max-height: 62vh;
  }
  .game-panel {
    width: 100%;
    max-width: 100%;
    /* duk-render.js's syncPanelHeight() stops forcing a fixed height below
       this breakpoint, but clear any inline height a wider viewport left
       behind (e.g. right after an orientation flip, before JS re-syncs). */
    height: auto !important;
    max-height: none !important;
  }
  .panel-section.panel-grow {
    flex: none;
  }
  .move-log {
    max-height: 220px;
  }
  #gameActionBtns .gsm-chip {
    padding: 10px 4px;
  }

  /* ── Top-right nav dropdowns ───────────────────────────────────────── */
  .nav-actions {
    top: max(12px, env(safe-area-inset-top)) !important;
    right: max(12px, env(safe-area-inset-right)) !important;
  }
  .nav-dropdown {
    width: min(320px, calc(100vw - 24px));
    top: max(52px, calc(env(safe-area-inset-top) + 44px));
  }
  .dd-flyout {
    width: min(236px, calc(100vw - 24px));
  }

  /* ── Setup screen ──────────────────────────────────────────────────── */
  .setup-screen {
    padding: 16px 12px 64px !important;
  }
  .setup-inner {
    max-width: 100%;
  }
  .setup-tagline {
    padding-left: 0;
  }
  .gsm-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .gsm-row-label {
    width: auto;
  }
  .gsm-chip {
    padding: 8px 12px;
  }
  /* Time-control grid: drop the fixed 4/5-column layout (too cramped on a
     phone) and use grid-gap-as-divider instead of the nth-child border
     rules above, since those assume a fixed column count that no longer
     matches at 3 columns. */
  .setup-time-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1px;
    background: var(--border);
  }
  .gsm-time-chip {
    background: var(--paper);
    border: none !important;
  }
  .gsm-time-chip.active {
    background: var(--ink);
  }
  .setup-start-btn {
    padding: 14px !important;
  }

  /* ── Account / settings pages ──────────────────────────────────────── */
  .page-content {
    padding: 24px 16px 64px;
  }
  .stats-grid,
  #accountPage .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .settings-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* ── Modals ────────────────────────────────────────────────────────── */
  .modal {
    width: 92%;
  }
  .duk-gate-modal {
    padding: 24px 20px 20px;
  }
  .duk-gate-overlay {
    padding: 16px;
  }

  /* ── Replay viewer: side-by-side canvas + sidebar → stacked ──────────── */
  .rv-split {
    flex-direction: column;
    overflow-y: auto !important;
  }
  .rv-canvas-pane {
    padding: 16px !important;
    flex: none !important;
  }
  .rv-sidebar {
    width: 100% !important;
    border-left: none !important;
    border-top: 1px solid var(--border);
    padding: 16px !important;
  }

  /* ── Tournament ticker bar ────────────────────────────────────────────
     Taller hit-area + safe-area padding so it's comfortable to tap and
     doesn't sit under the home-indicator on notched phones. */
  #tournament-ticker-bar {
    height: calc(40px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }
  #tournament-ticker-bar #tournamentCodeInput {
    width: 100%;
    font-size: 16px;
  }

  /* ── Touch targets: keep every tappable control at a comfortable size ── */
  .control-btn,
  .replay-btn,
  .nav-icon-btn,
  .dd-danger-btn,
  .duk-gate-btn-primary,
  .duk-gate-btn-secondary,
  .duk-gate-btn-ghost {
    min-height: 40px;
  }

  /* ── Prevent iOS Safari auto-zoom on input focus (needs >=16px font).
     !important because several auth-form variants (.dd-auth-form
     .auth-input, .gate-auth-form .auth-input) are more specific than a
     bare .auth-input rule and would otherwise keep their smaller
     desktop font-size. */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  .auth-input,
  .reset-input,
  .acc-name-input,
  .account-name-input {
    font-size: 16px !important;
  }

  /* ── Kill the tap-delay / double-tap-zoom on interactive elements ────── */
  canvas,
  button,
  .toggle-track,
  .dd-chevron-row,
  .dd-theme-card,
  .dd-stone-card,
  .dd-chip {
    touch-action: manipulation;
  }
}

@media (max-width: 420px) {
  .setup-time-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .stats-grid,
  #accountPage .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .modal-scores {
    gap: 8px;
  }
}
