/*
 * Games section (/games, /games/:slug) — loaded only on those pages via base.njk's
 * extraStylesheets, so none of this weighs on components.css. Colours come from variables.css
 * plus the game tokens below; dark theme overrides live under [data-bs-theme='dark'].
 */

:root {
  --game-cell: #e2e8f0;
  --game-cell-strong: #cbd5e1;
  --game-correct: #16a34a;
  --game-present: #d97706;
  --game-absent: #64748b;
  --game-red: #dc2626;
  --game-green: #16a34a;
  --game-yellow: #eab308;
  --game-blue: #2563eb;
  --sn-bg: #f8fafc;
  --sn-grid: #eef2f6;
  --sn-snake: #4f46e5;
  --sn-head: #3730a3;
  --sn-food: #dc2626;
}

[data-bs-theme='dark'] {
  --game-cell: #1e293b;
  --game-cell-strong: #334155;
  --game-correct: #15803d;
  --game-present: #b45309;
  --game-absent: #3f4b5e;
  --game-red: #ef4444;
  --game-green: #22c55e;
  --game-yellow: #facc15;
  --game-blue: #3b82f6;
  --sn-bg: #0f172a;
  --sn-grid: #152036;
  --sn-snake: #818cf8;
  --sn-head: #c7d2fe;
  --sn-food: #f87171;
}

.tool-icon-games {
  background-color: var(--primary-soft);
  border-color: var(--primary-soft-border);
  color: var(--primary);
}

.tool-card:hover .tool-icon-games {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* ---------- /games index: one section per game group ---------- */

.games-hero-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.games-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: fit-content;
  padding: 0.25rem 0.85rem;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid var(--primary-soft-border);
  margin-bottom: 0.25rem;
}

.games-leaderboard-link a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}

.games-group-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: var(--spacing-xl);
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  align-items: center;
}

.games-group-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background-color: var(--surface-alt);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.games-group-chip:hover,
.games-group-chip:focus-visible {
  border-color: var(--primary-soft-border);
  background-color: var(--primary-soft);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.games-group-chip-icon {
  display: inline-flex;
  align-items: center;
  color: var(--primary);
}

.games-group-chip-lb {
  background-color: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(217, 119, 6, 0.25);
  margin-left: auto;
}

.games-group-chip-lb .games-group-chip-icon {
  color: var(--accent);
}

.games-group-chip-lb:hover {
  background-color: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.games-group-chip-lb:hover .games-group-chip-icon {
  color: #ffffff;
}

.games-group-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.45rem;
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border-subtle);
}

.games-group + .games-group {
  margin-top: var(--spacing-xl);
}

.games-group {
  scroll-margin-top: 5.5rem;
}

.games-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: var(--spacing);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.games-group-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.games-group-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}

.games-group-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.games-group-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

/* ---------- Shared game chrome ---------- */

.game-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing);
}

.game-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

.game-select {
  width: auto;
  min-width: 10rem;
}

.game-check {
  margin: 0;
}

.game-hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--spacing-sm);
}

.game-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 5.5rem;
  padding: var(--spacing-xs) var(--spacing);
  background-color: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.game-stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.game-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.game-status {
  min-height: 1.5em;
  margin: 0;
  text-align: center;
  color: var(--text-muted);
}

.game-status-lg {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.game-board:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 4px;
}

/* Opt-in Full screen (lib/fullscreen.js, `fullscreen: true` in content/games/*.json).
   :fullscreen is the Fullscreen API; .is-focus is the overlay fallback for browsers without
   element full screen (iPhone Safari). */
.game-fullscreen-btn {
  display: block;
  margin: 0 0 var(--spacing-sm) auto;
}

.game-widget:fullscreen,
.game-widget.is-focus {
  margin: 0;
  padding: var(--spacing);
  overflow: auto;
  border-radius: 0;
  background-color: var(--background);
}

.game-widget.is-focus {
  position: fixed;
  inset: 0;
  z-index: 1090;
}

.game-widget:fullscreen::before,
.game-widget.is-focus::before {
  display: none;
}

body.game-focus-open {
  overflow: hidden;
}

/*
 * Fixed-size cells (GAMES.md §4): a cell's content (a lit dot, a digit, pencil marks, a long word)
 * must never resize its row or column. Boards with a fixed aspect ratio size their tracks with
 * minmax(0, 1fr) on BOTH axes, and both the boards and their cells drop the automatic
 * content-based minimum size (an aspect-ratio box otherwise grows to fit overflowing content).
 * Memory Match keeps overflow visible because overflow: hidden would flatten its 3D card flip.
 */
.lo-board,
.mc-board,
.ty-board,
.ty-centre,
.kk-board,
.cf-board,
.wh-board,
.gm-board,
.sm-board,
.g2048-board {
  min-height: 0;
}

.lo-cell,
.mc-cell,
.ty-sq,
.ty-centre,
.kk-cell,
.kk-block,
.cf-cell,
.wh-tile,
.gm-cell,
.sm-pad,
.ttt-cell,
.c4-cell,
.sd-cell,
.g2048-cell,
.wc-tile,
.ng-cell,
.ms-cell {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.mm-card {
  min-width: 0;
  min-height: 0;
}

/* Stops the browser scrolling/zooming while a swipe controls the game. */
.game-swipe {
  touch-action: none;
}

.game-segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.game-seg-btn {
  padding: 0.4rem 0.9rem;
  border: 0;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}

.game-seg-btn.is-active {
  background: var(--primary);
  color: #ffffff;
}

/* ---------- Leaderboards (game panel + /games/leaderboard) ---------- */

.lb-hero-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lb-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: fit-content;
  padding: 0.25rem 0.85rem;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid rgba(217, 119, 6, 0.25);
  margin-bottom: 0.25rem;
}

.lb-hero-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.25rem;
  margin-top: 0.85rem;
}

.lb-highlight-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}

.lb-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.lb-panel-game {
  margin-top: 2rem;
}

.lb-panel-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.35rem;
}

.lb-panel-title-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.lb-panel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(217, 119, 6, 0.25);
  flex-shrink: 0;
}

.lb-weight-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid var(--primary-soft-border);
}

.lb-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm) var(--spacing);
}

.lb-board-label {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin: 0;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.lb-board-select {
  width: auto;
  min-width: 9rem;
  font-size: 0.88rem;
  padding: 0.4rem 2rem 0.4rem 0.75rem;
  border-radius: var(--radius);
  border-color: var(--border);
  background-color: var(--surface);
}

/* Viewer HUD Card */
.lb-viewer-hud {
  margin-bottom: 1.35rem;
}

.lb-hud-card {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.lb-hud-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1 1 18rem;
  min-width: 0;
}

.lb-hud-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.lb-hud-icon-muted {
  background: rgba(148, 163, 184, 0.15);
}

.lb-hud-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.lb-hud-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.lb-hud-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.lb-hud-player-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
}

.lb-hud-playing-as {
  color: var(--text-muted);
}

.lb-hud-name {
  color: var(--text);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-hud-note {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.lb-hud-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

.lb-hud-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.85rem;
}

.lb-hud-stat-rank {
  color: var(--primary);
}

.lb-hud-stat-total {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.lb-hud-stat-score {
  color: var(--accent);
  padding-left: 0.35rem;
  border-left: 1px solid var(--border);
}

.lb-hud-settings {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.lb-hud-settings:hover {
  color: var(--primary);
  text-decoration: underline;
}

.lb-hud-btn {
  font-size: 0.85rem;
  padding: 0.35rem 0.95rem;
  border-radius: var(--radius);
}

/* Podium Top 3 Champions Showcase */
.lb-podium {
  margin-bottom: 1.5rem;
}

.lb-podium-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: flex-end;
}

.lb-podium-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.25rem 0.85rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.lb-podium-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.lb-podium-rank-1 {
  order: 2;
  min-height: 13rem;
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.09) 0%, var(--surface) 80%);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.15);
}

.lb-podium-rank-2 {
  order: 1;
  min-height: 11.5rem;
  border-color: rgba(148, 163, 184, 0.4);
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.08) 0%, var(--surface) 80%);
}

.lb-podium-rank-3 {
  order: 3;
  min-height: 10.5rem;
  border-color: rgba(180, 83, 9, 0.35);
  background: linear-gradient(180deg, rgba(180, 83, 9, 0.07) 0%, var(--surface) 80%);
}

.lb-podium-card.is-mine {
  outline: 2px solid var(--primary);
  box-shadow: 0 0 20px rgba(79, 70, 229, 0.25);
}

.lb-podium-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.lb-podium-crown {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #d97706;
  background: rgba(245, 158, 11, 0.15);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
}

[data-bs-theme='dark'] .lb-podium-crown {
  color: #fbbf24;
}

.lb-podium-avatar-wrap {
  margin: 0.4rem 0 0.5rem;
}

.lb-podium-avatar-wrap .lb-avatar {
  width: 3rem;
  height: 3rem;
  font-size: 1rem;
}

.lb-podium-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.lb-podium-score {
  margin-top: 0.35rem;
}

.lb-podium-score-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.lb-podium-score-lbl {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.lb-podium-games {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

@media (max-width: 575.98px) {
  .lb-podium-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .lb-podium-rank-1 {
    order: 1;
    min-height: auto;
  }
  .lb-podium-rank-2 {
    order: 2;
    min-height: auto;
  }
  .lb-podium-rank-3 {
    order: 3;
    min-height: auto;
  }
}

/* Avatar Component */
.lb-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: var(--radius-full);
  background: hsl(var(--lb-avatar-hue, 220), 75%, 90%);
  color: hsl(var(--lb-avatar-hue, 220), 80%, 28%);
  font-weight: 700;
  font-size: 0.75rem;
  border: 1.5px solid hsl(var(--lb-avatar-hue, 220), 65%, 80%);
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-bs-theme='dark'] .lb-avatar {
  background: hsl(var(--lb-avatar-hue, 220), 45%, 22%);
  color: hsl(var(--lb-avatar-hue, 220), 85%, 75%);
  border-color: hsl(var(--lb-avatar-hue, 220), 45%, 35%);
}

.lb-avatar-mine {
  box-shadow: 0 0 0 2px var(--primary);
}

/* Rank Badges */
.lb-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.9rem;
  height: 1.9rem;
  padding: 0 0.35rem;
  border-radius: var(--radius-full);
  font-weight: 800;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  gap: 0.15rem;
}

