:root {
  --bg: #f3ede2; --paper: #fbf8f2; --ink: #2b2622; --muted: #6f655b; --line: #ddd3c3; --line2: #c9bca7;
  --accent: #b4532f; --accent-ink: #fff; --felt: #3d5c48; --wood: #c9a77a; --wood2: #b48d5c;
  --board-light: #ecdcbf; --board-dark: #a7825a;
  --c-board: #e6d6bb; --c-cards: #d9e2d3; --c-dice: #e8d9c9; --c-party: #dcdde6;
  --shadow: 0 1px 0 rgba(43,38,34,.06), 0 6px 18px -10px rgba(43,38,34,.35);
  --r: 14px; --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1a17; --paper: #27231f; --ink: #ece4d6; --muted: #a89c8c; --line: #3a342d; --line2: #4c443a;
    --accent: #d27552; --felt: #2f4a39; --board-light: #cdb894; --board-dark: #8a6745;
    --c-board: #3b3128; --c-cards: #2e3a2f; --c-dice: #3b3029; --c-party: #2f3140;
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 8px 20px -12px rgba(0,0,0,.8); 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.5 var(--sans); min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, .brand { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; }
a { color: inherit; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px max(16px, env(safe-area-inset-left)); padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.35rem; }
.brand.small { font-size: 1.15rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--ink); color: var(--bg); font-size: 20px; }
.sub { margin-left: auto; color: var(--muted); font-size: .85rem; }
.back, .icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); text-decoration: none; font-size: 1.1rem; flex: none; }
.acts { display: flex; gap: 8px; }

/* Home */
main { max-width: 1120px; margin: 0 auto; padding: 0 16px 64px; }
.intro { padding: 28px 0 8px; }
.intro h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0 0 14px; }
.seg { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 2px; box-shadow: var(--shadow); }
.seg button { border: 0; background: none; min-width: 52px; height: 44px; border-radius: 9px; font-weight: 600; font-size: 1.05rem; padding: 0 12px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg.small button { font-size: .95rem; height: 40px; flex: 1; }
.seg.small { display: flex; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-top: 18px; }
.cats { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.cats button { border: 1px solid var(--line2); background: transparent; border-radius: 999px; padding: 6px 14px; white-space: nowrap; font-size: .92rem; }
.cats button[aria-pressed="true"] { background: var(--paper); border-color: var(--ink); font-weight: 600; }
input[type=search] { flex: 1; min-width: 180px; max-width: 320px; height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line2); background: var(--paper); }
.shelf { margin-top: 30px; }
.shelf header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.shelf h2 { margin: 0; font-size: 1.35rem; }
.count { color: var(--muted); font-size: .9rem; }
.link { margin-left: auto; border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px; }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 280px); gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 2px 12px; margin: 0 -16px; padding-inline: 16px; scrollbar-width: thin; }
.shelf.open .row { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); overflow: visible; margin: 0; padding-inline: 2px; }
.tile { scroll-snap-align: start; display: flex; gap: 14px; padding: 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); border-color: var(--line2); }
.glyph { flex: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 12px; font-size: 30px; font-family: var(--serif); background: var(--c-board); }
.glyph.big { width: 84px; height: 84px; font-size: 46px; border-radius: 18px; }
[data-cat="cards"] > .glyph, .glyph[data-cat="cards"] { background: var(--c-cards); }
[data-cat="dice"] > .glyph, .glyph[data-cat="dice"] { background: var(--c-dice); }
[data-cat="party"] > .glyph, .glyph[data-cat="party"] { background: var(--c-party); }
.tmeta { min-width: 0; display: flex; flex-direction: column; }
.tmeta strong { font-family: var(--serif); font-size: 1.08rem; }
.tmeta span { font-size: .82rem; color: var(--muted); }
.tmeta p { margin: 4px 0 0; font-size: .88rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { color: var(--muted); padding: 40px 0; }

/* Setup */
.setup { max-width: 640px; padding-top: 24px; }
.setup-head { display: flex; gap: 18px; align-items: flex-start; }
.setup-head h1 { margin: 0; font-size: 1.9rem; }
.setup-head p { margin: 4px 0 0; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-top: 18px; box-shadow: var(--shadow); }
.stepper { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.stepper span { flex: 1; font-weight: 600; }
.stepper output { min-width: 24px; text-align: center; font-size: 1.3rem; font-weight: 700; }
.round { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line2); background: var(--bg); font-size: 1.3rem; }
.round:disabled { opacity: .35; cursor: default; }
.field-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 16px 0 8px; font-weight: 600; }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.name { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line2); border-radius: 10px; padding: 0 12px; background: var(--bg); }
.name i, .chip i { width: 12px; height: 12px; border-radius: 50%; background: var(--pc); flex: none; }
.name input { border: 0; background: none; height: 44px; width: 100%; outline: none; }
.online-note { font-size: .92rem; color: var(--muted); }
.primary { display: block; width: 100%; margin-top: 18px; height: 52px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 1.05rem; text-decoration: none; text-align: center; line-height: 52px; }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.ghost { display: block; flex: 1; height: 48px; line-height: 46px; text-align: center; border: 1px solid var(--line2); border-radius: 12px; background: transparent; font-weight: 600; text-decoration: none; }
.rules summary { font-weight: 600; cursor: pointer; }
.rules ul, .rules-dlg ul { padding-left: 20px; margin: 10px 0 0; }
.rules li, .rules-dlg li { margin: 4px 0; }
.rules-dlg { max-width: 520px; width: calc(100% - 32px); border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); color: var(--ink); padding: 22px; }
.rules-dlg::backdrop { background: rgba(20,16,12,.5); }
.rules-dlg h2 { margin: 0; }

