:root {
  /* Warm charcoal surfaces + blue UI accent (aligned with X pieces) */
  --bg-1: #2e2c29;
  --bg-2: #312e2b;
  --sidebar-bg: #272522;
  --panel: #3d3935;
  --panel-strong: #454240;
  --panel-border: rgba(255, 255, 255, 0.07);
  --panel-border-hover: rgba(255, 255, 255, 0.14);
  --text: #eeedec;
  --muted: #a39f9b;
  --accent: #6ea8f5;
  --accent-hover: #8bb8f8;
  --accent-dim: rgba(110, 168, 245, 0.18);
  /* Piece colors — softer blue / red */
  --x-color: #6ea8f5;
  --x-glow: rgba(110, 168, 245, 0.35);
  --o-color: #e07070;
  --o-glow: rgba(224, 112, 112, 0.35);
  --active: rgba(110, 168, 245, 0.14);
  --active-border: #6ea8f5;
  --inactive: rgba(0, 0, 0, 0.12);
  --cell-bg: rgba(255, 255, 255, 0.045);
  --cell-bg-hover: rgba(255, 255, 255, 0.1);
  --cell-border: rgba(255, 255, 255, 0.06);
  --won-bg: rgba(0, 0, 0, 0.08);
  --hint: rgba(232, 197, 71, 0.85);
  --hint-soft: rgba(232, 197, 71, 0.14);
  --success: #6ea8f5;
  --danger: #e05858;
  --sidebar-width: 76px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.28);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* ── Light theme (Settings → Color theme) ── */

html[data-theme="light"] {
  color-scheme: light;
  --bg-1: #eceae7;
  --bg-2: #f4f2ef;
  --sidebar-bg: #e6e4e1;
  --panel: #ffffff;
  --panel-strong: #f7f6f4;
  --panel-border: rgba(0, 0, 0, 0.09);
  --panel-border-hover: rgba(0, 0, 0, 0.16);
  --text: #2c2926;
  --muted: #6b6560;
  --accent: #3d7dcc;
  --accent-hover: #5a93e0;
  --accent-dim: rgba(61, 125, 204, 0.14);
  --x-color: #2d6fc4;
  --x-glow: rgba(45, 111, 196, 0.28);
  --o-color: #c73e3e;
  --o-glow: rgba(199, 62, 62, 0.28);
  --active: rgba(61, 125, 204, 0.11);
  --active-border: #3d7dcc;
  --inactive: rgba(0, 0, 0, 0.045);
  --cell-bg: rgba(0, 0, 0, 0.035);
  --cell-bg-hover: rgba(0, 0, 0, 0.075);
  --cell-border: rgba(0, 0, 0, 0.1);
  --won-bg: rgba(0, 0, 0, 0.035);
  --hint: rgba(196, 145, 20, 0.98);
  --hint-soft: rgba(232, 197, 71, 0.22);
  --success: #3d7dcc;
  --danger: #d04545;
  --shadow-soft: 0 4px 18px rgba(0, 0, 0, 0.07);
  --shadow-card: 0 8px 26px rgba(0, 0, 0, 0.09);
}