.lb-rank-1 {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #d97706 100%);
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.lb-rank-2 {
  background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 50%, #94a3b8 100%);
  color: #1e293b;
  box-shadow: 0 2px 6px rgba(148, 163, 184, 0.35);
}

[data-bs-theme='dark'] .lb-rank-2 {
  background: linear-gradient(135deg, #94a3b8 0%, #64748b 50%, #475569 100%);
  color: #ffffff;
}

.lb-rank-3 {
  background: linear-gradient(135deg, #fed7aa 0%, #f97316 50%, #c2410c 100%);
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  box-shadow: 0 2px 6px rgba(249, 115, 22, 0.35);
}

.lb-rank-badge:not(.lb-rank-1):not(.lb-rank-2):not(.lb-rank-3) {
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  font-weight: 700;
}

.lb-rank-icon {
  font-size: 0.85rem;
  line-height: 1;
}

/* Modern Leaderboard Table */
.lb-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.lb-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.lb-table th,
.lb-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: middle;
}

.lb-table th {
  background: var(--surface-alt);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

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

.lb-table tbody tr {
  transition: background-color 0.15s ease;
}

.lb-table tbody tr:hover td {
  background: var(--surface-alt);
}

.lb-table .lb-col-rank {
  width: 4rem;
  text-align: center;
}

.lb-table .lb-col-value {
  width: 8.5rem;
  text-align: right;
}

.lb-table .lb-col-count {
  width: 6.5rem;
  text-align: right;
}

@media (max-width: 575.98px) {
  .lb-table th,
  .lb-table td {
    padding: 0.6rem 0.65rem;
  }
  .lb-table .lb-col-rank {
    width: 3.25rem;
  }
  .lb-table .lb-col-value {
    width: 6.5rem;
  }
  .lb-table .lb-col-count {
    width: 4.5rem;
  }
}

.lb-player {
  overflow: hidden;
}

.lb-player-inner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.lb-player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text);
  font-size: 0.92rem;
}

.lb-val-primary {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.lb-val-secondary {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  background: var(--surface-alt);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.lb-table tr.is-mine td {
  background: var(--primary-soft) !important;
  font-weight: 600;
}

.lb-table tr.is-mine td:first-child {
  position: relative;
  box-shadow: inset 3px 0 0 var(--primary);
}

.lb-you {
  display: inline-flex;
  align-items: center;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

.lb-gap td {
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.3em;
  font-size: 0.8rem;
  background: var(--surface-alt);
}

/* Skeleton Loading Shimmer */
.lb-row-skeleton td {
  padding: 0.85rem 1rem;
}

.lb-skeleton-bar {
  height: 1.15rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--surface-alt) 25%,
    var(--border) 50%,
    var(--surface-alt) 75%
  );
  background-size: 200% 100%;
  animation: lb-shimmer 1.5s infinite;
}

@keyframes lb-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.lb-loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.lb-spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: lb-spin 0.8s linear infinite;
}

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

/* Empty State */
.lb-empty-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  gap: 0.75rem;
}

.lb-empty-icon {
  font-size: 2.25rem;
  line-height: 1;
}

.lb-empty-msg {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
  max-width: 24rem;
  text-align: center;
}

/* Rules & Points Breakdown */
.lb-rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
  margin-bottom: 2.5rem;
}

.lb-rule-card {
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.lb-rule-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.lb-rule-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}

.lb-rule-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.lb-points-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
}

.lb-point-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  background: var(--surface-alt);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  font-weight: 600;
}

.lb-point-pill .lb-pos {
  color: var(--text-muted);
}

.lb-point-pill .lb-pts {
  color: var(--primary);
  font-weight: 700;
}

.lb-section-subhead {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 2rem 0 0.25rem;
}

.lb-tiers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.lb-tier-card {
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.lb-tier-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.lb-tier-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.25rem;
}

.lb-tier-blurb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.lb-tier-weight {
  display: inline-flex;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.lb-tier-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  margin: 0.5rem 0 0;
  list-style: none;
}

.lb-tier-list a,
.lb-game-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.lb-tier-list a:hover,
.lb-game-chip:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.lb-panel-footer {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

.lb-footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--primary);
  text-decoration: none;
  transition:
    gap 0.15s ease,
    color 0.15s ease;
}

.lb-footer-link:hover {
  color: var(--primary-hover);
  gap: 0.65rem;
}

/* ---------- 2048 ---------- */

/* Fixed tracks on both axes: tiles never resize with their number (plain 1fr tracks grow to fit
   content, and without explicit rows the row heights followed the content too). */
.g2048-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  width: min(100%, 26rem);
  aspect-ratio: 1;
  padding: 0.5rem;
  background-color: var(--game-cell-strong);
  border-radius: var(--radius-lg);
}

.g2048-cell {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background-color: var(--game-cell);
  font-weight: 800;
  font-size: clamp(1.1rem, 6vw, 2rem);
  color: #1f2937;
  font-variant-numeric: tabular-nums;
}

.g2048-v-2 {
  background-color: #eee4da;
}
.g2048-v-4 {
  background-color: #ede0c8;
}
.g2048-v-8 {
  background-color: #f2b179;
  color: #ffffff;
}
.g2048-v-16 {
  background-color: #f59563;
  color: #ffffff;
}
.g2048-v-32 {
  background-color: #f67c5f;
  color: #ffffff;
}
.g2048-v-64 {
  background-color: #f65e3b;
  color: #ffffff;
}
.g2048-v-128 {
  background-color: #edcf72;
  color: #ffffff;
  font-size: clamp(1rem, 5vw, 1.7rem);
}
.g2048-v-256 {
  background-color: #edcc61;
  color: #ffffff;
  font-size: clamp(1rem, 5vw, 1.7rem);
}
.g2048-v-512 {
  background-color: #edc850;
  color: #ffffff;
  font-size: clamp(1rem, 5vw, 1.7rem);
}
.g2048-v-1024 {
  background-color: #edc53f;
  color: #ffffff;
  font-size: clamp(0.9rem, 4vw, 1.4rem);
}
.g2048-v-2048 {
  background-color: #edc22e;
  color: #ffffff;
  font-size: clamp(0.9rem, 4vw, 1.4rem);
}
.g2048-v-big {
  background-color: #3c3a32;
  color: #ffffff;
  font-size: clamp(0.8rem, 3.5vw, 1.2rem);
}

.g2048-cell.is-new {
  animation: game-pop 0.18s ease-out;
}

@keyframes game-pop {
  from {
    transform: scale(0.6);
  }
  to {
    transform: scale(1);
  }
}

/* ---------- Word Guess ---------- */

.wg-board {
  display: grid;
  gap: 0.35rem;
  padding: 0.25rem;
}

.wg-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
}

.wg-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(2.6rem, 14vw, 3.6rem);
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1.6rem;
  font-weight: 800;
  text-transform: uppercase;
}

.wg-tile.is-filled {
  border-color: var(--game-cell-strong);
}

.wg-tile.is-correct,
.wg-tile.is-present,
.wg-tile.is-absent {
  color: #ffffff;
  border-color: transparent;
}

.wg-tile.is-correct {
  background-color: var(--game-correct);
}
.wg-tile.is-present {
  background-color: var(--game-present);
}
.wg-tile.is-absent {
  background-color: var(--game-absent);
}

/* Shape cue as well as colour: present letters get a dotted underline. */
.wg-tile.is-present {
  text-decoration: underline dotted 3px;
  text-underline-offset: 4px;
}

.wg-keyboard {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: min(100%, 32rem);
}

.wg-key-row {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
}

.wg-key {
  flex: 1 1 0;
  min-width: 0;
  height: 3.2rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background-color: var(--game-cell-strong);
  color: var(--text);
  font-weight: 700;
}

.wg-key-wide {
  flex: 1.6 1 0;
  font-size: 0.8rem;
}

.wg-key.is-correct,
.wg-key.is-present,
.wg-key.is-absent {
  color: #ffffff;
}

.wg-key.is-correct {
  background-color: var(--game-correct);
}
.wg-key.is-present {
  background-color: var(--game-present);
}
.wg-key.is-absent {
  background-color: var(--game-absent);
}

/* ---------- Number Guessing ---------- */

.ng-form {
  width: min(100%, 22rem);
}

.ng-input-row {
  display: flex;
  gap: var(--spacing-sm);
}

.ng-history {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.ng-history-item {
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  background-color: var(--surface-alt);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.ng-history-item.is-correct {
  background-color: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
  font-weight: 700;
}

/* ---------- Memory Match ---------- */

.mm-board {
  display: grid;
  grid-template-columns: repeat(var(--mm-cols, 4), minmax(0, 1fr));
  gap: 0.5rem;
  width: min(100%, 30rem);
}

.mm-card {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius);
  background: var(--primary-gradient);
  font-size: clamp(1.2rem, 6vw, 2.2rem);
  transition: transform 0.2s ease;
}

.mm-card.is-open {
  background: var(--surface-alt);
  border: 2px solid var(--border);
  transform: rotateY(180deg);
}

.mm-card.is-open .mm-card-face {
  transform: rotateY(180deg);
}

.mm-card.is-matched {
  background: var(--success-soft);
  border-color: var(--success);
}

.mm-card:disabled {
  opacity: 1;
}

.mm-card-face {
  display: inline-block;
}

/* ---------- Rock Paper Scissors ---------- */

.rps-arena {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

.rps-hand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-xs);
}

.rps-hand-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.rps-hand-pick {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 5rem;
  height: 5rem;
  border-radius: var(--radius-full);
  background-color: var(--surface-alt);
  font-size: 2.5rem;
}

.rps-vs {
  font-weight: 800;
  color: var(--text-muted);
}

.rps-choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--spacing-sm);
}

.rps-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 5.5rem;
  padding: 0.6rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface);
  color: var(--text);
  font-size: 1.8rem;
}

.rps-choice span {
  font-size: 0.85rem;
  font-weight: 600;
}

.rps-choice:hover {
  border-color: var(--primary);
}

