/* Sh!thead — purple theme: deep violet base + violet/gold accents (same
   navy-with-accents approach as Benny). Single stylesheet. */

:root {
  --bg-1: #1b1145;
  --bg-2: #271a63;
  --bg-3: #130c30;
  --felt: radial-gradient(ellipse at 50% 0%, #34227a 0%, #1c1450 45%, #0f0a29 100%);
  --panel: rgba(255, 255, 255, 0.07);
  --panel-2: rgba(255, 255, 255, 0.12);
  --ink: #f4f1ff;
  --ink-dim: #b9b2da;
  --accent: #8b5cf6;
  --accent-deep: #6233c9;
  --accent-soft: rgba(139, 92, 246, 0.24);
  --gold: #ffd23f;
  --gold-deep: #f5a623;
  --danger: #ff5d6c;
  --good: #46d39a;
  --card-w: 72px;
  --card-h: calc(var(--card-w) * 1.553);
  --radius: 16px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[data-card-size="s"]  { --card-w: 56px; }
[data-card-size="m"]  { --card-w: 72px; }
[data-card-size="l"]  { --card-w: 90px; }
[data-card-size="xl"] { --card-w: 108px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--felt);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ---------------- screens ---------------- */
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }
/* The play screen is a fixed-height, non-scrolling column: the player rows
   scroll internally while the hand + action bar stay pinned at the bottom
   (so the Play button is never hidden behind the iOS address bar). 100dvh
   tracks the *visible* viewport, and the action bar adds the safe-area inset. */
#screen-play { min-height: 0; }
#screen-play.active { height: 100dvh; max-height: 100dvh; overflow: hidden; }

/* ---------------- buttons ---------------- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  background: var(--panel-2); color: var(--ink);
  font-size: 1rem; font-weight: 650; padding: 12px 18px;
  border-radius: 999px; transition: transform .12s ease, filter .12s ease, opacity .12s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 6px 18px rgba(139, 92, 246, 0.45); }
.btn.primary:hover { background: var(--accent-deep); filter: none; }
.btn.big { padding: 15px 26px; font-size: 1.08rem; }
.btn.small { padding: 8px 14px; font-size: .9rem; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--panel-2); }
.btn.danger { background: rgba(255, 93, 108, .18); color: #ffd2d6; }
.link { background: none; border: 0; color: var(--ink-dim); cursor: pointer; font-size: .95rem; text-decoration: underline; }
.link:hover { color: var(--ink); }
.icon-btn { background: var(--panel); border: 0; color: var(--ink); width: 42px; height: 42px; border-radius: 12px; font-size: 1.3rem; cursor: pointer; }

/* ---------------- start ---------------- */
.start-wrap { max-width: 520px; margin: 0 auto; padding: 24px 18px 40px; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.hero-logo { width: min(80vw, 360px); height: auto; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, .5)); margin-top: 8px; }
.tagline { color: var(--gold); font-weight: 700; letter-spacing: .5px; margin: 4px 0 0; }

/* Selectable game-type tiles (was a pill tab-strip) — one row per mode so each
   game type reads as its own card, like Benny's mode picker. */
.mode-tiles { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.mode-tile { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--panel); border: 1.5px solid transparent; border-radius: 14px; padding: 12px 14px;
  color: var(--ink); cursor: pointer; font: inherit; box-shadow: var(--shadow);
  transition: border-color .12s ease, background .12s ease, transform .08s ease; }