html[data-theme="light"] body {
  background:
    radial-gradient(ellipse 900px 420px at 50% -20%, rgba(61, 125, 204, 0.07), transparent 55%),
    linear-gradient(165deg, var(--bg-1) 0%, var(--bg-2) 55%, #faf9f7 100%);
}

html[data-theme="light"] .sidebar {
  border-right-color: rgba(0, 0, 0, 0.1);
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .meta-board {
  background: linear-gradient(145deg, #dad8d5 0%, #cfcfcd 100%);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    0 12px 36px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .winner-overlay {
  background: rgba(244, 242, 239, 0.92);
}

html[data-theme="light"] .engine-card {
  background: rgba(0, 0, 0, 0.03);
}

html[data-theme="light"] .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.16);
}

html[data-theme="light"] .mode-tabs,
html[data-theme="light"] .segmented {
  background: rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .opening-preview {
  background: linear-gradient(155deg, #e8e6e3 0%, #dcdad7 100%);
  border-color: rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .opening-preview-meta {
  background: rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .opening-preview-mini {
  background: rgba(255, 255, 255, 0.55);
}

html[data-theme="light"] .room-code-display,
html[data-theme="light"] .share-link-input,
html[data-theme="light"] .join-input {
  background: rgba(0, 0, 0, 0.04);
}

html[data-theme="light"] .settings-switch-slider {
  background: rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .main-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.14);
}

html[data-theme="light"] .main-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.24);
}

html[data-theme="light"] .game-panel::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .nav-item.active {
  background: rgba(61, 125, 204, 0.11);
}

html[data-theme="light"] .nav-item.active::before {
  box-shadow: 0 0 12px rgba(61, 125, 204, 0.32);
}

html[data-theme="light"] .mode-tab.active {
  background: rgba(61, 125, 204, 0.14);
  border-color: rgba(61, 125, 204, 0.38);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}

html[data-theme="light"] .small-board.active {
  box-shadow:
    0 0 0 1px rgba(61, 125, 204, 0.28),
    0 8px 24px rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .eval-bar {
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: 'Figtree', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 900px 420px at 50% -20%, rgba(110, 168, 245, 0.06), transparent 55%),
    linear-gradient(165deg, var(--bg-1) 0%, var(--bg-2) 45%, #2f2d2a 100%);
  display: flex;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Saved UI preferences (<html data-uttt-*>) ── */

html[data-uttt-ui-density="compact"] {
  font-size: 93%;
}

html[data-uttt-ui-density="cozy"] {
  font-size: 108%;
}

html[data-uttt-board-scale="compact"] .board-wrapper {
  max-width: 340px;
  margin-inline: auto;
}

html[data-uttt-board-scale="large"] .board-wrapper {
  max-width: min(620px, 100%);
  margin-inline: auto;
}

html[data-uttt-hide-last-move="1"] .cell.last-move {
  box-shadow: none !important;
}

html[data-uttt-hide-analysis-hints="1"] .cell.hint-best,
html[data-uttt-hide-analysis-hints="1"] .cell.hint-other {
  background: var(--cell-bg) !important;
  box-shadow: none !important;
}

html[data-uttt-hide-analysis-hints="1"] .hint-rank {
  display: none !important;
}

html[data-uttt-hide-move-badges="1"] .cell-classification {
  display: none !important;
}

html[data-uttt-no-piece-glow="1"] .cell[data-mark="X"],
html[data-uttt-no-piece-glow="1"] .cell[data-mark="O"] {
  text-shadow: none !important;
}

html[data-uttt-no-piece-glow="1"] .winner-mark[data-mark="X"],
html[data-uttt-no-piece-glow="1"] .winner-mark[data-mark="O"] {
  text-shadow: none !important;
}

html[data-uttt-no-piece-glow="1"] .turn-mark[data-mark="X"] {
  box-shadow: 0 0 0 1px rgba(110, 168, 245, 0.35);
}

html[data-uttt-no-piece-glow="1"] .turn-mark[data-mark="O"] {
  box-shadow: 0 0 0 1px rgba(224, 112, 112, 0.35);
}

html[data-uttt-no-piece-glow="1"] .side-tag[data-mark="X"] {
  box-shadow: 0 0 0 1px rgba(110, 168, 245, 0.3);
}

html[data-uttt-no-piece-glow="1"] .side-tag[data-mark="O"] {
  box-shadow: 0 0 0 1px rgba(224, 112, 112, 0.3);
}

html[data-uttt-no-piece-glow="1"] .seg-btn[data-mark="X"].is-active {
  box-shadow: inset 0 0 0 1px rgba(110, 168, 245, 0.35);
}

html[data-uttt-no-piece-glow="1"] .seg-btn[data-mark="O"].is-active {
  box-shadow: inset 0 0 0 1px rgba(224, 112, 112, 0.35);
}

html[data-uttt-reduce-motion="1"] .home-page,
html[data-uttt-reduce-motion="1"] .game-page,
html[data-uttt-reduce-motion="1"] .settings-page,
html[data-uttt-reduce-motion="1"] .openings-page,
html[data-uttt-reduce-motion="1"] .help-page,
html[data-uttt-reduce-motion="1"] .history-page {
  animation: none !important;
}

html[data-uttt-reduce-motion="1"] .cell.placed {
  animation: none !important;
}

html[data-uttt-reduce-motion="1"] .winner-overlay,
html[data-uttt-reduce-motion="1"] .book-label {
  animation: none !important;
}

html[data-uttt-reduce-motion="1"] .settings-switch-slider,
html[data-uttt-reduce-motion="1"] .settings-switch-slider::after {
  transition: none !important;
}

html[data-uttt-reduce-motion="1"] .connection-dot.waiting {
  animation: none !important;
}

/* ── Sidebar ── */

.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  gap: 8px;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 12px;
  text-decoration: none;
}

.sidebar-logo-img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  transition: transform 150ms ease;
}

.sidebar-logo:hover .sidebar-logo-img {
  transform: scale(1.08);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 0 8px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px 8px;
  width: 100%;
  border-radius: 10px;
  text-decoration: none;
  color: var(--muted);
  transition: background 150ms ease, color 150ms ease;
  position: relative;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
  color: var(--text);
  background: rgba(110, 168, 245, 0.12);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 26px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 12px rgba(110, 168, 245, 0.35);
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Main content ── */

.main-content {
  flex: 1;
  min-height: 100vh;
  overflow-y: auto;
  padding: 28px 36px 40px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.game-container {
  width: 100%;
}

/* ── Home page ── */

.home-page {
  max-width: 880px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-top: 36px;
  padding-bottom: 24px;
}

.hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.hero-logo {
  width: 84px;
  height: 84px;
  border-radius: 20px;
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.hero h1 {
  font-size: clamp(1.85rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.15;
}

.hero-subtitle {
  color: var(--muted);
  font-size: 1.06rem;
  font-weight: 500;
  max-width: 480px;
  line-height: 1.55;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  max-width: 540px;
}

.hero-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--muted);
}

.home-section-title {
  font-size: 1.06rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
  padding-top: 6px;
}

.home-recent-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.home-recent-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.home-recent-title {
  padding-top: 0;
}

.home-recent-viewall {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.home-recent-viewall:hover {
  text-decoration: underline;
}

.home-recent-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.home-recent-row {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.home-recent-row:hover {
  border-color: rgba(110, 168, 245, 0.45);
  background: rgba(110, 168, 245, 0.06);
}

.home-recent-row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.home-recent-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.home-recent-meta {
  font-weight: 700;
  font-size: 0.92rem;
}

.home-recent-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.history-badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(110, 168, 245, 0.18);
  border: 1px solid rgba(110, 168, 245, 0.35);
  color: var(--accent-hover);
}

.history-badge--compact {
  flex-shrink: 0;
  font-size: 0.62rem;
  padding: 4px 8px;
}

.history-page {
  max-width: 560px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-list-wrap {
  padding-bottom: 24px;
}

.history-empty {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-row {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s, background 0.15s;
}

.history-row:hover {
  border-color: rgba(110, 168, 245, 0.45);
  background: rgba(110, 168, 245, 0.06);
}

.history-row-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.history-row-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.winner-inline-wins {
  display: inline-flex;
  align-items: center;
  gap: 0.28em;
  vertical-align: middle;
}

.winner-inline-piece {
  width: 1.05em;
  height: 1.05em;
  object-fit: contain;
  flex-shrink: 0;
}

.history-row-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.history-row-class-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  row-gap: 4px;
  margin-top: 6px;
  max-width: 100%;
  align-content: flex-start;
}

.history-rating-slot {
  position: relative;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-rating-slot--empty {
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  opacity: 0.65;
}

.history-rating-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: block;
}

.history-rating-player {
  position: absolute;
  right: 0px;
  bottom: 0px;
  z-index: 1;
  font-size: 7px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.06em;
  pointer-events: none;
  text-shadow:
    0 0 2px var(--bg-2),
    0 1px 2px rgba(0, 0, 0, 0.65);
}

.history-rating-player--x {
  color: var(--x-color);
}

.history-rating-player--o {
  color: var(--o-color);
}

.history-row-accuracy {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 0.84rem;
  color: var(--text);
}

.history-acc-side {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.history-acc-piece {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
}

.history-acc-val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.history-acc-sep {
  color: var(--muted);
}

.history-end-preview-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-end-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--panel-border);
  color: var(--muted);
  font-size: 1.1rem;
}

.history-end-preview.opening-preview {
  padding: 8px;
}

.history-end-preview .opening-preview-meta {
  width: 104px;
  height: 104px;
  gap: 3px;
}

.history-end-preview--compact.opening-preview {
  padding: 5px;
}

.history-end-preview--compact .opening-preview-meta {
  width: 72px;
  height: 72px;
  gap: 2px;
}

.history-end-preview--compact .opening-preview-mini {
  gap: 1px;
  padding: 1px;
  border-radius: 3px;
}

.home-more-cards {
  grid-template-columns: repeat(3, 1fr);
  max-width: none;
  margin: 0;
}

.home-rules {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 10px 18px;
  color: var(--muted);
  font-size: 0.93rem;
  box-shadow: var(--shadow-soft);
}

.home-rules summary {
  cursor: pointer;
  user-select: none;
  padding: 8px 0;
  font-weight: 700;
  color: var(--text);
}

.home-rules ol {
  padding-left: 22px;
  line-height: 1.62;
  margin: 8px 0;
}

.home-rules .rules-engine {
  margin: 6px 0 10px;
  line-height: 1.52;
  font-size: 0.87rem;
}

.home-bottom-nav {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 640px) {
  .home-bottom-nav {
    grid-template-columns: repeat(4, 1fr);
  }
}

.home-bottom-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 14px 10px;
  min-height: 100px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  background: var(--panel-strong);
  text-decoration: none;
  color: var(--text);
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.home-bottom-link:hover {
  border-color: rgba(110, 168, 245, 0.35);
  background: var(--panel);
  transform: translateY(-2px);
}

.home-bottom-link svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
  flex-shrink: 0;
}

.home-bottom-link span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35;
}

.play-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.play-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  text-align: center;
  cursor: pointer;
  transition: transform 200ms ease, border-color 200ms ease, background 200ms ease, box-shadow 200ms ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-soft);
}

.play-card:hover {
  transform: translateY(-2px);
  border-color: rgba(110, 168, 245, 0.35);
  background: var(--panel-strong);
  box-shadow: var(--shadow-card);
}

.play-card:active {
  transform: translateY(-1px);
}

.card-icon {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  background: rgba(110, 168, 245, 0.1);
  border: 1px solid rgba(110, 168, 245, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.card-icon svg {
  width: 26px;
  height: 26px;
}

.play-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.play-card p {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}

.home-help-cta {
  text-align: center;
  margin: 8px 0 0;
}

.home-help-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(110, 168, 245, 0.35);
  background: var(--accent-dim);
  transition: background 0.15s, border-color 0.15s;
}

.home-help-link:hover {
  background: rgba(110, 168, 245, 0.28);
  border-color: rgba(110, 168, 245, 0.55);
  color: var(--accent-hover);
}

.home-help-link svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ── Help page ── */

.help-page {
  max-width: 720px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.help-intro,
.help-visual-key {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 0;
}

.help-visual-key {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.help-key-gold {
  color: #ffc878;
  font-weight: 600;
}

.help-key-green {
  color: var(--accent-hover);
  font-weight: 600;
}

.help-sections {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.help-section {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
}

.help-section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--text);
}

.help-section p {
  margin: 0 0 10px;
  font-size: 0.93rem;
  color: var(--muted);
  line-height: 1.6;
}

.help-section p:last-child {
  margin-bottom: 0;
}

.help-diagram-wrap {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.help-diagram-fallback {
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
}

.opening-preview.help-diagram {
  padding: 14px;
}

.opening-preview.help-diagram .opening-preview-meta {
  width: min(260px, 85vw);
  height: min(260px, 85vw);
  gap: 5px;
}

.opening-preview.help-diagram .opening-preview-mini {
  gap: 3px;
  padding: 3px;
}

.help-mono {
  font-family: ui-monospace, 'Cascadia Code', 'Segoe UI Mono', Consolas, monospace;
  font-size: 0.92em;
  letter-spacing: 0.02em;
}

.help-forced-board {
  box-shadow:
    0 0 0 2px var(--accent),
    inset 0 0 12px rgba(129, 182, 76, 0.2);
  border-color: rgba(129, 182, 76, 0.65) !important;
}

.help-steer-wrap {
  margin-top: 4px;
}

.help-steer-caption {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 12px;
}

.help-steer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-width: 420px;
  margin: 0 auto;
}

.help-steer-cell {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
  min-height: 4.5rem;
}

.help-steer-local {
  font-weight: 600;
  color: var(--text);
  font-size: 0.74rem;
}

/* ── Game layout (play + analysis pages) ── */

.game-page {
  max-width: 1060px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-page-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.game-page-header .game-page-title {
  flex: 1;
  min-width: 0;
}

.back-btn {
  appearance: none;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: color 150ms ease, background 150ms ease;
}

.back-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.back-btn svg {
  width: 20px;
  height: 20px;
}

.game-page-title {
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.mode-tabs {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.2);
  padding: 5px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.mode-tab {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 7px;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.mode-tab svg {
  width: 15px;
  height: 15px;
}

.mode-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.mode-tab.active {
  color: var(--text);
  background: rgba(110, 168, 245, 0.22);
  border: 1px solid rgba(110, 168, 245, 0.35);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

/* ── Board column ── */

.board-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.game-status {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  min-height: 52px;
  box-shadow: var(--shadow-soft);
}

.game-status-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.clock-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  min-width: 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--panel-border);
}

.clock-row.hidden {
  display: none;
}

.clock-preset-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
  flex-shrink: 0;
  max-width: 42%;
}

.clock-preset-icon {
  flex-shrink: 0;
}

.clock-preset-details {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Time control glyphs — same gray treatment as sidebar .nav-icon (currentColor → --muted) */
.time-icon {
  display: block;
  flex-shrink: 0;
  background-color: var(--muted);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  transition: background-color 150ms ease;
}

.time-icon--clock {
  width: 22px;
  height: 22px;
}

.time-icon--panel {
  width: 28px;
  height: 28px;
}

.time-icon--lobby {
  width: 32px;
  height: 32px;
}

.time-icon--bullet {
  -webkit-mask-image: url('media/time/Bullet.svg');
  mask-image: url('media/time/Bullet.svg');
}

.time-icon--blitz {
  -webkit-mask-image: url('media/time/Blitz.svg');
  mask-image: url('media/time/Blitz.svg');
}

.time-icon--rapid {
  -webkit-mask-image: url('media/time/Rapid.svg');
  mask-image: url('media/time/Rapid.svg');
}

.time-icon--unlimited {
  -webkit-mask-image: url('media/time/Unlimited.svg');
  mask-image: url('media/time/Unlimited.svg');
}

.time-control-card:hover .time-icon,
.time-control-card.is-active .time-icon,
.lobby-time-opt:hover .time-icon,
.lobby-time-opt.is-active .time-icon {
  background-color: var(--text);
}

.clock-pair {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.game-clock {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.game-clock.clock-active {
  border-color: rgba(110, 168, 245, 0.55);
  box-shadow: 0 0 0 1px rgba(110, 168, 245, 0.2);
}

.game-clock[data-clock-player="2"].clock-active {
  border-color: rgba(224, 112, 112, 0.55);
  box-shadow: 0 0 0 1px rgba(224, 112, 112, 0.18);
}

.game-clock-mark {
  font-weight: 800;
  font-size: 1rem;
  width: 26px;
  text-align: center;
}

.game-clock[data-clock-player="1"] .game-clock-mark {
  color: var(--x-color);
}

.game-clock[data-clock-player="2"] .game-clock-mark {
  color: var(--o-color);
}

.game-clock-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.turn-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.turn-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.turn-mark {
  font-weight: 800;
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  transition: all 200ms ease;
}

.turn-mark[data-mark="X"] {
  color: var(--x-color);
  box-shadow: 0 0 0 1px rgba(110, 168, 245, 0.35), 0 0 14px var(--x-glow);
}

.turn-mark[data-mark="O"] {
  color: var(--o-color);
  box-shadow: 0 0 0 1px rgba(224, 112, 112, 0.35), 0 0 14px var(--o-glow);
}

.turn-piece {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.winner-piece {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.book-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  background: rgba(232, 197, 71, 0.22);
  border: 1px solid rgba(232, 197, 71, 0.48);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  white-space: nowrap;
  animation: fadeIn 300ms ease;
}

.book-label.hidden { display: none; }

.book-label .book-icon {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  margin-right: 5px;
}

.status-buttons {
  display: flex;
  gap: 6px;
}

/* ── Buttons ── */

.btn-primary, .btn-secondary, .btn-ghost {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 200ms ease, border-color 200ms ease, opacity 200ms ease;
  font-family: inherit;
  font-size: 0.88rem;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-hover) 0%, var(--accent) 100%);
  border: 1px solid #4a82c9;
  color: #fff;
  font-weight: 700;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #a8c9fb 0%, var(--accent-hover) 100%);
  border-color: #5c94e8;
}

.btn-secondary {
  background: var(--panel-strong);
  border-color: var(--panel-border-hover);
}

.btn-secondary:hover {
  background: #4f4b47;
  border-color: rgba(255, 255, 255, 0.18);
}

.btn-ghost {
  background: none;
  border-color: transparent;
  color: var(--muted);
  padding: 6px 10px;
}

.btn-ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.btn-primary:active, .btn-secondary:active, .btn-ghost:active {
  transform: scale(0.97);
}

.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
  border-radius: 12px;
}

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Board ── */

.board-wrapper {
  position: relative;
  width: 100%;
}

.meta-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  aspect-ratio: 1 / 1;
  padding: 10px;
  background: linear-gradient(145deg, #454240 0%, #3a3835 100%);
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-lg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 12px 40px rgba(0, 0, 0, 0.35);
}

.small-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  padding: 5px;
  border-radius: 10px;
  background: var(--inactive);
  border: 1.5px solid transparent;
  transition: background 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}

.small-board.active {
  background: var(--active);
  border-color: var(--active-border);
  box-shadow:
    0 0 0 1px rgba(110, 168, 245, 0.25),
    0 8px 28px rgba(0, 0, 0, 0.35);
}

.small-board.won { background: var(--won-bg); }

.small-board.won::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.92;
  background-size: 50%;
  background-repeat: no-repeat;
  background-position: center;
}

.small-board.won[data-winner="X"]::after {
  background-image: url('media/pieces/X256x256.png');
}

.small-board.won[data-winner="O"]::after {
  background-image: url('media/pieces/O256x256.png');
}

.cell {
  appearance: none;
  border: 1px solid var(--cell-border);
  background: var(--cell-bg);
  border-radius: 6px;
  font-size: clamp(0.85rem, 2.2vw, 1.3rem);
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease, transform 100ms ease, border-color 150ms ease, box-shadow 200ms ease;
  user-select: none;
  font-family: inherit;
  position: relative;
}

.cell:hover:not(:disabled) {
  background: var(--cell-bg-hover);
  border-color: rgba(255, 255, 255, 0.12);
}

.cell:active:not(:disabled) { transform: scale(0.95); }
.cell:disabled { cursor: not-allowed; }

.cell[data-mark="X"] {
  color: var(--x-color);
  text-shadow: 0 0 10px var(--x-glow);
}

.cell[data-mark="O"] {
  color: var(--o-color);
  text-shadow: 0 0 10px var(--o-glow);
}

.piece-img {
  width: 65%;
  height: 65%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.cell.placed { animation: pop 220ms cubic-bezier(0.2, 1.2, 0.4, 1); }

.cell.last-move {
  box-shadow: inset 0 0 0 2px rgba(232, 197, 71, 0.65);
}

.cell.hint-best {
  box-shadow: inset 0 0 0 2px var(--hint);
  background: var(--hint-soft);
}

.cell.hint-other {
  box-shadow: inset 0 0 0 2px rgba(232, 197, 71, 0.45);
  background: rgba(232, 197, 71, 0.07);
}

.cell .hint-rank {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(245, 220, 130, 0.98);
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

@keyframes pop {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

.small-board.won .cell { opacity: 0.15; }
.small-board.won .cell:has(.cell-classification) { opacity: 0.4; }

.cell-classification {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: clamp(11px, 42%, 20px);
  height: clamp(11px, 42%, 20px);
  pointer-events: none;
  z-index: 5;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}

/* ── Winner overlay ── */

.winner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: rgba(39, 37, 34, 0.88);
  backdrop-filter: blur(8px);
  z-index: 10;
  animation: fadeIn 300ms ease;
}

.winner-overlay.hidden { display: none; }

.winner-card {
  background: var(--panel-strong);
  border: 1px solid var(--panel-border);
  padding: 28px 36px;
  border-radius: var(--radius-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-card);
}

.winner-mark {
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 1;
}

.winner-mark[data-mark="X"] { color: var(--x-color); text-shadow: 0 0 22px var(--x-glow); }
.winner-mark[data-mark="O"] { color: var(--o-color); text-shadow: 0 0 22px var(--o-glow); }
.winner-mark[data-mark="-"] { color: var(--muted); font-size: 2rem; }

.winner-text {
  font-size: 1.1rem;
  font-weight: 600;
}

.winner-buttons {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Game panel (right sidebar) ── */

.game-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: var(--shadow-soft);
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-section[hidden] { display: none; }

.panel-section + .panel-section {
  border-top: 1px solid var(--panel-border);
  padding-top: 10px;
}

.panel-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.panel-section-title.is-follow {
  margin-top: 10px;
}

/* ── Segmented controls ── */

.segmented {
  display: grid;
  gap: 3px;
  background: rgba(0, 0, 0, 0.2);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--panel-border);
}

.segmented.cols-2 { grid-template-columns: 1fr 1fr; }
.segmented.cols-3 { grid-template-columns: repeat(3, 1fr); }
.segmented.cols-4 { grid-template-columns: repeat(4, 1fr); }

.seg-btn {
  appearance: none;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 6px;
  padding: 7px 8px;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, box-shadow 200ms ease;
  white-space: nowrap;
}

.seg-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.seg-btn.is-active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

.seg-btn[data-mark="X"].is-active {
  color: var(--x-color);
  box-shadow: inset 0 0 0 1px rgba(110, 168, 245, 0.35), 0 0 12px rgba(110, 168, 245, 0.2);
}

.seg-btn[data-mark="O"].is-active {
  color: var(--o-color);
  box-shadow: inset 0 0 0 1px rgba(224, 112, 112, 0.35), 0 0 12px rgba(224, 112, 112, 0.2);
}

/* ── Evaluation ── */

.eval-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.eval-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.eval-value {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.eval-bar {
  position: relative;
  height: 12px;
  border-radius: 6px;
  background: var(--o-color);
  overflow: hidden;
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.25);
}

.eval-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 50%;
  background: var(--x-color);
  transition: width 250ms ease;
}

.eval-center {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: calc(50% - 1px);
  width: 2px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

.eval-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
}

.eval-legend [data-mark="X"] { color: var(--x-color); }
.eval-legend [data-mark="O"] { color: var(--o-color); }

/* ── Engine status ── */

.engine-status { font-size: 0.88rem; }
.status-line { font-weight: 600; }
.status-stats {
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

/* ── Top moves list ── */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.section-header h3 {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-hint {
  font-size: 0.7rem;
  color: var(--muted);
}

.moves-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.move-item {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
  font-size: 0.85rem;
}

.move-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--panel-border);
}

.move-item.is-best {
  background: rgba(232, 197, 71, 0.12);
  border-color: rgba(232, 197, 71, 0.42);
}

.move-rank {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-align: center;
}

.move-coord {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.move-meta {
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.move-winrate {
  display: block;
  font-weight: 700;
  color: var(--text);
}

.panel-buttons {
  flex-direction: row;
  gap: 6px;
}

.panel-buttons button { flex: 1; }

/* ── Online play panel ── */

.online-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.connection-dot.connected { background: var(--success); box-shadow: 0 0 6px var(--success); }
.connection-dot.waiting { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: pulse 1.5s infinite; }
.connection-dot.disconnected { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.room-code-display {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: 'Consolas', 'Courier New', monospace;
  letter-spacing: 4px;
  text-align: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  user-select: all;
}

.share-link-input {
  width: 100%;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
  user-select: all;
}

.share-link-input:focus {
  border-color: var(--accent);
}

/* ── Difficulty picker ── */

.difficulty-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.difficulty-card {
  appearance: none;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 200ms ease;
  color: var(--text);
  font-family: inherit;
}

.difficulty-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--panel-border-hover);
}

.difficulty-card.is-active {
  background: rgba(110, 168, 245, 0.18);
  border-color: rgba(110, 168, 245, 0.45);
}

.difficulty-card .diff-name {
  font-weight: 700;
  font-size: 0.92rem;
  display: block;
}

.difficulty-card .diff-desc {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
  display: block;
}

.time-control-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.time-control-card {
  appearance: none;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 200ms ease;
  color: var(--text);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.time-control-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--panel-border-hover);
}

.time-control-card.is-active {
  background: rgba(110, 168, 245, 0.18);
  border-color: rgba(110, 168, 245, 0.45);
}

.time-control-card-name {
  font-weight: 700;
  font-size: 0.88rem;
}

.time-control-card-desc {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.25;
}

/* ── Review controls ── */

.review-nav {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.review-nav button {
  appearance: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: background 150ms ease;
}

.review-nav button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
}

.review-nav button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.review-nav button svg {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}

.move-counter {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ── Side picker ── */

.side-picker-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
}

.side-tag {
  font-weight: 800;
  font-size: 0.95rem;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
}

.side-tag[data-mark="X"] {
  color: var(--x-color);
  box-shadow: 0 0 0 1px rgba(110, 168, 245, 0.3), 0 0 10px var(--x-glow);
}

.side-tag[data-mark="O"] {
  color: var(--o-color);
  box-shadow: 0 0 0 1px rgba(224, 112, 112, 0.3), 0 0 10px var(--o-glow);
}

/* ── Join room dialog ── */

.join-dialog {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  padding: 16px 0;
}

.join-input {
  width: 100%;
  max-width: 200px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
  outline: none;
}

.join-input:focus {
  border-color: var(--accent);
}

.join-input::placeholder {
  color: var(--muted);
  letter-spacing: 1px;
  font-weight: 400;
  font-size: 0.9rem;
}

/* ── Online lobby ── */

.online-lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 48px 20px;
  max-width: 480px;
  margin: 0 auto;
}

.lobby-time-section {
  width: 100%;
}

.lobby-time-heading {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}

.lobby-time-options {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  width: 100%;
}

.lobby-time-options > .lobby-time-opt {
  flex: 1 1 0;
  min-width: 0;
}

.lobby-host-side-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 420px) {
  .lobby-host-side-options {
    grid-template-columns: 1fr;
  }
}

.lobby-time-opt {
  appearance: none;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s;
  box-shadow: var(--shadow-soft);
}

.lobby-time-opt:hover {
  border-color: var(--panel-border-hover);
  background: rgba(255, 255, 255, 0.04);
}

.lobby-time-opt.is-active {
  border-color: rgba(110, 168, 245, 0.55);
  background: rgba(110, 168, 245, 0.12);
}

.lobby-time-opt-label {
  font-weight: 800;
  font-size: 0.88rem;
}

.lobby-time-opt-desc {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.25;
}

.lobby-lead-note {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.45;
}

.lobby-lead {
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
  font-size: 0.95rem;
}

.join-card-heading {
  margin-bottom: 12px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.join-room-submit {
  margin-top: 12px;
  width: 100%;
}

.lobby-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 28px 26px;
  text-align: center;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow-soft);
}

.lobby-card .card-icon {
  margin-bottom: 12px;
}

.lobby-card h2 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.lobby-card h3 {
  font-size: 1rem;
  font-weight: 700;
}

.lobby-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.lobby-divider::before,
.lobby-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--panel-border);
}