/* ---------- Reaction Time ---------- */

.rt-pad {
  width: min(100%, 36rem);
  height: 16rem;
  border: 0;
  border-radius: var(--radius-xl);
  color: #ffffff;
  font-size: 1.4rem;
  font-weight: 700;
  user-select: none;
  touch-action: manipulation;
}

.rt-pad.is-idle,
.rt-pad.is-starting,
.rt-pad.is-result,
.rt-pad.is-done {
  background-color: var(--primary);
}
.rt-pad.is-waiting {
  background-color: #b91c1c;
}
.rt-pad.is-go {
  background-color: #15803d;
}
.rt-pad.is-early {
  background-color: #a16207;
}

.rt-times {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.rt-time {
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  background-color: var(--surface-alt);
  font-variant-numeric: tabular-nums;
}

/* ---------- Target Challenge ---------- */

.tc-arena {
  position: relative;
  width: min(100%, 40rem);
  aspect-ratio: 4 / 3;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface-alt);
  overflow: hidden;
  touch-action: manipulation;
}

/* --tc-x/--tc-y/--tc-size are percentages of the arena set from target-challenge.js (the size
   is a share of the width; the arena is 4:3, so the script keeps --tc-y within 100 - size * 4/3). */
.tc-target {
  position: absolute;
  left: calc(var(--tc-x, 40) * 1%);
  top: calc(var(--tc-y, 40) * 1%);
  width: calc(var(--tc-size, 14) * 1%);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0 18%, #dc2626 19% 40%, #ffffff 41% 60%, #dc2626 61%);
}

.tc-target:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Tic-Tac-Toe ---------- */

.ttt-board {
  display: grid;
  gap: 0.4rem;
  width: min(100%, 20rem);
}

.ttt-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.ttt-cell {
  aspect-ratio: 1;
  border: 0;
  border-radius: var(--radius);
  background-color: var(--game-cell);
  font-size: clamp(2rem, 12vw, 3.5rem);
  font-weight: 800;
  line-height: 1;
}

.ttt-cell:disabled {
  opacity: 1;
  color: var(--text);
}

.ttt-cell.is-x {
  color: var(--primary);
}
.ttt-cell.is-o {
  color: var(--accent);
}

.ttt-cell.is-win {
  background-color: var(--success-soft);
  outline: 2px solid var(--success);
}

/* ---------- Connect Four ---------- */

.c4-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.3rem;
  width: min(100%, 30rem);
  padding: 0.5rem;
  border-radius: var(--radius-lg);
  background-color: var(--game-blue);
}

.c4-col {
  display: grid;
  grid-template-rows: repeat(6, minmax(0, 1fr));
  gap: 0.3rem;
  padding: 0.15rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
}

.c4-col:hover:not(:disabled),
.c4-col.is-cursor {
  background-color: rgba(255, 255, 255, 0.18);
}

.c4-col:disabled {
  opacity: 1;
}

.c4-cell {
  display: block;
  aspect-ratio: 1;
  border-radius: 50%;
  background-color: var(--surface);
}

.c4-cell.is-p1 {
  background-color: var(--game-red);
}
.c4-cell.is-p2 {
  background-color: var(--game-yellow);
}

.c4-cell.is-win {
  box-shadow: 0 0 0 3px #ffffff inset;
}

.c4-cell.is-dropping {
  animation: c4-drop calc(0.06s * var(--c4-fall, 1) + 0.1s) ease-in;
}

@keyframes c4-drop {
  from {
    transform: translateY(calc(var(--c4-fall, 1) * -110%));
  }
  to {
    transform: translateY(0);
  }
}

/* ---------- Mini Sudoku ---------- */

.sd-board {
  display: grid;
  width: min(100%, 24rem);
  border: 2px solid var(--text);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.sd-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.sd-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background-color: var(--surface);
  font-size: clamp(1.2rem, 6vw, 1.8rem);
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

.sd-cell.is-box-right {
  border-right: 2px solid var(--text);
}
.sd-cell.is-box-bottom {
  border-bottom: 2px solid var(--text);
}
.sd-cell.is-given {
  color: var(--text);
  font-weight: 800;
}
.sd-cell.is-related {
  background-color: var(--surface-alt);
}
.sd-cell.is-same {
  background-color: var(--primary-soft);
}
.sd-cell.is-selected {
  background-color: var(--primary-soft);
  box-shadow: inset 0 0 0 2px var(--primary);
}
.sd-cell.is-conflict {
  color: var(--danger);
  background-color: var(--danger-soft);
}

.sd-notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  height: 100%;
  padding: 2px;
}

.sd-note {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-muted);
}

.sd-pad {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}

.sd-pad-btn {
  min-width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
}

.sd-pad-erase {
  padding: 0 0.8rem;
  font-size: 0.9rem;
}

/* ---------- Minesweeper ---------- */

.ms-scroll {
  max-width: 100%;
  overflow-x: auto;
  padding: 4px;
}

.ms-board {
  display: grid;
  gap: 2px;
  padding: 4px;
  background-color: var(--game-cell-strong);
  border-radius: var(--radius);
  user-select: none;
  -webkit-touch-callout: none;
}

.ms-row {
  display: grid;
  grid-template-columns: repeat(var(--ms-cols, 9), 1.9rem);
  gap: 2px;
}

.ms-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 1.9rem;
  border-radius: 3px;
  background-color: var(--surface-alt);
  box-shadow: inset 0 -2px 0 rgba(15, 23, 42, 0.15);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
}

.ms-cell.is-revealed {
  background-color: var(--surface);
  box-shadow: none;
  cursor: default;
}

.ms-cell.is-cursor {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.ms-cell.is-exploded {
  background-color: var(--danger);
}
.ms-cell.is-wrong-flag {
  background-color: var(--danger-soft);
}
.ms-n1 {
  color: #2563eb;
}
.ms-n2 {
  color: #16a34a;
}
.ms-n3 {
  color: #dc2626;
}
.ms-n4 {
  color: #7c3aed;
}
.ms-n5 {
  color: #b45309;
}
.ms-n6 {
  color: #0891b2;
}
.ms-n7 {
  color: #be185d;
}
.ms-n8 {
  color: #475569;
}

[data-bs-theme='dark'] .ms-n1 {
  color: #60a5fa;
}
[data-bs-theme='dark'] .ms-n2 {
  color: #4ade80;
}
[data-bs-theme='dark'] .ms-n3 {
  color: #f87171;
}
[data-bs-theme='dark'] .ms-n4 {
  color: #c084fc;
}

/* ---------- Snake ---------- */

.sn-canvas {
  width: min(100%, 26rem);
  height: auto;
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  image-rendering: pixelated;
}

/* ---------- Ludo ---------- */

.ludo-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  width: 100%;
}

.ludo-seats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--spacing-sm);
  margin: 0;
  padding: 0;
  border: 0;
}

.ludo-seats legend {
  width: 100%;
  text-align: center;
  font-size: 0.9rem;
  float: none;
}

.ludo-seat {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* flex: none — inside a flex row the dot would otherwise be squeezed into an oval whenever the
   turn text next to it wraps onto a second line. */
.ludo-seat-swatch,
.ludo-turn-swatch {
  display: inline-block;
  flex: none;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background-color: var(--border);
}

.ludo-seat-red .ludo-seat-swatch {
  background-color: var(--game-red);
}
.ludo-seat-green .ludo-seat-swatch {
  background-color: var(--game-green);
}
.ludo-seat-yellow .ludo-seat-swatch {
  background-color: var(--game-yellow);
}
.ludo-seat-blue .ludo-seat-swatch {
  background-color: var(--game-blue);
}

.ludo-seat-name {
  font-weight: 600;
  min-width: 3.5rem;
}

/* Board left, die + move log in a fixed column on the right; stacks only on narrow screens. */
.ludo-layout {
  display: grid;
  grid-template-columns: minmax(0, 36rem) 16rem;
  justify-content: center;
  align-items: start;
  gap: var(--spacing-lg);
  width: 100%;
}

@media (max-width: 767.98px) {
  .ludo-layout {
    grid-template-columns: minmax(0, 36rem);
  }
}

/* minmax(0, 1fr) on both axes: every square stays the same size whatever tokens sit on it
   (a plain 1fr track would grow to fit its content). */
.ludo-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  grid-template-rows: repeat(15, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface);
  box-shadow: var(--shadow-card);
}

.ludo-cell {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  align-content: center;
  min-width: 0;
  min-height: 0;
}

.ludo-track,
.ludo-homecol {
  border: 1px solid var(--game-cell-strong);
}

.ludo-c-red {
  --ludo-color: var(--game-red);
}
.ludo-c-green {
  --ludo-color: var(--game-green);
}
.ludo-c-yellow {
  --ludo-color: var(--game-yellow);
}
.ludo-c-blue {
  --ludo-color: var(--game-blue);
}

.ludo-homecol,
.ludo-start,
.ludo-base {
  background-color: var(--ludo-color);
}

.ludo-base-inner {
  background-color: var(--surface);
}

/* Centre cells are transparent so the .ludo-home triangles below show through; they still hold
   finished tokens (each colour's finish cell sits on its own triangle). */
.ludo-center {
  background-color: transparent;
}

/* Home: the 3x3 centre square (rows/columns 7-9 of 15, i.e. 40%-60% of the board), split into
   four triangles that point in from each colour's home column — green top, yellow right, blue
   bottom, red left — with a star emblem in the middle. Absolutely positioned rather than a grid
   item so it doesn't disturb the auto-placed cells. */
.ludo-home {
  position: absolute;
  top: 40%;
  left: 40%;
  width: 20%;
  height: 20%;
  background: conic-gradient(
    from -45deg,
    var(--game-green) 0 25%,
    var(--game-yellow) 0 50%,
    var(--game-blue) 0 75%,
    var(--game-red) 0
  );
  box-shadow:
    inset 0 0 0 1px rgba(15, 23, 42, 0.12),
    inset 0 0 18px rgba(15, 23, 42, 0.18);
}