/* Play */
.playarea { max-width: 900px; padding-top: 10px; display: flex; flex-direction: column; align-items: center; }
.tally { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); font-size: .85rem; white-space: nowrap; }
.chip b { margin-left: 4px; font-variant-numeric: tabular-nums; }
.chip.now { border-color: var(--pc); box-shadow: inset 0 0 0 1px var(--pc); font-weight: 700; font-size: .95rem; }
.status { min-height: 32px; margin: 10px 0 12px; text-align: center; font-size: 1rem; display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; }
.stage-wrap { position: relative; width: 100%; display: flex; justify-content: center; }
.stage { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.layer:empty { display: none; }
.cover { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--bg) 70%, rgba(20,16,12,.55)); backdrop-filter: blur(6px); animation: fade .2s; }
.cover:not(.result) { background: var(--bg); }
.sheet { width: min(420px, 100%); background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 26px; text-align: center; box-shadow: var(--shadow); }
.sheet h2 { margin: 0 0 6px; font-size: 1.6rem; }
.sheet p { color: var(--muted); margin: 0; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.btns .primary { flex-basis: 100%; margin-top: 0; }
@keyframes fade { from { opacity: 0; } }
.bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.btn { min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line2); background: var(--paper); font-weight: 600; box-shadow: var(--shadow); }
.btn.main { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn:disabled { opacity: .4; cursor: default; }
.note { color: var(--muted); font-size: .9rem; text-align: center; margin: 0; }
.board-size { --size: min(92vw, calc(100dvh - 230px), 560px); width: var(--size); }

/* Generic square boards */
.grid { display: grid; grid-auto-rows: 1fr; width: var(--size); aspect-ratio: 1; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.sq { border: 0; padding: 0; display: grid; place-items: center; position: relative; background: var(--board-light); }
.sq.dark { background: var(--board-dark); }
.sq.sel { box-shadow: inset 0 0 0 4px var(--accent); }
.sq.last { box-shadow: inset 0 0 0 3px rgba(43,38,34,.35); }
.sq .hint { width: 28%; height: 28%; border-radius: 50%; background: rgba(43,38,34,.28); }
.sq .hint.cap { width: 86%; height: 86%; background: none; border: 4px solid rgba(43,38,34,.28); }
.stone { width: 80%; height: 80%; border-radius: 50%; background: var(--pc); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), 0 2px 3px rgba(0,0,0,.25); transition: background .25s; display: grid; place-items: center; color: #fff; font-size: 60%; }
.stone.king::after { content: "♛"; font-size: calc(var(--size) / 18); line-height: 1; color: rgba(255,255,255,.9); }

/* Tic-tac-toe */
.ttt { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(var(--size), 420px); aspect-ratio: 1; }
.ttt button { border: 0; border-radius: 14px; background: var(--paper); box-shadow: var(--shadow); font: 700 clamp(2.4rem, 12vw, 4.5rem)/1 var(--serif); color: var(--pc); }
.ttt button.w { background: color-mix(in srgb, var(--pc) 18%, var(--paper)); }
/* Ultimate */
.ult { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: var(--size); aspect-ratio: 1; }
.ult .mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 5px; border-radius: 10px; background: var(--line); position: relative; }
.ult .mini.live { background: color-mix(in srgb, var(--pc) 35%, var(--line)); }
.ult .mini button { border: 0; border-radius: 5px; background: var(--paper); color: var(--c); font: 700 clamp(.9rem, 4vw, 1.6rem)/1 var(--serif); padding: 0; }
.ult .mini .big { position: absolute; inset: 0; display: grid; place-items: center; font: 700 calc(var(--size) / 4.2)/1 var(--serif); color: var(--c); background: color-mix(in srgb, var(--paper) 78%, transparent); border-radius: 10px; }

/* Four in a row */
.c4 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1.6%; padding: 2%; background: #2f4f6b; border-radius: 14px; width: var(--size); aspect-ratio: 7/6.3; box-shadow: var(--shadow); }
.c4 button { border: 0; background: none; padding: 0; display: grid; grid-template-rows: repeat(6, 1fr); gap: 4%; }
.c4 span { border-radius: 50%; background: var(--bg); box-shadow: inset 0 3px 4px rgba(0,0,0,.3); }
.c4 span[style] { background: var(--pc); }
.c4 span.w { outline: 3px solid #fff; outline-offset: -5px; }
.c4 button:hover span:not([style]) { background: color-mix(in srgb, var(--bg) 85%, #000); }

/* Gomoku */
.goban { background: var(--wood); position: relative; }
.goban .sq { background: none; }
.goban .sq::before, .goban .sq::after { content: ""; position: absolute; background: rgba(43,30,15,.55); }
.goban .sq::before { left: 0; right: 0; top: 50%; height: 1px; }
.goban .sq::after { top: 0; bottom: 0; left: 50%; width: 1px; }
.goban .stone { position: relative; z-index: 1; width: 88%; height: 88%; }

/* Chess */
.chess .sq { font-size: calc(var(--size) / 10); line-height: 1; }
.piece { font-family: "Segoe UI Symbol", "Noto Sans Symbols2", "DejaVu Sans", serif; position: relative; z-index: 1; }
.piece.w { color: #fbf6ea; text-shadow: 0 0 1px #222, 0 0 1px #222, 0 0 1px #222, 0 2px 2px rgba(0,0,0,.35); }
.piece.b { color: #231d18; text-shadow: 0 1px 0 rgba(255,255,255,.25); }
.sq.check { background: radial-gradient(circle, #c9533a 0%, transparent 75%), var(--board-light); }
.coord { position: absolute; font-size: 10px; opacity: .6; left: 3px; top: 2px; font-family: var(--sans); }
.captured { min-height: 26px; font-size: 22px; letter-spacing: -2px; }

/* Mancala */
.kalah { display: grid; grid-template-columns: 1fr 6fr 1fr; gap: 10px; padding: 14px; background: var(--wood2); border-radius: 60px; width: var(--size); box-shadow: var(--shadow); }
.kalah .pits { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pit, .store { border: 0; border-radius: 50%; background: rgba(60,40,20,.35); color: #fff8ea; aspect-ratio: 1; font-weight: 700; font-size: clamp(1rem, 4vw, 1.4rem); box-shadow: inset 0 4px 8px rgba(0,0,0,.35); position: relative; }
.store { border-radius: 40px; aspect-ratio: auto; display: grid; place-items: center; }
.pit.can { outline: 3px solid var(--pc); outline-offset: -3px; }
.pit:disabled { cursor: default; }
.kalah .lab { font-size: .75rem; opacity: .85; display: block; font-weight: 500; }

/* Morris */
.morris { position: relative; width: min(var(--size), 480px); aspect-ratio: 1; background: var(--wood); border-radius: 14px; box-shadow: var(--shadow); }
.morris svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.morris button { position: absolute; width: 11%; height: 11%; translate: -50% -50%; border: 0; background: none; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.morris button .dot { width: 30%; height: 30%; border-radius: 50%; background: #4a3520; }
.morris button .stone { width: 100%; height: 100%; }
.morris button.sel .stone { outline: 3px solid var(--ink); outline-offset: 2px; }
.morris button.can .dot { width: 46%; height: 46%; background: var(--accent); opacity: .7; }
.morris button.rm .stone { outline: 3px dashed #c9533a; outline-offset: 2px; }
.reserve { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; font-size: .92rem; }

/* Sea battle */
.sea { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; }
.sea-board { --cell: min(8.4vw, 36px); display: grid; grid-template-columns: repeat(10, var(--cell)); gap: 2px; padding: 6px; background: #2f5d7c; border-radius: 10px; }
.sea-board.mine { --cell: min(5vw, 22px); }
.sea-board .sq { width: var(--cell); height: var(--cell); background: #cfdde5; border-radius: 3px; }
.sea-board .sq.ship { background: #6b7378; }
.sea-board .sq.miss::after { content: ""; width: 26%; height: 26%; border-radius: 50%; background: #56636e; }
.sea-board .sq.hit { background: #b4532f; }
.sea-board .sq.hit::after { content: "✕"; color: #fff; font-weight: 700; font-size: calc(var(--cell) * .55); }
.sea-board .sq.sunk { background: #6e2c18; }
.sea h3 { margin: 0 0 6px; font-size: 1rem; text-align: center; }

/* Dots & boxes */
.dots { display: grid; width: min(var(--size), 520px); aspect-ratio: 1; }
.dots .d { background: var(--ink); border-radius: 50%; margin: 20%; }
.dots .l { border: 0; padding: 0; background: none; position: relative; }
.dots .l::before { content: ""; position: absolute; border-radius: 4px; background: var(--line); }
.dots .l.h::before { left: -6%; right: -6%; top: 38%; bottom: 38%; }
.dots .l.v::before { top: -6%; bottom: -6%; left: 38%; right: 38%; }
.dots .l:hover:not(.on)::before { background: var(--line2); }
.dots .l.on::before { background: var(--pc); }
.dots .b { display: grid; place-items: center; font: 700 1.1rem var(--serif); color: #fff; }
.dots .b[style] { background: color-mix(in srgb, var(--pc) 80%, transparent); border-radius: 4px; margin: 6%; }

/* Nim */
.nim { display: flex; flex-direction: column; gap: 16px; align-items: center; padding: 18px; }
.nim .r { display: flex; gap: 10px; min-height: 70px; }
.stick { width: 14px; height: 70px; border-radius: 7px; border: 0; background: var(--wood2); padding: 0; box-shadow: var(--shadow); transition: transform .15s, opacity .15s; }
.stick.sel { background: var(--accent); transform: translateY(-8px); }

/* Ludo & snakes */
.ludo { display: grid; grid-template-columns: repeat(15, 1fr); grid-auto-rows: 1fr; width: var(--size); aspect-ratio: 1; background: var(--paper); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line2); }
.ludo .c { position: relative; display: grid; place-items: center; border: .5px solid color-mix(in srgb, var(--line2) 70%, transparent); }
.ludo .c.base { border: 0; background: color-mix(in srgb, var(--pc) 22%, var(--paper)); }
.ludo .c.col { background: color-mix(in srgb, var(--pc) 65%, var(--paper)); }
.ludo .c.safe::before { content: "★"; color: var(--muted); font-size: calc(var(--size) / 30); position: absolute; opacity: .55; }
.ludo .c.center { background: var(--ink); border: 0; }
.ludo .c.spot::before { content: ""; position: absolute; inset: 14%; border-radius: 50%; background: var(--paper); }
.token { position: relative; z-index: 1; width: 78%; height: 78%; border-radius: 50%; border: 2px solid #fff; background: var(--pc); box-shadow: 0 2px 3px rgba(0,0,0,.35); padding: 0; font-size: calc(var(--size) / 40); color: #fff; font-weight: 700; }
.token.can { animation: bob .8s ease-in-out infinite alternate; outline: 2px solid var(--ink); outline-offset: 1px; }
@keyframes bob { to { transform: translateY(-3px); } }
.snl { position: relative; width: var(--size); aspect-ratio: 1; display: grid; grid-template-columns: repeat(10, 1fr); grid-auto-rows: 1fr; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.snl .c { position: relative; font-size: calc(var(--size) / 50); padding: 3px; color: var(--muted); background: var(--paper); }
.snl .c:nth-child(odd) { background: color-mix(in srgb, var(--wood) 30%, var(--paper)); }
.snl svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.snl .toks { position: absolute; display: flex; flex-wrap: wrap; gap: 1px; width: 10%; height: 10%; padding: 12% 6% 4%; z-index: 2; justify-content: center; align-content: center; transition: left .3s, top .3s; }
.snl .toks i { width: 38%; height: 38%; border-radius: 50%; background: var(--pc); border: 1.5px solid #fff; box-shadow: 0 1px 2px rgba(0,0,0,.4); }

/* Dice */
.dice { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.die { width: 56px; height: 56px; padding: 7px; border-radius: 12px; background: #fbf8f2; border: 1px solid #cfc3b0; box-shadow: 0 3px 0 #cfc3b0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); color: #2b2622; }
button.die { cursor: pointer; }
.die .pip { width: 74%; height: 74%; margin: auto; border-radius: 50%; background: #2b2622; }
.die.held { background: #e9d6c6; border-color: var(--accent); box-shadow: 0 3px 0 var(--accent); transform: translateY(2px); }
.die.rolling { animation: roll .35s; }
@keyframes roll { 30% { transform: rotate(-14deg) scale(.92); } 70% { transform: rotate(10deg); } }
.big-num { font: 700 3rem/1 var(--serif); }
.meter { width: min(520px, 100%); display: grid; gap: 6px; }
.meter div { display: grid; grid-template-columns: 90px 1fr 44px; gap: 8px; align-items: center; font-size: .9rem; }
.meter .track { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.meter .track i { display: block; height: 100%; background: var(--pc); border-radius: 5px; transition: width .3s; }
.score-table { border-collapse: collapse; font-size: .9rem; width: min(640px, 100%); background: var(--paper); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.score-wrap { width: 100%; overflow-x: auto; display: flex; justify-content: center; }
.score-table th, .score-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.score-table th:first-child, .score-table td:first-child { text-align: left; }
.score-table td.cur { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.score-table button { border: 1px dashed var(--accent); background: none; border-radius: 6px; padding: 2px 8px; color: var(--accent); font-weight: 700; min-width: 40px; }
.score-table tr.tot td { font-weight: 700; border-bottom: 0; }

/* Cards */
.felt { width: 100%; background: var(--felt); border-radius: 18px; padding: 16px 10px; display: flex; flex-direction: column; align-items: center; gap: 14px; color: #f3ede2; box-shadow: var(--shadow); }
.felt .note { color: #d6dccf; }
.hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.hand.fan .card:not(:first-child) { margin-left: -28px; }
.card { --w: clamp(52px, 13vw, 74px); width: var(--w); height: calc(var(--w) * 1.4); border-radius: 8px; background: #fffdf8; color: #222; border: 1px solid #cbbfa9; position: relative; padding: 0; flex: none; box-shadow: 0 2px 4px rgba(0,0,0,.2); font-family: var(--serif); transition: transform .12s; }
.card.small { --w: clamp(36px, 9vw, 48px); }
.card.red { color: #a3302a; }
.card .cr { position: absolute; top: 4px; left: 6px; font-weight: 700; font-size: calc(var(--w) * .26); line-height: 1; }
.card .cs { position: absolute; top: calc(var(--w) * .3); left: 6px; font-size: calc(var(--w) * .22); line-height: 1; }
.card .cc { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--w) * .52); padding-top: 14%; }
.card.down { background: repeating-linear-gradient(45deg, #7c3a24 0 6px, #8d4630 6px 12px); border: 3px solid #fffdf8; }
.card.playable:hover, .card.sel { transform: translateY(-8px); }
.card.sel { box-shadow: 0 0 0 3px var(--accent), 0 6px 10px rgba(0,0,0,.3); }
button.card:disabled { filter: saturate(.3) brightness(.85); cursor: default; }
.pile { display: flex; gap: 18px; align-items: center; }
.opps { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.opp { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 12px; background: rgba(0,0,0,.18); font-size: .85rem; }
.opp.on { outline: 2px solid #f3ede2; }
.opp button.chip, .opp .chip { color: var(--ink); }
.suitpick { display: flex; gap: 8px; }
.suitpick button { width: 56px; height: 56px; border-radius: 12px; border: 0; background: #fffdf8; font-size: 30px; }
.suitpick button.red { color: #a3302a; }
.books { font-size: .8rem; opacity: .85; }

/* Memory */
.mem { display: grid; gap: 8px; width: min(var(--size), 620px); }
.mem button { aspect-ratio: 3/4; border: 0; border-radius: 10px; font-size: clamp(1.2rem, 6vw, 2.2rem); background: repeating-linear-gradient(45deg, #3d5c48 0 6px, #46684f 6px 12px); box-shadow: var(--shadow); color: transparent; transition: transform .25s; }
.mem button.up { background: var(--paper); color: var(--ink); transform: rotateY(180deg); }
.mem button.up span { display: inline-block; transform: rotateY(180deg); }
.mem button.done { background: color-mix(in srgb, var(--pc) 22%, var(--paper)); color: var(--pc); }

/* Word games */
.word { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; font: 700 1.8rem var(--serif); }
.word span { min-width: 28px; border-bottom: 3px solid var(--ink); text-align: center; }
.word span.sp { border: 0; }
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; width: min(560px, 100%); }
.keys button { height: 44px; border-radius: 8px; border: 1px solid var(--line2); background: var(--paper); font-weight: 700; }
.keys button.no { opacity: .3; }
.keys button.yes { background: var(--felt); color: #fff; border-color: var(--felt); }
.gallows { width: 150px; height: 150px; stroke: var(--ink); stroke-width: 4; fill: none; stroke-linecap: round; }
.form { display: flex; gap: 8px; width: min(520px, 100%); }
.form input { flex: 1; height: 48px; border-radius: 10px; border: 1px solid var(--line2); background: var(--paper); padding: 0 14px; min-width: 0; }
.card-q { width: min(560px, 100%); background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.card-q .cat { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.card-q ol { padding-left: 22px; margin: 10px 0 0; }
.card-q li { margin: 8px 0; padding: 8px 10px; background: var(--bg); border-radius: 8px; animation: fade .3s; }
.card-q li::marker { font-weight: 700; color: var(--accent); }
.pts { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); }
.pts b { font: 700 1.6rem var(--serif); color: var(--ink); }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.rps { display: flex; gap: 12px; }
.rps button { width: 96px; height: 96px; border-radius: 20px; border: 1px solid var(--line2); background: var(--paper); font-size: 2.6rem; box-shadow: var(--shadow); }
.rps button span { display: block; font-size: .8rem; }
textarea { font: inherit; }

@media (max-width: 520px) {
  .sub { display: none; }
  .tile { padding: 12px; }
  .row { grid-auto-columns: 82%; }
  .shelf.open .row { grid-template-columns: 1fr; }
  .setup-head { flex-direction: column; }
  .die { width: 48px; height: 48px; padding: 6px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.grid > *, .ludo > *, .snl > * { min-width: 0; min-height: 0; overflow: hidden; }
.ludo .c.center { background: conic-gradient(from 45deg, var(--c1, #8a7f72), var(--c1, #8a7f72) 25%, var(--c2, #8a7f72) 25% 50%, var(--c3, #8a7f72) 50% 75%, var(--c4, #8a7f72) 75%); }