.mode-tile:hover { background: var(--panel-2); }
.mode-tile:active { transform: translateY(1px); }
.mode-tile.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--panel)); }
.mode-tile-icon { font-size: 1.55rem; line-height: 1; flex: 0 0 auto; }
.mode-tile-info { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.mode-tile-title { font-weight: 750; font-size: 1rem; }
.mode-tile-desc { font-size: .8rem; color: var(--ink-dim); }
.mode-tile-check { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 999px; border: 2px solid var(--panel-2); transition: border-color .12s ease, background .12s ease; }
.mode-tile.active .mode-tile-check { border-color: var(--accent); background: var(--accent) radial-gradient(circle, #fff 30%, transparent 32%); }

.setup-card { background: var(--panel); border-radius: var(--radius); padding: 18px; width: 100%; box-shadow: var(--shadow); }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0; }
.field > span { font-weight: 600; color: var(--ink-dim); }
.seg { display: inline-flex; background: var(--bg-3); border-radius: 12px; padding: 4px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--ink-dim); padding: 8px 14px; border-radius: 9px; font-weight: 650; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }

/* native dropdown styled to match the dark theme + a custom chevron */
.select { appearance: none; -webkit-appearance: none; cursor: pointer; font: inherit; font-weight: 650;
  color: var(--ink); border: 1px solid var(--panel-2); border-radius: 12px; padding: 10px 36px 10px 14px;
  background: var(--bg-3) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'><path d='M1 1l6 6 6-6' fill='none' stroke='%23a9a4c9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 13px center / 12px 7px; }
.select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#stats-player-field { margin: 0 0 14px; }
#stats-player-field .select { min-width: 55%; }

.names { margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.name-input input, #welcome-name { width: 100%; background: var(--bg-3); border: 1.5px solid transparent; color: var(--ink); border-radius: 10px; padding: 11px 13px; font-size: 1rem; }
.name-input input:focus, #welcome-name:focus { outline: none; border-color: var(--gold); }
#welcome-form .field { flex-direction: column; align-items: stretch; gap: 6px; }
#welcome-form .field > span { font-weight: 600; color: var(--ink-dim); }
#welcome-form .btn { width: 100%; margin-top: 14px; }
.cpu-note { color: var(--ink-dim); margin: 8px 2px; }

.house-rules { margin: 10px 0; background: var(--bg-3); border-radius: 12px; padding: 6px 12px; }
.house-rules summary { cursor: pointer; padding: 8px 0; font-weight: 650; color: var(--ink-dim); }
.toggle { display: flex; align-items: center; gap: 10px; margin: 10px 2px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--gold-deep); flex: 0 0 auto; }
.toggle span { font-size: 14px; line-height: 1.3; }
.rules-sub { margin: 14px 2px 2px; font-weight: 750; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-dim); opacity: .8; }
.rules-sub:first-of-type { margin-top: 4px; }

.start-btn, #start-btn { width: 100%; margin-top: 6px; }
.start-links { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }

/* ---------------- home sections ---------------- */
.home-section { width: 100%; background: var(--panel); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.home-section[hidden] { display: none; }
.home-section .setup-card { background: transparent; box-shadow: none; padding: 14px 0 0; }
.section-title { margin: 0 0 10px; font-size: 13px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-dim); }

.saved-list { display: flex; flex-direction: column; gap: 8px; }
.saved-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg-3); border-radius: 12px; padding: 10px 12px; box-shadow: inset 0 0 0 1.5px rgba(139, 92, 246, .35); }
.saved-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.saved-meta .muted { font-size: 12px; }
.saved-actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* "Stats & achievements" entry button */
/* "Stats & achievements" entry — gold treatment so it reads as a reward
   (mirrors Benny: pulsing trophy + a slow sheen sweep). */
.trophy-btn { position: relative; overflow: hidden; width: 100%; display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, #fff5d6, #f6d98a); border: 1px solid rgba(201,150,58,.55);
  border-radius: var(--radius); padding: 13px 16px; color: #5a3d10; cursor: pointer; font: inherit; font-weight: 700;
  box-shadow: 0 0 0 1px rgba(245,196,81,.25) inset, 0 4px 14px rgba(201,150,58,.22);
  transition: box-shadow .15s ease, transform .12s ease; }
