/* ============ Three Thirteen · Modern design system ============ */
:root {
  --bg: #161210;
  --ink: #f4ecdc;
  --ink-dim: #c9bba0;
  --muted: #9c8e77;
  --gold: #e9b95c;
  --gold-soft: #f4d48a;
  --crimson: #d4565f;
  --teal: #58b8a6;
  --panel: rgba(24, 19, 14, 0.78);
  --panel-solid: #1e1811;
  --panel-2: rgba(255, 244, 214, 0.055);
  --border: rgba(233, 185, 92, 0.16);
  --border-strong: rgba(233, 185, 92, 0.34);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --radius: 18px;
  --radius-sm: 12px;
  --tap: 52px;
  --card-w: clamp(62px, 16.5vw, 92px);
  --card-h: calc(var(--card-w) * 1.4);
  font-size: 17px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.has-wood { background-size: cover; background-attachment: fixed; background-position: center; }

button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

/* ---------- Buttons & fields ---------- */
.btn {
  min-height: var(--tap);
  min-width: 56px;
  padding: 0.7rem 1.15rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, rgba(246, 205, 110, 0.16), rgba(246, 205, 110, 0.05));
  color: var(--gold-soft);
  font-weight: 750;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 12px rgba(0, 0, 0, 0.22);
  transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--gold-soft);
  outline-offset: 2px;
}
.btn.primary {
  background: linear-gradient(180deg, #f0c368, #ce9a3a);
  color: #2a1c08;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(240, 195, 104, 0.28);
}
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-dim); }
.btn.danger { background: linear-gradient(180deg, rgba(212, 86, 95, 0.25), rgba(212, 86, 95, 0.1)); color: #f4a8ad; border-color: rgba(212, 86, 95, 0.4); }
.btn.small { min-height: 42px; padding: 0.45rem 0.85rem; font-size: 0.92rem; }
.btn.icon { min-width: var(--tap); padding: 0.55rem 0.8rem; }

input[type="text"], input:not([type]), input[type="number"], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(10, 8, 5, 0.65);
  color: var(--ink);
  font-size: 1.05rem;
}
label.field { display: grid; gap: 0.4rem; font-weight: 700; color: var(--ink-dim); font-size: 0.94rem; }
.switch { display: flex; align-items: center; gap: 0.7rem; min-height: var(--tap); font-weight: 650; cursor: pointer; }
.switch input { width: 26px; height: 26px; min-height: 0; accent-color: var(--gold); }

/* ---------- Layout shell ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem max(0.75rem, env(safe-area-inset-left)) 0.55rem max(0.75rem, env(safe-area-inset-right));
  background: rgba(16, 12, 8, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  min-height: 60px;
}
.topbar > * { flex-shrink: 0; }
.topbar .brand { flex-shrink: 1; min-width: 0; }
.topbar .spacer { flex-shrink: 1; min-width: 0; }
.brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 850; font-size: 1.12rem; letter-spacing: 0.02em; }
.brand .crest { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(150deg, #f0c368, #a97c2e); color: #241808; font-size: 1.15rem; box-shadow: var(--shadow-md); }
.topbar .spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.42rem 0.85rem; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border);
  font-weight: 750; font-size: 0.92rem; white-space: nowrap;
}
.pill .wild { color: var(--gold-soft); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #7a7166; }
.dot.on { background: #63d489; box-shadow: 0 0 8px #63d48988; }
.dot.off { background: var(--crimson); }

.page { width: min(1240px, 100%); margin: 0 auto; padding: clamp(0.6rem, 2.4vw, 1.4rem); padding-bottom: calc(1.4rem + env(safe-area-inset-bottom)); }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}
.panel.pad { padding: clamp(0.9rem, 2.4vw, 1.4rem); }
h1, h2, h3 { margin: 0 0 0.55rem; line-height: 1.15; }
h1 { font-size: clamp(1.9rem, 6vw, 3.2rem); letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; color: var(--gold-soft); }
small, .muted { color: var(--muted); }

/* ---------- Home ---------- */
.hero { display: grid; gap: 1.2rem; align-content: start; }
.hero-card { text-align: center; padding: clamp(1.4rem, 5vw, 3rem) clamp(1rem, 4vw, 2.4rem); }
.hero-card p { color: var(--ink-dim); max-width: 46ch; margin: 0.4rem auto 1.2rem; font-size: 1.05rem; }
.name-form { display: grid; gap: 0.7rem; max-width: 380px; margin: 0 auto; }
.quick-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }
.quick-actions .btn { flex: 1 1 150px; max-width: 220px; }