/* Thin white seams along the diagonals between the triangles. */
.ludo-home::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      45deg,
      transparent calc(50% - 1px),
      rgba(255, 255, 255, 0.75) 50%,
      transparent calc(50% + 1px)
    ),
    linear-gradient(
      -45deg,
      transparent calc(50% - 1px),
      rgba(255, 255, 255, 0.75) 50%,
      transparent calc(50% + 1px)
    );
}

.ludo-home::after {
  content: '★';
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  background-color: var(--surface);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.35);
  color: var(--accent);
  font-size: clamp(0.7rem, 2.6vw, 1.35rem);
  line-height: 1;
  transform: translate(-50%, -50%);
}

.ludo-safe::after,
.ludo-start::after {
  content: '★';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.5rem, 2.4vw, 1rem);
  color: var(--text-muted);
  pointer-events: none;
}

.ludo-start::after {
  color: rgba(255, 255, 255, 0.85);
}

.ludo-token {
  position: relative;
  z-index: 1;
  width: 78%;
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.45);
  color: #ffffff;
  font-size: clamp(0.45rem, 1.8vw, 0.75rem);
  font-weight: 800;
  line-height: 1;
}

.ludo-token:disabled {
  opacity: 1;
}

.ludo-token-red {
  background-color: var(--game-red);
}
.ludo-token-green {
  background-color: var(--game-green);
}
.ludo-token-yellow {
  background-color: var(--game-yellow);
  color: #1f2937;
}
.ludo-token-blue {
  background-color: var(--game-blue);
}

.has-stack .ludo-token {
  width: 48%;
  border-width: 1px;
}

.ludo-token.is-movable {
  cursor: pointer;
  outline: 3px solid var(--text);
  outline-offset: 1px;
  animation: ludo-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes ludo-pulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.15);
  }
}

.ludo-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  width: min(100%, 16rem);
}

.ludo-turn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin: 0;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.ludo-turn-swatch.ludo-c-red,
.ludo-turn-swatch.ludo-c-green,
.ludo-turn-swatch.ludo-c-yellow,
.ludo-turn-swatch.ludo-c-blue {
  background-color: var(--ludo-color);
}

.ludo-die {
  width: 5rem;
  height: 5rem;
  padding: 0.6rem;
  border: 3px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface);
}

.ludo-die-red {
  border-color: var(--game-red);
}
.ludo-die-green {
  border-color: var(--game-green);
}
.ludo-die-yellow {
  border-color: var(--game-yellow);
}
.ludo-die-blue {
  border-color: var(--game-blue);
}

.ludo-die:disabled {
  opacity: 0.75;
}

.ludo-die:not(:disabled) {
  box-shadow: var(--primary-glow);
}

/* Nine pip slots in a 3x3 grid; each face class shows the right ones. */
.ludo-die-face {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  width: 100%;
  height: 100%;
}

.ludo-die-face span {
  width: 70%;
  aspect-ratio: 1;
  margin: auto;
  border-radius: 50%;
  background-color: var(--text);
  visibility: hidden;
}

.ludo-face-1 span:nth-child(5),
.ludo-face-2 span:nth-child(1),
.ludo-face-2 span:nth-child(9),
.ludo-face-3 span:nth-child(1),
.ludo-face-3 span:nth-child(5),
.ludo-face-3 span:nth-child(9),
.ludo-face-4 span:nth-child(1),
.ludo-face-4 span:nth-child(3),
.ludo-face-4 span:nth-child(7),
.ludo-face-4 span:nth-child(9),
.ludo-face-5 span:nth-child(1),
.ludo-face-5 span:nth-child(3),
.ludo-face-5 span:nth-child(5),
.ludo-face-5 span:nth-child(7),
.ludo-face-5 span:nth-child(9),
.ludo-face-6 span:nth-child(1),
.ludo-face-6 span:nth-child(3),
.ludo-face-6 span:nth-child(4),
.ludo-face-6 span:nth-child(6),
.ludo-face-6 span:nth-child(7),
.ludo-face-6 span:nth-child(9) {
  visibility: visible;
}

.ludo-action {
  min-height: 1.5em;
  margin: 0;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.ludo-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.ludo-log {
  width: 100%;
  max-height: 14rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  font-size: 0.85rem;
}

.ludo-log-item {
  padding: 0.25rem 0.5rem;
  border-left: 3px solid var(--border);
}

.ludo-log-red {
  border-left-color: var(--game-red);
}
.ludo-log-green {
  border-left-color: var(--game-green);
}
.ludo-log-yellow {
  border-left-color: var(--game-yellow);
}
.ludo-log-blue {
  border-left-color: var(--game-blue);
}

/* ---------- Tycoon ---------- */

:root {
  --ty-g0: #0d9488;
  --ty-g1: #65a30d;
  --ty-g2: #7c3aed;
  --ty-g3: #0284c7;
  --ty-g4: #db2777;
  --ty-g5: #ea580c;
  --ty-g6: #ca8a04;
  --ty-g7: #b91c1c;
  --ty-p0: #ef4444;
  --ty-p1: #3b82f6;
  --ty-p2: #10b981;
  --ty-p3: #f59e0b;
  --ty-p4: #8b5cf6;
  --ty-p5: #64748b;
  --ty-board-bg: #f8fafc;
  --ty-center-bg: rgba(255, 255, 255, 0.92);
}

[data-bs-theme='dark'] {
  --ty-g0: #14b8a6;
  --ty-g1: #84cc16;
  --ty-g2: #8b5cf6;
  --ty-g3: #0ea5e9;
  --ty-g4: #ec4899;
  --ty-g5: #f97316;
  --ty-g6: #eab308;
  --ty-g7: #ef4444;
  --ty-p0: #f87171;
  --ty-p1: #60a5fa;
  --ty-p2: #34d399;
  --ty-p3: #fbbf24;
  --ty-p4: #a78bfa;
  --ty-p5: #94a3b8;
  --ty-board-bg: #0f172a;
  --ty-center-bg: rgba(30, 41, 59, 0.92);
}

.ty-shell {
  position: relative;
  width: 100%;
}

/* ---------- Setup Screen ---------- */
.ty-setup {
  display: flex;
  flex-direction: column;
  gap: var(--spacing);
  max-width: 48rem;
  margin: 0 auto;
  padding: var(--spacing-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.ty-setup-header {
  text-align: center;
}

.ty-setup-title {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.ty-setup-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.ty-presets-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.ty-presets-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
}

.ty-preset-btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

.ty-seats {
  margin: 0;
  padding: 0;
  border: 0;
}

.ty-seats legend {
  margin-bottom: 0.75rem;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
}

.ty-seats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.75rem;
}

.ty-seat-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.ty-seat-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ty-seat-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.ty-seat-select {
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
}

.ty-setup-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--spacing);
}

.ty-option {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
}

.ty-option-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.ty-setup-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--spacing-sm);
  margin-top: 0.5rem;
}

.ty-btn-play {
  padding: 0.6rem 1.8rem;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: var(--radius);
}

/* ---------- Game Toolbar & Sub-nav ---------- */
.ty-game-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing);
  width: 100%;
}

.ty-game-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.ty-toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ty-toolbar-btn {
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.ty-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.ty-round-badge {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.ty-badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--ty-p0);
  border-color: var(--ty-p0);
}

.ty-badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--ty-p3);
  border-color: var(--ty-p3);
}

.ty-badge-info {
  background: rgba(59, 130, 246, 0.15);
  color: var(--ty-p1);
  border-color: var(--ty-p1);
}

/* Mobile Segmented Tabs */
.ty-mobile-tabs {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.ty-tab-btn {
  padding: 0.4rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.ty-tab-btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---------- Layout: Board & Side Panel ---------- */
.ty-layout {
  display: grid;
  grid-template-columns: minmax(0, 52rem) 21rem;
  justify-content: center;
  align-items: start;
  gap: var(--spacing-lg);
  width: 100%;
}

@media (max-width: 991.98px) {
  .ty-layout {
    grid-template-columns: minmax(0, 52rem);
  }
  .ty-mobile-tabs {
    display: grid;
  }
}

/* ---------- The 11x11 Board ---------- */
.ty-board {
  --ty-tracks: minmax(0, 1.6fr) repeat(9, minmax(0, 1fr)) minmax(0, 1.6fr);
  display: grid;
  grid-template-columns: var(--ty-tracks);
  grid-template-rows: var(--ty-tracks);
  justify-self: center;
  width: min(100%, calc(100vh - 8rem));
  min-width: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--ty-board-bg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  position: relative;
}

/* Square Cells */
.ty-sq {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  grid-row: var(--ty-r);
  grid-column: var(--ty-c);
  padding: 2px;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  font-size: 0.65rem;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition:
    background-color 0.15s ease,
    box-shadow 0.15s ease;
}

.ty-sq:hover {
  background-color: var(--surface-alt);
  z-index: 2;
}

.ty-sq:focus-visible {
  z-index: 3;
  outline: 3px solid var(--primary);
  outline-offset: -3px;
}

.ty-sq.is-selected {
  box-shadow:
    inset 0 0 0 2px var(--primary),
    0 0 8px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.ty-sq.is-highlighted-owner {
  box-shadow: inset 0 0 0 3px var(--ty-owner, var(--primary));
  animation: ty-pulse-glow 1.5s infinite alternate ease-in-out;
}

@keyframes ty-pulse-glow {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.15);
  }
}

.ty-corner {
  background-color: var(--surface-alt);
  font-weight: 700;
}

/* Complete Group border */
.ty-sq.is-fullgroup {
  border-color: var(--ty-band, var(--primary));
}

/* Mortgaged property styling */
.ty-sq.is-mort {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(239, 68, 68, 0.08) 0 4px,
    var(--surface) 4px 8px
  );
  opacity: 0.75;
}

.ty-sq.is-mort::before {
  content: 'MORTGAGED';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 0.45rem;
  font-weight: 800;
  color: var(--ty-p0);
  background: rgba(0, 0, 0, 0.6);
  padding: 1px 3px;
  border-radius: 2px;
  z-index: 4;
  pointer-events: none;
}

/* Group Color variables */
.ty-g0 {
  --ty-band: var(--ty-g0);
}
.ty-g1 {
  --ty-band: var(--ty-g1);
}
.ty-g2 {
  --ty-band: var(--ty-g2);
}
.ty-g3 {
  --ty-band: var(--ty-g3);
}
.ty-g4 {
  --ty-band: var(--ty-g4);
}
.ty-g5 {
  --ty-band: var(--ty-g5);
}
.ty-g6 {
  --ty-band: var(--ty-g6);
}
.ty-g7 {
  --ty-band: var(--ty-g7);
}

