:root {
  /* Cards track the viewport, then the table container tightens them. */
  --card-w: clamp(48px, min(14vw, 11vh), 108px);
  --card-h: calc(var(--card-w) * 1.45);
  --card-face: #fffdf8;
  --card-ink: #1b140f;
  --suit-red: #9b1b2a;
  --suit-star: #8a5e08;
  --suit-club: #0e6a44;
  --drawn: #1b7a42;
  --gold-btn: #e6c27a;
  --on-felt: #f6efe4;
  --on-felt-gold: #f0d7a2;
  --danger-solid: #9d2433;
  --mark: #6e410c;
  --ink: #1b140f;
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
}
html[data-theme="dark"], html:not([data-theme]) {
  color-scheme: dark;
  --bg: #140e0c;
  --panel: #2a1814;
  --panel-2: #1a100e;
  --felt: #3a1418;
  --felt-2: #2a1014;
  --gold: #e6c27a;
  --gold-2: #a8843e;
  --text: #f4efe4;
  --muted: #cbbba6;
  --line: rgba(230, 194, 122, 0.35);
  --chip: #1c1210;
  --input: #120d0b;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  --danger-text: #ffb4b4;
  --overlay: rgba(8, 5, 4, 0.72);
  --ring: #e6c27a;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4ecdf;
  --panel: #fff9f1;
  --panel-2: #f3e6d4;
  --felt: #6d2832;
  --felt-2: #4c1b24;
  --gold: #8a5a12;
  --gold-2: #6e4714;
  --text: #1b140f;
  --muted: #5e4c3a;
  --line: rgba(90, 56, 20, 0.28);
  --chip: #fffdf8;
  --input: #fffdf8;
  --shadow: 0 10px 24px rgba(70, 42, 20, 0.12);
  --danger-text: #8d1e2c;
  --overlay: rgba(40, 24, 16, 0.45);
  --ring: #8a5a12;
}

