/* Cribbage web client. Three themes share one layout; every color comes
   from the tokens below. */

:root, [data-theme="felt"] {
  --page: #0d2a1d;
  --page-art: radial-gradient(120% 90% at 50% 0%, #1d5236 0%, #12392a 45%, #0b2318 100%);
  --bar: linear-gradient(180deg, #3b2716, #2a1b0f);
  --bar-ink: #f3e6c8;
  --surface: #f6eedc;
  --surface-2: #ece0c4;
  --ink: #2b2016;
  --muted: #7a6a55;
  --line: #d6c49f;
  --accent: #b8862b;
  --accent-ink: #fffaf0;
  --focus: #e8c547;
  --me: #e8c547;
  --me-ink: #3a2a00;
  --opp: #d8483e;
  --opp-ink: #fff;
  --felt: radial-gradient(130% 120% at 50% 40%, #2a7a4f 0%, #1d5c3b 55%, #164a2f 100%);
  --felt-ink: #eaf5ec;
  --felt-muted: #a9cdb3;
  --felt-line: #ffffff26;
  --zone: #0000001f;
  --wood-1: #9a6634;
  --wood-2: #6e4521;
  --wood-grain: #00000014;
  --groove: #00000038;
  --hole: #2a170a;
  --board-ink: #f8e9cc;
  --skunk: #ff6b57;
  --card: #fffdf6;
  --card-edge: #cfc3a6;
  --card-ink: #1d1d1d;
  --card-red: #c3242b;
  --back-1: #7d1d1d;
  --back-2: #a32c2c;
  --back-edge: #f3e6c8;
  --shadow: 0 6px 18px #0006;
  --display: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --radius: 10px;
}

[data-theme="parchment"] {
  --page: #efe9dc;
  --page-art: linear-gradient(180deg, #f4efe4, #e9e1cf);
  --bar: linear-gradient(180deg, #2f6d41, #245734);
  --bar-ink: #fff;
  --surface: #fffdf8;
  --surface-2: #f3eee2;
  --ink: #23201b;
  --muted: #7b7366;
  --line: #ddd3bf;
  --accent: #2e6b3f;
  --accent-ink: #fff;
  --focus: #2e6b3f;
  --me: #2e6b3f;
  --me-ink: #fff;
  --opp: #c0262d;
  --opp-ink: #fff;
  --felt: linear-gradient(180deg, #faf6ec, #f1eadb);
  --felt-ink: #23201b;
  --felt-muted: #857b6b;
  --felt-line: #d9cfbb;
  --zone: #ffffffa8;
  --wood-1: #e2c290;
  --wood-2: #c99c62;
  --wood-grain: #6b3f1210;
  --groove: #6b3f1226;
  --hole: #5b3a1a;
  --board-ink: #4a2f12;
  --skunk: #c0262d;
  --card: #fff;
  --card-edge: #c9c1b0;
  --card-ink: #222;
  --card-red: #c0262d;
  --back-1: #2e6b3f;
  --back-2: #3c8a52;
  --back-edge: #fff;
  --shadow: 0 4px 14px #5a4a2a26;
  --display: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

[data-theme="midnight"] {
  --page: #0b0e14;
  --page-art: radial-gradient(90% 70% at 80% -10%, #1e2a4a 0%, transparent 60%), radial-gradient(70% 60% at 0% 110%, #2a1640 0%, transparent 60%);
  --bar: #0f131bcc;
  --bar-ink: #e6edf3;
  --surface: #141a24;
  --surface-2: #1b2330;
  --ink: #e6edf3;
  --muted: #8b98a9;
  --line: #263041;
  --accent: #5eead4;
  --accent-ink: #062a25;
  --focus: #5eead4;
  --me: #38bdf8;
  --me-ink: #04202e;
  --opp: #f472b6;
  --opp-ink: #2e0619;
  --felt: radial-gradient(120% 120% at 50% 0%, #182235 0%, #111824 60%, #0e141e 100%);
  --felt-ink: #e6edf3;
  --felt-muted: #8b98a9;
  --felt-line: #2a3548;
  --zone: #ffffff08;
  --wood-1: #1b2433;
  --wood-2: #131a26;
  --wood-grain: #ffffff05;
  --groove: #00000055;
  --hole: #05070b;
  --board-ink: #8b98a9;
  --skunk: #fb7185;
  --card: #f5f7fb;
  --card-edge: #c8d0dc;
  --card-ink: #111827;
  --card-red: #e11d48;
  --back-1: #312e81;
  --back-2: #0e7490;
  --back-edge: #a5f3fc;
  --shadow: 0 8px 24px #000a;
  --display: ui-sans-serif, system-ui, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-variant-numeric: lining-nums;
  margin: 0; min-height: 100vh; font: 15px/1.45 ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  background: var(--page-art), var(--page); background-attachment: fixed; color: var(--ink);
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.row { display: flex; gap: .5rem; align-items: center; }
.wrap { flex-wrap: wrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  font: inherit; font-weight: 600; padding: .5rem .95rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: transform .12s, background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); box-shadow: 0 2px 8px #0002; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--opp); background: transparent; border-color: color-mix(in srgb, var(--opp) 45%, transparent); }
.btn-danger:hover:not(:disabled) { background: var(--opp); color: var(--opp-ink); border-color: var(--opp); }
.btn-small { padding: .3rem .7rem; font-size: .85rem; }
.icon-btn {
  font: inherit; font-size: 1.15rem; line-height: 1; width: 2.3rem; height: 2.3rem; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: inherit; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #ffffff1f; }
.lobby .icon-btn:hover { background: var(--surface-2); }

/* ---- Top bar ----------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: .6rem;
  padding: .45rem max(.8rem, env(safe-area-inset-right)) .45rem max(.8rem, env(safe-area-inset-left));
  background: var(--bar); color: var(--bar-ink); box-shadow: 0 2px 10px #0004; backdrop-filter: blur(8px);
}
.brand { margin: 0; font-size: 1.25rem; letter-spacing: .02em; display: flex; align-items: center; gap: .45rem; }
.brand-mark {
  display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 7px;
  background: var(--me); color: var(--me-ink); font-size: 1.15rem;
}
.status { font-size: .75rem; padding: .15rem .55rem; border-radius: 1rem; background: #0000004d; display: inline-flex; align-items: center; gap: .35rem; }
.status::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: #e0a43a; }
.status.online::before { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.settings { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + .4rem); width: 15.5rem; padding: .9rem; z-index: 50;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); animation: pop .15s ease-out;
}
.menu .who { margin: .6rem 0 .4rem; font-weight: 600; border-top: 1px solid var(--line); padding-top: .7rem; }
.hint { font-size: .8rem; color: var(--muted); margin: .2rem 0 0; }
.field { display: block; margin-bottom: .7rem; font-size: .85rem; color: var(--muted); }
.field input, .field select {
  display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem; font: inherit; font-size: 1rem;
  color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px;
}
.switch { display: flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 2.4rem; height: 1.35rem; border-radius: 1rem; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: .15rem; left: .15rem; width: 1.05rem; height: 1.05rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0005; transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(1.05rem); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- Layout ------------------------------------------------------------ */
main {
  display: grid; grid-template-columns: minmax(17rem, 21rem) minmax(0, 1fr); gap: 1rem; align-items: start;
  padding: 1rem max(1rem, env(safe-area-inset-right)) 2rem max(1rem, env(safe-area-inset-left));
  max-width: 1400px; margin: 0 auto;
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 .6rem; font-size: 1.15rem; }
.panel h3 { margin: 1.1rem 0 .35rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-family: inherit; }

.login { grid-column: 1 / -1; justify-self: center; width: min(100%, 25rem); margin-top: 6vh; padding: 1.5rem; }
.login-hero { text-align: center; margin-bottom: 1rem; }
.login-hero h2 { font-size: 1.35rem; margin: .4rem 0 .2rem; }
.login .row { flex-wrap: wrap; }
.login .row .btn { flex: 1 1 auto; white-space: nowrap; }
.suits { display: inline-flex; gap: .35rem; font-size: 1.4rem; color: var(--ink); }
.suits .r { color: var(--card-red); }
.suits b { animation: bob 2.4s ease-in-out infinite; }
.suits b:nth-child(2) { animation-delay: .15s; } .suits b:nth-child(3) { animation-delay: .3s; } .suits b:nth-child(4) { animation-delay: .45s; }
.suits.big { font-size: 2.6rem; }
.error { color: var(--opp); min-height: 1.2em; margin: .6rem 0 0; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* ---- Lobby ------------------------------------------------------------- */
.bot-picks { display: grid; gap: .5rem; }
.pick {
  display: flex; align-items: center; gap: .75rem; text-align: left; font: inherit; cursor: pointer;
  padding: .6rem .75rem; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.pick:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: 0 4px 12px #0002; }
.pick b { display: block; }
.pick small { color: var(--muted); }
.pick-icon {
  flex: none; width: 2.2rem; height: 2.2rem; border-radius: 8px; display: grid; place-items: center; font-size: 1.2rem;
  background: var(--accent); color: var(--accent-ink);
}
.people { margin-top: .7rem; }
.people .btn { flex: 1; padding-inline: .6rem; }
.notice { color: var(--accent); min-height: 1.2em; margin: .5rem 0 0; font-weight: 600; font-size: .9rem; }
[data-theme="felt"] .notice { color: #8a6418; }
.invite-row { margin-top: .45rem; }
.invite-row .text {
  flex: 1; min-width: 0; padding: .45rem .6rem; font: inherit; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px;
}
.invite-row .btn { flex: none; }
.invite-row > .btn:only-child { flex: 1; }
.invites li { cursor: default; flex-wrap: wrap; row-gap: .3rem; background: var(--surface-2); border-color: var(--line); }
.invites li.incoming { box-shadow: inset 3px 0 0 var(--accent); }
/* The name gets its own line; time left and the buttons go below it. */
.games.invites li .name { flex: 1 0 100%; white-space: normal; }
.invites .when { color: var(--muted); font-size: .8rem; }
.invites .code { font: 700 1.05rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; user-select: all; cursor: text; }
.invites .acts { display: flex; gap: .35rem; margin-left: auto; }
.games { list-style: none; padding: 0; margin: 0; display: grid; gap: .25rem; }
.games li {
  padding: .45rem .55rem; border-radius: 8px; display: flex; gap: .55rem; align-items: center; cursor: pointer;
  border: 1px solid transparent; transition: background .15s;
}
.games li:hover { background: var(--surface-2); }
.games li.selected { background: var(--surface-2); border-color: var(--line); box-shadow: inset 3px 0 0 var(--accent); }
.games li .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.games li .score { font-variant-numeric: lining-nums tabular-nums; color: var(--muted); font-size: .9rem; }
.games .empty-note { color: var(--muted); font-size: .85rem; cursor: default; padding-left: .2rem; }
.games .empty-note:hover { background: none; }
.tag { font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 1rem; background: var(--surface-2); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tag.turn { background: var(--accent); color: var(--accent-ink); animation: glow 1.6s ease-in-out infinite; }
.tag.won { background: color-mix(in srgb, var(--me) 30%, transparent); color: var(--ink); }
.tag.lost { background: color-mix(in srgb, var(--opp) 22%, transparent); color: var(--ink); }

/* ---- Table ------------------------------------------------------------- */
.table { display: grid; gap: .8rem; min-width: 0; }
.table-head { display: flex; align-items: center; gap: .6rem; color: var(--ink); }
[data-theme="felt"] .table-head, [data-theme="midnight"] .table-head { color: var(--felt-ink); }
.table-head h2 { margin: 0; font-size: 1.3rem; }
.chip { font-size: .75rem; font-weight: 700; padding: .15rem .6rem; border-radius: 1rem; background: var(--zone); border: 1px solid var(--felt-line); text-transform: uppercase; letter-spacing: .06em; }
.chip:empty { display: none; }

/* Board */
.board {
  border-radius: 14px; padding: .4rem; box-shadow: var(--shadow), inset 0 1px 0 #ffffff30;
  background: repeating-linear-gradient(92deg, var(--wood-grain) 0 3px, transparent 3px 11px), linear-gradient(180deg, var(--wood-1), var(--wood-2));
}
.board svg { display: block; width: 100%; height: auto; }
.board .groove { fill: none; stroke: var(--groove); stroke-width: 14; stroke-linecap: round; stroke-linejoin: round; }
.board .lane { fill: none; stroke-width: 20; stroke-linecap: round; stroke-linejoin: round; opacity: .38; }
.board .lane.me { stroke: var(--me); }
.board .lane.opp { stroke: var(--opp); }
.board .hole { fill: var(--hole); }
.board .hole.tick { fill: color-mix(in srgb, var(--hole) 70%, var(--board-ink)); }
.board text { fill: var(--board-ink); font: 600 11px ui-sans-serif, system-ui, sans-serif; letter-spacing: .06em; }
.board .name { font-weight: 800; }
.board .skunk { stroke: var(--skunk); stroke-width: 3; stroke-dasharray: 5 3; }
.board .skunk-text { fill: var(--skunk); font-weight: 800; }
.board .game-hole { fill: var(--hole); stroke: var(--board-ink); stroke-width: 1.5; }
/* Serpentine: the board is cut in the shape of its track and sits on the table. */
.board[data-style="serpentine"] { background: none; box-shadow: none; padding: 0; }
.board[data-style="serpentine"] .wood-1 { stop-color: var(--wood-1); }
.board[data-style="serpentine"] .wood-2 { stop-color: var(--wood-2); }
.board[data-style="serpentine"] .track, .board[data-style="serpentine"] .track-edge { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.board[data-style="serpentine"] .track { stroke-width: 46; }
.board[data-style="serpentine"] .track-edge { stroke-width: 49; stroke: color-mix(in srgb, var(--board-ink) 45%, var(--wood-2)); filter: drop-shadow(0 4px 5px #0006); }
.board[data-style="serpentine"] .lane { stroke-width: 13; opacity: .3; }
.board[data-style="serpentine"] .name { font-size: 10px; }
.board .num { font: italic 700 10px ui-sans-serif, system-ui, sans-serif; letter-spacing: 0; }
.board .num.skunk-num { fill: var(--skunk); paint-order: stroke; stroke: color-mix(in srgb, var(--wood-1) 50%, var(--wood-2)); stroke-width: 4px; }
.peg { transition: none; }
.peg circle.body { stroke: #0007; stroke-width: 1.2; }
.peg.me circle.body { fill: var(--me); }
.peg.opp circle.body { fill: var(--opp); }
.peg.trail { opacity: .62; }
.peg .shine { fill: #ffffff8c; }
[data-theme="midnight"] .peg circle.body { filter: drop-shadow(0 0 4px currentColor); }
[data-theme="midnight"] .peg.me { color: var(--me); } [data-theme="midnight"] .peg.opp { color: var(--opp); }

/* Felt */
.felt {
  position: relative; display: grid; gap: .7rem; padding: .9rem; border-radius: 16px; color: var(--felt-ink);
  background: var(--felt); box-shadow: var(--shadow), inset 0 0 0 1px var(--felt-line), inset 0 0 60px #0003; overflow: hidden;
}
[data-theme="felt"] .felt { box-shadow: var(--shadow), inset 0 0 0 6px #3b2716, inset 0 0 0 7px #c9a24a66, inset 0 0 80px #0005; padding: 1.2rem; }
[data-theme="parchment"] .felt { box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
.seat { display: grid; gap: .5rem; }
.me-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.actions { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin-left: auto; }
.prompt { font-weight: 700; }
.prompt.go { padding: .3rem .8rem; border-radius: 2rem; background: var(--me); color: var(--me-ink); animation: glow 1.6s ease-in-out infinite; }

.plate { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.avatar {
  flex: none; width: 2.3rem; height: 2.3rem; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 1rem; box-shadow: 0 2px 6px #0004; position: relative;
}
.plate.me .avatar { background: var(--me); color: var(--me-ink); }
.plate.opp .avatar { background: var(--opp); color: var(--opp-ink); }
.avatar .conn { position: absolute; right: -1px; bottom: -1px; width: .7rem; height: .7rem; border-radius: 50%; background: #9ca3af; border: 2px solid #fff; }
.avatar .conn.on { background: #4ade80; }
.plate .nm { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 12rem; }
.plate .sub { font-size: .75rem; color: var(--felt-muted); }
.plate .pts { font: 800 1.6rem/1 var(--display); font-variant-numeric: lining-nums tabular-nums; margin-left: .2rem; min-width: 2.2ch; }
.plate .pts.bump { animation: bump .5s ease-out; }
.dealer { font-size: .65rem; font-weight: 800; padding: .05rem .35rem; border-radius: .3rem; background: var(--accent); color: var(--accent-ink); margin-left: .3rem; vertical-align: middle; letter-spacing: .05em; }

.center { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .7rem; align-items: stretch; }
.zone { background: var(--zone); border: 1px solid var(--felt-line); border-radius: 12px; padding: .55rem .65rem .7rem; min-width: 0; position: relative; }
.zone-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--felt-muted); margin-bottom: .4rem; display: flex; align-items: center; gap: .5rem; }
.zone-deck, .zone-crib { display: flex; flex-direction: column; align-items: center; }
.zone-crib { border-style: dashed; border-width: 2px; }
.zone-crib.mine { border-color: color-mix(in srgb, var(--me) 75%, transparent); }
.zone-crib.theirs { border-color: color-mix(in srgb, var(--opp) 75%, transparent); }
.owner { margin-top: .45rem; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 1rem; white-space: nowrap; }
.zone-crib.mine .owner { background: var(--me); color: var(--me-ink); }
.zone-crib.theirs .owner { background: var(--opp); color: var(--opp-ink); }
.count {
  margin-left: auto; min-width: 2.2rem; height: 2.2rem; padding: 0 .3rem; border-radius: 50%; display: inline-grid; place-items: center;
  font: 800 1.15rem/1 var(--display); color: var(--felt-ink); background: #0003; border: 2px solid var(--felt-line); letter-spacing: 0;
}
[data-theme="parchment"] .count { background: var(--surface); }
.count.hot { border-color: var(--me); animation: bump .5s ease-out; }
.count:empty { visibility: hidden; }

/* Cards */
.cards { --cw: clamp(2.7rem, 9.5vw, 3.9rem); display: flex; gap: .4rem; flex-wrap: wrap; min-height: calc(var(--cw) * 1.4); align-items: flex-end; }
.card {
  --cw: inherit; width: var(--cw, 3.4rem); height: calc(var(--cw, 3.4rem) * 1.4); flex: none; position: relative;
  border-radius: calc(var(--cw, 3.4rem) * .12); background: var(--card); border: 1px solid var(--card-edge);
  color: var(--card-ink); box-shadow: 0 2px 5px #0004; font-family: var(--display); padding: 0; user-select: none;
  transition: transform .18s ease, box-shadow .18s ease, opacity .2s;
}
.card.red { color: var(--card-red); }
.card .ix { position: absolute; left: 10%; top: 5%; display: flex; flex-direction: column; align-items: center; line-height: 1; font-weight: 700; font-size: calc(var(--cw, 3.4rem) * .3); }
.card .ix i { font-style: normal; font-size: .85em; margin-top: .05em; }
.card .pip { position: absolute; right: 9%; bottom: 4%; font-size: calc(var(--cw, 3.4rem) * .52); line-height: 1; }
.card.back {
  border: calc(var(--cw, 3.4rem) * .06) solid var(--back-edge);
  background: repeating-linear-gradient(45deg, var(--back-1) 0 4px, var(--back-2) 4px 8px);
}
.card.back::after { content: ""; position: absolute; inset: 10%; border: 1px solid #ffffff55; border-radius: 4px; }
button.card { cursor: pointer; }
button.card:not(:disabled):hover { transform: translateY(-6px); box-shadow: 0 8px 16px #0005; }
button.card:disabled { cursor: default; }
.hand button.card.dim { opacity: .5; filter: saturate(.6); }
.card.selected { transform: translateY(-14px) !important; box-shadow: 0 0 0 3px var(--me), 0 10px 18px #0006; }
.card.playable { box-shadow: 0 0 0 2px color-mix(in srgb, var(--me) 70%, transparent), 0 4px 10px #0004; }
.card.by-me { box-shadow: 0 0 0 2px var(--me), 0 2px 5px #0004; }
.card.by-opp { box-shadow: 0 0 0 2px var(--opp), 0 2px 5px #0004; }
.card.starter-card { box-shadow: 0 0 0 2px var(--accent), 0 4px 10px #0005; }
.hand { justify-content: center; }
.hand-opp { justify-content: center; }
.hand-opp .card { margin-left: calc(var(--cw) * -.45); }
.hand-opp .card:first-child { margin-left: 0; }
.seq .card + .card { margin-left: calc(var(--cw) * -.28); }
.seq.small { --cw: clamp(1.9rem, 6vw, 2.4rem); min-height: 0; margin-top: .4rem; opacity: .6; }
.seq { min-height: calc(var(--cw) * 1.4); }

/* Deck with the starter turned up on top. */
.deck { --cw: clamp(2.7rem, 9.5vw, 3.9rem); position: relative; width: calc(var(--cw) + 8px); height: calc(var(--cw) * 1.4 + 8px); }
.deck .card { position: absolute; left: 0; top: 0; }
.deck .card:nth-child(1) { transform: translate(6px, 6px); }
.deck .card:nth-child(2) { transform: translate(3px, 3px); }
.deck .card.starter-card { transform: rotate(-4deg); }

/* Crib pile: cards fanned slightly. */
.pile { --cw: clamp(2.3rem, 8vw, 3.2rem); position: relative; width: calc(var(--cw) * 1.9); height: calc(var(--cw) * 1.4 + 6px); }
.pile .card { position: absolute; top: 0; }
.pile.open { width: auto; height: auto; display: flex; gap: .25rem; }
.pile.open .card { position: relative; }

/* Show results */
.show { display: grid; gap: .45rem; }
.show-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .3rem .7rem;
  padding: .45rem .55rem; border-radius: 10px; background: #0000001a; border-left: 4px solid var(--felt-line);
}
[data-theme="parchment"] .show-row { background: var(--surface); }
.show-row.me { border-left-color: var(--me); }
.show-row.opp { border-left-color: var(--opp); }
.show-row .who { font-weight: 700; font-size: .85rem; }
.show-row .mini { display: flex; gap: .2rem; align-items: center; --cw: clamp(1.8rem, 6vw, 2.3rem); grid-column: 1; flex-wrap: wrap; }
.show-row .mini .plus { color: var(--felt-muted); margin: 0 .15rem; font-weight: 700; }
.show-row .tot { grid-row: 1 / span 2; grid-column: 2; font: 800 1.7rem/1 var(--display); }
.show-row .why { grid-column: 1 / -1; font-size: .78rem; color: var(--felt-muted); }
.show-row.enter { animation: slide-in .45s ease-out both; }
.show-title { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--felt-muted); }

/* Effects */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.float {
  position: absolute; transform: translate(-50%, -50%); font: 800 1.1rem/1.1 var(--display); white-space: nowrap; text-align: center;
  padding: .3rem .7rem; border-radius: 1rem; box-shadow: 0 6px 16px #0006; animation: float-up 1.6s ease-out forwards;
}
.float small { display: block; font: 600 .72rem/1.2 ui-sans-serif, system-ui, sans-serif; opacity: .9; }
.float.me { background: var(--me); color: var(--me-ink); }
.float.opp { background: var(--opp); color: var(--opp-ink); }
.float.neutral { background: var(--surface); color: var(--ink); }
.deal-in { animation: deal-in .38s cubic-bezier(.2, .9, .3, 1.2) both; }
.deal-in-opp { animation: deal-in-top .38s cubic-bezier(.2, .9, .3, 1.2) both; }
.flip-in { animation: flip-in .55s ease-out both; }

.offline {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 1rem;
  background: #0008; backdrop-filter: blur(2px); animation: fade-in .3s ease-out;
}
.offline-card {
  width: min(100%, 25rem); padding: 1.4rem 1.6rem; border-radius: var(--radius); text-align: center;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.offline-card h2 { margin: 0 0 .6rem; font-size: 1.25rem; }
.offline-card p { margin: .4rem 0; }

.banner {
  position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; background: #0008; backdrop-filter: blur(2px);
  animation: fade-in .3s ease-out;
}
.banner-card {
  text-align: center; padding: 1.4rem 1.8rem; border-radius: 16px; background: var(--surface); color: var(--ink);
  box-shadow: 0 20px 50px #000a; animation: pop .45s cubic-bezier(.2, .9, .3, 1.3); max-width: 90%;
}
.banner-card h3 { margin: 0; font-size: 2rem; }
.banner-card .final { font: 800 1.3rem var(--display); margin: .3rem 0; }
.banner-card .skunk-note { color: var(--opp); font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.banner-card .row { justify-content: center; margin-top: 1rem; }
.confetti { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; z-index: 9; }

/* Toasts */
.toasts { position: fixed; z-index: 60; left: 50%; top: 4rem; transform: translateX(-50%); display: grid; gap: .4rem; width: min(92vw, 26rem); pointer-events: none; }
.toast { padding: .6rem .9rem; border-radius: 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 600; animation: toast 3.2s ease forwards; }

/* Log */
.log-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.log-panel summary { cursor: pointer; padding: .6rem 1rem; font-weight: 700; font-family: var(--display); list-style: none; display: flex; align-items: center; gap: .5rem; }
.log-panel summary::-webkit-details-marker { display: none; }
.log-panel summary::before { content: "▸"; transition: transform .2s; color: var(--muted); }
.log-panel[open] summary::before { transform: rotate(90deg); }
.log { list-style: none; max-height: 15rem; overflow-y: auto; padding: 0 1rem .8rem; margin: 0; font-size: .88rem; scroll-behavior: smooth; }
.log li { padding: .18rem 0 .18rem .6rem; border-left: 3px solid transparent; }
.log li.me { border-left-color: var(--me); }
.log li.opp { border-left-color: var(--opp); }
.log li.hand { font-weight: 700; margin-top: .5rem; color: var(--muted); border-left: 0; padding-left: 0; }
.log li .pts { font-weight: 800; }
.log li.enter { animation: log-in .4s ease-out both; }

/* ---- Animations -------------------------------------------------------- */
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes glow { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--me) 35%, transparent); } }
@keyframes bump { 30% { transform: scale(1.35); } }
@keyframes deal-in { from { transform: translateY(40px) scale(.8) rotate(6deg); opacity: 0; } }
@keyframes deal-in-top { from { transform: translateY(-40px) scale(.8) rotate(-6deg); opacity: 0; } }
@keyframes flip-in { from { transform: rotateY(90deg) scale(1.1); } to { transform: rotate(-4deg); } }
@keyframes slide-in { from { transform: translateX(-24px); opacity: 0; } }
@keyframes log-in { from { transform: translateX(-16px); opacity: 0; max-height: 0; } to { max-height: 4em; } }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.7); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---- Account and history ----------------------------------------------- */
.link-btn {
  background: none; border: 0; padding: 0; margin-top: .4rem; font: inherit; font-size: .9rem; color: var(--accent);
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.login h2 { margin: 0 0 .4rem; }
.login > .muted { margin: 0 0 1rem; }
.error.ok { color: var(--accent); }
.menu-links { display: flex; gap: .5rem; justify-content: center; margin: .8rem 0 0; font-size: .85rem; color: var(--muted); }
.menu-links a { color: inherit; text-underline-offset: 2px; }
.menu-links a:hover { color: var(--accent); }
.login-links { margin-top: 1.2rem; }
#delete-form .btn-danger { margin-top: .2rem; }
.menu .row .btn { flex: 1; }
.history-btn { margin-top: .7rem; width: 100%; }
.history { min-width: 0; }
.history-head { display: flex; align-items: center; gap: .6rem; }
.history-head h2 { margin: 0; }
.history-total { font-size: 1.05rem; margin: .6rem 0 0; }
.history-total b { font-variant-numeric: tabular-nums; }
.records-wrap { overflow-x: auto; }
.records { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.records th, .records td { padding: .4rem .5rem; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.records th { font-size: .78rem; color: var(--muted); font-weight: 600; }
.records th:first-child, .records td:first-child { text-align: left; white-space: normal; }
.records tbody tr:last-child td { border-bottom: 0; }
.history-games li { cursor: default; }
.history-games li:hover { background: none; }
.history-games .when { color: var(--muted); font-size: .85rem; min-width: 4.6rem; font-variant-numeric: tabular-nums; }
#history-more { margin-top: .6rem; }
.dialog {
  width: min(92vw, 26rem); max-height: 90dvh; padding: 1.2rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.dialog::backdrop { background: #0009; }
.dialog-head { display: flex; align-items: center; }
.dialog-head h2 { margin: 0; font-size: 1.2rem; }
.dialog .icon-btn { color: var(--ink); }
.dialog .icon-btn:hover { background: var(--surface-2); }
.dialog h3 { margin: 1.1rem 0 .5rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-family: inherit; }
.dialog .hint { margin: 0 0 .6rem; font-size: .85rem; }
.code-input { font-size: 1.4rem !important; letter-spacing: .12em; font-variant-numeric: tabular-nums; text-align: center; }
.passkey-list { list-style: none; margin: 0 0 .7rem; padding: 0; }
.passkey-list li { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.passkey-list li > span { flex: 1; min-width: 0; }
.passkey-list b { display: block; overflow-wrap: anywhere; }
.passkey-list small { color: var(--muted); font-size: .78rem; }
.device-code { font-size: 1.8rem; font-weight: 700; letter-spacing: .14em; text-align: center; margin: .4rem 0 .8rem; font-variant-numeric: tabular-nums; }
.callout { margin: .8rem 0 0; padding: .6rem .75rem; border-radius: 8px; background: color-mix(in srgb, var(--accent) 16%, transparent); font-weight: 600; }

/* ---- Games drawer ------------------------------------------------------ */
/* With a game open, the lobby slides out from the left on demand and the
   table takes the full width. */
.only-narrow { display: none; }
body.has-table #menu { display: inline-flex; }
.scrim { position: fixed; inset: 0; background: #0007; z-index: 44; animation: fade-in .2s; }
body.has-table main { grid-template-columns: minmax(0, 1fr); }
body.has-table .lobby {
  position: fixed; z-index: 45; top: 0; bottom: 0; left: 0; width: min(88vw, 22rem); border-radius: 0 14px 14px 0;
  overflow-y: auto; transform: translateX(-105%); transition: transform .25s ease; padding-top: 1.2rem;
}
body.has-table.drawer-open .lobby { transform: none; }

/* On a landscape screen the serpentine board stands upright in its own
   column, start at the bottom, as tall as the window. */
.table.side-board { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto auto 1fr; column-gap: 1.2rem; align-items: start; }
.table.side-board > * { grid-column: 2; }
.table.side-board > .board { grid-column: 1; grid-row: 1 / -1; position: sticky; top: 4rem; }
.table.side-board .board svg { width: auto; height: calc(100dvh - 7rem); min-height: 30rem; }
.table.side-board .board .num { font-size: 12px; }

/* ---- Narrow screens ---------------------------------------------------- */
@media (max-width: 860px) {
  .only-narrow { display: inline-flex; }
  main { grid-template-columns: minmax(0, 1fr); padding: .6rem .6rem 1.5rem; gap: .6rem; }
  .brand { font-size: 1.1rem; }
  .felt, [data-theme="felt"] .felt { padding: .7rem; gap: .55rem; }
  .center { grid-template-columns: auto minmax(0, 1fr); }
  .zone-play { grid-column: 1 / -1; grid-row: 2; }
  .zone-deck { grid-column: 1; grid-row: 1; flex-direction: row; gap: .6rem; }
  .zone-crib { grid-column: 2; grid-row: 1; flex-direction: row; justify-content: center; gap: .6rem; }
  .zone-deck .zone-label, .zone-crib .zone-label { margin: 0; writing-mode: vertical-rl; transform: rotate(180deg); }
  .zone-crib .owner { margin: 0; }
  .plate .pts { font-size: 1.35rem; }
  .table-head h2 { font-size: 1.1rem; }
  .board { padding: .2rem; border-radius: 10px; }
  .board .name { display: none; }
  .board .goal, .board .skunk-text { font-size: 22px; }
  .board .num { font-size: 14px; }
  .board .num.start { display: none; }
  #empty { display: none !important; }
  .log { max-height: 11rem; }
  .show.compact .mini { display: none; }
  .hand-opp, .deck, .pile { --cw: 2.4rem; }
  .hand-opp { min-height: 0; }
  .show.compact .show-row { padding: .3rem .55rem; }
  .show.compact .show-row .tot { font-size: 1.3rem; }
  .actions { width: 100%; margin-left: 0; flex-wrap: nowrap; }
  .prompt { flex: 1; font-size: .9rem; }
  .actions .btn { flex: none; }
}
@media (max-width: 420px) {
  .status { font-size: 0; padding: .3rem; }
  .status::before { margin: 0; }
  .hand { gap: .25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---- Privacy page -------------------------------------------------------- */
.doc-page { padding: 1rem; }
main.doc { display: block; max-width: 44rem; margin: 1rem auto 2rem; padding: 1.4rem 1.6rem; }
.doc h1 { margin: 0 0 .3rem; }
.doc h2 { font-size: 1.1rem; margin: 1.4rem 0 .4rem; }
.doc ul { padding-left: 1.2rem; }
.doc li { margin: .35rem 0; }
.doc a { color: var(--accent); }
@media (max-width: 560px) { main.doc { padding: 1rem; } }