/* Property color band */
.ty-band {
  position: absolute;
  background-color: var(--ty-band);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.ty-side-b .ty-band,
.ty-side-t .ty-band {
  left: 0;
  right: 0;
  height: 22%;
}

.ty-side-b .ty-band {
  top: 0;
}
.ty-side-t .ty-band {
  bottom: 0;
}

.ty-side-l .ty-band,
.ty-side-r .ty-band {
  top: 0;
  bottom: 0;
  width: 22%;
}

.ty-side-l .ty-band {
  right: 0;
}
.ty-side-r .ty-band {
  left: 0;
}

.ty-side-b:has(.ty-band) {
  padding-top: 24%;
}
.ty-side-t:has(.ty-band) {
  padding-bottom: 24%;
}
.ty-side-l:has(.ty-band) {
  padding-right: 24%;
}
.ty-side-r:has(.ty-band) {
  padding-left: 24%;
}

/* Cell Content */
.ty-name {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: anywhere;
  font-weight: 700;
  font-size: 0.65rem;
}

.ty-price {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.6rem;
}

.ty-sq-icon {
  font-size: 0.9rem;
  line-height: 1;
  margin-bottom: 1px;
}

.ty-marks,
.ty-toks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  z-index: 2;
}

/* Owner Edge Strip */
.ty-sq[data-owner]::after {
  content: '';
  position: absolute;
  background-color: var(--ty-owner);
  box-shadow: 0 0 4px var(--ty-owner);
}

.ty-side-b[data-owner]::after,
.ty-side-t[data-owner]::after {
  left: 0;
  right: 0;
  height: 4px;
}

.ty-side-b[data-owner]::after {
  bottom: 0;
}
.ty-side-t[data-owner]::after {
  top: 0;
}

.ty-side-l[data-owner]::after,
.ty-side-r[data-owner]::after {
  top: 0;
  bottom: 0;
  width: 4px;
}

.ty-side-l[data-owner]::after {
  left: 0;
}
.ty-side-r[data-owner]::after {
  right: 0;
}

.ty-sq[data-owner='0'] {
  --ty-owner: var(--ty-p0);
}
.ty-sq[data-owner='1'] {
  --ty-owner: var(--ty-p1);
}
.ty-sq[data-owner='2'] {
  --ty-owner: var(--ty-p2);
}
.ty-sq[data-owner='3'] {
  --ty-owner: var(--ty-p3);
}
.ty-sq[data-owner='4'] {
  --ty-owner: var(--ty-p4);
}
.ty-sq[data-owner='5'] {
  --ty-owner: var(--ty-p5);
}

.ty-sq .ty-token.ty-own {
  width: 0.55rem;
  height: 0.55rem;
}

/* Buildings */
.ty-house,
.ty-tower {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.ty-house {
  font-size: 0.65rem;
}

.ty-tower {
  font-size: 0.8rem;
}

/* Player Tokens */
.ty-p0 {
  --ty-pc: var(--ty-p0);
}
.ty-p1 {
  --ty-pc: var(--ty-p1);
}
.ty-p2 {
  --ty-pc: var(--ty-p2);
}
.ty-p3 {
  --ty-pc: var(--ty-p3);
}
.ty-p4 {
  --ty-pc: var(--ty-p4);
}
.ty-p5 {
  --ty-pc: var(--ty-p5);
}

.ty-token {
  display: inline-block;
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  background-color: var(--ty-pc, var(--border));
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.4);
  transition: transform 0.2s ease;
}

.ty-sq .ty-token {
  width: 0.85rem;
  height: 0.85rem;
}

.ty-sq .ty-token.is-turn {
  transform: scale(1.4);
  box-shadow: 0 0 8px var(--ty-pc);
  z-index: 3;
}

.ty-token.ty-p0 {
  border-radius: 50%;
}
.ty-token.ty-p1 {
  border-radius: 3px;
}
.ty-token.ty-p2 {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.ty-token.ty-p3 {
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}
.ty-token.ty-p4 {
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}
.ty-token.ty-p5 {
  clip-path: polygon(
    50% 0,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 91%,
    50% 70%,
    21% 91%,
    32% 57%,
    2% 35%,
    39% 35%
  );
}

/* Special Corner Styling */
.ty-kind-start {
  background: linear-gradient(135deg, var(--surface), rgba(16, 185, 129, 0.12));
}

.ty-kind-jail {
  background: linear-gradient(135deg, var(--surface), rgba(100, 116, 139, 0.15));
}

.ty-kind-rest {
  background: linear-gradient(135deg, var(--surface), rgba(14, 165, 233, 0.12));
}

.ty-kind-gotojail {
  background: linear-gradient(135deg, var(--surface), rgba(239, 68, 68, 0.15));
}

/* ---------- Board Centre Hub ---------- */
.ty-centre {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  grid-row: 2 / 11;
  grid-column: 2 / 11;
  padding: var(--spacing);
  text-align: center;
  overflow: hidden;
}

.ty-centre-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 24rem;
  padding: var(--spacing);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--ty-center-bg);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-card);
}

.ty-centre-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.ty-edition-badge {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.ty-edition {
  margin: 0;
  color: var(--primary);
  font-size: clamp(1.1rem, 3.5vw, 1.6rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ty-turn-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.875rem;
}

/* 3D Dice Display */
.ty-dice-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.ty-dice {
  display: flex;
  gap: 0.6rem;
  margin: 0.25rem 0;
}

.ty-die {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  width: 2.6rem;
  height: 2.6rem;
  padding: 4px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  background: #ffffff;
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.15),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s ease;
}

[data-bs-theme='dark'] .ty-die {
  background: #f1f5f9;
}

.ty-die.is-rolling {
  animation: ty-die-roll 0.25s infinite ease-in-out;
}

@keyframes ty-die-roll {
  0% {
    transform: rotate(0deg) scale(0.9);
  }
  25% {
    transform: rotate(-15deg) scale(1.1);
  }
  50% {
    transform: rotate(12deg) scale(0.95);
  }
  75% {
    transform: rotate(-8deg) scale(1.05);
  }
  100% {
    transform: rotate(0deg) scale(1);
  }
}

.ty-pip {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1e293b;
}

/* Pip placements on 3x3 grid */
.ty-die-1 .ty-pip:nth-child(1) {
  grid-column: 2;
  grid-row: 2;
}

.ty-die-2 .ty-pip:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}
.ty-die-2 .ty-pip:nth-child(2) {
  grid-column: 3;
  grid-row: 3;
}

.ty-die-3 .ty-pip:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}
.ty-die-3 .ty-pip:nth-child(2) {
  grid-column: 2;
  grid-row: 2;
}
.ty-die-3 .ty-pip:nth-child(3) {
  grid-column: 3;
  grid-row: 3;
}

.ty-die-4 .ty-pip:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}
.ty-die-4 .ty-pip:nth-child(2) {
  grid-column: 3;
  grid-row: 1;
}
.ty-die-4 .ty-pip:nth-child(3) {
  grid-column: 1;
  grid-row: 3;
}
.ty-die-4 .ty-pip:nth-child(4) {
  grid-column: 3;
  grid-row: 3;
}

.ty-die-5 .ty-pip:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}
.ty-die-5 .ty-pip:nth-child(2) {
  grid-column: 3;
  grid-row: 1;
}
.ty-die-5 .ty-pip:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}
.ty-die-5 .ty-pip:nth-child(4) {
  grid-column: 1;
  grid-row: 3;
}
.ty-die-5 .ty-pip:nth-child(5) {
  grid-column: 3;
  grid-row: 3;
}

.ty-die-6 .ty-pip:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}
.ty-die-6 .ty-pip:nth-child(2) {
  grid-column: 3;
  grid-row: 1;
}
.ty-die-6 .ty-pip:nth-child(3) {
  grid-column: 1;
  grid-row: 2;
}
.ty-die-6 .ty-pip:nth-child(4) {
  grid-column: 3;
  grid-row: 2;
}
.ty-die-6 .ty-pip:nth-child(5) {
  grid-column: 1;
  grid-row: 3;
}
.ty-die-6 .ty-pip:nth-child(6) {
  grid-column: 3;
  grid-row: 3;
}

.ty-double-badge {
  position: absolute;
  top: -8px;
  right: -24px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: #f59e0b;
  color: #000000;
  font-weight: 800;
  font-size: 0.7rem;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.4);
  animation: ty-bounce 0.8s infinite alternate ease-in-out;
}

@keyframes ty-bounce {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-4px);
  }
}

.ty-action {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  min-height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ty-centre-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}

.ty-centre-actions button {
  padding: 0.4rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
}

.ty-btn-roll {
  padding: 0.5rem 1.25rem !important;
  font-size: 0.95rem !important;
  box-shadow: 0 4px 12px rgba(var(--primary-rgb, 13, 148, 136), 0.35);
}

.ty-btn-danger {
  border-color: var(--ty-p0);
  color: var(--ty-p0);
}

.ty-btn-danger:hover {
  background: var(--ty-p0);
  color: #ffffff;
}

/* Card Drawer */
.ty-card-wrap {
  width: 100%;
}