* { box-sizing: border-box; }
html {
  font-size: clamp(16px, 14px + 0.25vw, 20px);
}
html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(ellipse at 50% 20%, color-mix(in srgb, var(--felt, #3a1418) 28%, transparent), transparent 52%),
    var(--bg);
  color: var(--text);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
body, button, .card {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea, select, .log, .link-line {
  -webkit-user-select: text;
  user-select: text;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
select { min-height: 44px; background: var(--input); color: var(--text); border: 1px solid var(--line); border-radius: 10px; }
#app { min-height: 100dvh; }

.screen {
  min-height: 100dvh;
  padding:
    calc(16px + env(safe-area-inset-top))
    calc(16px + env(safe-area-inset-right))
    calc(16px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
}

.setup {
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(157, 36, 51, 0.35), transparent 55%),
    var(--bg);
}
.setup-card {
  width: min(760px, 100%);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(16px, 3vw, 36px) clamp(14px, 2.4vw, 28px);
  box-shadow: var(--shadow);
}
.brand-mark {
  display: flex;
  gap: 14px;
  align-items: center;
}
.crown {
  width: 54px;
  height: 54px;
  flex: none;
}
h1 {
  font-size: clamp(1.7rem, 4vw + 0.6rem, 3.1rem);
  line-height: 0.95;
  margin: 0;
  letter-spacing: -0.03em;
}
h1 span { display: block; color: var(--gold); font-size: 0.62em; letter-spacing: 0.14em; text-transform: uppercase; }
.lede { color: var(--muted); max-width: 46ch; line-height: 1.45; }
.seats { display: grid; gap: 12px; margin: 18px 0; }
.seat-setup, .plaque, .dialog, .log, .pile, .seat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.seat-setup { padding: 12px; display: grid; gap: 8px; }
.seat-setup header, .plaque header, .seat header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
label { font-size: 0.85rem; color: var(--muted); }
input[type="text"] {
  width: 100%;
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 48px;
}
.field-label { margin: 8px 0 4px; font-size: 0.85rem; }
.segment { display: flex; flex-wrap: wrap; gap: 6px; }
.segment button, .btn, .text-btn {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  padding: 0 clamp(12px, 1.2vw, 18px);
  font-size: clamp(0.95rem, 0.35vw + 0.85rem, 1.1rem);
}
.segment button[aria-pressed="true"], .btn.primary {
  background: var(--gold-btn);
  color: var(--ink);
  border-color: transparent;
  font-weight: 700;
}
.btn.danger { background: var(--danger-solid); border-color: transparent; color: #fffdf8; }
.icon-btn { min-width: 44px; padding: 0 12px; }
.fs-icon { width: 22px; height: 22px; display: block; }
.btn.ghost { background: transparent; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--muted); min-height: 44px; }

.table-screen {
  background:
    radial-gradient(ellipse at 50% 18%, color-mix(in srgb, var(--felt) 62%, transparent), transparent 58%),
    var(--bg);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: clamp(4px, 0.8vh, 10px);
  padding:
    calc(8px + env(safe-area-inset-top))
    calc(8px + env(safe-area-inset-right))
    calc(8px + env(safe-area-inset-bottom))
    calc(8px + env(safe-area-inset-left));
  width: min(1680px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  margin-inline: auto;
  overflow: hidden;
  container-type: size;
  container-name: table;
  --card-w: clamp(48px, min(16cqi, 13cqb), 112px);
  --card-h: calc(var(--card-w) * 1.45);
}
.topbar, .scoreboard, .dock, .handbar {
  min-width: 0;
}
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.wild-pill { min-width: 0; }
.wild-pill, .phase-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--chip);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  white-space: pre-wrap;
}
.phase-pill { color: var(--gold); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; }
.wild-pill strong { color: var(--gold); }
.scoreboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(148px, 100%), 1fr)); gap: 8px; }
.plaque { padding: 8px 10px; }
.plaque.is-turn { outline: 2px solid var(--gold); }
.plaque.is-out { opacity: 0.55; }
.plaque .who { font-weight: 700; }
.plaque .meta { color: var(--muted); font-size: 0.78rem; }
.plaque .pts { font-size: 1.35rem; color: var(--gold); }

.arena {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  overflow: auto;
}
.opponents { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 8px; }
.seat { padding: 8px; min-width: 0; }
.seat.is-turn { box-shadow: inset 0 0 0 2px var(--gold); }
.backs { display: flex; min-height: 48px; }
.back {
  width: 28px;
  height: 40px;
  margin-right: -12px;
  border-radius: 4px;
  border: 1px solid var(--gold-2);
  background:
    radial-gradient(circle at 50% 40%, rgba(230, 194, 122, 0.9) 0 3px, transparent 4px),
    repeating-linear-gradient(135deg, #4a1c24 0 6px, #2a1014 6px 12px);
}
.count { margin: 4px 0 0; color: var(--muted); font-size: 0.8rem; }

.piles {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at center, rgba(255, 248, 230, 0.08), transparent 70%),
    linear-gradient(180deg, var(--felt), var(--felt-2));
  border-radius: 16px;
  border: 1px solid var(--line);
  min-height: 0;
  padding: 10px;
  position: relative;
}
.pile-btn {
  background: transparent;
  border: none;
  padding: 0;
  min-width: var(--card-w);
  min-height: var(--card-h);
}
.deck-stack {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  border: 1px solid var(--gold-2);
  background:
    radial-gradient(circle at 50% 42%, rgba(230, 194, 122, 0.95) 0 7px, transparent 8px),
    repeating-linear-gradient(135deg, #6a2430 0 8px, #3a1418 8px 16px);
  box-shadow: 6px 6px 0 #1a0c0e, var(--shadow);
  display: grid;
  place-items: end center;
  color: var(--on-felt-gold);
  font-size: 0.75rem;
  padding-bottom: 6px;
}
.pile-label { display: block; text-align: center; color: var(--on-felt); font-size: 0.75rem; margin-top: 4px; }
.inplay { display: flex; flex-direction: column; gap: 6px; align-items: center; color: var(--on-felt-gold); font-size: 0.8rem; }
.log {
  display: none;
  padding: 8px 10px;
  overflow: auto;
  max-height: 100%;
}
.log p { margin: 0 0 8px; font-size: 0.86rem; line-height: 1.35; color: var(--muted); }
.log p:last-child { color: var(--text); }
.ticker {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 100%;
  margin: 0;
}

.dock { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.prompt { margin: 0; flex: 1 1 180px; }
.prompt em { color: var(--gold); font-style: normal; }
.err { color: var(--danger-text); }

.handbar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  min-height: calc(var(--card-h) + 20px);
  padding: 8px 8px 12px;
  scroll-snap-type: x proximity;
}
.handbar .card { scroll-snap-align: start; }

.card {
  width: var(--card-w);
  height: var(--card-h);
  flex: 0 0 auto;
  border-radius: 8px;
  border: 1px solid #d9d0c2;
  background: var(--card-face);
  color: var(--card-ink);
  padding: 4px;
  position: relative;
  box-shadow: var(--shadow);
  text-align: left;
  touch-action: manipulation;
  transition: transform calc(180ms * var(--motion, 1)) ease, box-shadow calc(180ms * var(--motion, 1)) ease;
}
.card.ink-red { color: var(--suit-red); }
.card.ink-gold { color: var(--suit-star); }
.card.ink-clubs { color: var(--suit-club); }
.card i { font-style: normal; }
.card .corner { position: absolute; top: 4px; left: 6px; display: flex; flex-direction: column; line-height: 1; font-size: calc(var(--card-w) * 0.22); }
.playmat { display: grid; gap: 8px; min-height: 0; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
body.using-focus :focus {
  outline: 3px solid #f0d7a2;
  outline-offset: 3px;
}
body.using-focus .card:focus { z-index: 3; }
.card .corner.bl { top: auto; bottom: 4px; left: auto; right: 6px; transform: rotate(180deg); }
.card .face { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--card-w) * 0.42); }
.card .ribbon, .card .drawn-tag {
  position: absolute;
  left: 0; right: 0; bottom: 6px;
  text-align: center;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--danger-solid);
  font-weight: 700;
}
.card.is-wild { box-shadow: inset 0 0 0 3px var(--mark), var(--shadow); }
.card.is-selected {
  transform: translateY(-10px);
  outline: 3px solid var(--mark);
  box-shadow: inset 0 0 0 3px var(--mark);
}
html[data-theme="dark"] .card.is-selected {
  box-shadow: inset 0 0 0 3px var(--mark), 0 0 0 3px #e6c27a;
}
.card.is-drawn {
  outline: 3px solid var(--drawn);
  box-shadow: inset 0 0 0 3px var(--drawn);
  animation: card-in calc(280ms * var(--motion, 1)) ease;
}
@keyframes card-in {
  from { transform: translateY(-16px); }
  to { transform: none; }
}
.pile-btn { transition: transform calc(160ms * var(--motion, 1)) ease; }
.plaque.is-turn, .seat.is-turn { transition: box-shadow calc(200ms * var(--motion, 1)) ease; }
.match-list { margin: 0; padding-left: 18px; }
.match-list li { margin: 4px 0; }
.audio-ctl { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: 0.85rem; }
.audio-ctl input { width: 92px; }
.card.is-legal { box-shadow: inset 0 0 0 3px var(--drawn); }
.card.is-helped { box-shadow: inset 0 0 0 2px var(--drawn); }
.hint-line { color: var(--on-felt-gold); }
.byline, .site-footer { margin: 0.2em 0 0; color: var(--muted); font-size: 0.95rem; }
.site-footer { margin-top: 14px; }
.meld-sheet {
  position: fixed;
  z-index: 30;
  top: 64px;
  right: 12px;
  bottom: 12px;
  width: min(340px, 38vw);
  overflow: auto;
  padding: 14px 16px 18px;
  border-radius: 16px;
  background: var(--panel, #1c1410);
  color: var(--text, #f6efe4);
  border: 1px solid #f0d7a2;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.meld-sheet header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.meld-sheet h2, .meld-sheet h3 { margin: 0.6em 0 0.3em; font-size: 1rem; }
.meld-sheet ul { margin: 0 0 0.4em; padding-left: 1.1em; }
.meld-sheet li { margin: 0.2em 0; }
@media (max-width: 800px) {
  .meld-sheet {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 48vh;
    border-radius: 16px 16px 0 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}
.card:disabled { opacity: 0.45; }
.card-action {
  background: #1b120f;
  color: #f6efe4;
  border-color: #f0d7a2;
  border-width: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  padding: 3px;
}
.a-band {
  align-self: stretch;
  text-align: center;
  background: #f0d7a2;
  color: #1b120f;
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.3;
}
.card-action .a-icon { display: block; width: 1.45rem; height: 1.45rem; flex: none; color: #f6efe4; }
.card.is-mini .a-icon { width: 1rem; height: 1rem; }
.a-icon svg { width: 100%; height: 100%; display: block; }
.card-action .a-name { font-size: 0.62rem; line-height: 1.05; text-align: center; }
.guide-card { display: flex; gap: 12px; align-items: flex-start; margin: 10px 0; }
.guide-card .a-icon { width: 48px; height: 48px; flex: none; color: var(--gold); }
.dialog h2 .a-icon { width: 32px; height: 32px; display: inline-block; vertical-align: middle; margin-right: 8px; color: var(--gold); }
.info-pip { font-size: 1.4rem; margin-right: 8px; }
html[data-theme="light"] .card-action,
html[data-theme="dark"] .card-action,
html[data-face="classic"] .card-action,
html[data-face="contrast"] .card-action {
  color: #f6efe4;
  border-color: #f0d7a2;
}
.tone-guillotine { background: #4a1020; }
.tone-tax { background: #1d3328; }
.tone-theft { background: #2a2142; }
.tone-raid { background: #14343a; }
.tone-joke { background: #3a2418; }
.tone-pardon { background: #24324a; }
.card-joker { background: #241833; color: #f3e7ff; border-color: #c9a6ff; }
.card.is-mini { --card-w: 52px; --card-h: 74px; width: 52px; height: 74px; }
.card.is-mini .face { font-size: 1.2rem; }
.card.is-mini .corner { font-size: 0.72rem; }

.dialog-back {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}
.dialog {
  width: min(560px, 100%);
  max-height: min(80dvh, 720px);
  overflow: auto;
  padding: 16px;
  background: var(--panel);
  color: var(--text);
}
.dialog h2 { margin: 0 0 8px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.dialog.rules-sheet {
  width: min(960px, 100%);
  max-height: min(92dvh, 900px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}
.rules-sheet [hidden] { display: none !important; }
.rules-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rules-head h2 { margin: 0; }
.rules-search input {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.rules-layout { display: flex; flex-direction: column; gap: 10px; min-height: 0; flex: 1; }
.rules-toc { display: flex; flex-wrap: wrap; gap: 8px; }
.rules-toc .btn { flex: none; }
.rules-body { overflow: auto; min-height: 0; flex: 1; }
.rules-section { padding: 8px 0 16px; border-bottom: 1px solid var(--line); }
.rules-section h3 { margin: 0 0 6px; color: var(--gold); scroll-margin-top: 8px; }
.rules-section p { margin: 0 0 8px; line-height: 1.45; }
.rules-example { margin: 8px 0 12px; }
.rules-example figcaption { color: var(--muted); font-size: 0.9rem; margin-top: 6px; }
.rules-table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.rules-table th, .rules-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rules-table th { color: var(--gold); }
.rules-empty { color: var(--muted); }
@media (min-width: 800px) {
  .rules-layout { flex-direction: row; align-items: stretch; }
  .rules-toc { flex-direction: column; overflow: auto; width: 220px; flex: none; max-height: 100%; }
  .rules-toc .btn { width: 100%; text-align: left; }
}
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.suit-btn { min-width: 48px; font-size: 1.3rem; }
.group { margin: 8px 0; }
.group h3 { margin: 0 0 6px; font-size: 0.95rem; color: var(--gold); }
.mini-row { display: flex; gap: 6px; overflow-x: auto; }
.dead { color: var(--danger-text); }
.score-list { display: grid; gap: 12px; }
.board-row.is-entering { animation: board-in calc(420ms * var(--motion, 1)) ease both; animation-delay: calc(var(--i, 0) * 70ms * var(--motion, 1)); }
.board-row.is-biggest { box-shadow: inset 3px 0 0 var(--gold); padding-left: 10px; }
.board-row.is-danger .danger-line { color: var(--danger-text); font-weight: 700; }
.board-row.is-eliminated { animation: board-out calc(500ms * var(--motion, 1)) ease; }
.hit { color: var(--gold); font-weight: 700; }
@keyframes board-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes board-out { from { transform: scale(1); } 40% { transform: scale(1.03); } to { transform: none; } }
.score-player { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.score-player header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.stamp { color: var(--danger-text); font-weight: 700; letter-spacing: 0.08em; }

@container table (min-width: 980px) {
  .arena { grid-template-columns: minmax(0, 1fr) minmax(220px, 28cqi); grid-template-rows: minmax(0, 1fr); }
  .log { display: block; }
  .ticker { display: none; }
  .playmat { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; min-height: 0; }
}

@container table (max-width: 720px) {
  .plaque .pts { font-size: 1.1rem; }
  .topbar { display: flex; flex-wrap: wrap; }
  .brand-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wild-pill, .phase-pill { flex: 1 1 100%; }
  .backs { min-height: 0; }
}

@container table (max-height: 520px) {
  .arena, .handbar, .dock { --card-w: clamp(44px, 14.5cqb, 64px); --card-h: calc(var(--card-w) * 1.38); }
  .ticker { display: none; }
  .backs, .lede, .phase-pill, .count, .opponents, .dock .audio-ctl, .dock [data-act="mute"] { display: none; }
  .plaque { padding: 4px 8px; }
  .plaque .meta { font-size: 0.66rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dock .btn, .dock .segment button { min-height: 34px; padding: 2px 10px; font-size: 0.85rem; }
  .dock .check { min-height: 34px; font-size: 0.85rem; }
  .dock .row-actions { gap: 6px; }
  .wild-pill { flex: 1 1 auto; }
  .plaque .pts { font-size: 1rem; }
  .wild-pill { min-height: 36px; padding: 4px 10px; }
  .handbar { min-height: calc(var(--card-h) + 6px); padding: 2px 4px 4px; }
  .dock { gap: 4px; }
  .prompt { flex-basis: auto; }
  .scoreboard { grid-template-columns: repeat(auto-fit, minmax(min(92px, 100%), 1fr)); }
  .opponents { grid-template-columns: repeat(auto-fit, minmax(min(108px, 100%), 1fr)); }
  .seat { padding: 4px 6px; }
}

@media (max-height: 520px) {
  .table-screen { gap: 4px; }
}

@media (max-width: 720px) {
  .setup-card { padding: 18px 14px; }
}

@media (min-width: 980px) and (max-height: 860px) {
  .table-screen { padding: 8px 10px; }
}

.rotate-hint { display: none; }
@media (orientation: portrait) and (max-width: 700px) {
  #app:has(> .rotate-hint) {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  .rotate-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    position: relative;
    flex: none;
    z-index: 4;
    margin: calc(8px + env(safe-area-inset-top)) 10px 0;
    padding: 8px 10px;
    border-radius: 14px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--gold-2);
    box-shadow: var(--shadow);
  }
  .rotate-hint p { margin: 0; flex: 1; line-height: 1.3; }
  #app:has(> .rotate-hint) > .table-screen,
  #app:has(> .rotate-hint) > .screen {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
  }
}
.mode-grid { display: grid; gap: 10px; margin: 18px 0; }
.mode-grid .btn { min-height: 52px; font-size: 1.15rem; }
.room-code {
  font-size: clamp(2rem, 8vw, 3.4rem);
  letter-spacing: 0.28em;
  text-align: center;
  margin: 8px 0;
  color: var(--gold);
}
.link-line { overflow-wrap: anywhere; color: var(--muted); }
.status { color: var(--gold); }
.curtain .setup-card { text-align: center; }
.curtain .brand-mark { justify-content: center; }
.claim { min-height: 56px; font-size: 1.2rem; margin-top: 8px; }
.coach {
  flex: 1 1 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
}
.coach p { margin: 4px 0 8px; }
.card-back {
  background:
    repeating-linear-gradient(135deg, #4a1820, #4a1820 8px, #2a1014 8px, #2a1014 16px);
  color: var(--gold);
}
h2 { font-size: 1.25rem; margin: 18px 0 8px; }

.brand-mark .crown { color: var(--gold); }
.mini-crown { width: 22px; height: 22px; }
.player-title {
  display: block;
  color: var(--gold);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pip-contrast, .shape { display: none; }

.toasts {
  position: fixed;
  z-index: 6;
  top: calc(8px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100% - 24px));
  display: grid;
  gap: 6px;
  pointer-events: none;
}
.toast {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--gold-2);
  box-shadow: var(--shadow);
}
.collection h3 { margin-top: 16px; }
.achieve-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.achieve { display: flex; gap: 10px; align-items: flex-start; }
.achieve p { margin: 2px 0; }
.achieve-icon { width: 28px; height: 28px; flex: none; color: var(--gold); }
.progress {
  display: block;
  height: 8px;
  margin-top: 6px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--text) 16%, transparent);
  overflow: hidden;
}
.progress > span { display: block; height: 100%; background: var(--gold-btn); }
.progress-label, .how { color: var(--muted); font-size: 0.82rem; }
.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 8px; }
.style-option {
  min-height: 44px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
}
.style-option[aria-pressed="true"] { outline: 3px solid var(--mark); }
.style-option.is-locked { opacity: 0.78; }
.style-name { display: block; font-weight: 700; }
.preview { display: flex; gap: 4px; margin-bottom: 6px; min-height: 44px; }
.preview .card { --card-w: 42px; --card-h: 60px; width: 42px; height: 60px; box-shadow: none; }
.preview .card .face { font-size: 1rem; }
.preview .card .corner { font-size: 0.65rem; }
.felt-chip {
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--felt), var(--felt-2));
  border: 1px solid var(--line);
}
.card-back { display: grid; place-items: center; }
.card-back .crown { width: 62%; height: auto; }

html[data-face="royal"] .card[data-suit],
html .preview[data-face="royal"] .card[data-suit] {
  background:
    radial-gradient(circle at 50% 42%, rgba(230, 194, 122, 0.34), transparent 46%),
    #fffaf0;
  border: 2px solid #a8843e;
  box-shadow: inset 0 0 0 4px #f6e7c1, var(--shadow);
}
html[data-face="minimal"] .card[data-suit],
html .preview[data-face="minimal"] .card[data-suit] {
  background: #fff;
  border: 1px solid #1b140f;
  box-shadow: none;
  border-radius: 3px;
}
html[data-face="neon"] .card[data-suit],
html .preview[data-face="neon"] .card[data-suit] {
  background: #141824;
  border: 1px solid #3d4d73;
  box-shadow: none;
}
html[data-face="neon"] .card[data-suit="spades"],
html .preview[data-face="neon"] .card[data-suit="spades"] { color: #e8eefc; }
html[data-face="neon"] .card[data-suit="hearts"],
html .preview[data-face="neon"] .card[data-suit="hearts"] { color: #ff6b8a; }
html[data-face="neon"] .card[data-suit="diamonds"],
html .preview[data-face="neon"] .card[data-suit="diamonds"] { color: #ffb020; }
html[data-face="neon"] .card[data-suit="clubs"],
html .preview[data-face="neon"] .card[data-suit="clubs"] { color: #3ddc97; }
html[data-face="neon"] .card[data-suit="stars"],
html .preview[data-face="neon"] .card[data-suit="stars"] { color: #ffe566; }
html[data-face="neon"] .card[data-suit] .ribbon { color: #ff8fa3; }
html[data-face="neon"] { --mark: #dffbff; }
html[data-face="neon"] .card.is-selected {
  outline: 3px solid #7ef0ff;
  box-shadow: inset 0 0 0 3px #7ef0ff, 0 0 0 3px #7ef0ff;
}
html[data-face="contrast"] .card[data-suit],
html .preview[data-face="contrast"] .card[data-suit] {
  background: #fff;
  border: 2px solid #111;
  box-shadow: none;
}
html[data-face="contrast"] .pip-classic,
html .preview[data-face="contrast"] .pip-classic { display: none; }
html[data-face="contrast"] .pip-contrast,
html .preview[data-face="contrast"] .pip-contrast { display: block; }
html[data-face="contrast"] .card[data-suit="spades"],
html .preview[data-face="contrast"] .card[data-suit="spades"] { color: #1a1a1a; }
html[data-face="contrast"] .card[data-suit="hearts"],
html .preview[data-face="contrast"] .card[data-suit="hearts"] { color: #0b3fbf; }
html[data-face="contrast"] .card[data-suit="diamonds"],
html .preview[data-face="contrast"] .card[data-suit="diamonds"] { color: #9a3412; }
html[data-face="contrast"] .card[data-suit="clubs"],
html .preview[data-face="contrast"] .card[data-suit="clubs"] { color: #5b21b6; }
html[data-face="contrast"] .card[data-suit="stars"],
html .preview[data-face="contrast"] .card[data-suit="stars"] { color: #0f6e62; }
.shape { width: 1.15rem; height: 1.15rem; margin: auto; }
.shape-spades {
  width: 0;
  height: 0;
  border-left: 0.48rem solid transparent;
  border-right: 0.48rem solid transparent;
  border-bottom: 0.84rem solid currentColor;
  background: none;
}
.shape-hearts { border-radius: 50%; background: currentColor; }
.shape-diamonds { width: 0.78rem; height: 0.78rem; background: currentColor; transform: rotate(45deg); }
.shape-clubs { background: currentColor; border-radius: 2px; }
.shape-stars {
  background: currentColor;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

html .preview[data-face="classic"] .card[data-suit] {
  background: var(--card-face);
  color: var(--card-ink);
  border: 1px solid #d9d0c2;
  box-shadow: none;
  border-radius: 8px;
}
html .preview[data-face="classic"] .card[data-suit="hearts"],
html .preview[data-face="classic"] .card[data-suit="diamonds"] { color: var(--suit-red); }
html .preview[data-face="classic"] .card[data-suit="clubs"] { color: var(--suit-club); }
html .preview[data-face="classic"] .card[data-suit="stars"] { color: var(--suit-star); }

html[data-back="royal"] .card-back,
html[data-back="royal"] .deck-stack,
html[data-back="royal"] .back,
html .preview[data-back="royal"] .card-back {
  background:
    radial-gradient(circle at 50% 38%, rgba(230, 194, 122, 0.95) 0 5px, transparent 6px),
    repeating-linear-gradient(45deg, #6b3a16 0 6px, #3a1418 6px 12px);
  border: 2px solid #e6c27a;
  color: #e6c27a;
}
html[data-back="minimal"] .card-back,
html[data-back="minimal"] .deck-stack,
html[data-back="minimal"] .back,
html .preview[data-back="minimal"] .card-back {
  background: #1b140f;
  border: 1px solid #f4efe4;
  color: #f4efe4;
  box-shadow: none;
}
html[data-back="neon"] .card-back,
html[data-back="neon"] .deck-stack,
html[data-back="neon"] .back,
html .preview[data-back="neon"] .card-back {
  background: #10131c;
  border: 2px solid #7ef0ff;
  box-shadow: inset 0 0 0 3px #c84bff;
  color: #7ef0ff;
}
html[data-back="contrast"] .card-back,
html[data-back="contrast"] .deck-stack,
html[data-back="contrast"] .back,
html .preview[data-back="contrast"] .card-back {
  background: #111;
  border: 3px solid #fff;
  color: #fff;
  box-shadow: none;
}
html .preview[data-back="classic"] .card-back {
  background: repeating-linear-gradient(135deg, #4a1820, #4a1820 8px, #2a1014 8px, #2a1014 16px);
  border: 1px solid var(--gold-2);
  color: var(--gold);
  box-shadow: none;
}

html[data-felt="baize"],
html .preview[data-felt="baize"] { --felt: #0f5132; --felt-2: #0a3a24; }
html[data-felt="midnight"],
html .preview[data-felt="midnight"] { --felt: #121826; --felt-2: #0c1018; }
html[data-felt="royal"],
html .preview[data-felt="royal"] { --felt: #3a2158; --felt-2: #241438; }

html .preview[data-face="classic"] .pip-classic,
html .preview[data-face="royal"] .pip-classic,
html .preview[data-face="minimal"] .pip-classic,
html .preview[data-face="neon"] .pip-classic { display: inline; }
html .preview[data-face="classic"] .pip-contrast,
html .preview[data-face="royal"] .pip-contrast,
html .preview[data-face="minimal"] .pip-contrast,
html .preview[data-face="neon"] .pip-contrast { display: none; }

html[data-face="royal"] .card[data-suit].is-selected,
html[data-face="minimal"] .card[data-suit].is-selected,
html[data-face="contrast"] .card[data-suit].is-selected {
  outline: 3px solid var(--mark);
  box-shadow: inset 0 0 0 3px var(--mark);
}
html[data-theme="dark"][data-face="royal"] .card[data-suit].is-selected,
html[data-theme="dark"][data-face="minimal"] .card[data-suit].is-selected,
html[data-theme="dark"][data-face="contrast"] .card[data-suit].is-selected {
  box-shadow: inset 0 0 0 3px var(--mark), 0 0 0 3px #e6c27a;
}
html[data-face="royal"] .card[data-suit].is-wild,
html[data-face="minimal"] .card[data-suit].is-wild,
html[data-face="contrast"] .card[data-suit].is-wild,
html[data-face="neon"] .card[data-suit].is-wild {
  box-shadow: inset 0 0 0 3px var(--mark);
}
html[data-face="royal"] .card[data-suit].is-drawn,
html[data-face="royal"] .card[data-suit].is-legal,
html[data-face="minimal"] .card[data-suit].is-drawn,
html[data-face="minimal"] .card[data-suit].is-legal,
html[data-face="contrast"] .card[data-suit].is-drawn,
html[data-face="contrast"] .card[data-suit].is-legal,
html[data-face="neon"] .card[data-suit].is-drawn,
html[data-face="neon"] .card[data-suit].is-legal {
  box-shadow: inset 0 0 0 3px var(--drawn);
}
html .card-action.is-selected,
html .card-joker.is-selected {
  outline: 3px solid #f0d7a2;
  box-shadow: inset 0 0 0 3px #f0d7a2, 0 0 0 3px #f0d7a2;
}
@media (prefers-reduced-motion: reduce) {
  :root { --motion: 0; }
  .card, .pile-btn, .plaque, .seat, .toast {
    animation: none !important;
    transition: none !important;
  }
}