/* ── Classification progress ── */

.classify-progress-section {
  padding: 8px 12px;
}

.classify-progress-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.classify-progress-bar-wrap {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.classify-progress-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.3s ease;
  width: 0%;
}

/* ── Eval graph ── */

.eval-graph-section {
  padding: 4px 0;
}

.eval-graph-canvas {
  width: 100%;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

/* ── Played move display ── */

.played-move-section {
  padding: 6px 12px;
}

.played-move-number {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.played-move-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
}

.played-move-display {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.played-move-label {
  color: var(--muted);
  font-size: 0.78rem;
}

.played-move-piece {
  width: 18px;
  height: 18px;
}

.played-move-coord {
  font-weight: 600;
}

.played-move-cls-icon {
  width: 18px;
  height: 18px;
  margin-left: 4px;
}

.played-move-cls {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Classification summary ── */

.classification-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.summary-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.summary-col-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.85rem;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 2px;
}

.summary-col-header .summary-piece {
  width: 18px;
  height: 18px;
}

.accuracy-box {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  padding: 6px 0;
  margin-bottom: 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.accuracy-pending {
  color: var(--muted);
  letter-spacing: 2px;
}

.class-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  padding: 3px 6px;
  border-radius: 6px;
}

.class-item img {
  width: 16px;
  height: 16px;
}

.class-item .class-count {
  font-weight: 700;
  margin-left: auto;
}

/* ── Openings page ── */

.openings-page {
  max-width: 1200px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: pageIn 250ms ease;
}

.openings-intro {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.openings-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 992px) {
  .openings-list {
    grid-template-columns: repeat(3, 1fr);
    align-items: stretch;
  }
}

.openings-loading {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 20px;
  text-align: center;
  grid-column: 1 / -1;
}

.opening-card {
  position: relative;
  z-index: 0;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: transform 200ms ease, border-color 200ms ease, background 200ms ease, box-shadow 200ms ease, z-index 0s linear;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: visible;
  box-shadow: var(--shadow-soft);
}

.opening-card:has(.opening-variants-help:hover),
.opening-card:has(.opening-variants-help:focus-within) {
  z-index: 40;
}

.opening-card-inner {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 18px;
  width: 100%;
  position: relative;
}

.opening-card-main {
  position: relative;
  z-index: 2;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.opening-preview {
  position: relative;
  z-index: 0;
  flex-shrink: 0;
  padding: 10px;
  border-radius: var(--radius-md);
  background: linear-gradient(155deg, #454240 0%, #363432 100%);
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 6px 20px rgba(0, 0, 0, 0.35);
}

.opening-preview--empty {
  width: 140px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.opening-preview-placeholder {
  font-size: 0.75rem;
  color: var(--muted);
}

.opening-preview-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 140px;
  height: 140px;
  padding: 2px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 8px;
}

.opening-preview-mini {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.opening-preview-mini--x {
  background: rgba(110, 168, 245, 0.22);
  border-color: rgba(110, 168, 245, 0.45);
  box-shadow: inset 0 0 12px rgba(110, 168, 245, 0.12);
}

.opening-preview-mini--o {
  background: rgba(224, 112, 112, 0.18);
  border-color: rgba(224, 112, 112, 0.45);
  box-shadow: inset 0 0 12px rgba(224, 112, 112, 0.1);
}

.opening-preview-mini--tie {
  background: rgba(130, 130, 160, 0.2);
  border-color: rgba(255, 255, 255, 0.12);
}

.opening-preview-cell {
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.opening-preview-cell img {
  width: 72%;
  height: 72%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.opening-preview-cell--last {
  box-shadow:
    inset 0 0 0 2px rgba(255, 200, 120, 0.95),
    0 0 8px rgba(255, 200, 120, 0.25);
  border-radius: 2px;
}

.opening-card:hover {
  transform: translateY(-2px);
  border-color: rgba(110, 168, 245, 0.35);
  background: var(--panel-strong);
  box-shadow: var(--shadow-card);
}

.opening-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.opening-book-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.opening-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.opening-desc {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.opening-move {
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
}

.opening-move[data-player="X"] {
  color: var(--x-color);
  border-color: rgba(110, 168, 245, 0.35);
}

.opening-move[data-player="O"] {
  color: var(--o-color);
  border-color: rgba(224, 112, 112, 0.35);
}

.opening-arrow {
  color: var(--muted);
  font-size: 0.78rem;
}

.opening-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.opening-footer-left {
  min-height: 28px;
  display: flex;
  align-items: center;
}

.opening-variants-help {
  position: relative;
  z-index: 3;
  display: inline-flex;
  align-items: center;
}

.opening-variants-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  cursor: help;
  user-select: none;
  line-height: 1;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.opening-variants-help:hover .opening-variants-help-icon,
.opening-variants-help:focus-within .opening-variants-help-icon {
  color: var(--accent);
  border-color: rgba(110, 168, 245, 0.45);
  background: rgba(110, 168, 245, 0.14);
}

.opening-variants-popover {
  position: absolute;
  z-index: 10000;
  left: 0;
  bottom: calc(100% + 10px);
  min-width: 260px;
  max-width: min(360px, 85vw);
  padding: 10px 12px;
  background: var(--panel-strong);
  border: 1px solid var(--panel-border-hover);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease, visibility 120ms ease;
}

.opening-variants-help:hover .opening-variants-popover,
.opening-variants-help:focus-within .opening-variants-popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.opening-variants-popover-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.opening-variants-popover-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 240px;
  overflow-y: auto;
}

.opening-variant-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.78rem;
}

.opening-variant-num {
  flex-shrink: 0;
  color: var(--muted);
  font-weight: 700;
  width: 1.25rem;
}

.opening-variant-moves {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  line-height: 1.4;
}

.opening-variant-chip {
  font-size: 0.75rem;
  padding: 2px 6px;
}

.opening-explore-btn {
  font-size: 0.82rem !important;
}

@media (max-width: 560px) {
  .opening-card-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .opening-card-main {
    align-items: center;
  }

  .opening-card-header {
    justify-content: center;
  }

  .opening-footer {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
}

/* ── Settings page ── */

.settings-page {
  max-width: 640px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: pageIn 250ms ease;
}

.settings-section {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-soft);
}

.settings-section-title {
  font-size: 1rem;
  margin: 0 0 8px;
}

.settings-hint {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 0 0 16px;
}

.settings-option {
  margin-top: 20px;
}

.settings-section > .settings-option:first-of-type {
  margin-top: 0;
}

.settings-option-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-option-title {
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

.settings-option-desc {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.settings-option-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--panel-border);
}

.settings-option-row:first-of-type {
  padding-top: 4px;
  margin-top: 4px;
  border-top: none;
}

.settings-option-row .settings-option-header {
  flex: 1;
  min-width: 0;
}

.settings-segmented {
  margin-top: 10px;
}

.settings-review-budget {
  margin-top: 0;
}

.settings-hint-tight {
  margin-bottom: 0;
  margin-top: 10px;
}

.settings-range-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

.settings-range {
  flex: 1;
  min-width: 0;
  height: 8px;
  border-radius: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}

.settings-range-value {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  min-width: 3.2rem;
  text-align: right;
}

.settings-switch {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.settings-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  clip: rect(0, 0, 0, 0);
}

.settings-switch-slider {
  display: block;
  width: 46px;
  height: 28px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
  transition: background 180ms ease, border-color 180ms ease;
  position: relative;
}

.settings-switch-slider::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text);
  transform: translateY(-50%);
  transition: transform 180ms ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.settings-switch input:checked + .settings-switch-slider {
  background: rgba(110, 168, 245, 0.38);
  border-color: rgba(110, 168, 245, 0.55);
}

.settings-switch input:checked + .settings-switch-slider::after {
  transform: translate(18px, -50%);
}

.settings-switch input:focus-visible + .settings-switch-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 520px) {
  .settings-option-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .settings-switch {
    align-self: flex-end;
  }
}

.engine-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.engine-card {
  appearance: none;
  text-align: left;
  width: 100%;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 150ms ease, background 150ms ease;
}

.engine-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--panel-border-hover);
}

.engine-card.is-active {
  border-color: rgba(110, 168, 245, 0.55);
  background: rgba(110, 168, 245, 0.14);
}

.engine-card-title {
  display: block;
  font-weight: 700;
  font-size: 0.98rem;
  margin-bottom: 6px;
}

.engine-card-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

/* ── Page transitions ── */

.home-page, .game-page {
  animation: pageIn 250ms ease;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ── */

.main-content::-webkit-scrollbar {
  width: 6px;
}

.main-content::-webkit-scrollbar-track {
  background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.main-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.game-panel::-webkit-scrollbar {
  width: 4px;
}

.game-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
}

/* ── Responsive ── */

@media (max-width: 960px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .game-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 700px) {
  .play-cards {
    grid-template-columns: 1fr;
  }

  .home-more-cards {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 16px;
  }

  .home-page {
    padding-top: 16px;
    gap: 22px;
  }

  .game-page-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .mode-tabs {
    width: 100%;
    order: 2;
  }

  .mode-tab {
    flex: 1;
    justify-content: center;
    padding: 7px 6px;
    font-size: 0.76rem;
  }
}

@media (max-width: 520px) {
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-height: auto;
    height: 60px;
    flex-direction: row;
    padding: 0 8px;
    border-right: none;
    border-top: 1px solid var(--panel-border);
    z-index: 200;
  }

  .sidebar-logo {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    justify-content: space-around;
    padding: 0;
    width: 100%;
  }

  .nav-item {
    padding: 8px 4px 6px;
    gap: 2px;
  }

  .nav-item.active::before {
    display: none;
  }

  .nav-item.active {
    border-radius: 12px;
    box-shadow: inset 0 -3px 0 var(--accent);
  }

  .nav-label {
    font-size: 0.62rem;
  }

  body {
    flex-direction: column;
    overflow: auto;
  }

  .main-content {
    padding: 12px 12px 72px;
    min-height: calc(100vh - 60px);
  }

  .meta-board {
    gap: 5px;
    padding: 5px;
  }

  .small-board {
    gap: 2px;
    padding: 3px;
  }
}

/* ── Puzzles ── */

.puzzle-page {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.puzzle-streak-bar {
  display: flex;
  gap: 32px;
  justify-content: center;
  padding: 8px 0;
}

.puzzle-streak-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.puzzle-streak-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.puzzle-streak-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.puzzle-id {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: monospace;
  text-align: center;
  opacity: 0.6;
}

.puzzle-prompt {
  font-size: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  text-align: center;
  justify-content: center;
  flex-wrap: wrap;
}

.puzzle-prompt-piece {
  width: 24px;
  height: 24px;
  vertical-align: middle;
}

.puzzle-board-container {
  width: 100%;
  max-width: 480px;
}

.puzzle-board-wrapper {
  margin: 0 auto;
}

.puzzle-controls {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.puzzle-next-btn {
  padding: 10px 32px;
  font-size: 1rem;
}

.puzzle-generating {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

.puzzle-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: puzzle-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes puzzle-spin {
  to { transform: rotate(360deg); }
}

.puzzle-result-correct {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.1rem;
}

.puzzle-result-wrong {
  color: var(--danger, #ef4444);
  font-weight: 700;
  font-size: 1.1rem;
}

.cell.puzzle-correct {
  position: relative;
}

.cell.puzzle-correct::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: var(--accent);
  opacity: 0.35;
  animation: puzzle-flash-green 0.6s ease-out forwards;
  pointer-events: none;
}

@keyframes puzzle-flash-green {
  0% { opacity: 0.5; transform: scale(1.1); }
  100% { opacity: 0.25; transform: scale(1); }
}

.cell.puzzle-wrong {
  position: relative;
}

.cell.puzzle-wrong::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: var(--danger, #ef4444);
  opacity: 0.35;
  animation: puzzle-flash-red 0.6s ease-out forwards;
  pointer-events: none;
}

@keyframes puzzle-flash-red {
  0% { opacity: 0.5; transform: scale(1.1); }
  100% { opacity: 0.25; transform: scale(1); }
}

.cell.puzzle-reveal {
  position: relative;
}

.cell.puzzle-reveal::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: var(--gold, #f59e0b);
  opacity: 0;
  animation: puzzle-reveal-pulse 0.8s ease-out 0.3s forwards;
  pointer-events: none;
}

@keyframes puzzle-reveal-pulse {
  0% { opacity: 0; }
  40% { opacity: 0.45; }
  100% { opacity: 0.3; }
}

.puzzle-analyze {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}

.puzzle-analyze-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  transition: color 0.15s;
}

.puzzle-analyze-btn:hover {
  color: var(--accent);
}

.puzzle-analyze-btn svg {
  width: 15px;
  height: 15px;
}