.session { display: flex; gap: 0.9rem; align-items: center; flex-wrap: wrap; padding: 0.85rem 1rem; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px solid var(--border); }
.session .meta { flex: 1 1 220px; min-width: 0; }
.session .badge, .session .code { flex-shrink: 0; }
.session .meta strong { display: block; font-size: 1.06rem; }
.session .meta small { display: block; }
.session .code { font-family: ui-monospace, monospace; letter-spacing: 0.12em; color: var(--gold); font-weight: 800; }
.badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.82rem; font-weight: 750; border: 1px solid var(--border); background: rgba(0,0,0,0.28); }
.badge.live { color: #ffd98a; border-color: var(--border-strong); }
.badge.lobby { color: var(--teal); }
.badge.bot { color: #a9d7ff; }

/* ---------- Lobby ---------- */
.lobby-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 860px) { .lobby-grid { grid-template-columns: 1.1fr 1fr; align-items: start; } }
.player-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.75rem; border-radius: var(--radius-sm); background: var(--panel-2); }
.player-row + .player-row { margin-top: 0.45rem; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 850; font-size: 1.1rem; color: #241808; background: linear-gradient(150deg, #f0c368, #b8873a); flex: 0 0 auto; }
.avatar.bot { background: linear-gradient(150deg, #9cc6f2, #4a7bb5); color: #0c1a2c; }
.player-row .who { flex: 1; min-width: 0; }
.player-row .who strong { font-size: 1.05rem; display: block; }
.settings-grid { display: grid; gap: 0.15rem; }
.deck-pick { display: grid; gap: 0.55rem; }
.deck-option { display: flex; gap: 0.75rem; align-items: center; padding: 0.6rem 0.7rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel-2); cursor: pointer; min-height: var(--tap); }
.deck-option.selected { border-color: var(--gold); background: rgba(240, 195, 104, 0.1); }
.deck-option img, .deck-thumb-blank { width: 40px; height: 56px; border-radius: 6px; object-fit: cover; background: linear-gradient(140deg, #2e4a75, #1a2438); flex: 0 0 auto; }
.deck-option .cond { margin-left: auto; font-weight: 800; color: var(--gold-soft); }

/* ---------- Game screen ---------- */
.game { display: grid; gap: 0.75rem; padding-bottom: 84px; }
@media (min-width: 1080px) {
  .game { grid-template-columns: minmax(0, 1fr) 330px; }
  .game > .rail, .game > .table-card, .game > .staging, .game > .hand-zone { grid-column: 1; }
  .game > .feed-col { grid-column: 2; grid-row: 1 / 8; position: sticky; top: 72px; align-self: start; max-height: calc(100vh - 88px); overflow: auto; display: block !important; }
  .fullscreen-fab { display: none !important; }
}

.rail { display: flex; gap: 0.55rem; overflow-x: auto; padding: 0.15rem 0.05rem 0.4rem; scrollbar-width: thin; }
.opponent { position: relative; min-width: 168px; flex: 1 0 168px; max-width: 240px; padding: 0.55rem 0.6rem; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--border); transition: box-shadow 0.25s, border-color 0.25s; }
.opponent.turn { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(240, 195, 104, 0.55), 0 0 26px rgba(240, 195, 104, 0.22); }
.opponent.moving { animation: oppBump 0.45s ease; }
@keyframes oppBump { 40% { transform: translateY(-4px); } }
.opponent .head { display: flex; align-items: center; gap: 0.5rem; }
.opponent .head .avatar { width: 34px; height: 34px; font-size: 0.95rem; }
.opponent .head .who { min-width: 0; flex: 1; }
.opponent .head .who strong { display: block; font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opponent .head .who small { display: block; }
.opponent .pts { font-weight: 850; color: var(--gold-soft); font-size: 1.02rem; }
.self-player { position: sticky; left: 0; z-index: 4; min-width: 190px; border-color: rgba(88, 184, 166, 0.48); background: var(--panel-solid); }
.self-player.turn { border-color: var(--gold); }
.self-standing { display: grid; grid-template-columns: 1fr 1.25fr; gap: 0.4rem; margin-top: 0.55rem; }
.self-standing > span { display: grid; place-items: center; min-width: 0; padding: 0.42rem 0.3rem; border-radius: 9px; background: var(--panel-2); text-align: center; }
.self-standing b { color: var(--gold-soft); font-size: 1.08rem; line-height: 1.1; white-space: nowrap; }
.self-standing small { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; }
.self-watching { margin-top: 0.55rem; color: var(--muted); font-size: 0.8rem; }
.mini-rack { display: grid; gap: 4px; margin-top: 0.55rem; }
.mini-row { display: flex; height: 34px; padding-left: 6px; }
.mini-card { width: 24px; height: 33px; margin-left: -6px; border-radius: 4px; background: linear-gradient(135deg, #33517e 0%, #22344f 55%, #16233a 100%); border: 1px solid #e8dcc4; box-shadow: 0 1px 3px rgba(0,0,0,0.55); flex: 0 0 auto; background-size: cover; background-position: center; }
.mini-staging { display: flex; gap: 7px; margin-top: 5px; flex-wrap: wrap; }
.mini-group { position: relative; display: flex; padding: 10px 5px 3px 6px; border: 2px solid var(--group-color, var(--gold)); border-radius: 8px; background: rgba(255, 255, 255, 0.05); }
.mini-group b { position: absolute; top: -7px; left: 5px; font-size: 0.68rem; color: var(--group-color, var(--gold)); background: var(--panel-solid); padding: 0 3px; border-radius: 4px; }
.mini-group .mini-card { width: 19px; height: 26px; }

/* ---------- Table ---------- */
.table-card {
  position: relative;
  scroll-margin-top: 62px;
  border-radius: 26px;
  border: 1px solid var(--border);
  background: radial-gradient(120% 130% at 50% 0%, rgba(78, 52, 26, 0.5), rgba(20, 13, 8, 0.42) 60%), rgba(12, 9, 6, 0.35);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.45), var(--shadow-md);
  min-height: clamp(230px, 34vh, 400px);
  display: grid;
  grid-template-columns: 1fr auto auto 1fr;
  align-items: center;
  gap: clamp(0.4rem, 3vw, 1.4rem);
  padding: clamp(0.9rem, 3vw, 1.6rem);
}
.turn-banner {
  position: absolute;
  top: 0.8rem; left: 50%; transform: translateX(-50%);
  padding: 0.5rem 1.3rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #f0c368, #ce9a3a);
  color: #2a1c08; font-weight: 850; font-size: 1.05rem;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  z-index: 3;
}
.turn-banner.wait { background: rgba(20, 15, 9, 0.85); color: var(--ink-dim); border: 1px solid var(--border); }
.pile-zone { display: grid; justify-items: center; gap: 0.55rem; position: relative; }
.pile { position: relative; width: var(--card-w); height: var(--card-h); border-radius: 10px; cursor: pointer; transition: transform 0.15s ease; border: 0; background: none; padding: 0; }
.pile:active { transform: scale(0.96); }
.pile .depth { position: absolute; inset: 0; border-radius: 10px; background: #efe4cd; border: 1px solid #241d14; }
.pile .face { position: relative; z-index: 2; }
.pile-count { font-weight: 750; font-size: 0.95rem; color: var(--ink-dim); text-align: center; }
.pile .glow { position: absolute; inset: -12px; border-radius: 18px; background: radial-gradient(circle, rgba(240,195,104,0.3), transparent 65%); opacity: 0; transition: opacity 0.2s; z-index: 0; }
.pile.can-draw .glow, .pile.drop-ready .glow { opacity: 1; }
.latest-action { grid-column: 1 / -1; text-align: center; color: var(--gold-soft); font-weight: 650; min-height: 1.4em; }

/* Deck slab (cut phase) */
.deck-slab { grid-column: 2 / 4; display: grid; justify-items: center; gap: 0.8rem; position: relative; animation: cutControlsReady 2.45s step-end both; }
.slab { position: relative; width: min(430px, 82vw); height: 96px; cursor: crosshair; border-radius: 12px; touch-action: manipulation; }
.slab .edge { position: absolute; inset: 0; border-radius: 12px; background: linear-gradient(180deg, #f2e7d0, #cdbb97); border: 1px solid #241d14; box-shadow: 0 10px 22px rgba(0,0,0,0.5); }
.slab .edge::after { content: ""; position: absolute; inset: 0; border-radius: 12px; background: repeating-linear-gradient(90deg, rgba(60,45,25,0.16) 0 2px, transparent 2px 4px); }
.cut-marker { position: absolute; top: -12px; bottom: -12px; width: 5px; border-radius: 3px; background: var(--gold); box-shadow: 0 0 14px rgba(240,195,104,0.9); transform: translateX(-50%); }
.shuffle-theater { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 1rem; width: min(520px, 92%); min-height: 104px; margin: 2.4rem auto 0.15rem; padding: 0.55rem 0.8rem; border-radius: 16px; border: 1px solid var(--border); background: rgba(7, 5, 3, 0.34); overflow: hidden; }
.shuffle-packets { position: relative; flex: 0 0 190px; height: 80px; perspective: 500px; }
.shuffle-packet, .shuffle-block { position: absolute; left: 67px; top: 27px; width: 58px; height: 38px; transform-style: preserve-3d; }
.shuffle-packet i, .shuffle-block i { position: absolute; inset: 0; border-radius: 5px; border: 1px solid #e9deca; background: linear-gradient(135deg, #33517e, #17253b); box-shadow: 0 2px 5px rgba(0,0,0,0.48); }
.shuffle-packet i:nth-child(2), .shuffle-block i:nth-child(2) { transform: translate(2px, 2px); }
.shuffle-packet i:nth-child(3), .shuffle-block i:nth-child(3) { transform: translate(4px, 4px); }
.shuffle-packet i:nth-child(4) { transform: translate(6px, 6px); }
.shuffle-packet i:nth-child(5) { transform: translate(8px, 8px); }
.shuffle-packet.left { animation: riffleLeft 2.45s cubic-bezier(.45,.05,.25,1) both; }
.shuffle-packet.right { animation: riffleRight 2.45s cubic-bezier(.45,.05,.25,1) both; }
.shuffle-block { z-index: 4; opacity: 0; animation: blockLift 2.45s ease both; animation-play-state: paused; }
.shuffle-theater.with-block-transfer .shuffle-block { animation-play-state: running; }
.shuffle-caption { display: grid; gap: 0.12rem; min-width: 0; }
.shuffle-caption b { color: var(--gold-soft); }
.shuffle-caption span, .shuffle-caption small { color: var(--ink-dim); }
@keyframes riffleLeft {
  0%, 8% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-48px) rotate(-7deg); }
  48% { transform: translateX(-16px) rotate(-3deg) skewY(5deg); }
  66%, 100% { transform: translateX(0) rotate(0); }
}
@keyframes riffleRight {
  0%, 8% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(48px) rotate(7deg); }
  48% { transform: translateX(16px) rotate(3deg) skewY(-5deg); }
  66%, 100% { transform: translateX(0) rotate(0); }
}
@keyframes blockLift {
  0%, 65% { opacity: 0; transform: translate(0, 0); }
  69% { opacity: 1; transform: translate(8px, -2px); }
  83% { opacity: 1; transform: translate(-28px, -24px) rotate(-5deg); }
  96% { opacity: 1; transform: translate(5px, 1px); }
  100% { opacity: 0; transform: translate(0, 0); }
}
@keyframes cutControlsReady {
  0%, 99% { opacity: 0.52; pointer-events: none; filter: saturate(0.55); }
  100% { opacity: 1; pointer-events: auto; filter: none; }
}
@media (max-width: 520px) {
  .shuffle-theater { gap: 0.45rem; padding-inline: 0.45rem; }
  .shuffle-packets { flex-basis: 155px; transform: scale(0.82); margin-inline: -12px; }
  .shuffle-caption { font-size: 0.82rem; }
}

/* ---------- Hand zone ---------- */
.hand-zone { border-radius: var(--radius); background: linear-gradient(180deg, rgba(18, 13, 9, 0.55), rgba(14, 10, 7, 0.85)); border: 1px solid var(--border); padding: 0.6rem; padding-bottom: 0.75rem; }
.hand-bar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.55rem; min-height: 52px; }
.hand-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); margin: 0.55rem 0 0; }
.hand-control-primary { grid-column: 2; display: flex; justify-content: center; min-width: 0; }
.hand-control-secondary { grid-column: 3; display: flex; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.hand-bar .grow { flex: 1; }
.hand-hint { color: var(--muted); font-size: 0.92rem; }
.drawn-dock { display: flex; align-items: center; gap: 0.8rem; padding: 0.5rem 0.7rem; margin-top: 0.6rem; border-radius: var(--radius-sm); border: 2px dashed rgba(240, 195, 104, 0.45); background: rgba(240, 195, 104, 0.07); }
.drawn-dock .label { font-weight: 800; color: var(--gold-soft); }
.drawn-actions { display: grid; gap: 0.25rem; justify-items: center; }
.drawn-action-buttons { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
@media (max-width: 720px) {
  .hand-controls { grid-template-columns: 1fr; justify-items: center; }
  .hand-control-primary, .hand-control-secondary { grid-column: 1; justify-content: center; }
}
.hand-rack { display: grid; gap: 10px; min-height: calc(var(--card-h) + 14px); border-radius: 14px; padding: 0.55rem 0.45rem; background: rgba(8, 6, 4, 0.5); border: 1px solid var(--border); }
.hand-row { position: relative; display: flex; justify-content: center; padding-left: calc(var(--card-w) * 0.34); min-height: var(--card-h); }
.hand-row .card { margin-left: calc(var(--card-w) * -0.34); }
/* Fan overlap direction is a per-user display preference, because artwork
   differs: standard art has the value in the TOP-LEFT corner (left cards must
   sit on top), while the Regal Foil art has it TOP-RIGHT (right cards on top).
   Default paints natural DOM order (right cards on top). Selecting
   "values on the left" flips it via .fan-lefttop. */
.app-root.fan-lefttop .hand-row .card:nth-child(1), .app-root.fan-lefttop .stage-cards .card:nth-child(1), .app-root.fan-lefttop .deck-fan .card:nth-child(1) { z-index: 30; }
.app-root.fan-lefttop .hand-row .card:nth-child(2), .app-root.fan-lefttop .stage-cards .card:nth-child(2), .app-root.fan-lefttop .deck-fan .card:nth-child(2) { z-index: 29; }
.app-root.fan-lefttop .hand-row .card:nth-child(3), .app-root.fan-lefttop .stage-cards .card:nth-child(3), .app-root.fan-lefttop .deck-fan .card:nth-child(3) { z-index: 28; }
.app-root.fan-lefttop .hand-row .card:nth-child(4), .app-root.fan-lefttop .stage-cards .card:nth-child(4), .app-root.fan-lefttop .deck-fan .card:nth-child(4) { z-index: 27; }
.app-root.fan-lefttop .hand-row .card:nth-child(5), .app-root.fan-lefttop .stage-cards .card:nth-child(5), .app-root.fan-lefttop .deck-fan .card:nth-child(5) { z-index: 26; }
.app-root.fan-lefttop .hand-row .card:nth-child(6), .app-root.fan-lefttop .stage-cards .card:nth-child(6), .app-root.fan-lefttop .deck-fan .card:nth-child(6) { z-index: 25; }
.app-root.fan-lefttop .hand-row .card:nth-child(7), .app-root.fan-lefttop .stage-cards .card:nth-child(7), .app-root.fan-lefttop .deck-fan .card:nth-child(7) { z-index: 24; }
.app-root.fan-lefttop .hand-row .card:nth-child(8), .app-root.fan-lefttop .stage-cards .card:nth-child(8), .app-root.fan-lefttop .deck-fan .card:nth-child(8) { z-index: 23; }
.app-root.fan-lefttop .hand-row .card:nth-child(9), .app-root.fan-lefttop .stage-cards .card:nth-child(9), .app-root.fan-lefttop .deck-fan .card:nth-child(9) { z-index: 22; }
.app-root.fan-lefttop .hand-row .card:nth-child(10), .app-root.fan-lefttop .stage-cards .card:nth-child(10), .app-root.fan-lefttop .deck-fan .card:nth-child(10) { z-index: 21; }
.app-root.fan-lefttop .hand-row .card:nth-child(11), .app-root.fan-lefttop .stage-cards .card:nth-child(11) { z-index: 20; }
.app-root.fan-lefttop .hand-row .card:nth-child(12), .app-root.fan-lefttop .stage-cards .card:nth-child(12) { z-index: 19; }
.app-root.fan-lefttop .hand-row .card:nth-child(13), .app-root.fan-lefttop .stage-cards .card:nth-child(13) { z-index: 18; }
.app-root.fan-lefttop .hand-row .card:nth-child(14), .app-root.fan-lefttop .stage-cards .card:nth-child(14) { z-index: 17; }
.app-root.fan-lefttop .hand-row .card:nth-child(15), .app-root.fan-lefttop .stage-cards .card:nth-child(15) { z-index: 16; }
.hand-row .card.selected { z-index: 45; }
.hand-row .card.dragging, .stage-cards .card.dragging { z-index: 60; }
.hand-row.drop-ready { background: rgba(240, 195, 104, 0.055); border-radius: 10px; outline: 2px solid rgba(240, 195, 104, 0.28); }
.insert-marker { position: absolute; z-index: 70; top: -5px; bottom: -5px; width: 24px; transform: translateX(-50%); border-radius: 12px; border: 2px solid rgba(255, 224, 146, 0.95); background: rgba(240, 195, 104, 0.18); box-shadow: 0 0 10px rgba(240,195,104,0.9), 0 0 24px rgba(240,195,104,0.55), inset 0 0 10px rgba(255,255,255,0.18); pointer-events: none; animation: insertLanePulse 0.7s ease-in-out infinite alternate; }
.insert-marker::before { content: ""; position: absolute; top: 7px; bottom: 7px; left: 50%; width: 4px; transform: translateX(-50%); border-radius: 999px; background: #ffe092; box-shadow: 0 0 8px #ffe092; }
.insert-marker::after { content: "DROP HERE"; position: absolute; left: 50%; bottom: -25px; transform: translateX(-50%); white-space: nowrap; padding: 2px 6px; border-radius: 999px; background: #2b1d0a; color: #ffe092; border: 1px solid rgba(255,224,146,0.7); font-size: 0.62rem; font-weight: 900; letter-spacing: 0.05em; }
@keyframes insertLanePulse { from { opacity: 0.72; } to { opacity: 1; } }

/* ---------- Card ---------- */
.card {
  position: relative; isolation: isolate; width: var(--card-w); height: var(--card-h);
  border-radius: calc(var(--card-w) * 0.09);
  background: #fdfaf1; color: #181510;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.45);
  user-select: none; -webkit-user-select: none; touch-action: none;
  flex: 0 0 auto; cursor: grab;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.2s;
  overflow: hidden;
  background-size: cover; background-position: center;
}
.card.procedural { border: 1px solid #1c1712; }
.card .corner { position: absolute; display: grid; justify-items: center; line-height: 0.95; font-family: Georgia, serif; font-weight: 800; font-size: calc(var(--card-w) * 0.23); z-index: 2; }
.card .corner.tl { top: 7%; left: 8%; }
.card .corner.br { right: 8%; bottom: 7%; transform: rotate(180deg); }
.card.red { color: #a41425; }
.card .center { position: absolute; inset: 17% 13%; display: grid; place-items: center; font-family: Georgia, serif; font-size: calc(var(--card-w) * 0.58); }
.card .joker-word { font-size: calc(var(--card-w) * 0.15); letter-spacing: 0.14em; writing-mode: vertical-rl; font-weight: 800; }
.card.back, .card.mini-back { background: linear-gradient(135deg, #33517e, #16233a); background-size: cover; background-position: center; border: calc(var(--card-w) * 0.05) solid #f4ead7; }
.card.selected { transform: translateY(-14px) scale(1.03); box-shadow: 0 0 0 3px var(--gold), 0 16px 26px rgba(0,0,0,0.55); z-index: 9; }
.card.dragging { opacity: 0.92; cursor: grabbing; z-index: 60; box-shadow: 0 22px 40px rgba(0,0,0,0.6); }
.card.wild::after { content: ""; position: absolute; inset: -45% -80%; background: linear-gradient(105deg, transparent 42%, rgba(255, 247, 196, 0.5) 50%, transparent 58%); animation: sheen 3.6s ease-in-out infinite; pointer-events: none; z-index: 3; }
.card.wild-marked { box-shadow: 0 0 0 3px #65d7c0, 0 0 18px rgba(88, 184, 166, 0.72), 0 5px 14px rgba(0, 0, 0, 0.45); }
.card.wild-marked::before { content: "WILD"; position: absolute; z-index: 7; top: 3px; left: 50%; transform: translateX(-50%); padding: 1px 4px; border-radius: 999px; background: #167866; color: #fff; font: 900 8px/1.25 ui-sans-serif, system-ui, sans-serif; letter-spacing: 0.08em; box-shadow: 0 1px 4px rgba(0,0,0,0.55); pointer-events: none; }
@keyframes sheen { 0%, 55% { transform: translateX(-55%) rotate(4deg); } 85%, 100% { transform: translateX(55%) rotate(4deg); } }
.card .wear { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply; z-index: 4; }
.card .wear::before { content: ""; position: absolute; width: 42%; height: 30%; left: var(--stain-x, 18%); top: var(--stain-y, 55%); border-radius: 50%; background: radial-gradient(ellipse, rgba(91, 55, 24, var(--stain-a, 0)), transparent 72%); transform: rotate(var(--stain-r, 12deg)); }
.card.folded::after { content: ""; position: absolute; right: -1px; top: -1px; width: 28%; height: 25%; clip-path: polygon(100% 0, 0 0, 100% 100%); background: linear-gradient(135deg, rgba(255,255,255,0.8), rgba(115,92,62,0.35)); z-index: 4; }
.card[data-fade="1"] { filter: saturate(0.92) contrast(0.97); }
.card[data-fade="2"] { filter: saturate(0.72) contrast(0.91) sepia(0.08); }
.card[data-fade="3"] { filter: saturate(0.48) contrast(0.83) sepia(0.18); }
.card.associated { box-shadow: 0 0 0 3px var(--assoc), 0 8px 16px rgba(0,0,0,0.45); }

/* ---------- Context action bar (tap-select fallback) ---------- */
.ctx-bar { display: flex; gap: 0.5rem; align-items: center; padding: 0.55rem 0.65rem; border-radius: 999px; background: rgba(14, 10, 7, 0.92); border: 1px solid var(--border-strong); box-shadow: var(--shadow-md); flex-wrap: wrap; }
.ctx-bar .label { width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; color: var(--gold-soft); padding: 0 0.4rem; font-size: 0.95rem; }

/* ---------- Round review ---------- */
.review-grid { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.review-player { padding: 0.7rem 0.8rem; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px solid var(--border); }
.review-player.out { border-color: rgba(88, 184, 166, 0.5); }
.review-player .head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.review-player .who { flex: 1; min-width: 0; }
.review-player .who strong { display: block; font-size: 1.05rem; }
.review-player .stuck { font-size: 1.35rem; font-weight: 850; color: #f4a8ad; }
.review-player .stuck.clean { color: var(--teal); }
.review-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0.4rem 0 0.25rem; }
.review-melds { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.review-meld { display: flex; flex: 0 0 auto; width: max-content; max-width: 100%; overflow-x: auto; padding: 0.3rem 0.3rem 0.3rem 12px; border-radius: 8px; background: rgba(88, 184, 166, 0.08); border: 1px solid rgba(88, 184, 166, 0.25); }
.review-meld .card, .review-card-fan .card { --card-w: 42px; width: 42px; min-width: 42px; max-width: 42px; height: 59px; min-height: 59px; max-height: 59px; flex: 0 0 42px; }
.review-meld .card { margin-left: -9px; }
.review-card-fan { display: flex; width: 100%; min-width: 0; overflow-x: auto; padding: 0.3rem 0.3rem 0.45rem 12px; }
.review-card-fan .card { margin-left: -7px; }
.review-card-fan.dead .card { filter: saturate(0.75) brightness(0.92); }
.laid-down-public { margin-top: 0.5rem; padding: 0.45rem; border-radius: 10px; border: 1px solid rgba(88, 184, 166, 0.5); background: rgba(88, 184, 166, 0.08); }
.laid-down-public > small { color: #8edbc9; font-weight: 800; }

/* ---------- Game finale ---------- */
.finale { position: relative; grid-column: 1; overflow: hidden; padding: clamp(1.2rem, 4vw, 2.4rem); text-align: center; background: radial-gradient(circle at 50% 12%, rgba(240,195,104,0.24), transparent 42%), var(--panel); border-color: rgba(240,195,104,0.55); }
.finale-hero { position: relative; z-index: 2; display: grid; justify-items: center; gap: 0.35rem; }
.finale-hero .trophy { display: grid; place-items: center; width: 74px; height: 74px; border-radius: 24px; background: linear-gradient(145deg, #ffe092, #b77b20); color: #291905; font-size: 2.5rem; box-shadow: 0 0 30px rgba(240,195,104,0.48); animation: trophyArrive 0.8s cubic-bezier(.2,.8,.2,1) both; }
.finale-kicker { color: var(--gold); font-size: 0.78rem; font-weight: 900; letter-spacing: 0.18em; margin-top: 0.35rem; }
.finale h1 { margin: 0.2rem 0 0; color: var(--gold-soft); }
.finale p { margin: 0; color: var(--ink-dim); font-size: 1.08rem; }
.last-round-note { margin-top: 0.4rem; padding: 0.35rem 0.75rem; border-radius: 999px; border: 1px solid rgba(88,184,166,0.45); background: rgba(88,184,166,0.1); color: #8edbc9; font-weight: 750; }
.final-standings { position: relative; z-index: 2; width: min(560px, 100%); margin: 1.25rem auto; padding: 0; display: grid; gap: 0.45rem; list-style: none; counter-reset: place; }
.final-standings li { display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 0.7rem; min-height: 56px; padding: 0.5rem 0.8rem; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--border); text-align: left; }
.final-standings li.winner { border-color: rgba(240,195,104,0.65); background: rgba(240,195,104,0.12); }
.final-standings li.is-me { box-shadow: inset 4px 0 0 var(--teal); }
.final-standings .place { text-align: center; color: var(--gold-soft); font-weight: 900; }
.final-points { color: var(--gold-soft); font-size: 1.15rem; font-weight: 900; }
.finale-actions { position: relative; z-index: 2; }
.fanfare { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fanfare i { position: absolute; top: -18px; left: calc(6% + (var(--i) * 8%)); width: 8px; height: 18px; border-radius: 3px; background: hsl(calc(35 + var(--i) * 24) 75% 62%); transform: rotate(calc(var(--i) * 29deg)); animation: confettiFall calc(1.8s + (var(--i) * .06s)) ease-out calc(var(--i) * .045s) both; }
@keyframes trophyArrive { from { transform: translateY(-18px) scale(.55) rotate(-12deg); opacity: 0; } 70% { transform: translateY(3px) scale(1.08); } }
@keyframes confettiFall { 0% { transform: translateY(-20px) rotate(0); opacity: 1; } 100% { transform: translateY(430px) rotate(620deg); opacity: 0; } }
.mini-staging.staged { border-left: 3px solid var(--gold); padding-left: 6px; }
.mini-staging.laid-down { border: 2px solid var(--teal); border-radius: 8px; padding: 5px 6px; background: rgba(88, 184, 166, 0.12); box-shadow: 0 0 14px rgba(88, 184, 166, 0.22); }

/* ---------- Staging ---------- */
.staging { border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); overflow: hidden; }
.staging.has-staged-cards { border-color: rgba(240, 195, 104, 0.58); box-shadow: inset 4px 0 0 rgba(240, 195, 104, 0.75); }
.staging.is-laid-down { border: 2px solid rgba(88, 184, 166, 0.9); background: linear-gradient(90deg, rgba(88, 184, 166, 0.16), var(--panel) 38%); box-shadow: 0 0 24px rgba(88, 184, 166, 0.22), inset 5px 0 0 var(--teal); }
.staging-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 0.85rem; flex-wrap: wrap; }
.staging-state { min-width: 8.6rem; text-align: center; padding: 0.35rem 0.55rem; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--muted); font-size: 0.76rem; font-weight: 900; letter-spacing: 0.07em; }
.has-staged-cards .staging-state { color: var(--gold-soft); border-color: rgba(240, 195, 104, 0.65); background: rgba(240, 195, 104, 0.1); }
.is-laid-down .staging-state { color: #10251f; border-color: transparent; background: var(--teal); }
.is-laid-down .staging-head strong { color: #8edbc9; }
.staging-head .grow { flex: 1 1 200px; min-width: 160px; }
.staging-head strong { font-size: 1.02rem; white-space: nowrap; }
.staging-head small { display: block; }
.staging-body { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.7rem; padding: 0.7rem 0.85rem; overflow-x: visible; border-top: 1px solid var(--border); min-height: calc(var(--card-h) + 46px); }
.staging-body.drop-ready { background: rgba(240, 195, 104, 0.06); }
.stage-group { min-width: min(240px, 100%); max-width: 100%; padding: 0.5rem 0.55rem 0.4rem; border-radius: 12px; border: 3px solid var(--group-color, var(--gold)); background: rgba(255, 255, 255, 0.045); }
.stage-group .ghead { display: flex; justify-content: space-between; gap: 0.8rem; font-size: 0.85rem; color: var(--ink-dim); margin-bottom: 0.4rem; align-items: center; }
.stage-cards { position: relative; display: flex; justify-content: center; align-items: center; min-height: calc(var(--card-h) + 14px); padding: 7px calc(var(--card-w) * 0.26) 7px calc(var(--card-w) * 0.52); border-radius: 10px; border: 2px dashed rgba(240,195,104,0.24); background: rgba(8,6,4,0.26); }
.stage-cards.drop-ready { border-color: rgba(255,224,146,0.82); background: rgba(240,195,104,0.09); }
.stage-cards .card { margin-left: calc(var(--card-w) * -0.26); }
.stage-new { align-self: stretch; border: 2px dashed var(--border-strong); border-radius: 12px; background: transparent; color: var(--ink-dim); font-weight: 700; min-width: 180px; min-height: calc(var(--card-h) + 42px); cursor: pointer; }
.touch-place-target {
  outline: 3px solid rgba(240, 195, 104, 0.85);
  outline-offset: 3px;
  box-shadow: 0 0 10px rgba(240, 195, 104, 0.75), 0 0 28px rgba(240, 195, 104, 0.38) !important;
  animation: touchTargetGlow 1.35s ease-in-out infinite alternate;
}
.drop-invalid { filter: grayscale(0.75) brightness(0.62) !important; box-shadow: none !important; }
@keyframes touchTargetGlow {
  from { outline-color: rgba(240, 195, 104, 0.55); box-shadow: 0 0 7px rgba(240, 195, 104, 0.48), 0 0 18px rgba(240, 195, 104, 0.22); }
  to { outline-color: rgba(255, 224, 146, 1); box-shadow: 0 0 13px rgba(255, 224, 146, 0.9), 0 0 34px rgba(240, 195, 104, 0.48); }
}

/* ---------- Feed / history column ---------- */
.feed-col { display: block; }
.feed { display: grid; gap: 0.8rem; align-content: start; }
.log { display: grid; gap: 0.35rem; max-height: 300px; overflow: auto; }
.log p { margin: 0; padding: 0.45rem 0.6rem; border-radius: 9px; background: var(--panel-2); font-size: 0.9rem; color: var(--ink-dim); }

/* ---------- Chat ---------- */
.fullscreen-fab { position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 45; width: 62px; height: 62px; border-radius: 50%; font-size: 1.5rem; display: grid; place-items: center; }
.drawer-backdrop, .modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(5, 4, 3, 0.66); backdrop-filter: blur(3px); display: grid; align-items: end; animation: fadeIn 0.16s ease; }
.modal-backdrop { align-items: center; justify-items: center; padding: 1rem; }
@keyframes fadeIn { from { opacity: 0; } }
.drawer { height: min(76dvh, 700px); background: var(--panel-solid); border-top: 1px solid var(--border-strong); border-radius: 22px 22px 0 0; display: grid; grid-template-rows: auto 1fr auto; padding: 0.8rem; gap: 0.6rem; animation: slideUp 0.22s ease; }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0.4; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.chat-log { overflow-y: auto; display: grid; align-content: start; gap: 0.4rem; padding: 0.2rem; }
.chat-msg { padding: 0.5rem 0.7rem; border-radius: 12px; background: var(--panel-2); }
.chat-msg.sys { background: transparent; color: var(--muted); font-style: italic; }
.chat-msg strong { color: var(--gold-soft); font-size: 0.85rem; display: block; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; }

/* ---------- Modal ---------- */
.modal { width: min(760px, 100%); max-height: 92dvh; overflow: auto; background: var(--panel-solid); border: 1px solid var(--border-strong); border-radius: 22px; padding: clamp(1rem, 3vw, 1.6rem); box-shadow: var(--shadow-lg); animation: slideUp 0.2s ease; }
.modal.wide { width: min(1100px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-bottom: 0.8rem; }
.modal-head h2 { margin: 0; }
.form-stack { display: grid; gap: 0.85rem; }
.art-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.7rem; }
.art-option { padding: 0.6rem; border-radius: var(--radius-sm); border: 2px solid var(--border); background: var(--panel-2); cursor: pointer; text-align: center; }
.art-option.selected { border-color: var(--gold); }
.art-option img { width: 64px; height: 90px; border-radius: 8px; object-fit: cover; }
.art-option b { display: block; margin-top: 0.4rem; }

/* ---------- Scoresheet ---------- */
.scoresheet-wrap { color: #2c241b; background: #f3e7c7; background-image: repeating-linear-gradient(0deg, transparent 0 31px, rgba(91, 123, 162, 0.2) 32px 33px); border-radius: 6px; padding: 22px 16px 26px 52px; box-shadow: var(--shadow-lg); transform: rotate(-0.2deg); overflow: auto; font-family: "Segoe Print", "Bradley Hand", ui-rounded, cursive; }
.scoresheet-wrap h2 { color: #40382d; }
.score-table { border-collapse: collapse; min-width: 620px; width: 100%; font-size: 1rem; color: #322b22; }
.score-table th, .score-table td { height: 33px; padding: 3px 10px; text-align: center; border-right: 1px solid rgba(46, 50, 55, 0.16); }
.score-table th:first-child, .score-table td:first-child { text-align: left; position: sticky; left: 0; background: rgba(243, 231, 199, 0.94); }
.score-table .total-row { border-top: 3px solid #40382d; font-weight: 900; font-size: 1.12rem; }
.score-cell small { display: block; color: #6d6255; }

/* ---------- Deck manager ---------- */
.deck-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); }
.deck-tile { padding: 1rem; display: grid; gap: 0.6rem; }
.deck-tile .top { display: flex; gap: 0.8rem; align-items: center; }
.deck-tile .stats { display: flex; gap: 1rem; flex-wrap: wrap; color: var(--ink-dim); font-size: 0.92rem; }
.cond-ring { --pct: 100; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--gold) calc(var(--pct) * 1%), rgba(255,255,255,0.08) 0); margin-left: auto; flex: 0 0 auto; }
.cond-ring span { width: 44px; height: 44px; border-radius: 50%; background: var(--panel-solid); display: grid; place-items: center; font-weight: 850; font-size: 0.86rem; }
.deck-fan { display: flex; align-items: center; min-height: 104px; overflow: hidden; }
.deck-fan .card { --card-w: 64px; margin-left: -34px; }
.art-library { display: grid; gap: 0.55rem; }
.art-library-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.7rem; border-radius: 12px; border: 1px solid var(--border); background: var(--panel-2); }
.art-library-row img, .art-library-row .deck-thumb-blank { width: 44px; height: 62px; border-radius: 6px; object-fit: cover; flex: 0 0 auto; }
.art-library-row .grow { min-width: 0; }

/* Deck detail + shuffle viewer */
.artwork-deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: clamp(5px, 0.8vw, 10px); padding: 0.75rem; border-radius: var(--radius-sm); background: rgba(8, 6, 4, 0.55); border: 1px solid var(--border); }
.artwork-deck-grid .card { --card-w: min(100%, 78px); width: var(--card-w); justify-self: center; cursor: default; }
.deck-order-details { margin-top: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel-2); overflow: hidden; }
.deck-order-details summary { min-height: 52px; display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 0.8rem; cursor: pointer; list-style-position: inside; }
.deck-order-details summary b { color: var(--ink); }
.deck-order-details summary small { color: var(--muted); margin-left: auto; text-align: right; }
.deck-order-details[open] summary { border-bottom: 1px solid var(--border); }
.deck-order-details .order-strip { border: 0; border-radius: 0; }
.order-strip { display: flex; flex-wrap: wrap; gap: 3px; padding: 0.7rem; border-radius: var(--radius-sm); background: rgba(8, 6, 4, 0.55); border: 1px solid var(--border); max-height: 46dvh; overflow: auto; }
.order-strip .mini { width: 30px; height: 42px; border-radius: 4px; background: #fdfaf1; color: #181510; display: grid; place-items: center; font-weight: 800; font-size: 0.62rem; font-family: Georgia, serif; line-height: 1; flex: 0 0 auto; background-size: cover; background-position: center; }
.order-strip .mini.red { color: #a41425; }
.order-strip .mini.moved { outline: 3px solid var(--gold); box-shadow: 0 0 9px rgba(240,195,104,0.75); }
.order-strip .mini.backside { background: linear-gradient(135deg, #33517e, #16233a); background-size: cover; }
.order-strip .mini.custom { color: transparent; background-repeat: no-repeat; }
.shuffle-steps { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.step-meta { flex: 1; min-width: 160px; }
.step-meta b { color: var(--gold-soft); }
input[type="range"].step-range { width: 100%; accent-color: var(--gold); min-height: 44px; }

/* ---------- Toasts ---------- */
.toast-region { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(1.1rem + env(safe-area-inset-bottom)); display: grid; gap: 0.5rem; width: min(430px, 92vw); }
.toast { display: grid; gap: 0.55rem; background: #241c11; color: var(--ink); border: 1px solid var(--border-strong); border-radius: 14px; padding: 0.75rem 0.9rem; box-shadow: var(--shadow-lg); animation: slideUp 0.2s ease; }
.toast.error { border-color: rgba(212, 86, 95, 0.6); }
.toast .btn { width: 100%; white-space: normal; min-height: 48px; padding: 0.5rem 0.8rem; }

.empty { padding: 1.3rem; text-align: center; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.divider { height: 1px; background: var(--border); margin: 0.7rem 0; }
.hidden { display: none !important; }

/* ---------- Card size preference ---------- */
.app-root[data-cardsize="s"] { --card-w: clamp(52px, 14vw, 74px); }
.app-root[data-cardsize="m"] { --card-w: clamp(62px, 16.5vw, 92px); }
.app-root[data-cardsize="l"] { --card-w: clamp(74px, 19vw, 108px); }
.app-root[data-cardsize="xl"] { --card-w: clamp(86px, 22vw, 126px); }

@media (min-width: 900px) {
  :root { --card-w: 84px; }
  .app-root[data-cardsize="m"] { --card-w: 84px; }
  .app-root[data-cardsize="l"] { --card-w: 100px; }
  .app-root[data-cardsize="xl"] { --card-w: 118px; }
}

@media (max-width: 720px) {
  .page { padding: 0.35rem; padding-bottom: calc(0.7rem + env(safe-area-inset-bottom)); }
  .game { gap: 0.4rem; padding-bottom: 72px; }
  .rail { gap: 0.35rem; padding: 0.05rem 0 0.18rem; }
  .opponent { padding: 0.4rem 0.45rem; }
  .table-card { grid-template-columns: 1fr auto auto 1fr; min-height: 205px; gap: 0.3rem 0.65rem; padding: 0.45rem 0.35rem 0.4rem; }
  .turn-banner {
    position: relative;
    grid-column: 1 / -1;
    grid-row: 1;
    top: auto;
    left: auto;
    transform: none;
    justify-self: center;
    max-width: calc(100% - 0.5rem);
    margin: 0;
    padding: 0.38rem 0.72rem;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }
  .hand-zone { padding: 0.35rem; padding-bottom: 0.45rem; }
  .hand-rack { padding: 0.35rem 0.25rem; gap: 6px; }
  .hand-controls { margin-top: 0.32rem; gap: 0.3rem; }
  .ctx-bar { padding: 0.38rem 0.45rem; gap: 0.3rem; }
  .drawn-dock { margin-top: 0.35rem; padding: 0.38rem 0.45rem; gap: 0.5rem; }
  .staging-head { padding: 0.45rem 0.55rem; gap: 0.4rem; }
  .staging-body { padding: 0.45rem 0.55rem; gap: 0.45rem; }
  .stage-group { flex: 1 1 min(240px, 100%); }
  .latest-action { min-height: 1.1em; font-size: 0.86rem; }
  .pile-zone { gap: 0.3rem; }
  .pile-count { font-size: 0.84rem; }
  .brand span { max-width: 26vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
  .topbar { gap: 0.35rem; min-height: 56px; }
  .topbar .hide-sm { display: none; }
  .pill { padding: 0.38rem 0.6rem; font-size: 0.86rem; }
  .btn.icon { min-width: 46px; padding: 0.5rem 0.6rem; }
  .modal { max-height: 96dvh; }
}

:fullscreen body { min-height: 100dvh; }
:fullscreen .topbar { padding-top: max(0.35rem, env(safe-area-inset-top)); }

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