:root {
  --bg: #f6f5fb;
  --surface: #ffffff;
  --ink: #17152e;
  --muted: #5d5a78;
  --line: #e3e1ef;
  --accent: #ff4f81;
  --accent-2: #2bb8bf;
  --accent-ink: #ffffff;
  --header: #14122b;
  --board: #eef0f7;
  --board-grid: #e4e7f2;
  --card-back: linear-gradient(135deg, #6c5ce7, #2bb8bf);
  --radius: 16px;
  --shadow: 0 10px 30px rgba(23, 21, 46, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0e1f;
    --surface: #1a1932;
    --ink: #f1f0fa;
    --muted: #a9a6c6;
    --line: #2c2a4a;
    --header: #0a0917;
    --board: #14132a;
    --board-grid: #1a1934;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 Inter, system-ui, -apple-system, sans-serif;
}
h1, h2, h3, .logo { font-family: 'Space Grotesk', Inter, sans-serif; line-height: 1.2; }
a { color: inherit; }
[hidden] { display: none !important; }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip-link:focus { left: 16px; }
.noscript { background: var(--header); color: #fff; padding: 14px 20px; text-align: center; }

/* ===== Header / footer ===== */
.site-header { background: var(--header); color: #fff; }
.site-header-inner, .site-footer-inner, .wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.site-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.logo { font-size: 22px; font-weight: 700; text-decoration: none; letter-spacing: -.02em; }
.logo .dot { color: var(--accent); }
.logo .subtag { color: var(--accent-2); font-weight: 500; margin-left: 2px; }
.main-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.main-nav a { text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: 14px; color: #d8d6ee; }
.main-nav a:hover, .main-nav a.active { background: rgba(255, 255, 255, .1); color: #fff; }

.site-footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 24px 0; color: var(--muted); font-size: 14px; }
.site-footer p { margin: 4px 0; }

/* ===== Page ===== */
.page-head { padding: 40px 0 24px; }
.page-head h1 { font-size: clamp(30px, 5vw, 44px); margin: 0 0 10px; letter-spacing: -.02em; }
.lede { color: var(--muted); max-width: 680px; margin: 0; font-size: 17px; }
.eyebrow ol { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.eyebrow li + li::before { content: '/'; margin-right: 8px; opacity: .6; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 15px/1 Inter, sans-serif; padding: 12px 18px; border-radius: 12px; cursor: pointer;
}
.btn:hover { border-color: var(--accent-2); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.05); border-color: var(--accent); }
.btn-small { padding: 8px 12px; font-size: 13px; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

/* ===== Game cards ===== */
.game-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.game-card {
  display: flex; flex-direction: column; gap: 6px; padding: 24px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.game-card:hover { transform: translateY(-3px); border-color: var(--accent-2); }
.game-card-icon { font-size: 40px; }
.game-card-name { margin: 4px 0 0; font-size: 22px; }
.game-card p { margin: 0; color: var(--muted); }
.game-card-cta { margin-top: auto; padding-top: 10px; color: var(--accent); font-weight: 600; }

/* ===== Game layout ===== */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .game-layout { grid-template-columns: 1fr; } }
.game-shell { position: relative; padding: 20px; }

.hud { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.hud-item { display: flex; flex-direction: column; background: var(--bg); border-radius: 12px; padding: 8px 14px; min-width: 84px; }
.hud-item span { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.hud-item strong { font: 700 20px/1.2 'Space Grotesk', sans-serif; font-variant-numeric: tabular-nums; }
.hud .btn-small { margin-left: auto; }

/* ===== Result panel ===== */
.result {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--surface) 75%, transparent); backdrop-filter: blur(4px); border-radius: var(--radius); z-index: 5;
}
.result-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; width: min(380px, 100%); text-align: center; }
.result-card h2 { margin: 0 0 8px; }
.result-score { margin: 0; color: var(--muted); }
.result-score strong { display: block; font: 700 44px/1.1 'Space Grotesk', sans-serif; color: var(--accent); }
.result-detail { margin: 4px 0 16px; color: var(--muted); }
.score-form { text-align: left; margin-bottom: 8px; }
.score-form label { font-size: 13px; color: var(--muted); }
.score-form-row { display: flex; gap: 8px; margin-top: 4px; }
.score-form input {
  flex: 1; min-width: 0; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: inherit;
}
.score-status { min-height: 1.6em; margin: 4px 0 12px; font-size: 14px; color: var(--muted); }
.result-card .btn-primary { width: 100%; }

/* ===== Leaderboard ===== */
.leaderboard { padding: 20px; }
.leaderboard h2 { margin: 0 0 12px; font-size: 20px; }
.leaderboard-list { margin: 0; padding: 0; list-style: none; counter-reset: rank; }
.leaderboard-list li {
  counter-increment: rank; display: flex; align-items: center; gap: 10px; padding: 8px 6px;
  border-bottom: 1px solid var(--line); font-size: 15px;
}
.leaderboard-list li::before { content: counter(rank); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); font-size: 12px; font-weight: 700; flex-shrink: 0; }
.leaderboard-list li:nth-child(1)::before { background: #ffd166; color: #3b2a00; }
.leaderboard-list li:nth-child(2)::before { background: #d6d9e4; color: #2b2d38; }
.leaderboard-list li:nth-child(3)::before { background: #f0b08a; color: #3a1d0c; }
.leaderboard-list li.is-you { background: color-mix(in srgb, var(--accent-2) 14%, transparent); border-radius: 8px; }
.lb-player { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.leaderboard-empty { color: var(--muted); margin: 0; }

/* ===== Memory ===== */
.memory-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 520px; margin: 0 auto; }
.memory-card {
  position: relative; aspect-ratio: 1; border: 0; padding: 0; background: none; cursor: pointer;
  perspective: 600px;
}
.memory-face {
  position: absolute; inset: 0; border-radius: 14px; display: grid; place-items: center;
  backface-visibility: hidden; transition: transform .35s ease;
}
.memory-back { background: var(--card-back); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .18); }
.memory-back::after { content: '?'; color: rgba(255, 255, 255, .8); font: 700 clamp(20px, 5vw, 32px) 'Space Grotesk', sans-serif; }
.memory-front { background: var(--bg); border: 2px solid var(--line); transform: rotateY(180deg); font-size: clamp(28px, 8vw, 48px); }
.memory-card.is-flipped .memory-back { transform: rotateY(180deg); }
.memory-card.is-flipped .memory-front { transform: rotateY(360deg); }
.memory-card.is-matched .memory-front { border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 15%, var(--bg)); }
.memory-card:disabled { cursor: default; }
@media (prefers-reduced-motion: reduce) { .memory-face { transition: none; } }

/* ===== Snake ===== */
.snake-stage { position: relative; max-width: 480px; margin: 0 auto; }
.snake-canvas { display: block; width: 100%; aspect-ratio: 1; border-radius: 14px; touch-action: none; }
.snake-overlay {
  position: absolute; inset: 0; border: 0; border-radius: 14px; cursor: pointer;
  background: color-mix(in srgb, var(--board) 70%, transparent); color: var(--ink);
  font: 600 16px/1.4 Inter, sans-serif; padding: 24px;
}
.dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 48px); gap: 6px; justify-content: center; margin-top: 16px; }
.dpad-btn { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 12px; font-size: 18px; cursor: pointer; }
.dpad-btn:active { background: var(--accent-2); color: #fff; }
.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
@media (hover: hover) and (pointer: fine) { .dpad { display: none; } }

/* ===== Prose ===== */
.prose { max-width: 760px; margin-top: 48px; }
.prose h2 { font-size: 26px; margin: 0 0 12px; }
.prose h2 ~ h2 { margin-top: 28px; }
.prose h3 { font-size: 18px; margin: 20px 0 6px; }
.prose p, .prose li { color: var(--muted); }
.prose .game-cards { margin-top: 16px; }

/* ===== Account nav & auth pages ===== */
.user-nav { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.user-nav a { color: #d8d6ee; text-decoration: none; }
.user-nav a:hover { color: #fff; }
.user-nav form { margin: 0; }
.user-name { color: #fff; font-weight: 600; }
.link-btn { background: none; border: 0; padding: 0; color: #d8d6ee; font: inherit; cursor: pointer; }
.link-btn:hover { color: #fff; text-decoration: underline; }
.nav-cta { background: var(--accent); color: #fff !important; padding: 6px 14px; border-radius: 999px; font-weight: 600; }

.auth-card { max-width: 420px; margin: 48px auto 0; padding: 28px; }
.auth-card h1 { margin: 0 0 20px; font-size: 28px; }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label { font-size: 14px; color: var(--muted); margin-top: 8px; }
.auth-form input[type=text], .auth-form input[type=email], .auth-form input[type=password] {
  padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit;
}
.auth-form input[aria-invalid=true] { border-color: #d03b3b; }
.auth-form .checkbox { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.auth-form .btn-primary { margin-top: 16px; }
.field-error { color: #d03b3b; font-size: 13px; margin: 2px 0 0; }
@media (prefers-color-scheme: dark) { .field-error { color: #ff8080; } .auth-form input[aria-invalid=true] { border-color: #ff8080; } }
.auth-switch { margin: 18px 0 0; color: var(--muted); font-size: 14px; }
.auth-switch a { color: var(--accent); }

/* ===== Online multiplayer (Drop Four) ===== */
.game-shell { --p1: #ff4f81; --p2: #f5b700; }
@media (prefers-color-scheme: dark) { .game-shell { --p1: #ff5c8a; --p2: #ffc933; } }
.mp-view { min-height: 340px; }
.mp-lobby, .mp-code { display: flex; flex-direction: column; gap: 8px; max-width: 420px; margin: 0 auto; }
.mp-lobby label, .mp-code label { font-size: 14px; color: var(--muted); }
.mp-lobby input, .mp-code input, .share-row input {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; min-width: 0;
}
.mp-code { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); }
.mp-code input { flex: 1; text-transform: uppercase; letter-spacing: .2em; font-weight: 600; }
.mp-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.mp-actions .btn { flex: 1; min-width: 140px; }
.mp-message { min-height: 1.6em; margin: 12px auto 0; max-width: 420px; text-align: center; color: var(--muted); font-size: 14px; }

.mp-waiting { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 24px; }
.mp-waiting h2 { margin: 12px 0 4px; }
.mp-waiting p { margin: 0 0 12px; max-width: 420px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.share-row { display: flex; gap: 8px; width: min(440px, 100%); }
.share-row input { flex: 1; font-size: 14px; }
.mp-code-big { font-size: 15px; color: var(--muted); }
.mp-code-big strong { color: var(--ink); font: 700 26px 'Space Grotesk', sans-serif; letter-spacing: .15em; margin-left: 6px; }
.mp-spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent-2); animation: mp-spin 1s linear infinite; }
@keyframes mp-spin { to { transform: rotate(360deg); } }

.mp-players { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.mp-player { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 14px; border: 2px solid transparent; background: var(--bg); min-width: 150px; transition: border-color .2s; }
.mp-player.is-turn { border-color: var(--accent-2); }
.mp-player.is-winner { border-color: var(--p2); }
.mp-player .disc { width: 26px; height: 26px; flex-shrink: 0; }
.mp-player-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.mp-player-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.mp-player-meta { display: flex; gap: 6px; font-size: 12px; color: var(--muted); }
.mp-player-meta [data-you]:not(:empty)::after { content: '·'; margin-left: 6px; }
.mp-online::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #2fbf71; margin-right: 4px; vertical-align: 1px; }
.mp-online.is-offline::before { background: var(--muted); }
.mp-vs { font: 700 14px 'Space Grotesk', sans-serif; color: var(--muted); }
.mp-status { text-align: center; font-weight: 600; margin: 16px 0; min-height: 1.6em; }
.mp-status.is-yours { color: var(--accent-2); }
.mp-match-actions { justify-content: center; margin-top: 16px; }
.mp-match-actions .btn { flex: 0 1 auto; }

.disc { border-radius: 50%; display: block; }
.disc-1 { background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--p1) 60%, #fff), var(--p1) 60%); }
.disc-2 { background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--p2) 60%, #fff), var(--p2) 60%); box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--p2) 70%, #000); }

.d4-board {
  display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 6px;
  max-width: 520px; margin: 0 auto; padding: 10px; border-radius: 18px;
  background: linear-gradient(160deg, #3b3a8f, #24236a);
}
.d4-col {
  display: grid; grid-template-rows: repeat(var(--rows), 1fr); gap: 6px;
  border: 0; background: transparent; padding: 4px; border-radius: 12px; cursor: default;
}
.d4-board.is-active .d4-col:not(:disabled) { cursor: pointer; }
.d4-board.is-active .d4-col:not(:disabled):hover, .d4-board.is-active .d4-col:not(:disabled):focus-visible { background: rgba(255, 255, 255, .12); }
.d4-cell { aspect-ratio: 1; border-radius: 50%; position: relative; }
.d4-cell:not(.disc) { background: var(--board); box-shadow: inset 0 3px 6px rgba(0, 0, 0, .35); }
.d4-cell.disc { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); }
.d4-cell.disc-2 { box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--p2) 70%, #000); }
.d4-cell.is-last::after { content: ''; position: absolute; inset: 34%; border-radius: 50%; background: rgba(255, 255, 255, .55); }
.d4-cell.is-winning { animation: d4-pulse 1s ease-in-out infinite alternate; outline: 3px solid #fff; outline-offset: -3px; }
.d4-cell.is-new { animation: d4-drop .35s cubic-bezier(.4, 0, .9, .6); }
@keyframes d4-drop { from { transform: translateY(calc(-100% * (var(--row) + 1) - 6px * (var(--row) + 1))); } }
@keyframes d4-pulse { to { transform: scale(.86); } }
@media (prefers-reduced-motion: reduce) { .d4-cell.is-new, .d4-cell.is-winning, .mp-spinner { animation: none; } }

/* ===== Ludo ===== */
.game-shell {
  --ludo-red: #e5484d; --ludo-green: #2b9a55; --ludo-yellow: #f0b000; --ludo-blue: #2f7ae5;
  --ludo-cell: #ffffff; --ludo-line: #d9d9e6;
}
@media (prefers-color-scheme: dark) {
  .game-shell { --ludo-cell: #f2f1f8; --ludo-line: #c9c8d8; }
}
.ludo-red { --c: var(--ludo-red); }
.ludo-green { --c: var(--ludo-green); }
.ludo-yellow { --c: var(--ludo-yellow); }
.ludo-blue { --c: var(--ludo-blue); }

.ludo-room { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.ludo-room h2 { margin: 0; }
.ludo-seats { list-style: none; margin: 0; padding: 0; width: min(440px, 100%); display: flex; flex-direction: column; gap: 8px; }
.ludo-seat { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg); text-align: left; }
.ludo-seat.is-empty { opacity: .6; border: 1px dashed var(--line); background: transparent; }
.ludo-seat-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ludo-seat-meta { font-size: 13px; color: var(--muted); }
.ludo-room-note { margin: 4px 0; max-width: 440px; }
.ludo-room .mp-actions { width: min(440px, 100%); }
.ludo-chip { width: 22px; height: 22px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .55); flex-shrink: 0; }

.ludo-players { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.ludo-player { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--bg); border: 2px solid transparent; min-width: 0; }
.ludo-player.is-turn { border-color: var(--accent-2); }
.ludo-player.is-winner { border-color: var(--ludo-yellow); }

.ludo-layout { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 16px; align-items: center; max-width: 620px; margin: 0 auto; }
@media (max-width: 560px) { .ludo-layout { grid-template-columns: 1fr; } }

.ludo-board {
  position: relative; display: grid; grid-template-columns: repeat(15, 1fr); grid-template-rows: repeat(15, 1fr);
  aspect-ratio: 1; width: 100%; background: var(--ludo-cell); border-radius: 12px; overflow: hidden;
  box-shadow: 0 0 0 2px var(--ludo-line);
}
.ludo-cell { border: 1px solid var(--ludo-line); background: var(--ludo-cell); position: relative; }
.ludo-lane, .ludo-start { background: var(--c); }
.ludo-star::after, .ludo-start::after {
  content: '★'; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: clamp(8px, 2.2vw, 16px); color: rgba(0, 0, 0, .28);
}
.ludo-start::after { color: rgba(255, 255, 255, .85); }
.ludo-yard { background: var(--c); padding: 14%; display: grid; }
.ludo-yard-inner { background: var(--ludo-cell); border-radius: 14%; position: relative; }
.ludo-spot { position: absolute; width: 26%; aspect-ratio: 1; border-radius: 50%; background: color-mix(in srgb, var(--c) 30%, var(--ludo-cell)); transform: translate(-50%, -50%); }
.ludo-spot:nth-child(1) { left: 30%; top: 30%; }
.ludo-spot:nth-child(2) { left: 70%; top: 30%; }
.ludo-spot:nth-child(3) { left: 30%; top: 70%; }
.ludo-spot:nth-child(4) { left: 70%; top: 70%; }
.ludo-center {
  background: conic-gradient(from 45deg, var(--ludo-green) 0 25%, var(--ludo-yellow) 0 50%, var(--ludo-blue) 0 75%, var(--ludo-red) 0);
}

.ludo-token {
  position: absolute; width: 5.4%; aspect-ratio: 1; padding: 0; border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, .55); background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 45%, #fff), var(--c) 65%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .35), inset 0 0 0 2px rgba(255, 255, 255, .6);
  transform: translate(calc(-50% + var(--shift-x, 0%)), calc(-50% + var(--shift-y, 0%)));
  transition: left .35s ease, top .35s ease, transform .2s ease; z-index: 2; cursor: default;
}
.ludo-token.is-stacked { width: 4.2%; }
.ludo-token.is-home { width: 3.6%; }
.ludo-token:disabled { opacity: 1; }
.ludo-token.is-movable { cursor: pointer; z-index: 3; animation: ludo-glow .8s ease-in-out infinite alternate; }
.ludo-token.is-movable:hover, .ludo-token.is-movable:focus-visible { transform: translate(-50%, -50%) scale(1.25); }
@keyframes ludo-glow { from { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); } to { box-shadow: 0 0 0 3px #fff, 0 0 10px 6px var(--c); } }

.ludo-side { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
@media (max-width: 560px) { .ludo-side { flex-direction: row; flex-wrap: wrap; justify-content: center; } }
@keyframes ludo-bounce { 50% { transform: translateY(-5px); } }
.ludo-die-label { margin: 0; font-weight: 600; font-size: 14px; }
.ludo-timer { margin: 0; font-size: 13px; color: var(--accent); min-height: 1.4em; }
.ludo-event { margin: 0; font-size: 13px; color: var(--muted); min-height: 2.8em; }


/* ----- Ludo: sound toggle ----- */
.ludo-sound {
  position: absolute; bottom: 12px; right: 12px; z-index: 4; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); font-size: 18px; cursor: pointer; line-height: 1;
}
.ludo-sound[aria-pressed=false] { opacity: .65; }

/* ----- Ludo: 3D die with countdown ring ----- */
.ludo-dice-wrap { position: relative; width: 116px; height: 116px; display: grid; place-items: center; --c: var(--line); }
.ludo-dice-wrap.ludo-red { --c: var(--ludo-red); }
.ludo-dice-wrap.ludo-green { --c: var(--ludo-green); }
.ludo-dice-wrap.ludo-yellow { --c: var(--ludo-yellow); }
.ludo-dice-wrap.ludo-blue { --c: var(--ludo-blue); }
.ludo-ring { position: absolute; inset: 0; transform: rotate(-90deg); opacity: 0; transition: opacity .2s; }
.ludo-dice-wrap.has-timer .ludo-ring { opacity: 1; }
.ludo-ring circle { fill: none; stroke-width: 7; }
.ludo-ring-track { stroke: var(--line); }
.ludo-ring-bar { stroke: var(--c); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 0; transition: stroke-dashoffset .25s linear, stroke .2s; }
.ludo-dice-wrap.is-urgent .ludo-ring-bar { stroke: #ff4d4f; }
.ludo-dice-wrap.is-urgent { animation: ludo-urgent .5s ease-in-out infinite alternate; }
@keyframes ludo-urgent { to { transform: scale(1.05); } }

.ludo-die {
  width: 84px; height: 84px; padding: 0; border: 0; background: none; cursor: default;
  perspective: 420px; display: grid; place-items: center; border-radius: 18px;
}
.ludo-die.is-ready { cursor: pointer; animation: ludo-bounce .9s ease-in-out infinite; }
.ludo-die.is-ready .ludo-face { box-shadow: inset 0 0 0 3px var(--c), inset 0 -6px 10px rgba(0, 0, 0, .12); }
.ludo-die:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 4px; }
@keyframes ludo-bounce { 50% { transform: translateY(-6px); } }

.ludo-cube {
  --half: 29px; position: relative; width: 58px; height: 58px; transform-style: preserve-3d;
  transition: transform .9s cubic-bezier(.2, .9, .25, 1.15);
}
.ludo-cube.is-rolling { animation: ludo-tumble .45s linear infinite; transition: none; }
@keyframes ludo-tumble {
  from { transform: rotateX(0) rotateY(0) rotateZ(0); }
  to { transform: rotateX(360deg) rotateY(720deg) rotateZ(180deg); }
}
.ludo-face {
  position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: 8px; gap: 2px; border-radius: 12px; backface-visibility: hidden;
  background: radial-gradient(circle at 30% 25%, #ffffff, #ececf4 70%, #d9d9e6);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08), inset 0 -6px 10px rgba(0, 0, 0, .12);
}
.ludo-face span { display: block; }
.ludo-face .pip { width: 76%; aspect-ratio: 1; margin: auto; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #4a4866, #15142a); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .5); }
.ludo-face-1 .pip { background: radial-gradient(circle at 35% 30%, #ff7a7f, #c8202a); width: 100%; }
.ludo-face-1 { transform: rotateY(0deg) translateZ(var(--half)); }
.ludo-face-6 { transform: rotateY(180deg) translateZ(var(--half)); }
.ludo-face-2 { transform: rotateY(90deg) translateZ(var(--half)); }
.ludo-face-5 { transform: rotateY(-90deg) translateZ(var(--half)); }
.ludo-face-3 { transform: rotateX(90deg) translateZ(var(--half)); }
.ludo-face-4 { transform: rotateX(-90deg) translateZ(var(--half)); }

/* ----- Ludo: token motion and capture ----- */
.ludo-token.is-moving { z-index: 6; transition: left .13s ease-out, top .13s ease-out; transform: translate(-50%, -50%) scale(1.25); }
.ludo-token.is-captured { z-index: 6; animation: ludo-captured .38s ease-in; }
@keyframes ludo-captured {
  0% { transform: translate(-50%, -50%) scale(1); filter: brightness(1); }
  40% { transform: translate(-50%, -80%) scale(1.5) rotate(20deg); filter: brightness(1.8); }
  100% { transform: translate(-50%, -50%) scale(.6) rotate(-30deg); opacity: .4; }
}
.ludo-board.is-shaking { animation: ludo-shake .45s ease-in-out; }
@keyframes ludo-shake {
  20% { transform: translateX(-6px) rotate(-.5deg); }
  40% { transform: translateX(5px) rotate(.4deg); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}

/* ----- Ludo: autopilot banner ----- */
.ludo-autopilot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0 auto 14px; max-width: 620px; padding: 10px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--ludo-yellow) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ludo-yellow) 50%, var(--line));
  font-weight: 600; font-size: 14px;
}

/* ----- Ludo: chat ----- */
.ludo-chat { margin: 20px auto 0; max-width: 620px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.ludo-chat-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.ludo-chat-head h2 { margin: 0; font-size: 16px; }
.ludo-chat-body { padding: 10px 14px 12px; }
.ludo-chat-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.ludo-chat-empty { margin: 4px 0 8px; font-size: 14px; }
.ludo-msg { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; align-items: baseline; max-width: 92%; }
.ludo-msg.is-mine { align-self: flex-end; text-align: right; }
.ludo-msg-name { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); grid-column: 1 / -1; }
.ludo-msg.is-mine .ludo-msg-name { justify-content: flex-end; }
.ludo-msg-body {
  grid-column: 1 / 3; background: var(--surface); border: 1px solid var(--line); padding: 7px 11px; border-radius: 12px;
  word-break: break-word; font-size: 15px; text-align: left;
}
.ludo-msg.is-mine .ludo-msg-body { background: color-mix(in srgb, var(--accent-2) 18%, var(--surface)); }
.ludo-msg-body.is-emoji { font-size: 30px; line-height: 1.1; background: none; border: 0; padding: 0 2px; }
.ludo-msg time { font-size: 11px; color: var(--muted); grid-column: 3; grid-row: 2; align-self: end; }
.ludo-chip-sm { width: 10px; height: 10px; box-shadow: none; }
.ludo-quick { display: flex; gap: 4px; flex-wrap: wrap; margin: 10px 0 8px; }
.ludo-quick-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; font-size: 20px; line-height: 1;
  padding: 6px 9px; cursor: pointer; transition: transform .12s;
}
.ludo-quick-btn:hover, .ludo-quick-btn:focus-visible { transform: scale(1.18); }
.ludo-chat-form { display: flex; gap: 6px; }
.ludo-chat-form input { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; }
.ludo-emoji-toggle { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; font-size: 20px; width: 42px; cursor: pointer; }
.ludo-emoji-picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; margin-top: 8px; padding: 8px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); max-height: 160px; overflow-y: auto;
}
.ludo-emoji-picker button { border: 0; background: none; font-size: 22px; padding: 4px; border-radius: 8px; cursor: pointer; }
.ludo-emoji-picker button:hover, .ludo-emoji-picker button:focus-visible { background: var(--bg); }

@media (prefers-reduced-motion: reduce) {
  .ludo-token, .ludo-token.is-moving { transition: none; }
  .ludo-token.is-movable, .ludo-die.is-ready, .ludo-cube.is-rolling, .ludo-token.is-captured,
  .ludo-board.is-shaking, .ludo-dice-wrap.is-urgent { animation: none; }
  .ludo-cube { transition: none; }
}

/* ----- Ludo: dice colour ----- */
.ludo-cube { --dice-face: #ffffff; --dice-pip: #15142a; }
.ludo-face {
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--dice-face) 55%, #fff), var(--dice-face) 65%, color-mix(in srgb, var(--dice-face) 80%, #000));
}
.ludo-face .pip, .ludo-face-1 .pip { background: var(--dice-pip); }
.ludo-dice-colors { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; max-width: 130px; }
.ludo-swatch {
  width: 22px; height: 22px; border-radius: 50%; padding: 0; cursor: pointer; position: relative;
  border: 2px solid var(--line); background: var(--swatch, transparent);
}
.ludo-swatch.is-default { background: conic-gradient(var(--ludo-red) 0 25%, var(--ludo-green) 0 50%, var(--ludo-yellow) 0 75%, var(--ludo-blue) 0); }
.ludo-swatch.is-active { border-color: var(--accent-2); box-shadow: 0 0 0 2px var(--accent-2); }
.ludo-swatch-custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); overflow: hidden; display: inline-block; }
.ludo-swatch-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }

/* ----- Ludo: token colours ----- */
.ludo-token.has-skin { box-shadow: 0 0 0 2px var(--seat-ring, #fff), 0 2px 3px rgba(0, 0, 0, .35), inset 0 0 0 2px rgba(255, 255, 255, .6); }
.ludo-token.ludo-red.has-skin { --seat-ring: var(--ludo-red); }
.ludo-token.ludo-green.has-skin { --seat-ring: var(--ludo-green); }
.ludo-token.ludo-yellow.has-skin { --seat-ring: var(--ludo-yellow); }
.ludo-token.ludo-blue.has-skin { --seat-ring: var(--ludo-blue); }
.ludo-token-colors { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; margin: 16px auto 0; max-width: 620px; }
.ludo-token-colors-label { font-size: 14px; font-weight: 600; color: var(--muted); }
.ludo-token-palette { display: flex; flex-wrap: wrap; gap: 6px; }
.ludo-token-swatch {
  width: 28px; height: 28px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid rgba(0, 0, 0, .45);
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 45%, #fff), var(--c) 65%);
}
.ludo-token-swatch.is-active { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent-2); }
.ludo-token-swatch:disabled { opacity: .25; cursor: not-allowed; }
.ludo-token-colors .mp-message { flex-basis: 100%; margin: 0; min-height: 0; }

/* ----- Ludo: GIFs in chat ----- */
.ludo-gif-toggle { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; font: 700 13px Inter, sans-serif; padding: 0 10px; cursor: pointer; }
.ludo-gif-picker { margin-top: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); max-height: 240px; overflow-y: auto; }
.ludo-gif-status { margin: 4px; font-size: 14px; }
.ludo-gif-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.ludo-gif-option { padding: 0; border: 2px solid transparent; border-radius: 10px; background: var(--bg); cursor: pointer; overflow: hidden; aspect-ratio: 1; }
.ludo-gif-option:hover, .ludo-gif-option:focus-visible { border-color: var(--accent-2); }
.ludo-gif-option img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ludo-msg-body.is-gif { padding: 4px; background: none; border: 0; }
.ludo-msg-body.is-gif img { display: block; max-width: 180px; max-height: 160px; border-radius: 10px; }
.ludo-msg-body.is-removed { font-style: italic; color: var(--muted); }

.game-layout.is-wide { grid-template-columns: minmax(0, 1fr); }

/* ===== Watch Together ===== */
.watch-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .watch-grid { grid-template-columns: minmax(0, 1fr); } }
.watch-player { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 14px; overflow: hidden; }
.watch-frame, .watch-frame iframe, .watch-frame > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.watch-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #c9c8de; gap: 4px; padding: 16px; }
.watch-empty span { font-size: 48px; }
.watch-empty p { margin: 0; }
.watch-status { margin: 12px 0 8px; font-weight: 600; }
.watch-url { display: flex; gap: 8px; margin-bottom: 10px; }
.watch-url input, .mp-lobby input[type=url] {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit;
}
.watch-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.watch-actions .share-row { flex: 1; min-width: 220px; width: auto; }
.watch-code { font-size: 14px; color: var(--muted); }
.watch-code strong { color: var(--ink); letter-spacing: .12em; }
.watch-join-title { margin: 0 0 6px; font-weight: 700; font-size: 18px; text-align: center; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }

.watch-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.watch-viewers { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--bg); }
.watch-viewers h2 { margin: 0 0 8px; font-size: 16px; }
.watch-viewers ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 160px; overflow-y: auto; }
.watch-viewers li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.watch-viewer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.watch-viewer-meta { font-size: 12px; color: var(--muted); }
.watch-viewer-meta.is-offline { opacity: .7; }
.watch-side .ludo-chat { margin: 0; max-width: none; }
.watch-side .ludo-chat-list { max-height: 340px; }
.watch-side .ludo-msg { max-width: 100%; }

/* ----- Watch Together: stage and fullscreen -----
   YouTube policy: nothing may sit on top of the embedded player, so the
   controls are a bar below it and the fullscreen chat is a separate panel. */
.watch-stage { display: grid; grid-template-columns: minmax(0, 1fr); border-radius: 14px; overflow: hidden; background: #000; border: 1px solid var(--line); }
.watch-screen { position: relative; min-height: 0; }
.watch-screen .watch-player { border-radius: 0; }
.watch-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 10px; background: var(--surface); border-top: 1px solid var(--line); }
.watch-controls-spacer { flex: 1; }
.watch-controls-note { font-size: 13px; color: var(--muted); }

.watch-stage.is-fullscreen {
  width: 100vw; height: 100vh; border-radius: 0; border: 0;
  grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "screen" "controls";
}
.watch-stage.is-fullscreen.has-chat { grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: "screen chat" "controls chat"; }
@media (orientation: portrait) {
  .watch-stage.is-fullscreen.has-chat { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto 38vh; grid-template-areas: "screen" "controls" "chat"; }
}
.watch-stage.is-fullscreen .watch-screen { grid-area: screen; }
.watch-stage.is-fullscreen .watch-player { position: absolute; inset: 0; aspect-ratio: auto; }
.watch-stage.is-fullscreen .watch-controls { grid-area: controls; }
.watch-stage.is-pseudo { position: fixed; inset: 0; z-index: 1000; }
html.watch-locked, html.watch-locked body { overflow: hidden; }

.watch-fs-chat { grid-area: chat; display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
@media (orientation: portrait) { .watch-fs-chat { border-left: 0; border-top: 1px solid var(--line); } }
.watch-fs-list { list-style: none; margin: 0; padding: 12px; flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.watch-fs-list li { padding: 7px 10px; border-radius: 10px; background: var(--bg); font-size: 14px; word-break: break-word; }
.watch-fs-list img { display: block; max-width: 160px; max-height: 110px; border-radius: 8px; margin-top: 4px; }
.watch-fs-form { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.watch-fs-emoji { display: flex; gap: 2px; }
.watch-fs-emoji button { border: 0; background: none; font-size: 20px; line-height: 1; padding: 4px; border-radius: 8px; cursor: pointer; }
.watch-fs-emoji button:hover, .watch-fs-emoji button:focus-visible { background: var(--bg); }
.watch-fs-input { display: flex; gap: 6px; }
.watch-fs-input input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 14px; }

.watch-attribution { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.watch-attribution a, .watch-source, .consent a { color: var(--accent-2); }
.watch-results-source { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.watch-source { font-size: 12px; font-weight: 600; text-decoration: none; align-self: flex-start; }
.watch-source:hover { text-decoration: underline; }
.consent { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); line-height: 1.45; margin-top: 4px; }
.consent input { margin-top: 3px; flex-shrink: 0; }

/* ----- Watch Together: now playing, search, queue ----- */
.watch-now { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.watch-now-text { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.watch-now-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-2); font-weight: 700; }
.watch-now-text strong { overflow: hidden; text-overflow: ellipsis; }
.watch-search { margin: 6px 0 14px; }
.watch-search .mp-message { text-align: left; margin: 0 0 8px; max-width: none; }
.watch-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; }
.watch-result { display: grid; grid-template-columns: 136px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 6px; border-radius: 12px; background: var(--bg); }
@media (max-width: 560px) {
  .watch-result { grid-template-columns: 112px minmax(0, 1fr); }
  .watch-result-actions { grid-column: 1 / -1; }
}
.watch-thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #000; }
.watch-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.watch-duration { position: absolute; right: 4px; bottom: 4px; background: rgba(0, 0, 0, .8); color: #fff; font-size: 11px; font-weight: 600; padding: 1px 5px; border-radius: 4px; }
.watch-result-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 14px; }
.watch-result-text strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.watch-result-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.watch-queue ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.watch-queue li { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.watch-queue img { width: 56px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; }
.watch-queue-text { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.watch-queue-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-queue-remove { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: 6px; }
.watch-queue-remove:hover { background: var(--surface); color: var(--ink); }

/* ===== Legal pages ===== */
.legal .prose { margin-top: 8px; }
.legal-body li { margin-bottom: 8px; }
.legal-body a, .legal .lede a { color: var(--accent-2); }
.legal-body code { font-size: 14px; }