.ty-card {
  margin: 0;
  padding: 0.6rem 0.85rem;
  border: 1px dashed var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  animation: ty-card-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ty-card-in {
  from {
    transform: translateY(10px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Floating Money Popups */
.ty-cash-popup {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 800;
  z-index: 10;
  pointer-events: none;
  animation: ty-float-up 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ty-cash-popup.is-gain {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4);
}

.ty-cash-popup.is-loss {
  background: #ef4444;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

@keyframes ty-float-up {
  0% {
    transform: translate(-50%, 0) scale(0.8);
    opacity: 0;
  }
  20% {
    transform: translate(-50%, -8px) scale(1.1);
    opacity: 1;
  }
  80% {
    transform: translate(-50%, -20px) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -30px) scale(0.9);
    opacity: 0;
  }
}

/* ---------- Side Panel / HUD ---------- */
.ty-panel {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  min-width: 0;
}

.ty-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: var(--spacing-sm) var(--spacing);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
}

.ty-box-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}

.ty-box-icon {
  font-size: 1rem;
}

.ty-box-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
}

/* Title Deed Card */
.ty-deed-card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.ty-deed-band {
  width: 100%;
  height: 1.25rem;
  background-color: var(--primary);
}

.ty-deed-title {
  margin: 0.35rem 0 0;
  font-size: 1rem;
  font-weight: 800;
  text-align: center;
}

.ty-deed-type {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.ty-detail-list {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.2rem 0.75rem;
  margin: 0;
  font-size: 0.825rem;
}

.ty-detail-list dt {
  color: var(--text-muted);
  font-weight: 600;
}

.ty-detail-list dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.ty-manage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.ty-manage-actions button {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Player Standings */
.ty-players {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ty-player {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.ty-player:hover {
  border-color: var(--ty-pc, var(--primary));
}

.ty-player.is-turn {
  border-left: 4px solid var(--ty-pc, var(--primary));
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.ty-player.is-inspecting {
  box-shadow: inset 0 0 0 2px var(--ty-pc, var(--primary));
}

.ty-player.is-out {
  opacity: 0.5;
  text-decoration: line-through;
}

.ty-player-row-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ty-player-name {
  font-weight: 700;
  font-size: 0.85rem;
}

.ty-player-row-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
}

.ty-player-cash {
  font-weight: 700;
  color: #10b981;
  font-variant-numeric: tabular-nums;
}

.ty-player-net {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.ty-player-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

/* Activity Feed */
.ty-log {
  max-height: 13rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ty-log-item {
  padding: 0.3rem 0.5rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-alt);
  border-left: 3px solid var(--ty-pc, var(--border));
  line-height: 1.3;
}

/* Live Auction */
.ty-auction-desc {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.ty-auction-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ty-bid-btn {
  font-weight: 700;
}

/* Trade Room */
.ty-trade-partner-label {
  font-weight: 600;
  font-size: 0.85rem;
}

.ty-trade-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.ty-trade-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}

.ty-trade-col legend {
  float: none;
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
}

.ty-trade-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-height: 8rem;
  overflow-y: auto;
  font-size: 0.75rem;
}

.ty-trade-msg {
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0;
}

/* Game Over Modal */
.ty-game-over-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--spacing);
}

.ty-game-over-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  max-width: 26rem;
  width: 100%;
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 2px solid var(--primary);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  text-align: center;
  animation: ty-modal-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ty-modal-in {
  from {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.ty-trophy-icon {
  font-size: 3rem;
  line-height: 1;
}

.ty-game-over-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
}

.ty-winner-text {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.ty-final-standings {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  margin: 0.5rem 0;
}

.ty-final-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-size: 0.85rem;
  font-weight: 600;
}

.ty-final-rank {
  font-weight: 800;
  min-width: 1.5rem;
}

.ty-final-cash {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: #10b981;
}

/* ---------- Responsive Adjustments ---------- */
@media (max-width: 575.98px) {
  .ty-board {
    width: 100%;
  }

  .ty-sq {
    font-size: 0.5rem;
  }

  .ty-name {
    font-size: 0.55rem;
  }

  .ty-price {
    font-size: 0.5rem;
  }

  .ty-sq-icon {
    font-size: 0.75rem;
  }

  .ty-sq .ty-token {
    width: 0.55rem;
    height: 0.55rem;
  }

  .ty-house {
    font-size: 0.5rem;
  }

  .ty-tower {
    font-size: 0.65rem;
  }

  .ty-centre {
    padding: 2px;
  }

  .ty-centre-card {
    padding: 0.4rem;
    gap: 0.3rem;
  }

  .ty-edition {
    font-size: 0.9rem;
  }

  .ty-edition-badge {
    display: none;
  }

  .ty-die {
    width: 1.9rem;
    height: 1.9rem;
    padding: 2px;
  }

  .ty-pip {
    width: 4px;
    height: 4px;
  }

  .ty-centre-actions button {
    padding: 0.3rem 0.55rem;
    font-size: 0.75rem;
  }
}

/* Full screen */
.game-widget:fullscreen .ty-layout,
.game-widget.is-focus .ty-layout {
  grid-template-columns: minmax(0, calc(100vh - 6rem)) 21rem;
}

.game-widget:fullscreen .ty-board,
.game-widget.is-focus .ty-board {
  width: 100%;
}

@media (max-width: 991.98px) {
  .game-widget:fullscreen .ty-layout,
  .game-widget.is-focus .ty-layout {
    grid-template-columns: minmax(0, 52rem);
  }
}

/* ---------- Word Connections ---------- */

.wc-board {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(100%, 36rem);
}

.wc-solved {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wc-solved:empty {
  display: none;
}

.wc-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.wc-tile {
  min-height: 4rem;
  padding: 0.25rem;
  border: 2px solid transparent;
  border-radius: var(--radius);
  background-color: var(--game-cell);
  color: var(--text);
  font-size: clamp(0.7rem, 2.8vw, 0.95rem);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.wc-tile.is-long {
  font-size: clamp(0.6rem, 2.2vw, 0.8rem);
}

.wc-tile:hover:not(:disabled) {
  background-color: var(--game-cell-strong);
}

/* Selected tiles invert and gain a corner tick, so selection never relies on colour alone. */
.wc-tile.is-selected {
  position: relative;
  background-color: var(--text);
  color: var(--surface);
}

.wc-tile.is-selected::after {
  content: '✓';
  position: absolute;
  top: 0.15rem;
  right: 0.35rem;
  font-size: 0.7rem;
}

.wc-tile:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.wc-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 4rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  color: #111827;
  text-align: center;
}

.wc-group-title {
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.wc-group-words {
  font-size: 0.9rem;
}

.wc-tier-0 {
  background-color: #fde68a;
}
.wc-tier-1 {
  background-color: #a7f3d0;
}
.wc-tier-2 {
  background-color: #bfdbfe;
}
.wc-tier-3 {
  background-color: #ddd6fe;
}

.wc-mistakes {
  letter-spacing: 0.15em;
}

/* ---------- Mini Crossword ---------- */

.mc-clue-bar {
  width: min(100%, 26rem);
  min-height: 2.75rem;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  background-color: var(--primary-soft);
  color: var(--text);
  font-weight: 600;
}

.mc-board {
  display: grid;
  grid-template-columns: repeat(var(--mc-size, 5), minmax(0, 1fr));
  grid-template-rows: repeat(var(--mc-size, 5), minmax(0, 1fr));
  width: min(100%, 26rem);
  aspect-ratio: 1;
  border: 2px solid var(--text);
  background-color: var(--text);
  gap: 1px;
}

.mc-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface);
  cursor: pointer;
  user-select: none;
}

.mc-cell.is-block {
  background-color: var(--text);
  cursor: default;
}

.mc-cell.is-word {
  background-color: var(--primary-soft);
}

.mc-cell.is-cursor {
  background-color: var(--game-yellow);
  color: #111827;
}

/* Wrong letters get a diagonal slash as well as the colour. */
.mc-cell.is-wrong .mc-letter {
  color: var(--game-red);
  text-decoration: line-through;
}

.mc-board.is-solved .mc-cell:not(.is-block) {
  background-color: var(--game-correct);
  color: #ffffff;
}

.mc-num {
  position: absolute;
  top: 0.1rem;
  left: 0.2rem;
  font-size: clamp(0.5rem, 1.8vw, 0.7rem);
  font-weight: 600;
  line-height: 1;
}

.mc-letter {
  font-size: clamp(1rem, 5vw, 1.75rem);
  font-weight: 700;
}

.mc-clues {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--spacing);
  width: min(100%, 44rem);
}

.mc-clues-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.mc-clue-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mc-clue-btn {
  display: block;
  width: 100%;
  padding: 0.3rem 0.5rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  text-align: left;
}

.mc-clue-btn.is-active {
  background-color: var(--primary-soft);
}

/* ---------- Word Ladder ---------- */

.wl-ladder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.wl-rung {
  display: flex;
  gap: 0.3rem;
}

.wl-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 2px solid var(--game-cell-strong);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  font-size: 1.35rem;
  font-weight: 800;
}

/* The changed letter of each step is underlined as well as tinted. */
.wl-letter.is-changed {
  border-color: var(--primary);
  background-color: var(--primary-soft);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.wl-rung.is-start .wl-letter {
  background-color: var(--game-cell);
}

.wl-rung.is-target .wl-letter {
  border-style: dashed;
  border-color: var(--game-correct);
  color: var(--game-correct);
}

.wl-gap {
  min-height: 1.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.wl-form {
  display: flex;
  gap: var(--spacing-sm);
}

.wl-input {
  width: 9rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 700;
  text-align: center;
}

/* ---------- Cryptogram ---------- */

.cg-board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem 1.1rem;
  width: min(100%, 44rem);
  padding: var(--spacing-sm);
}

.cg-word {
  display: inline-flex;
  gap: 0.15rem;
}

.cg-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: 1.6rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.cg-guess {
  display: block;
  width: 100%;
  min-height: 1.6rem;
  border-bottom: 2px solid var(--text);
  font-size: 1.15rem;
  font-weight: 800;
  text-align: center;
}

.cg-cipher {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.cg-punct {
  align-self: flex-start;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.6rem;
}

.cg-cell.is-active {
  background-color: var(--primary-soft);
}

.cg-cell.is-cursor {
  background-color: var(--game-yellow);
  color: #111827;
}

.cg-cell.is-cursor .cg-cipher {
  color: #111827;
}

/* Two cipher letters given the same guess: red and wavy-underlined. */
.cg-cell.is-conflict .cg-guess {
  color: var(--game-red);
  text-decoration: underline wavy;
}

.cg-cell.is-given .cg-guess {
  color: var(--game-correct);
}

.cg-source {
  margin: 0;
  min-height: 1.5em;
  font-style: italic;
  color: var(--text-muted);
}

/* ---------- Word Hunt ---------- */

.wh-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  width: min(100%, 22rem);
  aspect-ratio: 1;
  padding: 0.5rem;
  border-radius: var(--radius-lg);
  background-color: var(--game-cell-strong);
  touch-action: none;
  user-select: none;
}

.wh-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background-color: var(--surface);
  font-size: clamp(1.4rem, 8vw, 2.2rem);
  font-weight: 800;
  box-shadow: inset 0 -3px 0 var(--game-cell);
}

.wh-tile.is-path {
  background-color: var(--primary-soft);
  outline: 2px solid var(--primary);
}

.wh-tile.is-head {
  background-color: var(--primary);
  color: #ffffff;
}

/* Before Start the letters are hidden so nobody gets a head start on the clock. */
.wh-board.is-hidden .wh-tile {
  color: transparent;
}

.wh-current {
  min-height: 1.75rem;
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.wh-input {
  width: 12rem;
  text-transform: uppercase;
  font-weight: 700;
}

.wh-lists {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--spacing);
  width: min(100%, 44rem);
}

.wh-word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.wh-word {
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  background-color: var(--game-cell);
  font-size: 0.85rem;
  font-weight: 600;
}

.wh-word-list.is-missed .wh-word {
  background-color: transparent;
  border: 1px dashed var(--border);
  color: var(--text-muted);
}

/* ---------- Lights Out ---------- */

.lo-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  width: min(100%, 22rem);
  aspect-ratio: 1;
  padding: 0.5rem;
  border-radius: var(--radius-lg);
  background-color: #0f172a;
}

.lo-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background-color: #1e293b;
  color: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  transition: background-color 120ms ease;
}