.trophy-btn:hover { box-shadow: 0 0 0 1px rgba(245,196,81,.45) inset, 0 6px 18px rgba(201,150,58,.3); }
.trophy-btn:active { transform: translateY(1px); }
.trophy-btn-icon { font-size: 1.5rem; line-height: 1; flex: 0 0 auto; transform-origin: 50% 60%; filter: drop-shadow(0 1px 2px rgba(0,0,0,.18)); animation: trophy-pulse 2.4s ease-in-out infinite; }
.trophy-btn-text { flex: 1; text-align: left; font-weight: 750; }
.trophy-btn-count { flex: 0 0 auto; font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums;
  color: #5a3d10; background: rgba(255,255,255,.55); border: 1px solid rgba(201,150,58,.5);
  border-radius: 999px; padding: 3px 10px; box-shadow: 0 1px 2px rgba(201,150,58,.18); }
.trophy-btn-chev { color: #8a5a14; font-size: 1.4rem; font-weight: 700; flex: 0 0 auto; }
.trophy-btn::after { content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 30%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent); transform: skewX(-18deg);
  animation: trophy-sheen 5s ease-in-out infinite; pointer-events: none; }
@keyframes trophy-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes trophy-sheen { 0%, 70%, 100% { left: -40%; } 85% { left: 110%; } }
@media (prefers-reduced-motion: reduce) { .trophy-btn-icon { animation: none; } .trophy-btn::after { display: none; } }

.app-version { color: var(--ink-dim); opacity: .7; font-size: 12px; margin: 2px 0 0; text-align: center; }
.app-version.stale { color: var(--danger); opacity: .95; }

