:root {
  color-scheme: light;
  --bg: oklch(97% 0.012 85);
  --fg: oklch(24% 0.02 55);
  --card: oklch(99% 0.008 90);
  --muted: oklch(45% 0.02 60);
  --line: oklch(45% 0.03 70 / 0.18);
  --gold: #9a6a2f;
  --gold-2: #6d4a1e;
  --felt: #d7ebe3;
  --ink: #1c1814;
  --wood: #e7d3b4;
  --danger: #9a3b32;
  --ok: #1d6b4f;
  --shadow: 0 18px 50px oklch(30% 0.03 60 / 0.12);
  --radius: 18px;
  font-family: Manrope, "Segoe UI", sans-serif;
}
html.dark {
  color-scheme: dark;
  --bg: oklch(16% 0.014 70);
  --fg: oklch(94% 0.02 90);
  --card: oklch(23% 0.016 65);
  --muted: oklch(76% 0.025 80);
  --line: oklch(55% 0.03 75 / 0.28);
  --gold: #e4c48a;
  --gold-2: #a97832;
  --felt: #1d4a3a;
  --ink: #14110e;
  --wood: #3c291b;
  --danger: #e07a72;
  --ok: #8dcead;
  --shadow: 0 18px 50px oklch(0% 0 0 / 0.35);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--fg);
  background:
    radial-gradient(980px 520px at 0% -10%, color-mix(in oklab, var(--gold) 22%, transparent), transparent 58%),
    radial-gradient(820px 480px at 100% 0%, color-mix(in oklab, var(--felt) 70%, transparent), transparent 52%),
    var(--bg);
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(16px);
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: Unbounded, Manrope, sans-serif; letter-spacing: 0.04em; }
.top-nav { flex: 1; }
.quiet { color: var(--muted); }
.top-actions, .row, .card-actions, .modes, .tabs, .options { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
main { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 28px 0 72px; }
.hero h1, .game-head h1 { font-family: Unbounded, Manrope, sans-serif; font-weight: 500; letter-spacing: -0.03em; font-size: clamp(40px, 6vw, 72px); line-height: 0.95; margin: 8px 0; }
.kicker { text-transform: uppercase; letter-spacing: 0.16em; font-size: 12px; color: var(--gold); margin: 0; }
.lede { max-width: 62ch; font-size: 18px; line-height: 1.5; }
.note { color: var(--muted); max-width: 70ch; }
.modes { margin-top: 18px; }
.mode, .tab, .ghost, .primary, .badge, .options button, .lesson button {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  padding: 10px 16px;
  text-decoration: none;
  cursor: pointer;
}
.mode.on, .tab.on, .primary { background: var(--gold); color: var(--ink); border-color: transparent; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 28px; }
.game-card, .lesson, .soon, dialog, .seat, .dock, .log, .advice {
  background: color-mix(in oklab, var(--card) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.game-card { padding: 18px 18px 16px; min-height: 220px; display: flex; flex-direction: column; }
.game-card h2, .lesson h2 { font-family: Unbounded, Manrope, sans-serif; font-weight: 500; font-size: 28px; margin: 6px 0; }
.game-card p { flex: 1; line-height: 1.45; }
.game-card.dim { opacity: 0.55; }
.family, .badge { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.card-actions { margin-top: 12px; }
.hidden { display: none; }
.lessons { display: grid; gap: 14px; }
.lesson, .soon { padding: 18px; }
.prompt { font-weight: 650; }
.error { color: var(--danger); min-height: 1.2em; }
dialog { border: 0; padding: 22px; width: min(440px, calc(100% - 24px)); }
dialog::backdrop { background: oklch(0% 0 0 / 0.55); }
label { display: grid; gap: 6px; margin: 10px 0; font-size: 14px; }
input, select { border-radius: 12px; border: 1px solid var(--line); background: transparent; padding: 10px 12px; }
.lobby { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; }
.panel-box, .lobby form, .side-box { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in oklab, var(--card) 88%, transparent); }
.table-wrap { position: relative; height: min(680px, 78vh); min-height: 520px; margin-top: 8px; }
.felt {
  position: absolute; inset: 8% 6%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 45%, #3e8f72, #1a4336 72%);
  box-shadow: inset 0 0 80px oklch(0% 0 0 / 0.35), 0 0 0 14px var(--wood), 0 0 0 18px var(--gold);
}
html:not(.dark) .felt { background: radial-gradient(circle at 50% 45%, #8fceba, #3e7d68 74%); }
.board-row, .pot-label { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); display: flex; gap: 6px; z-index: 2; }
.pot-label { top: 58%; color: #f6efe4; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
.pcard {
  width: 52px; height: 74px; border-radius: 8px; background: #f7f1e6; color: #1c1814;
  display: flex; flex-direction: column; justify-content: space-between; padding: 6px;
  box-shadow: 0 8px 16px oklch(0% 0 0 / 0.25);
  animation: deal 0.45s ease both;
}
.pcard b { font-size: 18px; line-height: 1; }
.pcard i { font-style: normal; align-self: flex-end; font-size: 18px; }
.pcard.red { color: #9a3030; }
.pcard.back { background: repeating-linear-gradient(45deg, #1d4a3a, #1d4a3a 6px, #163c30 6px, #163c30 12px); border: 2px solid var(--gold); }
.seat { position: absolute; width: 148px; padding: 8px; z-index: 3; text-align: center; transform: translate(-50%, -50%); }
.seat.turn { outline: 2px solid var(--gold); }
.seat .who { font-weight: 700; }
.seat .meta { color: var(--muted); font-size: 12px; }
.seat .hole { display: flex; gap: 4px; justify-content: center; margin-top: 6px; }
.seat .hole .pcard { width: 40px; height: 58px; }
.dock { position: sticky; bottom: 12px; display: flex; gap: 8px; align-items: center; padding: 12px; margin-top: 12px; flex-wrap: wrap; }
.advice, .log { padding: 12px 14px; margin-top: 12px; }
.log { max-height: 180px; overflow: auto; font-size: 14px; }
.log p, .advice p { margin: 4px 0; }
.grid-board, .mem-grid, .sdk { display: grid; gap: 4px; }
.grid-board { grid-template-columns: repeat(8, 42px); }
.cell, .mem {
  width: 42px; height: 42px; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; cursor: pointer; background: transparent;
}
.cell.dark { background: color-mix(in oklab, var(--wood) 70%, var(--card)); }
.disc { width: 28px; height: 28px; border-radius: 50%; }
.disc.b, .piece.b { background: #1c1814; }
.disc.w, .piece.w { background: #f4efe4; border: 1px solid #1c1814; }
.piece { width: 26px; height: 26px; border-radius: 50%; }
.piece.king { box-shadow: inset 0 0 0 3px var(--gold); }
.sdk { grid-template-columns: repeat(9, 38px); }
.sdk input { width: 38px; height: 38px; text-align: center; padding: 0; border-radius: 6px; }
.sdk input.given { background: color-mix(in oklab, var(--gold) 25%, transparent); }
.mem-grid { grid-template-columns: repeat(4, 72px); }
.nard, .go-board, .erudit, .mj { display: grid; gap: 3px; margin: 12px 0; }
.nard { grid-template-columns: repeat(12, 1fr); }
.erudit { grid-template-columns: repeat(15, 28px); }
.go-board .cell, .erudit .cell { width: 28px; height: 28px; padding: 0; font-size: 14px; }
.mj { grid-template-columns: repeat(12, 52px); position: relative; }
.dim { opacity: 0.45; }
.mem { width: 72px; height: 72px; font-family: Unbounded, Manrope, sans-serif; }
#toasts { position: fixed; right: 12px; bottom: 12px; display: grid; gap: 8px; }
.toast { background: var(--ink); color: #f6efe4; padding: 10px 14px; border-radius: 12px; }
@keyframes deal { from { transform: translateY(-16px) rotate(-6deg); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 900px) {
  .grid, .lobby { grid-template-columns: 1fr; }
  .table-wrap { height: 520px; min-height: 480px; }
  .felt { inset: 10% 6% 12%; }
  .pcard { width: 36px; height: 52px; }
  .seat { width: 104px; }
  .seat .hole .pcard { width: 30px; height: 44px; }
  .dock { position: static; }
  .hero h1, .game-head h1 { font-size: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  .pcard { animation: none; }
}