/* Lit cells glow and carry a dot, so "on" never depends on colour alone. */
.lo-cell.is-on {
  background-color: #fde047;
  color: #a16207;
  box-shadow: 0 0 18px rgba(253, 224, 71, 0.55);
}

.lo-cell.is-cursor {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

.lo-cell.is-hint {
  outline: 3px dashed #4ade80;
  outline-offset: 2px;
}

/* ---------- Nonograms ---------- */

.ng-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
  overflow-x: auto;
}

.ng-board {
  display: grid;
  grid-template-columns: auto repeat(var(--ng-n, 10), var(--ng-cell, 28px));
  grid-auto-rows: auto;
  user-select: none;
  touch-action: none;
}

.ng-corner {
  border-right: 2px solid var(--text);
  border-bottom: 2px solid var(--text);
}

.ng-clue {
  display: flex;
  gap: 0.2rem;
  color: var(--text);
  font-size: calc(var(--ng-cell, 28px) * 0.45);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ng-col-clue {
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--text);
}

.ng-row-clue {
  justify-content: flex-end;
  align-items: center;
  height: var(--ng-cell, 28px);
  padding-right: 0.35rem;
  border-right: 2px solid var(--text);
}

/* A satisfied clue fades and is struck through. */
.ng-clue.is-done {
  color: var(--text-muted);
  text-decoration: line-through;
  opacity: 0.6;
}

.ng-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--ng-cell, 28px);
  border-right: 1px solid var(--game-cell-strong);
  border-bottom: 1px solid var(--game-cell-strong);
  background-color: var(--surface);
  color: var(--text-muted);
  font-size: calc(var(--ng-cell, 28px) * 0.5);
  cursor: pointer;
}

.ng-cell.is-edge-right {
  border-right: 2px solid var(--text);
}

.ng-cell.is-edge-bottom {
  border-bottom: 2px solid var(--text);
}

.ng-cell.is-filled {
  background-color: var(--text);
}

.ng-cell.is-cursor {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
}

.ng-board.is-solved .ng-cell.is-filled {
  background-color: var(--primary);
}

/* ---------- Kakuro ---------- */

.kk-board {
  display: grid;
  grid-template-columns: repeat(var(--kk-size, 8), minmax(0, 1fr));
  grid-template-rows: repeat(var(--kk-size, 8), minmax(0, 1fr));
  width: min(100%, 30rem);
  aspect-ratio: 1;
  gap: 1px;
  padding: 1px;
  background-color: var(--text);
}

.kk-block {
  position: relative;
  background-color: #334155;
  color: #ffffff;
  font-size: clamp(0.55rem, 2.4vw, 0.85rem);
  font-weight: 700;
}

/* Clue cells: across sum top-right, down sum bottom-left, split by a diagonal. */
.kk-block.has-clue {
  background-image: linear-gradient(
    to top right,
    transparent calc(50% - 1px),
    #94a3b8,
    transparent calc(50% + 1px)
  );
}

.kk-across {
  position: absolute;
  top: 6%;
  right: 10%;
}

.kk-down {
  position: absolute;
  bottom: 6%;
  left: 10%;
}

.kk-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface);
  cursor: pointer;
}

.kk-value {
  font-size: clamp(1rem, 4.5vw, 1.5rem);
  font-weight: 700;
}

.kk-notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  font-size: clamp(0.45rem, 1.6vw, 0.6rem);
  line-height: 1;
  color: var(--text-muted);
  text-align: center;
  align-items: center;
}

.kk-cell.is-run {
  background-color: var(--primary-soft);
}

.kk-cell.is-cursor {
  background-color: var(--game-yellow);
  color: #111827;
}

/* A repeated digit or a wrong total: red text plus an underline. */
.kk-cell.is-bad .kk-value {
  color: var(--game-red);
  text-decoration: underline;
}

.kk-board.is-solved .kk-cell {
  background-color: var(--game-correct);
  color: #ffffff;
}

.kk-helper {
  min-height: 2.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.kk-pad {
  display: grid;
  grid-template-columns: repeat(5, 3rem);
  gap: 0.35rem;
}

.kk-key {
  height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface-alt);
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
}

/* ---------- Color Flow ---------- */

.cf-board {
  display: grid;
  grid-template-columns: repeat(var(--cf-size, 7), minmax(0, 1fr));
  grid-template-rows: repeat(var(--cf-size, 7), minmax(0, 1fr));
  width: min(100%, 28rem);
  aspect-ratio: 1;
  padding: 2px;
  gap: 2px;
  border-radius: var(--radius);
  background-color: #1e293b;
  touch-action: none;
  user-select: none;
}

.cf-cell {
  position: relative;
  background-color: #0f172a;
  cursor: pointer;
}

.cf-cell.is-filled {
  background-color: color-mix(in srgb, var(--cf-color) 22%, #0f172a);
}

.cf-arm,
.cf-joint {
  position: absolute;
  display: none;
  background-color: var(--cf-color);
}

.cf-joint {
  inset: 33%;
  border-radius: 50%;
}

.cf-arm-up,
.cf-arm-down {
  left: 33%;
  right: 33%;
  height: 50%;
}

.cf-arm-left,
.cf-arm-right {
  top: 33%;
  bottom: 33%;
  width: 50%;
}

.cf-arm-up {
  top: 0;
}
.cf-arm-down {
  bottom: 0;
}
.cf-arm-left {
  left: 0;
}
.cf-arm-right {
  right: 0;
}

.cf-cell.link-up .cf-arm-up,
.cf-cell.link-down .cf-arm-down,
.cf-cell.link-left .cf-arm-left,
.cf-cell.link-right .cf-arm-right,
.cf-cell.link-up .cf-joint,
.cf-cell.link-down .cf-joint,
.cf-cell.link-left .cf-joint,
.cf-cell.link-right .cf-joint {
  display: block;
}

/* Dots are labelled with a letter, so pairs never depend on colour alone. */
.cf-cell.is-dot::after {
  content: attr(data-label);
  position: absolute;
  inset: 14%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: var(--cf-color);
  color: #ffffff;
  font-size: clamp(0.7rem, 3.5vw, 1.1rem);
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.cf-cell.is-cursor {
  outline: 3px solid #f8fafc;
  outline-offset: -3px;
}

.cf-cell.is-active {
  box-shadow: inset 0 0 0 2px var(--cf-color);
}

.cf-board.is-solved {
  box-shadow: 0 0 0 4px var(--game-correct);
}

/* ---------- Mancala ---------- */

.mn-board {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: min(100%, 44rem);
  padding: 0.75rem;
  border-radius: 2rem;
  background-color: #92400e;
  box-shadow: inset 0 0 0 4px #78350f;
}

.mn-rows {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.5rem;
}

.mn-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.5rem;
}

.mn-pit {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  padding: 0.2rem;
  border: 0;
  border-radius: 50%;
  background-color: #78350f;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.45);
  color: #fef3c7;
}

.mn-store {
  flex: 0 0 13%;
  aspect-ratio: auto;
  border-radius: 999px;
}

button.mn-pit:not(:disabled) {
  cursor: pointer;
  box-shadow:
    inset 0 3px 6px rgba(0, 0, 0, 0.45),
    0 0 0 3px #fcd34d;
}

button.mn-pit:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
}

.mn-pit.is-last {
  background-color: #a16207;
}

.mn-seeds {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  max-width: 80%;
}

.mn-seed {
  width: clamp(4px, 1.3vw, 8px);
  aspect-ratio: 1;
  border-radius: 50%;
  background-color: #e0f2fe;
}

.mn-count {
  font-size: clamp(0.75rem, 2.8vw, 1rem);
  font-weight: 800;
}

/* ---------- Gomoku ---------- */

.gm-board {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  grid-template-rows: repeat(15, minmax(0, 1fr));
  width: min(100%, 34rem);
  aspect-ratio: 1;
  padding: 0.4rem;
  border-radius: var(--radius);
  background-color: #dcb35c;
  box-shadow: inset 0 0 0 2px #a0782c;
}