/* ---------------- topbar ---------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; gap: 8px; }
.topbar h2 { margin: 0; font-size: 1.1rem; }
.turn-pill { background: var(--panel); padding: 9px 16px; border-radius: 999px; font-weight: 700; }
.turn-pill.yours { background: var(--accent); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { filter: brightness(1.18); } }

/* ---------------- cards ---------------- */
.card {
  width: var(--card-w); height: var(--card-h);
  border-radius: calc(var(--card-w) * 0.11);
  background: #fff; color: #111; position: relative;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .4); flex: 0 0 auto;
  user-select: none; overflow: hidden;
}
.card.is-modern .card-art { width: 100%; height: 100%; display: block; object-fit: contain; }
.card.back {
  background:
    repeating-linear-gradient(45deg, #6a3df0 0 8px, #4a2cc0 8px 16px);
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 5px #2a1a6b, 0 3px 10px rgba(0,0,0,.4);
}
/* Lift (hover/selected) is written into --card-y so it composes with the hand
   fan's per-card rotation (--card-rot) instead of overriding the transform. */
.card.selectable, .card.in-hand { transition: transform .12s ease, box-shadow .12s ease; }
.card.selectable { cursor: pointer; transform: translateY(var(--card-y, 0)); }
.card.in-hand { transform: rotate(var(--card-rot, 0deg)) translateY(var(--card-y, 0)); transform-origin: 50% 50%; }
.card.selectable:hover { --card-y: -7px; }
.card.selected { --card-y: -16px; box-shadow: 0 0 0 3px var(--gold), 0 10px 22px rgba(0,0,0,.5); }
.card.dim { opacity: .5; filter: grayscale(.4); }
.card.back.blind { cursor: pointer; box-shadow: inset 0 0 0 3px var(--gold), inset 0 0 0 5px #2a1a6b, 0 3px 14px rgba(255,210,63,.5); animation: pulse 1.4s infinite; }

/* classic renderer bits */
.card .corner { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: 1; font-weight: 800; }
.card .corner.top-left { top: 4px; left: 5px; }
.card .corner.bottom-right { bottom: 4px; right: 5px; transform: rotate(180deg); }
.card .corner .rank { font-size: calc(var(--card-w) * .22); }
.card .corner .suit { font-size: calc(var(--card-w) * .2); }
.card.suit-h, .card.suit-d { color: #d8232a; }
.card.suit-s, .card.suit-c { color: #1a1a2e; }
.card .face { position: absolute; inset: 18% 10% 18% 10%; display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(7,1fr); }
.card .pip { display: flex; align-items: center; justify-content: center; font-size: calc(var(--card-w) * .2); }
.card .pip.flip { transform: rotate(180deg); }
.card .pip.big { font-size: calc(var(--card-w) * .5); }
.card .portrait { position: absolute; inset: 16% 12%; color: currentColor; }
.card .portrait svg { width: 100%; height: 100%; }

/* classic-mode joker */
.card.joker { color: #6b1fb1; }
.card.joker .joker-face { position: absolute; inset: 14% 8%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4%; }
.card.joker .joker-star { font-size: calc(var(--card-w) * .5); line-height: 1; }
.card.joker .joker-word { font-size: calc(var(--card-w) * .15); font-weight: 800; letter-spacing: .06em; writing-mode: vertical-rl; }

.card-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.card-row.tight { gap: 4px; }

/* ---------------- player rows (stacked above the deck, Benny-style) ---------------- */
/* Every player is a panel: name + key stat, then their table cards. The whole
   list scrolls vertically when it's too tall; each row's cards scroll
   horizontally when too wide. Row cards are half a play card and scale with the
   size selection (override --card-w just for this subtree). */
.player-rows { flex: 1 1 auto; min-height: 0; width: 100%; max-width: 560px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; padding: 2px;
  /* Halve the card size for row cards. --card-h must be overridden too: the
     :root --card-h bakes in the base --card-w, so it won't follow this halved
     --card-w on its own (which left the card box double-height → white bars). */
  --card-w: calc(var(--base-cw, 72px) * .5); --card-h: calc(var(--card-w) * 1.553); }
/* Full table → 2×2 grid of player panels (smaller cards so 3 fit in a half-width cell). */
.player-rows.cols-2 { display: grid; grid-template-columns: 1fr 1fr; align-content: start;
  --card-w: calc(var(--base-cw, 72px) * .42); --card-h: calc(var(--card-w) * 1.553); }
.player-row { background: var(--panel); border: 1.5px solid transparent; border-radius: 14px; padding: 7px 10px 9px; box-shadow: var(--shadow); transition: border-color .2s, box-shadow .2s; }
.player-row.is-current { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(245,196,81,.3) inset, var(--shadow); }
.player-row.finished { opacity: .6; }
.player-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.player-row-name { display: flex; align-items: center; gap: 7px; font-weight: 750; font-size: .92rem; min-width: 0; }
.pr-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-badge { flex: 0 0 auto; font-size: .62rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #ffe7a8; background: rgba(245,196,81,.22); border: 1px solid rgba(245,196,81,.4); border-radius: 999px; padding: 1px 7px; }
.player-row-meta { flex: 0 0 auto; color: var(--ink-dim); font-weight: 700; font-size: .85rem; font-variant-numeric: tabular-nums; }
.hand-count { white-space: nowrap; }
.badge.done { background: var(--good); color: #06321f; border-radius: 999px; padding: 1px 8px; font-weight: 800; font-size: .78rem; }

/* the row of table cards — face-up lifted over face-down so the hidden card peeks out.
   min-height includes headroom for that lift, or overflow-y:hidden clips the card top. */
.player-row-table { position: relative; display: flex; align-items: flex-end; gap: 6px; min-height: calc(var(--card-h) * 1.2); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding-bottom: 2px; }
.player-row-table::-webkit-scrollbar { display: none; }
.player-row-table .mini-stack { flex: 0 0 auto; width: var(--card-w); height: var(--card-h); }
/* an emptied slot holds its column as an invisible spacer so cards don't slide left */
.player-row-table .mini-stack.slot-empty { pointer-events: none; }
.player-row-table > .card { flex: 0 0 auto; }
.player-row-table .mini-stack .card.on-top { transform: translateY(-16%); }
.player-row-table.ov-right { -webkit-mask-image: linear-gradient(90deg, #000 86%, transparent 100%); mask-image: linear-gradient(90deg, #000 86%, transparent 100%); }
.player-row-table.ov-left { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14%); mask-image: linear-gradient(90deg, transparent 0, #000 14%); }
.player-row-table.ov-left.ov-right { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14%, #000 86%, transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 14%, #000 86%, transparent 100%); }
.pr-empty { color: var(--ink-dim); opacity: .5; font-weight: 700; align-self: center; }

/* shared stack internals (used by the player-row table cards) */
.mini-stack { position: relative; }
.mini-stack .card { position: absolute; inset: 0; width: 100%; height: 100%; }
.card.on-top { position: absolute; left: 0; top: 0; }
/* Endgame: face-up cards you can tap to pull into your hand. */
.card.takeable { cursor: pointer; outline: 2px dashed var(--gold); outline-offset: 2px; border-radius: calc(var(--card-w) * .11); animation: takeablePulse 1.5s ease-in-out infinite; z-index: 2; }
@keyframes takeablePulse { 0%, 100% { outline-color: var(--gold); } 50% { outline-color: color-mix(in srgb, var(--gold) 35%, transparent); } }

/* ---------------- center table ---------------- */
.center-table { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 6px 6px; min-height: 0; --base-cw: var(--card-w); }
.pile-zone { position: relative; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: 16px; }
.deck-stack { position: relative; }
.deck-stack .count, .pile-count, .burned-zone .count { position: absolute; bottom: -6px; right: -6px; background: var(--bg-3); color: var(--ink); border-radius: 999px; padding: 2px 7px; font-size: .8rem; font-weight: 800; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.deck-stack.empty { opacity: .35; }
.discard-zone { position: relative; width: var(--card-w); height: var(--card-h); display: flex; align-items: center; justify-content: center; }
.discard-zone .discard-card { position: absolute; left: calc(var(--i, 0) * 6px); top: calc(var(--i, 0) * -2px); }
.discard-empty { width: var(--card-w); height: var(--card-h); border: 2px dashed var(--panel-2); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--ink-dim); font-weight: 700; }
.burned-zone { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 1.2rem; opacity: .85; align-self: center; }
.burned-zone .count { position: static; font-size: .78rem; }
.burned-zone.pulse { animation: burnedPulse .7s ease-out; }
@keyframes burnedPulse { 0% { transform: scale(1); } 35% { transform: scale(1.5); filter: drop-shadow(0 0 8px #ff8c28); } 100% { transform: scale(1); } }
.req-hint { color: var(--gold); font-weight: 700; min-height: 1.2em; text-align: center; }

/* ---------------- table effects ---------------- */
/* the freshly played card drops onto the pile */
@keyframes dropIn { from { transform: translateY(-44px) scale(1.14) rotate(-5deg); opacity: 0; } to { transform: none; opacity: 1; } }
.discard-zone .discard-card.drop-in { animation: dropIn .28s cubic-bezier(.2,.85,.3,1.2); }
/* burn / pickup radial flashes over the centre */
.center-fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; border-radius: 24px; }
.center-fx.fx-burn { background: radial-gradient(circle at 50% 50%, rgba(255,150,50,.6), rgba(255,80,0,0) 62%); animation: fxBurn .6s ease-out forwards; }
@keyframes fxBurn { 0% { opacity: 0; transform: scale(.5); } 30% { opacity: 1; } 100% { opacity: 0; transform: scale(1.5); } }
.center-fx.fx-pickup { background: radial-gradient(circle at 50% 50%, rgba(139,92,246,.45), rgba(139,92,246,0) 62%); animation: fxPick .5s ease-out forwards; }
@keyframes fxPick { 0% { opacity: 0; transform: scale(1.35); } 40% { opacity: 1; } 100% { opacity: 0; transform: scale(.65); } }
/* floating call-outs: Reverse / Joker / Reset / pickup count */
.float-label { position: absolute; left: 50%; top: 40%; z-index: 6; font-weight: 800; font-size: 1.25rem; color: var(--gold); text-shadow: 0 2px 10px rgba(0,0,0,.7); pointer-events: none; white-space: nowrap; animation: floatUp 1.1s ease-out forwards; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.8); } 18% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -40px) scale(1); } }

/* ---------------- dealer reveal (slot-machine reel) ---------------- */
#screen-reveal { align-items: center; justify-content: center; padding: 24px; text-align: center; }
.reveal-wrap { width: 100%; max-width: 420px; }
.reveal-title { margin: 0 0 18px; font-size: 1.3rem; color: var(--ink-dim); }
.reel-frame { position: relative; height: 200px; margin: 0 auto 18px; width: min(100%, 320px);
  background: var(--panel); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid var(--panel-2);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 25%, #000 75%, transparent 100%);
          mask-image: linear-gradient(180deg, transparent 0, #000 25%, #000 75%, transparent 100%); }
.reel { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.reel-item { height: 56px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 800; color: var(--ink); }
.reel-marker { position: absolute; left: 12px; right: 12px; top: 50%; height: 56px; transform: translateY(-50%);
  border-top: 2px solid var(--gold); border-bottom: 2px solid var(--gold); pointer-events: none; border-radius: 6px; }
.reveal-name { font-size: 1.4rem; font-weight: 800; color: var(--gold); min-height: 1.3em; margin: 10px 0 18px; }
#reveal-continue { width: 100%; max-width: 320px; }

/* ---------------- tutorial coach ---------------- */
.tour-offer .tour-text { margin: 0 0 12px; color: var(--ink-dim); line-height: 1.45; }
.tour-offer .tour-actions { display: flex; gap: 10px; }
.tour-offer .tour-actions .btn { flex: 1; }

#coach { position: fixed; inset: 0; z-index: 100; }
.coach-block { position: fixed; inset: 0; z-index: 100; }            /* blocks game taps while the coach talks */
.coach-spot { position: fixed; z-index: 101; border-radius: 14px; border: 2px solid var(--gold); box-shadow: 0 0 0 9999px rgba(7, 5, 26, .82); pointer-events: none; transition: left .2s ease, top .2s ease, width .2s ease, height .2s ease; }
.coach-balloon { position: fixed; z-index: 102; left: 50%; transform: translateX(-50%); width: min(340px, 88vw); background: var(--bg-2); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow); border: 1px solid var(--panel-2); }
.coach-balloon.vcenter { top: 50%; transform: translate(-50%, -50%); }
.coach-step { font-size: 11px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 4px; }
.coach-title { font-weight: 800; font-size: 1.12rem; margin-bottom: 6px; color: var(--gold); }
.coach-body { line-height: 1.5; color: var(--ink); }
.coach-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }

/* ---------------- card zoom ---------------- */
.card-zoom { position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%); z-index: 120; pointer-events: none; }
.card-zoom .zoom-card { --card-w: 210px; position: relative; width: var(--card-w); height: calc(var(--card-w) * 1.553); background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 24px 70px rgba(0,0,0,.65); display: block; animation: zoomPop .14s ease-out; }
.card-zoom .zoom-card.is-modern { background: transparent; overflow: visible; }
.card-zoom .zoom-card .card-art { width: 100%; height: 100%; object-fit: contain; }
@keyframes zoomPop { from { transform: scale(.85); opacity: .4; } to { transform: scale(1); opacity: 1; } }

/* ---------------- you area ---------------- */
/* clip horizontally (so a mis-sized hand can never bleed off the side) but keep
   vertical visible for the fan lift. overflow-x:clip + overflow-y:visible does NOT
   trigger the spec's visible→auto conversion, so this stays a non-scrolling box. */
.you-area { padding: 4px 8px max(6px, env(safe-area-inset-bottom)); overflow-x: clip; overflow-y: visible; }
/* overflow is visible (NOT overflow-x:auto) on purpose: with overflow-x:auto and
   overflow-y:visible the spec computes overflow-y to auto too, which made the dock
   a scroll container — the fanned cards' transforms then created a phantom
   scrollable strip below the hand. Keeping it visible lets the fan lift show; the
   hand is sized by layoutHand to fit, and #screen-play (overflow:hidden) clips any
   stray edge so nothing scrolls the page. */
.hand-dock { min-height: var(--card-h); display: flex; justify-content: center; align-items: flex-end; padding: 6px 8px; overflow: visible; }
/* Hand overlap is driven by --hand-overlap (set by layoutHand); the fan adds a
   per-card tilt around a pivot below the row + top padding so tilted corners
   have room. Either way the left strip of every card stays exposed so its
   top-left rank+suit is always readable. */
.card-row.hand { flex-wrap: nowrap; }
.card-row.hand > .card + .card { margin-left: var(--hand-overlap, 4px); }
.card-row.hand > .card.selected { z-index: 10; }
.card-row.hand.fanned { padding-top: 16px; }
.card-row.hand.fanned > .card { transform-origin: 50% 240%; }

/* ---------------- hand drag & drop ---------------- */
/* Claim the touch gesture so the long-press → drag isn't pre-empted by scroll. */
.card.in-hand { touch-action: none; }
.card.dragging { z-index: 200; box-shadow: 0 14px 30px rgba(0,0,0,.55); transform-origin: 50% 50%; transform: translateY(-10px) scale(1.04); --card-rot: 0deg; opacity: .6; }
.card.drag-placeholder { opacity: 0; pointer-events: none; }
/* While dragging, kill native selection/callout document-wide (Android Chrome
   otherwise starts a text-selection gesture that cancels the drag). */
body.hand-dragging, body.hand-dragging * { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
body.hand-dragging input, body.hand-dragging textarea { -webkit-user-select: text; user-select: text; }
/* The discard pile lights up while a card hovers over it. */
.discard-zone.is-drop-hover { box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(255,210,63,.5); border-radius: var(--radius); }
.discard-zone.is-drop-hover .discard-empty { border-color: var(--gold); color: var(--gold); }

/* ---------------- match-select toggle ---------------- */
.match-row { display: flex; justify-content: center; padding: 2px 12px 0; }
.match-row[hidden] { display: none; }
.match-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-dim); cursor: pointer; background: var(--panel); padding: 6px 13px; border-radius: 999px; }
.match-toggle input { width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; }

/* ---------------- action bar ---------------- */
.action-bar { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
/* On the play screen the buttons sit ABOVE the hand (Benny-style), so the
   safe-area inset moves to the hand area below; this is a control strip. */
.play-actions { background: var(--bg-3); padding-bottom: 12px; border-top: 1px solid var(--panel-2); }
.sel-info { color: var(--ink-dim); font-weight: 650; min-width: 80px; text-align: center; }

/* ---------------- swap ---------------- */
.swap-hint { text-align: center; color: var(--ink-dim); padding: 0 18px; line-height: 1.5; }
.swap-area { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 26px; padding: 12px; }
.swap-section h3 { text-align: center; color: var(--gold); margin: 0 0 10px; }

/* ---------------- over ---------------- */
.over-wrap { max-width: 480px; margin: 0 auto; padding: 30px 18px; width: 100%; text-align: center; }
#over-title { font-size: 1.6rem; }
.results { display: flex; flex-direction: column; gap: 8px; margin: 18px 0; }
.result-row { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: 12px; padding: 12px 16px; }
.result-row.winner { background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 0 0 2px var(--accent); }
.result-row.loser { box-shadow: inset 0 0 0 2px var(--danger); }
.result-row .rplace { font-size: 1.4rem; width: 36px; }
.result-row .rname { flex: 1; text-align: left; font-weight: 700; }
.result-row .rtag { font-weight: 700; opacity: .8; }
.earned { margin: 16px 0; display: flex; flex-direction: column; gap: 8px; }
.ach-chip { background: var(--panel); border-radius: 10px; padding: 10px 12px; text-align: left; }
.over-actions { display: flex; gap: 12px; justify-content: center; margin-top: 10px; }

/* ---------------- modals ---------------- */
.modal { position: fixed; inset: 0; background: rgba(8, 5, 24, .7); display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 50; backdrop-filter: blur(4px); }
.modal[hidden] { display: none; }
.modal-box { background: var(--bg-2); border-radius: 18px; padding: 22px; max-width: 460px; width: 100%; max-height: 86dvh; overflow-y: auto; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.modal-box h2 { margin: 0 0 4px; }
.howto-body p, .howto-body li { line-height: 1.55; color: var(--ink); }
.howto-body ul { padding-left: 18px; }
.howto-body b { color: var(--gold); }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.muted { color: var(--ink-dim); }

.stat-card { background: var(--panel); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.stat-card h3 { margin: 0 0 8px; }
.stat-grid { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 4px 10px; font-size: .95rem; }
.stat-grid span { color: var(--ink-dim); }
.stat-grid b { text-align: right; }
.ach-count { margin: 12px 0 8px; font-weight: 700; font-size: 13px; color: var(--gold); }

/* ---------------- achievements board ---------------- */
.achievements-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 460px) { .achievements-grid { grid-template-columns: 1fr 1fr; } }
.achievement-card { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 12px; background: var(--bg-3); box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); text-align: left; }
.achievement-card.is-unlocked { background: linear-gradient(180deg, rgba(255,210,63,.18), rgba(245,166,35,.1)); box-shadow: inset 0 0 0 1.5px rgba(255,210,63,.5); }
.achievement-card.is-locked { opacity: .45; filter: grayscale(.5); }
.achievement-icon { font-size: 1.4rem; line-height: 1; width: 30px; text-align: center; flex: 0 0 auto; }
.achievement-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.achievement-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.achievement-desc { font-size: 12px; color: var(--ink-dim); line-height: 1.3; }
/* difficulty chip (easy / medium / hard / rare) */
.ach-tier { flex: 0 0 auto; align-self: flex-start; font-size: 9px; font-weight: 800; letter-spacing: .05em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 999px; color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.ach-tier-easy   { background: #2f9e57; }
.ach-tier-medium { background: #2f7bd0; }
.ach-tier-hard   { background: #c9603a; }
.ach-tier-rare   { background: linear-gradient(135deg, #b07bff, #f5a623); }
.achievement-card.is-locked .ach-tier { box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }

/* Game-over unlock banner reuses the same tile. */
.earned .achievement-card.is-unlocked { animation: pulse 1.6s ease-in-out 2; }

/* section headings inside the stats modal */
.ach-section-title { margin: 14px 0 6px; font-weight: 750; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-dim); }

/* lifetime-goal progress bars */
.ach-progress { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.ach-progress-track { flex: 1; height: 7px; border-radius: 999px; background: rgba(0,0,0,.3); overflow: hidden; }
.ach-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #b07bff); border-radius: 999px; transition: width .4s ease-out; }
.achievement-card.has-progress.is-unlocked .ach-progress-fill { background: linear-gradient(90deg, #ffd97c, #f5a623); }
.ach-progress-label { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-dim); flex: 0 0 auto; min-width: 36px; text-align: right; }

/* recent-results sparkline (one bar per game, taller = better) */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 38px; padding: 2px; }
.spark-bar { width: 7px; border-radius: 3px; background: var(--ink-dim); opacity: .85; }
.spark-bar.win { background: var(--gold); opacity: 1; }
.spark-bar.mid { background: var(--accent); }
.spark-bar.shit { background: var(--danger); }

/* ---------------- toast / banner ---------------- */
.toast-host { position: fixed; bottom: 90px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 60; }
.toast { background: var(--bg-3); color: var(--ink); padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: .3s; font-weight: 600; }
.toast.show { opacity: 1; transform: none; }
.banner-host { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 70; }
.banner-host.show { display: flex; }
.banner-host.blocking { background: var(--felt); }
.pass-card { text-align: center; padding: 30px; max-width: 360px; }
.pass-card h2 { font-size: 1.6rem; }
.pass-card p { color: var(--ink-dim); line-height: 1.5; margin-bottom: 22px; }

@media (min-width: 700px) {
  :root { --card-w: 84px; }
  [data-card-size="m"] { --card-w: 84px; }
  .opp { min-width: 120px; }
}