/* Each cell draws the two grid lines through its centre; stones sit on the intersection. */
.gm-cell {
  position: relative;
  cursor: pointer;
  background:
    linear-gradient(#7c5a1d, #7c5a1d) center / 1px 100% no-repeat,
    linear-gradient(#7c5a1d, #7c5a1d) center / 100% 1px no-repeat;
}

.gm-cell::after {
  content: '';
  position: absolute;
  inset: 8%;
  border-radius: 50%;
}

.gm-cell.is-black::after {
  background: radial-gradient(circle at 35% 35%, #4b5563, #030712 70%);
}

.gm-cell.is-white::after {
  background: radial-gradient(circle at 35% 35%, #ffffff, #d1d5db 75%);
  box-shadow: inset 0 0 0 1px #9ca3af;
}

/* The last stone gets a red ring, winning stones a green one. */
.gm-cell.is-last::after {
  outline: 2px solid #dc2626;
  outline-offset: 1px;
}

.gm-cell.is-win::after {
  outline: 3px solid #16a34a;
  outline-offset: 1px;
}

.gm-cell.is-cursor {
  box-shadow: inset 0 0 0 2px #1d4ed8;
  border-radius: 3px;
}

/* ---------- Nine Men's Morris ---------- */

.mm9-board {
  position: relative;
  width: min(100%, 26rem);
  aspect-ratio: 1;
  border-radius: var(--radius);
  background-color: #e7c88a;
}

.mm9-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: #5b3d12;
  stroke-width: 0.06;
}

/* Points sit on a 7x7 lattice: --x/--y are set per point (0-6). */
.mm9-point {
  position: absolute;
  left: calc((var(--x) + 0.5) / 7 * 100%);
  top: calc((var(--y) + 0.5) / 7 * 100%);
  width: 11%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, #5b3d12 0 18%, transparent 20%);
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.mm9-point.is-white {
  background: radial-gradient(circle at 35% 35%, #ffffff, #d1d5db 75%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
}

.mm9-point.is-black {
  background: radial-gradient(circle at 35% 35%, #4b5563, #030712 70%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
}

.mm9-point.is-selected {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

/* Legal destinations get a dashed ring, capturable pieces a red ring with a cross. */
.mm9-point.is-target {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.55);
  outline: 2px dashed #1d4ed8;
}

.mm9-point.is-removable {
  outline: 3px solid #dc2626;
  outline-offset: 2px;
}

.mm9-point.is-removable::after {
  content: '✕';
  color: #dc2626;
  font-weight: 800;
}

.mm9-point:focus-visible {
  outline: 3px solid #0f172a;
  outline-offset: 3px;
}

/* ---------- Playing cards (Spider, FreeCell) ---------- */

.pc-table {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--radius-lg);
  background-color: #166534;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.3);
  user-select: none;
}

.pc-row {
  display: grid;
  grid-template-columns: repeat(var(--pc-cols, 8), minmax(0, 1fr));
  gap: clamp(0.2rem, 1vw, 0.6rem);
}

.pc-row + .pc-row {
  margin-top: 0.75rem;
}

/* A slot: an empty pile outline (foundation, free cell, empty column). */
.pc-slot {
  position: relative;
  aspect-ratio: 5 / 7;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.5);
  font-size: clamp(0.7rem, 2.5vw, 1.2rem);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pc-column {
  display: flex;
  flex-direction: column;
  min-height: 8rem;
  border-radius: 6px;
}

.pc-column:focus-visible,
.pc-slot:focus-visible {
  outline: 3px solid #fde047;
  outline-offset: 2px;
}

.pc-card {
  position: relative;
  flex: none;
  aspect-ratio: 5 / 7;
  width: 100%;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  background-color: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

/* Cards in a column overlap: face-up ones show their top corner, face-down ones less. */
.pc-column .pc-card + .pc-card {
  margin-top: -105%;
}

.pc-column .pc-card.is-back + .pc-card {
  margin-top: -122%;
}

.pc-column.is-tight .pc-card + .pc-card {
  margin-top: -118%;
}

.pc-card.is-back {
  background: repeating-linear-gradient(45deg, #1e3a8a 0 6px, #1d4ed8 6px 12px);
  border-color: #1e3a8a;
  cursor: default;
}

.pc-corner {
  position: absolute;
  top: 2%;
  left: 6%;
  font-size: clamp(0.6rem, 2.3vw, 1rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.pc-pip {
  position: absolute;
  inset: 30% 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1rem, 4vw, 2rem);
}

.pc-card.is-red {
  color: #b91c1c;
}

.pc-card.is-black {
  color: #111827;
}

.pc-card.is-selected {
  outline: 3px solid #facc15;
  outline-offset: -1px;
  transform: translateY(-2px);
}

.pc-card.is-hint,
.pc-column.is-hint,
.pc-slot.is-hint {
  box-shadow: 0 0 0 3px #22d3ee;
}

.fc-table {
  --pc-cols: 8;
  max-width: 46rem;
}

.fc-number {
  width: 7.5rem;
}

.sp-table {
  --pc-cols: 10;
  max-width: 56rem;
}

.sp-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.sp-stock,
.sp-done {
  width: calc((100% - 9 * clamp(0.2rem, 1vw, 0.6rem)) / 10);
}

.sp-stock {
  cursor: pointer;
}

.sp-deals {
  position: absolute;
  right: -0.4rem;
  bottom: -0.4rem;
  min-width: 1.4rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background-color: #fde047;
  color: #111827;
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
}

.sp-done-row {
  display: flex;
  gap: 0.25rem;
  color: #ffffff;
  font-weight: 700;
}

/* ---------- Country Guesser ---------- */

.cg2-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--spacing);
  width: min(100%, 40rem);
  align-items: center;
}

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

.cg2-figure {
  margin: 0;
}

.cg2-shape {
  width: 100%;
  aspect-ratio: 1;
  padding: 0.5rem;
  border-radius: var(--radius-lg);
  background-color: var(--surface-alt);
}

.cg2-svg {
  width: 100%;
  height: 100%;
}

.cg2-svg path {
  fill: var(--text);
  stroke: var(--text);
  stroke-width: 0.4;
  stroke-linejoin: round;
}

.cg2-clues {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cg2-clue {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
}

.cg2-clue.is-locked {
  border-style: dashed;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.cg2-clue-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.cg2-flag {
  width: 7.5rem;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.cg2-form .form-control {
  width: min(16rem, 60vw);
}

.cg2-guesses {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: min(100%, 32rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.cg2-guess {
  display: grid;
  grid-template-columns: 1fr auto auto 3.5rem;
  gap: 0.75rem;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius);
  background-color: var(--surface-alt);
  font-variant-numeric: tabular-nums;
}

.cg2-guess.is-correct {
  background-color: var(--game-correct);
  color: #ffffff;
  font-weight: 700;
}

.cg2-guess-name {
  font-weight: 600;
}

.cg2-guess-pct {
  text-align: right;
  font-weight: 700;
}

/* ---------- Timeline ---------- */

.tl-axis {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.tl-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(100%, 36rem);
  margin: 0;
  padding: 0;
  list-style: none;
  touch-action: none;
}

.tl-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  user-select: none;
}

.tl-card:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.tl-card.is-lifted {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: scale(1.02);
}

.tl-handle {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.tl-text {
  flex: 1;
  font-weight: 600;
}

.tl-move {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface-alt);
  color: var(--text);
  font-weight: 700;
}

.tl-move:disabled {
  opacity: 0.35;
}

.tl-year {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Results carry a tick or cross as well as the border colour. */
.tl-card.is-right {
  border-color: var(--game-correct);
  border-left-width: 6px;
}

.tl-card.is-wrong {
  border-color: var(--game-red);
  border-left-width: 6px;
}

.tl-mark {
  font-weight: 800;
}

.tl-card.is-right .tl-mark {
  color: var(--game-correct);
}

.tl-card.is-wrong .tl-mark {
  color: var(--game-red);
}

/* ---------- Simon ---------- */

.sm-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  width: min(100%, 22rem);
  aspect-ratio: 1;
  padding: 0.75rem;
  border-radius: 50%;
  background-color: #111827;
}

.sm-pad {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  color: rgba(255, 255, 255, 0.85);
  filter: brightness(0.55) saturate(0.8);
  transition: filter 80ms ease;
}

.sm-pad:disabled {
  cursor: default;
}

.sm-pad:not(:disabled) {
  cursor: pointer;
  filter: brightness(0.75);
}

/* Lit pads brighten and grow their shape, so a flash is visible without relying on colour. */
.sm-pad.is-lit {
  filter: brightness(1.25) saturate(1.1);
}

.sm-pad.is-lit .sm-shape {
  transform: scale(1.35);
}

.sm-pad-0 {
  border-top-left-radius: 100%;
  background-color: #16a34a;
}
.sm-pad-1 {
  border-top-right-radius: 100%;
  background-color: #dc2626;
}
.sm-pad-2 {
  border-bottom-left-radius: 100%;
  background-color: #eab308;
}
.sm-pad-3 {
  border-bottom-right-radius: 100%;
  background-color: #2563eb;
}

.sm-shape {
  font-size: clamp(1.5rem, 8vw, 2.5rem);
  transition: transform 80ms ease;
}

.sm-num {
  position: absolute;
  font-size: 0.9rem;
  font-weight: 800;
}

.sm-pad-0 .sm-num,
.sm-pad-2 .sm-num {
  right: 22%;
}

.sm-pad-1 .sm-num,
.sm-pad-3 .sm-num {
  left: 22%;
}

.sm-pad-0 .sm-num,
.sm-pad-1 .sm-num {
  bottom: 18%;
}

.sm-pad-2 .sm-num,
.sm-pad-3 .sm-num {
  top: 18%;
}

/* ---------- Brick Breaker, Tower Stacker (canvas) ---------- */

.bb-canvas {
  --bb-bg: #0f172a;
  --bb-paddle: #e2e8f0;
  --bb-ball: #facc15;
  --bb-text: #f8fafc;
  width: min(100%, 40rem);
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  touch-action: none;
  cursor: none;
}

.ts-canvas {
  --ts-sky-top: #bae6fd;
  --ts-sky-bottom: #6366f1;
  width: min(100%, 26rem);
  height: auto;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-lg);
  touch-action: manipulation;
  cursor: pointer;
}

[data-bs-theme='dark'] .ts-canvas {
  --ts-sky-top: #1e1b4b;
  --ts-sky-bottom: #4338ca;
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .g2048-cell.is-new,
  .c4-cell.is-dropping,
  .ludo-token.is-movable {
    animation: none;
  }

  .mm-card,
  .mm-card.is-open,
  .mm-card.is-open .mm-card-face {
    transition: none;
    transform: none;
  }
}

/* Small screens: give boards the full card width (the shared widget padding is sized for forms). */
@media (max-width: 575.98px) {
  .game-widget {
    padding: var(--spacing-lg) var(--spacing-sm);
  }
}
