@font-face {
  font-family: "Bagel Fat One";
  src: url("./assets/fonts/bagel-fat-one-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Fredoka";
  src: url("./assets/fonts/fredoka-latin-variable.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --primary: #ff6b4a;
  --primary-ink: #141210;
  --primary-soft: #ffe1c2;
  --secondary: #2c2140;
  --secondary-ink: #fffdf8;
  --secondary-soft: #e1d6c1;
  --tertiary: #f0c84a;
  --tertiary-ink: #141210;
  --tertiary-soft: #fdeec2;
  --bg: #fff4d6;
  --surface: #fffaf0;
  --surface-2: #ffe8a8;
  --surface-3: #f2dca2;
  --ink: #2c2140;
  --ink-2: #5a4e78;
  --ink-3: #706488;
  --line: #ead8a0;
  --line-strong: #a2927c;
  --success: #2f9e5b;
  --success-ink: #141210;
  --success-soft: #e2e8c5;
  --success-on-soft: #206b3e;
  --warning: #f0c84a;
  --warning-ink: #141210;
  --warning-soft: #fdeec2;
  --warning-on-soft: #7f6a27;
  --danger: #ff6b4a;
  --danger-ink: #141210;
  --danger-soft: #ffe1c2;
  --danger-on-soft: #98402c;
  --info: #4a6ab4;
  --info-ink: #fffdf8;
  --info-soft: #e6e1d1;
  --info-on-soft: #415d9e;
  --focus: #ff6b4a;
  --link: #ba4d36;
  --overlay: #141210;
  --inverse: #2c2140;
  --inverse-ink: #fff4d6;
  --table-surface: var(--secondary);
  --table-ink: var(--secondary-ink);
  --card-face: #fffaf0;
  --card-ink: #2c2140;
  --font-display: "Bagel Fat One", "Helvetica Neue", Arial, sans-serif;
  --font-text: "Fredoka", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 14px;
  --radius-card: 14px;
  --control: 48px;
  --gap: 24px;
  --pad: 20px;
  --shadow: 0 12px 28px -16px rgba(0, 0, 0, .16);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --t-ui: 200ms;
  --t-layout: 320ms;
  --t-sheet: 400ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --primary: #ff7f62;
    --primary-ink: #141210;
    --primary-soft: #54313c;
    --secondary: #fff4d6;
    --secondary-ink: #141210;
    --secondary-soft: #544d58;
    --tertiary: #f0c84a;
    --tertiary-ink: #141210;
    --tertiary-soft: #504236;
    --bg: #1e1830;
    --surface: #272040;
    --surface-2: #31294e;
    --surface-3: #463d5c;
    --ink: #fff4d6;
    --ink-2: #d2c6e0;
    --ink-3: #9a8eb4;
    --line: #3a3158;
    --line-strong: #857b88;
    --success: #6ad49a;
    --success-ink: #141210;
    --success-soft: #304549;
    --success-on-soft: #6ad49a;
    --warning: #f0c84a;
    --warning-ink: #141210;
    --warning-soft: #504236;
    --warning-on-soft: #f0c84a;
    --danger: #ff7f62;
    --danger-ink: #141210;
    --danger-soft: #54313c;
    --danger-on-soft: #ff8e75;
    --info: #8aa4ff;
    --info-ink: #141210;
    --info-soft: #383a62;
    --info-on-soft: #8aa4ff;
    --focus: #ff7f62;
    --link: #ff7f62;
    --overlay: #070605;
    --inverse: #fff4d6;
    --inverse-ink: #1e1830;
    --table-surface: var(--surface-2);
    --table-ink: var(--ink);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #ff7f62;
  --primary-ink: #141210;
  --primary-soft: #54313c;
  --secondary: #fff4d6;
  --secondary-ink: #141210;
  --secondary-soft: #544d58;
  --tertiary: #f0c84a;
  --tertiary-ink: #141210;
  --tertiary-soft: #504236;
  --bg: #1e1830;
  --surface: #272040;
  --surface-2: #31294e;
  --surface-3: #463d5c;
  --ink: #fff4d6;
  --ink-2: #d2c6e0;
  --ink-3: #9a8eb4;
  --line: #3a3158;
  --line-strong: #857b88;
  --success: #6ad49a;
  --success-ink: #141210;
  --success-soft: #304549;
  --success-on-soft: #6ad49a;
  --warning: #f0c84a;
  --warning-ink: #141210;
  --warning-soft: #504236;
  --warning-on-soft: #f0c84a;
  --danger: #ff7f62;
  --danger-ink: #141210;
  --danger-soft: #54313c;
  --danger-on-soft: #ff8e75;
  --info: #8aa4ff;
  --info-ink: #141210;
  --info-soft: #383a62;
  --info-on-soft: #8aa4ff;
  --focus: #ff7f62;
  --link: #ff7f62;
  --overlay: #070605;
  --inverse: #fff4d6;
  --inverse-ink: #1e1830;
  --table-surface: var(--surface-2);
  --table-ink: var(--ink);
}

:root[data-theme="light"] {
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  touch-action: pan-y;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
button:disabled { cursor: not-allowed; opacity: .42; }
[hidden] { display: none !important; }

.app-frame {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.app-header {
  width: min(100% - 48px, 1240px);
  min-height: 80px;
  margin: 0 auto;
  padding-top: max(16px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  color: var(--ink);
  text-decoration: none;
  font: 400 28px/1 var(--font-display);
  letter-spacing: -.015em;
}

.wordmark-period { color: var(--primary); }

.desktop-tabs {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 28px;
}

.tab-link {
  min-height: 44px;
  padding: 4px 2px 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}

.tab-link:hover { color: var(--ink); }
.tab-link.is-current { color: var(--ink); border-bottom-color: var(--primary); }

.header-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.connection-pill, .preview-badge, .seat-count, .points-chip, .quick-facts span {
  border-radius: 999px;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  background: var(--success-soft);
  color: var(--success-on-soft);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.connection-dot, .turn-dot, .waiting-pulse {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
}

.icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}

.icon-button:hover { background: var(--surface-2); color: var(--ink); }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.network-banner {
  width: min(100% - 40px, 1240px);
  min-height: 42px;
  margin: 0 auto;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
  background: var(--warning-soft);
  color: var(--warning-on-soft);
  font-size: 14px;
  font-weight: 600;
}

.network-banner .connection-dot { background: var(--warning); }
.is-offline .connection-pill { background: var(--warning-soft); color: var(--warning-on-soft); }
.is-offline .connection-dot { background: var(--warning); }

.main-content {
  width: min(100% - 48px, 1240px);
  margin: 0 auto;
  padding: 30px 0 24px;
}

.view { min-height: 520px; }

.welcome-layout {
  min-height: min(690px, calc(100dvh - 140px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .88fr);
  align-items: center;
  gap: clamp(30px, 6vw, 84px);
}

.welcome-copy { max-width: 570px; padding: 22px 0; }

.eyebrow, .section-kicker {
  margin: 0;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.25;
  text-transform: uppercase;
}

.eyebrow { display: flex; align-items: center; gap: 9px; }

.eyebrow-mark {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-ink);
  font-family: var(--font-text);
  font-size: 13px;
  letter-spacing: 0;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { color: var(--ink); }

.welcome-copy h1 {
  max-width: 620px;
  margin: 18px 0 14px;
  font: 400 clamp(52px, 7.2vw, 86px)/.96 var(--font-display);
  letter-spacing: -.018em;
}

.welcome-dek, .page-dek {
  max-width: 480px;
  margin-bottom: 28px;
  color: var(--ink-2);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.45;
}

.play-actions { width: min(100%, 445px); }
.play-actions > .button-wide + .button-wide { margin-top: 12px; }
.local-seat-tools { margin: -4px 0 10px; }
.local-seat-tools[hidden] { display: none; }
.local-seat-tools .button { min-height: 44px; font-size: 13px; }
.seat-picker-row { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 12px; margin-top: 12px; }
.seat-picker-row label { color: var(--ink-2); font-size: 14px; }
.seat-picker-row select { width: 100%; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--bg); color: var(--ink); font: inherit; font-size: 16px; }
.seat-order { margin: 16px 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }

.nickname-field { display: grid; gap: 8px; margin-bottom: 16px; }
.nickname-field > span { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.nickname-field input {
  appearance: none;
  width: 100%;
  min-width: 0;
  min-height: 54px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
  transition: border-color var(--t-ui) var(--ease), background var(--t-ui) var(--ease);
}
.nickname-field input::placeholder { color: var(--ink-3); opacity: 1; }
.nickname-field input:focus { border-color: var(--primary); background: var(--surface-2); }

.button {
  min-height: var(--control);
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: transform var(--t-ui) var(--ease), background var(--t-ui) var(--ease), border-color var(--t-ui) var(--ease);
}

.button:hover { border-color: var(--ink); }
.button:active { transform: scale(.98); }
.button svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.button-primary { border-color: transparent; background: var(--primary-soft); color: var(--ink); }
.button-primary:hover { background: var(--surface-2); border-color: transparent; }
.button-outline { border-color: var(--line-strong); background: transparent; color: var(--ink); }
.button-soft { border-color: transparent; background: var(--primary-soft); color: var(--ink); }
.button-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.button-wide { width: 100%; min-height: 54px; justify-content: space-between; padding: 0 20px 0 22px; font-size: 16px; }

.join-form {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.field-label { display: block; margin-bottom: 8px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.join-row { display: flex; gap: 8px; }
.join-row input {
  width: 0;
  min-width: 0;
  height: var(--control);
  flex: 1 1 auto;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.join-row input::placeholder { color: var(--ink-3); font-weight: 500; letter-spacing: .02em; text-transform: none; }
.join-row input[aria-invalid="true"] { border-color: var(--danger); }
.field-hint { display: block; min-height: 18px; margin-top: 7px; color: var(--ink-3); font-size: 12px; }
.text-button { min-height: 44px; padding: 0 2px; border: 0; background: transparent; color: var(--link); cursor: pointer; font-size: 14px; font-weight: 600; }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.preview-link { margin-top: 12px; }
.quick-facts { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 28px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.fact-dot { width: 4px; height: 4px; padding: 0; background: var(--line-strong); }

.welcome-preview, .surface-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.welcome-preview { padding: 20px; }
.preview-topline, .card-heading, .hand-heading, .page-heading, .table-toolbar, .room-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.preview-badge {
  min-height: 26px;
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  background: var(--tertiary-soft);
  color: var(--warning-on-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
}

.mini-table {
  position: relative;
  height: 300px;
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--table-ink) 18%, transparent);
  border-radius: var(--radius-card);
  background: var(--table-surface);
  color: var(--table-ink);
}

.mini-table::before {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 230px;
  height: 170px;
  border: 1px solid color-mix(in srgb, var(--table-ink) 22%, transparent);
  border-radius: 50%;
  content: "";
  transform: translate(-50%, -50%);
}

.mini-seat {
  position: absolute;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--table-ink);
  font-size: 11px;
  font-weight: 600;
}
.mini-seat-nw { top: 16px; left: 16px; }
.mini-seat-ne { top: 16px; right: 16px; }
.mini-seat-west { top: 114px; left: 12px; }
.mini-seat-east { top: 114px; right: 12px; }
.mini-avatar, .player-avatar, .seat-avatar, .score-dot {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  font-weight: 700;
}
.mini-avatar { width: 25px; height: 25px; font-size: 11px; }
.avatar-coral { background: var(--primary); color: var(--primary-ink); }
.avatar-gold { background: var(--tertiary); color: var(--tertiary-ink); }
.avatar-cream { background: var(--surface); color: var(--ink); }
.avatar-lavender { background: var(--info-soft); color: var(--info-on-soft); }
.avatar-navy { background: var(--secondary); color: var(--secondary-ink); }
.mini-fan, .opponent-fan { display: flex; align-items: center; }
.mini-fan i, .opponent-fan i {
  width: 10px;
  height: 15px;
  margin-left: -4px;
  border: 1px solid color-mix(in srgb, var(--table-ink) 40%, transparent);
  border-radius: 3px;
  background: color-mix(in srgb, var(--table-ink) 13%, transparent);
  transform: rotate(-9deg);
}
.mini-fan i:nth-child(2), .opponent-fan i:nth-child(2) { transform: translateY(-2px); }
.mini-fan i:nth-child(3), .opponent-fan i:nth-child(3) { transform: rotate(9deg); }

.mini-piles { position: absolute; top: 100px; left: 50%; display: flex; align-items: center; gap: 16px; transform: translateX(-50%); }
.mini-card-back, .mini-discard, .mini-playing-card {
  width: 47px;
  height: 67px;
  display: inline-flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 3px 6px rgba(0, 0, 0, .12);
  font-size: 16px;
  font-weight: 700;
  line-height: .95;
}
.mini-card-back { position: relative; border-color: color-mix(in srgb, var(--table-ink) 35%, transparent); background: repeating-linear-gradient(135deg, var(--table-ink) 0 2px, transparent 2px 6px), color-mix(in srgb, var(--table-ink) 13%, transparent); transform: rotate(-6deg); }
.mini-discard { color: var(--primary); transform: rotate(5deg); }
.mini-discard i, .mini-playing-card span { font-style: normal; }
.mini-hand { position: absolute; z-index: 2; bottom: 26px; left: 50%; display: flex; transform: translateX(-50%); }
.mini-playing-card { width: 42px; height: 60px; margin-left: -10px; padding: 5px; font-size: 14px; }
.mini-playing-card:first-child { margin-left: 0; }
.mini-playing-card:nth-child(1), .mini-playing-card:nth-child(5) { transform: translateY(5px) rotate(-5deg); }
.mini-playing-card:nth-child(2), .mini-playing-card:nth-child(4) { transform: translateY(0) rotate(-2deg); }
.mini-playing-card:nth-child(3) { transform: translateY(-3px); }
.red-suit { color: var(--primary); }
.black-suit { color: var(--card-ink); }
.mini-you { position: absolute; bottom: 8px; left: 50%; color: var(--table-ink); font-size: 10px; font-weight: 600; transform: translateX(-50%); }
.preview-caption { display: flex; align-items: center; gap: 9px; margin-top: 14px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.caption-pip { color: var(--primary); font-size: 11px; }
.app-credit, .page-footnote { color: var(--ink-3); font-size: 12px; }
.app-credit { margin-top: 36px; text-align: center; }
.app-credit a { color: var(--link); text-decoration: none; }
.app-credit a:hover { text-decoration: underline; }

.page-heading { align-items: flex-end; margin: 10px 0 26px; }
.page-heading h1 { margin: 10px 0 8px; font: 400 clamp(38px, 5vw, 58px)/.98 var(--font-display); letter-spacing: -.015em; }
.page-dek { margin: 0; font-size: 16px; }
.eyebrow-code { color: var(--link); letter-spacing: .08em; }

.lobby-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(300px, .72fr); gap: 20px; align-items: stretch; }
.surface-card { padding: 22px; }
.card-heading { align-items: flex-start; }
.card-heading h2, .invite-card h2 { margin: 7px 0 0; font: 400 26px/1.05 var(--font-display); }
.seat-count { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 700; }
.seat-count svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.seat-list { margin-top: 20px; border-top: 1px solid var(--line); }
.seat-row { min-height: 62px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.seat-avatar { width: 36px; height: 36px; font-size: 13px; }
.seat-empty { border: 1px dashed var(--line-strong); background: transparent; color: var(--ink-3); font-size: 18px; }
.seat-name { flex: 1; font-size: 14px; font-weight: 600; }
.seat-name small { margin-left: 7px; color: var(--ink-3); font-size: 11px; font-weight: 500; }
.seat-status { color: var(--success-on-soft); font-size: 12px; font-weight: 600; }
.seat-status-muted { color: var(--ink-3); }
.waiting-note { display: flex; align-items: center; gap: 9px; margin-top: 16px; color: var(--ink-2); font-size: 13px; }
.waiting-pulse { background: var(--tertiary); box-shadow: 0 0 0 4px var(--tertiary-soft); }
.lobby-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.prototype-note { margin: 14px 0 0; color: var(--ink-3); font-size: 12px; }
.bot-remove { min-height: 44px; padding: 0 10px; font-size: 12px; }
.selected-count { display: none; }
.bot-activity { max-width: 240px; margin: 6px 0 0; color: var(--table-ink); font-size: 11px; line-height: 1.3; text-align: center; }
.invite-card { display: flex; flex-direction: column; align-items: stretch; }
.invite-card-heading { display: flex; align-items: center; gap: 12px; }
.invite-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--ink); }
.invite-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.qr-preview-wrap { display: grid; place-items: center; margin: 20px auto 12px; }
.qr-preview { width: 184px; height: 184px; padding: 9px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 8px 20px rgba(44, 33, 64, .1); }
.qr-preview[hidden], .qr-preview-wrap[hidden], .dialog-qr-caption[hidden] { display: none !important; }
.qr-preview svg { display: block; width: 100%; height: 100%; }
.qr-caption { max-width: 250px; margin: 0 auto 16px; color: var(--ink-2); font-size: 12px; line-height: 1.45; text-align: center; }
.room-code-row { min-height: 64px; padding: 10px 12px 10px 15px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--bg); }
.room-code-row > div { display: grid; gap: 2px; }
.room-code-row strong { font: 400 24px/1 var(--font-display); letter-spacing: .06em; }
.button-copy { min-height: 42px; }
.button-copy svg { width: 16px; height: 16px; }
.install-link { align-self: flex-start; margin: 8px 0 -6px; }
.page-footnote { margin: 18px 0 0; }

.table-view { min-height: 0; }
.table-toolbar { min-height: 48px; margin-bottom: 12px; }
.back-button { min-height: 44px; padding: 0; display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 13px; }
.back-button strong { color: var(--ink); letter-spacing: .06em; }
.back-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.turn-status { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; border-radius: 999px; background: var(--success-soft); color: var(--success-on-soft); font-size: 12px; font-weight: 700; }
.turn-dot { width: 7px; height: 7px; }
.invite-table-button { min-height: 42px; }
.invite-table-button svg { width: 17px; height: 17px; }
.view.is-entering { animation: view-enter 360ms var(--ease-out) both; }
@keyframes view-enter { from { opacity: 0; translate: 0 10px; } to { opacity: 1; translate: 0 0; } }

.game-layout { width: min(100%, 1000px); margin: 0 auto; }
.felt {
  position: relative;
  height: clamp(330px, 44svh, 470px);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--table-ink) 20%, transparent);
  border-radius: var(--radius-card);
  background: var(--table-surface);
  color: var(--table-ink);
  box-shadow: var(--shadow);
}

.felt::before, .felt::after {
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(58%, 460px);
  height: 58%;
  border: 1px solid color-mix(in srgb, var(--table-ink) 22%, transparent);
  border-radius: 50%;
  content: "";
  transform: translate(-50%, -50%);
}
.felt::after { width: min(45%, 360px); height: 44%; border-style: dashed; opacity: .68; }

.seat {
  position: absolute;
  z-index: 1;
  min-width: 120px;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 6px;
  border: 1px solid color-mix(in srgb, var(--table-ink) 20%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--table-surface) 86%, transparent);
  color: var(--table-ink);
  transition: border-color var(--t-ui) var(--ease), box-shadow var(--t-ui) var(--ease), transform var(--t-ui) var(--ease-out);
}
.seat.is-current-turn { z-index: 3; border-color: color-mix(in srgb, var(--tertiary) 76%, var(--table-ink)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tertiary) 24%, transparent); transform: translateY(-2px); }
.seat-nw { top: 14px; left: 8%; }
.seat-ne { top: 14px; right: 8%; }
.seat-west { top: 48%; left: 12px; }
.seat-east { top: 48%; right: 12px; }
.player-avatar { width: 32px; height: 32px; font-size: 12px; }
.player-copy { min-width: 40px; display: grid; line-height: 1.12; }
.player-copy strong { font-size: 12px; font-weight: 700; }
.player-copy small { margin-top: 3px; color: color-mix(in srgb, var(--table-ink) 72%, transparent); font-size: 10px; }
.opponent-fan { margin-left: auto; padding-left: 3px; display: flex; align-items: center; }
.opponent-fan i {
  position: relative;
  width: 13px;
  height: 19px;
  flex: 0 0 auto;
  margin-left: -7px;
  border: 1px solid color-mix(in srgb, var(--primary) 65%, var(--ink));
  border-radius: 4px;
  background: repeating-linear-gradient(135deg, var(--surface) 0 2px, var(--primary-soft) 2px 4px);
  box-shadow: 0 1px 2px rgba(20, 18, 16, .18);
}
.opponent-fan i:first-child { margin-left: 0; }
.opponent-fan i::after { position: absolute; top: 7px; left: 4px; width: 3px; height: 3px; background: var(--primary); content: ""; transform: rotate(45deg); }
.opponent-fan i:nth-child(1), .opponent-fan i:nth-child(5) { transform: translateY(2px) rotate(-10deg); }
.opponent-fan i:nth-child(2), .opponent-fan i:nth-child(4) { transform: translateY(-1px) rotate(-4deg); }
.opponent-fan i:nth-child(3) { transform: translateY(-2px); }
.seat.is-concealed .opponent-fan { display: none; }
.seat.is-concealed .player-copy small { color: color-mix(in srgb, var(--tertiary) 75%, var(--table-ink)); font-style: italic; }
.seat.is-out { opacity: .58; filter: grayscale(.65); }
.seat.is-out .player-avatar { text-decoration: line-through; }
.seat-west, .seat-east { min-width: 94px; }
.seat-west, .seat-east { flex-direction: column; gap: 3px; padding: 7px 5px; }
.seat-west .opponent-fan, .seat-east .opponent-fan { margin: 0; padding: 0; }
.seat-west .player-copy, .seat-east .player-copy { text-align: center; }
.seat-west .player-copy small, .seat-east .player-copy small { display: block; margin-top: 2px; }
.seat-west.is-concealed .opponent-fan, .seat-east.is-concealed .opponent-fan { display: none; }

.center-play {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
}
.center-label { margin: 0 0 12px; color: color-mix(in srgb, var(--table-ink) 70%, transparent); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.piles { display: flex; align-items: flex-start; justify-content: center; gap: 28px; }
.pile { position: relative; min-width: 76px; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 7px; border: 0; background: transparent; color: var(--table-ink); cursor: default; font: inherit; }
.pile-draw { cursor: pointer; }
.pile-draw:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 10px; }
.pile-discard:not(:disabled) { cursor: pointer; }
.pile-discard:not(:disabled):hover .discard-playing-card { transform: translateY(-3px) rotate(-2deg); }
.pile-discard:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 10px; }
#discard-pile:disabled { cursor: default; opacity: 1; }
.pile-card-back, .discard-playing-card {
  position: relative;
  width: 58px;
  height: 82px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 7px;
  border: 1px solid color-mix(in srgb, var(--table-ink) 45%, transparent);
  border-radius: 12px;
  box-shadow: 0 5px 10px rgba(0, 0, 0, .16);
}
.pile-card-back {
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--table-ink) 14%, transparent) 0 2px, transparent 2px 7px), color-mix(in srgb, var(--table-surface) 75%, var(--table-ink) 25%);
}
.pile-card-back::after { position: absolute; inset: 4px; border: 1px solid color-mix(in srgb, var(--table-ink) 36%, transparent); border-radius: 8px; content: ""; }
.pile-draw:hover .pile-card-back { transform: translateY(-3px) rotate(-2deg); }
.pile-draw:not(:disabled) .pile-card-back { animation: none; }
@keyframes deck-breathe { 50% { translate: 0 -3px; rotate: -1deg; } }
.discard-playing-card { background: var(--card-face); color: var(--primary); font-size: 20px; font-style: normal; font-weight: 700; line-height: 1; transform-origin: center; transition: transform var(--t-ui) var(--ease-out), box-shadow var(--t-ui) var(--ease); }
.discard-playing-card.black-suit { color: var(--card-ink); }
.discard-playing-card i { font-size: 21px; font-style: normal; }
.discard-target { position: absolute; z-index: 5; top: -37px; left: 50%; min-height: 29px; padding: 4px 9px; display: flex; align-items: center; gap: 5px; border: 1px solid color-mix(in srgb, var(--primary) 42%, var(--table-ink)); border-radius: 999px; background: var(--table-surface); color: var(--table-ink); box-shadow: 0 3px 9px rgba(0, 0, 0, .14); font-size: 10px; font-weight: 700; white-space: nowrap; opacity: 0; pointer-events: none; transform: translate(-50%, 6px) scale(.92); transition: opacity var(--t-ui) var(--ease), transform var(--t-ui) var(--ease-out), background var(--t-ui) var(--ease), color var(--t-ui) var(--ease); }
.discard-target svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pile-discard.is-toss-target .discard-target { opacity: 1; transform: translate(-50%, 0) scale(1); }
.pile-discard.is-toss-target .discard-playing-card { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tertiary) 82%, transparent), 0 8px 16px rgba(0, 0, 0, .25); transform: rotate(-3deg) scale(1.06); }
.pile-discard.is-toss-target .pile-caption { color: var(--tertiary); }
.discard-playing-card.is-landed { animation: discard-land 480ms var(--ease-out) both; }
@keyframes discard-land { from { transform: translateY(-2px) scale(.98); } to { transform: translateY(0) scale(1); } }
.pile-caption { display: flex; align-items: center; gap: 5px; color: color-mix(in srgb, var(--table-ink) 78%, transparent); font-size: 11px; font-weight: 600; white-space: nowrap; }
.pile-caption b { min-width: 18px; padding: 1px 5px; border-radius: 999px; background: color-mix(in srgb, var(--table-ink) 14%, transparent); color: var(--table-ink); font-size: 10px; text-align: center; }
.turn-callout { margin-top: 13px; padding: 5px 13px; border-radius: 999px; background: color-mix(in srgb, var(--tertiary) 88%, transparent); color: var(--ink); font-size: 11px; font-weight: 700; }
.felt-bottom-note { position: absolute; bottom: 13px; left: 50%; color: color-mix(in srgb, var(--table-ink) 58%, transparent); font-size: 9px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; transform: translateX(-50%); }

.hand-section { padding: 18px 10px 0; }
.hand-heading { align-items: flex-end; }
.hand-heading h1 { margin: 5px 0 0; font: 400 32px/1 var(--font-display); }
.points-chip { min-height: 42px; padding: 5px 12px; display: inline-flex; align-items: baseline; gap: 5px; background: var(--primary-soft); color: var(--ink); }
.points-chip span { font-size: 11px; font-weight: 600; }
.points-chip strong { font: 400 22px/1 var(--font-display); }
.points-chip small { color: var(--ink-2); font-size: 10px; }
.points-chip.is-bumped { animation: total-bump 440ms var(--ease-out); }
@keyframes total-bump { 42% { scale: 1.14; rotate: -3deg; } 100% { scale: 1; rotate: 0; } }
.hand-privacy-row { min-height: 36px; margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hand-privacy-status { min-width: 0; flex: 1; color: var(--ink-2); font-size: 11px; font-weight: 600; line-height: 1.2; }
.privacy-toggle { min-height: 34px; flex: 0 0 auto; padding: 0 11px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink); cursor: pointer; font: 600 11px/1 var(--font-text); transition: transform var(--t-ui) var(--ease-out), background var(--t-ui) var(--ease); }
.privacy-toggle:hover { background: var(--tertiary-soft); transform: translateY(-1px); }
.privacy-toggle[aria-pressed="true"] { border-color: color-mix(in srgb, var(--primary) 55%, var(--line)); background: var(--primary-soft); }
.privacy-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.privacy-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hand-tray { position: relative; margin: 8px 0 0; }
.hand-cards { min-height: 188px; padding: 36px 10px 8px; display: flex; align-items: flex-end; justify-content: center; isolation: isolate; }
.playing-card {
  position: relative;
  width: clamp(88px, 8vw, 108px);
  height: clamp(128px, 11vw, 154px);
  flex: 0 0 auto;
  margin-left: -40px;
  padding: 9px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--card-face);
  color: var(--card-ink);
  box-shadow: 0 8px 16px rgba(44, 33, 64, .16);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  transition: transform 320ms var(--ease), box-shadow var(--t-ui) var(--ease);
  transform: translate(var(--drag-x, 0px), calc(var(--fan-drop, 0px) + var(--drag-y, 0px))) rotate(var(--fan-tilt, 0deg));
  transform-origin: 50% 100%;
}
.playing-card:disabled { cursor: default; opacity: 1; }
.playing-card:first-child { margin-left: 0; }
@media (hover: hover) and (pointer: fine) {
  .playing-card:hover:not(:disabled):not(.is-dragging):not(.is-selected) { z-index: 2; transform: translate(var(--drag-x, 0px), calc(var(--fan-drop, 0px) - 5px)) rotate(var(--fan-tilt, 0deg)); }
}
.playing-card.is-selected:not(.is-dragging) { z-index: 3; transform: translate(var(--drag-x, 0px), calc(-22px + var(--drag-y, 0px))) rotate(0deg); box-shadow: 0 13px 22px rgba(44, 33, 64, .23); outline: 2px solid var(--primary); outline-offset: 2px; }
.playing-card.is-dragging { z-index: 8; box-shadow: 0 18px 28px rgba(44, 33, 64, .28); transition: none; transform: translate(var(--drag-x, 0px), calc(var(--fan-drop, 0px) + var(--drag-y, 0px))) rotate(var(--fan-tilt, 0deg)); }
.playing-card.is-dragging.is-selected { transform: translate(var(--drag-x, 0px), calc(-22px + var(--drag-y, 0px))) rotate(0deg); }
.playing-card.is-dragging.is-going-up { filter: saturate(1.18); }
.playing-card.is-in-flight { opacity: 0; }
.hand-cards.is-tossing { pointer-events: none; }
.hand-cards.is-drawing { pointer-events: none; }
.toss-flight-card { position: fixed !important; z-index: 1000 !important; margin: 0 !important; pointer-events: none !important; transform-origin: 50% 50% !important; transition: none !important; }
.toss-flight-card:disabled { color: inherit; }
.draw-flight-card { position: fixed !important; z-index: 1000 !important; margin: 0 !important; pointer-events: none !important; transform-origin: 50% 50% !important; transition: none !important; }
.hand-cards.is-dealing .playing-card { animation: card-deal 640ms var(--ease-out) both; animation-delay: calc(var(--deal-index, 0) * 58ms); }
@keyframes card-deal { 0% { opacity: 0; translate: 0 82px; scale: .84; } 72% { opacity: 1; translate: 0 -9px; scale: 1.03; } 100% { opacity: 1; translate: 0 0; scale: 1; } }
.hand-cards.has-invalid-selection .playing-card.is-selected { outline: 2px solid var(--danger); outline-offset: 2px; }
.card-corner { position: absolute; top: 9px; left: 10px; display: grid; justify-items: center; font-size: 20px; font-weight: 700; line-height: .92; }
.card-corner i { margin-top: 3px; font-size: 17px; font-style: normal; }
.card-corner-bottom { top: auto; right: 10px; bottom: 9px; left: auto; transform: rotate(180deg); }
.card-center-suit { position: absolute; top: 50%; left: 50%; font-size: 38px; line-height: 1; transform: translate(-50%, -50%); }
.hand-hint { min-height: 21px; margin: 0; color: var(--ink-2); font-size: 12px; text-align: center; }
.hand-actions { display: flex; justify-content: center; gap: 10px; margin-top: 10px; }
.action-button { min-width: 150px; }
.action-button svg { width: 17px; height: 17px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.toss-button { min-height: 52px; box-shadow: 0 6px 0 color-mix(in srgb, var(--primary) 55%, var(--line)); }
.toss-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--t-ui) var(--ease-out); }
.toss-button.is-ready:not(:disabled) { animation: none; }
.toss-button.is-ready:not(:disabled) svg { transform: translateY(-2px); }
@keyframes toss-ready { 50% { transform: translateY(-2px) rotate(-1deg); } }
.dhumbal-button { gap: 6px; }
.dhumbal-button:not(:disabled) { animation: none; }
@keyframes call-glimmer { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--tertiary) 20%, transparent), 0 5px 14px rgba(44, 33, 64, .18); } }
.dhumbal-button small { color: var(--ink-3); font-size: 10px; font-weight: 500; }
.demo-disclaimer { margin: 9px 0 0; color: var(--ink-3); font-size: 11px; text-align: center; }

.content-view { max-width: 900px; margin: 0 auto; }
.score-card { overflow: hidden; padding: 0 18px; margin-bottom: 20px; }
.score-row { min-height: 60px; display: grid; grid-template-columns: minmax(0, 1fr) 70px 80px 80px; align-items: center; gap: 10px; border-top: 1px solid var(--line); font-size: 14px; }
.score-row:first-child { border-top: 0; }
.score-row > :nth-child(2), .score-row > :nth-child(3) { text-align: right; }
.score-row strong { font-size: 16px; }
.score-header { min-height: 42px; color: var(--ink-3); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.score-row > span:first-child { display: flex; align-items: center; gap: 10px; }
.score-player > span { min-width: 0; display: grid; line-height: 1.1; }
.score-player strong { font-size: 14px; }
.score-player small { margin-top: 3px; color: var(--ink-3); font-size: 10px; }
.score-value { text-align: right; font-variant-numeric: tabular-nums; }
.score-total { text-align: right; font: 400 20px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.score-entry { animation: score-enter 420ms var(--ease-out) both; animation-delay: calc(var(--row-index, 0) * 55ms); }
@keyframes score-enter { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }
.score-entry.is-winner { background: color-mix(in srgb, var(--tertiary-soft) 50%, transparent); }
.score-entry.is-eliminated { opacity: .5; }
.score-reveal { grid-column: 1 / -1; margin: -8px 0 11px 36px; color: var(--ink-2); font-size: 11px; letter-spacing: .04em; }
.score-dot { width: 26px; height: 26px; font-size: 10px; font-style: normal; }
.score-row.is-you { background: var(--primary-soft); margin: 0 -18px; padding: 0 18px; }
.round-summary { margin: 0 -18px; padding: 13px 18px; background: var(--tertiary-soft); color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.4; }
.score-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.rules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.rule-card { min-height: 130px; display: flex; align-items: flex-start; gap: 14px; }
.rule-number { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--ink); font-size: 12px; font-weight: 700; }
.rule-card h2 { margin: 1px 0 6px; font-size: 16px; font-weight: 700; }
.rule-card p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.rule-open { background: var(--warning-soft); }
.rule-open .rule-number { background: var(--warning); }
.content-view > .button { margin-top: 20px; }

.phone-tabs {
  display: none;
}

.app-credit a, .page-footnote a { color: var(--link); }

.invite-dialog, .install-dialog {
  position: fixed;
  width: min(420px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: min(90dvh, 760px);
  padding: 22px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.invite-dialog::backdrop, .install-dialog::backdrop { background: color-mix(in srgb, var(--overlay) 48%, transparent); }
.invite-dialog[open], .install-dialog[open] { animation: dialog-in var(--t-sheet) var(--ease-out) both; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 6px 0 0; font: 400 28px/1 var(--font-display); }
.dialog-close { width: 40px; height: 40px; }
.dialog-copy { margin: 12px 0; color: var(--ink-2); font-size: 14px; }
.dialog-qr { display: block; width: min(204px, 62vw); height: min(204px, 62vw); margin: 16px auto 8px; }
.dialog-qr-caption { margin: 0 0 12px; color: var(--ink-2); font-size: 12px; line-height: 1.4; text-align: center; }
.dialog-room-code { display: flex; justify-content: space-between; align-items: center; margin: 14px 0; padding: 12px 14px; border-radius: var(--radius-card); background: var(--bg); }
.dialog-room-code span { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.dialog-room-code strong { font: 400 24px/1 var(--font-display); letter-spacing: .08em; }
.dialog-copy-button { width: 100%; }
.dialog-note { margin: 12px 0 0; color: var(--ink-3); font-size: 11px; text-align: center; }

.install-dialog { width: min(480px, calc(100vw - 32px)); padding: 22px; }
.install-heading { display: flex; align-items: center; gap: 14px; }
.install-heading > div { flex: 1; }
.install-heading h2 { margin: 5px 0 2px; font: 400 28px/1 var(--font-display); }
.install-heading p:last-child { margin: 0; color: var(--ink-2); font-size: 13px; }
.app-icon { position: relative; width: 58px; height: 58px; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; border-radius: 14px; background: var(--secondary); color: var(--secondary-ink); font: 400 26px/1 var(--font-display); }
.app-icon::before, .app-icon::after { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); content: ""; }
.app-icon::before { top: 12px; left: 12px; box-shadow: 27px 0 0 var(--primary), 0 27px 0 var(--primary), 27px 27px 0 var(--primary); }
.app-icon::after { top: 25px; left: 25px; }
.app-icon span { position: relative; z-index: 1; }
.app-icon i { display: none; }
.install-benefits { display: grid; gap: 10px; margin: 20px 0; padding: 0; list-style: none; }
.install-benefits li { display: flex; align-items: center; gap: 11px; min-height: 54px; padding: 8px 10px; border-radius: var(--radius-card); background: var(--primary-soft); }
.benefit-mark { width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 700; }
.install-benefits strong, .install-benefits small { display: block; }
.install-benefits strong { font-size: 13px; }
.install-benefits small { margin-top: 2px; color: var(--ink-2); font-size: 11px; }
.install-instructions { margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-card); color: var(--ink-2); font-size: 13px; }
.install-done { width: 100%; }
.install-later { width: 100%; margin-top: 4px; color: var(--ink-2); }
.sheet-grab { display: none; }
.toast { position: fixed; z-index: 20; right: 20px; bottom: max(20px, env(safe-area-inset-bottom)); max-width: min(360px, calc(100vw - 40px)); padding: 12px 16px; border-radius: 999px; background: var(--inverse); color: var(--inverse-ink); box-shadow: var(--shadow); font-size: 13px; font-weight: 600; }

@media (max-width: 760px) {
  .app-frame { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .app-header { width: 100%; min-height: 64px; padding: max(10px, env(safe-area-inset-top)) 16px 8px; gap: 12px; }
  .wordmark { font-size: 25px; }
  .desktop-tabs { display: none; }
  .header-tools { margin-left: auto; }
  .connection-pill { min-height: 30px; padding: 0 9px; font-size: 11px; }
  .theme-button { width: 40px; height: 40px; }
  .main-content { width: 100%; padding: 18px 16px 16px; }
  .welcome-layout { min-height: unset; display: flex; flex-direction: column; align-items: stretch; gap: 24px; }
  .welcome-copy { padding: 8px 0 0; }
  .welcome-copy h1 { max-width: 520px; margin-top: 14px; font-size: clamp(48px, 13vw, 66px); }
  .welcome-dek { margin-bottom: 20px; font-size: 16px; }
  .play-actions { width: 100%; }
  .quick-facts { margin-top: 18px; }
  .welcome-preview { padding: 16px; }
  .mini-table { height: 270px; margin-top: 12px; }
  .mini-seat-west, .mini-seat-east { top: 98px; }
  .mini-piles { top: 92px; }
  .mini-hand { bottom: 23px; }
  .app-credit { margin-top: 22px; }
  .phone-tabs {
    position: fixed;
    z-index: 10;
    right: 0;
    bottom: 0;
    left: 0;
    height: calc(72px + env(safe-area-inset-bottom));
    padding: 0 12px max(14px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    border-top: 1px solid var(--line);
    background: var(--surface);
  }
  .phone-tab { min-width: 0; min-height: 48px; padding: 5px 4px 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; border-top: 2px solid transparent; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 11px; font-weight: 600; }
  .phone-tab svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
  .phone-tab.is-current { border-top-color: var(--primary); color: var(--ink); }
  .app-frame[data-view="table"] { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .app-frame[data-view="table"] .phone-tabs { display: none; }
  .app-frame[data-view="table"] .main-content { padding-top: 8px; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 44px; }
  .lobby-grid { grid-template-columns: 1fr; gap: 14px; }
  .surface-card { padding: 18px; }
  .invite-card { min-height: unset; }
  .qr-preview-wrap { margin-top: 14px; }
  .invite-card .qr-preview { width: 168px; height: 168px; }
  .dialog-qr { width: min(190px, 58vw); height: min(190px, 58vw); }
  .table-toolbar { gap: 8px; }
  .turn-status { max-width: 48%; min-height: 30px; padding: 0 9px; font-size: 10px; white-space: nowrap; }
  .invite-table-button { min-height: 40px; padding: 0 12px; font-size: 13px; }
  .felt { height: clamp(310px, 43svh, 390px); }
  .seat { min-width: 110px; min-height: 38px; gap: 6px; padding: 3px 8px 3px 4px; }
  .seat-nw { top: 10px; left: 5%; }
  .seat-ne { top: 10px; right: 5%; }
  .seat-west { top: 47%; left: 6px; }
  .seat-east { top: 47%; right: 6px; }
  .player-avatar { width: 29px; height: 29px; font-size: 11px; }
  .player-copy strong { font-size: 11px; }
  .player-copy small { font-size: 9px; }
  .seat-west, .seat-east { min-width: 72px; min-height: 72px; padding: 4px 3px; flex-direction: column; border-radius: 14px; background: color-mix(in srgb, var(--table-surface) 92%, transparent); }
  .seat-west .player-copy, .seat-east .player-copy { text-align: center; }
  .seat-west .player-copy small, .seat-east .player-copy small { display: block; font-size: 8px; }
  .seat-west .opponent-fan i, .seat-east .opponent-fan i { width: 11px; height: 16px; margin-left: -6px; }
  .seat-west .opponent-fan i:first-child, .seat-east .opponent-fan i:first-child { margin-left: 0; }
  .seat-west .opponent-fan i::after, .seat-east .opponent-fan i::after { top: 6px; left: 3px; width: 3px; height: 3px; }
  .center-play { width: 220px; top: 52%; }
  .piles { gap: 20px; }
  .pile-card-back, .discard-playing-card { width: 52px; height: 74px; }
  .hand-section { padding: 14px 0 0; }
  .hand-heading h1 { font-size: 29px; }
  .hand-cards { min-height: 176px; padding: 34px 8px 8px; }
  .playing-card { width: clamp(74px, 23vw, 92px); height: clamp(112px, 32vw, 130px); margin-left: -31px; padding: 7px; }
  .playing-card:first-child { margin-left: 0; }
  .card-corner { top: 7px; left: 8px; font-size: 17px; }
  .card-corner i { font-size: 14px; }
  .card-corner-bottom { right: 8px; bottom: 7px; }
  .card-center-suit { font-size: 32px; }
  .hand-actions { gap: 7px; }
  .action-button { min-width: 0; flex: 1 1 auto; padding: 0 12px; font-size: 13px; }
  .dhumbal-button { flex: 0 0 auto; }
  .rules-grid { grid-template-columns: 1fr; }
  .rule-card { min-height: 108px; }
  .score-card { padding: 0 14px; }
  .score-row { grid-template-columns: minmax(0, 1fr) 60px 60px; }
  .score-row.is-you { margin: 0 -14px; padding: 0 14px; }
  .invite-dialog, .install-dialog { width: 100%; max-width: 100%; max-height: min(88dvh, 760px); margin: auto 0 0; padding: 22px 20px max(24px, env(safe-area-inset-bottom)); border-radius: var(--radius-card) var(--radius-card) 0 0; }
  .sheet-grab { width: 36px; height: 4px; display: block; margin: -9px auto 18px; border-radius: 999px; background: var(--line-strong); opacity: .55; }
  .toast { right: 16px; bottom: calc(82px + env(safe-area-inset-bottom)); left: 16px; max-width: none; text-align: center; }
}

@media (max-width: 420px) {
  .connection-pill { gap: 6px; padding: 0 8px; font-size: 10px; }
  .connection-pill .connection-dot { width: 7px; height: 7px; }
  .main-content { padding-right: 12px; padding-left: 12px; }
  .welcome-copy h1 { font-size: 49px; }
  .welcome-dek { font-size: 15px; }
  .join-form { padding: 15px; }
  .join-row .button { padding: 0 15px; }
  .mini-seat-west, .mini-seat-east { gap: 4px; font-size: 10px; }
  .mini-seat-west { left: 6px; }
  .mini-seat-east { right: 6px; }
  .mini-fan { display: none; }
  .table-toolbar { margin-right: 2px; margin-left: 2px; }
  .back-button { gap: 4px; font-size: 12px; }
  .turn-status { gap: 5px; max-width: 48%; padding: 0 7px; font-size: 9px; }
  .invite-table-button { min-height: 38px; padding: 0 9px; font-size: 12px; }
  .felt { height: 318px; }
  .seat { min-width: 98px; }
  .seat-nw { left: 3%; }
  .seat-ne { right: 3%; }
  .seat-west { left: 3px; }
  .seat-east { right: 3px; }
  .player-copy small { display: none; }
  .seat-west, .seat-east { min-width: 62px; }
  .center-play { top: 53%; }
  .center-label { margin-bottom: 8px; }
  .hand-heading h1 { font-size: 27px; }
  .points-chip { min-height: 38px; padding: 4px 9px; gap: 4px; }
  .points-chip span { font-size: 10px; }
  .points-chip strong { font-size: 20px; }
  .playing-card { width: clamp(70px, 23vw, 90px); height: clamp(106px, 32vw, 128px); margin-left: -29px; padding: 6px; }
  .playing-card:first-child { margin-left: 0; }
  .card-corner { top: 6px; left: 7px; font-size: 16px; }
  .card-corner i { font-size: 13px; }
  .card-corner-bottom { right: 7px; bottom: 6px; }
  .card-center-suit { font-size: 29px; }
  .hand-hint { font-size: 11px; }
  .action-button { padding: 0 9px; font-size: 12px; }
  .dhumbal-button small { display: none; }
}

@media (max-width: 350px) {
  .theme-button { width: 36px; height: 36px; }
  .connection-pill { max-width: 125px; overflow: hidden; text-overflow: ellipsis; }
  .seat-nw, .seat-ne { min-width: 90px; }
  .player-avatar { width: 26px; height: 26px; }
  .seat-west, .seat-east { min-width: 58px; }
  .playing-card { margin-left: -35px; }
  .playing-card:first-child { margin-left: 0; }
  .hand-actions { flex-wrap: wrap; }
  .action-button { min-height: 46px; }
}

@media (max-height: 720px) and (max-width: 760px) {
  .felt { height: 300px; }
  .hand-section { padding-top: 10px; }
  .hand-cards { min-height: 154px; padding-top: 30px; }
  .playing-card { height: 104px; }
  .demo-disclaimer { display: none; }
}

@media (max-width: 320px) {
  html, body { min-width: 0; }
}

@media (max-width: 760px) {
  body { overflow-x: hidden; }
  .app-frame[data-view="table"] { height: 100svh; min-height: 100svh; overflow: hidden; padding-bottom: 0; }
  .app-frame[data-view="table"] .app-header { min-height: 58px; height: 58px; padding: max(7px, env(safe-area-inset-top)) 13px 5px; }
  .app-frame[data-view="table"] .wordmark { font-size: 23px; }
  .app-frame[data-view="table"] .connection-pill { min-height: 28px; }
  .app-frame[data-view="table"] .theme-button { width: 36px; height: 36px; }
  .app-frame[data-view="table"] .main-content { height: calc(100svh - 58px); padding: 2px 8px 0; overflow: hidden; }
  .table-view { height: 100%; }
  .table-toolbar { min-height: 40px; height: 40px; margin: 0 2px 4px; gap: 5px; }
  .back-button { min-height: 36px; font-size: 11px; }
  .turn-status { max-width: 50%; min-height: 27px; padding: 0 8px; gap: 5px; font-size: 9px; }
  .invite-table-button { min-height: 34px; padding: 0 9px; font-size: 11px; }
  .game-layout { position: relative; height: calc(100% - 44px); min-height: 0; overflow: visible; }
  .felt { height: clamp(330px, 44svh, 380px); border-radius: 21px; }
  .seat { min-height: 34px; min-width: 92px; padding: 3px 6px 3px 4px; gap: 5px; }
  .seat-nw, .seat-ne { top: 9px; }
  .seat-nw { left: 4%; }
  .seat-ne { right: 4%; }
  .seat-west, .seat-east { top: 46%; min-width: 60px; min-height: 65px; padding: 4px 3px; gap: 2px; }
  .player-avatar { width: 26px; height: 26px; font-size: 10px; }
  .player-copy { min-width: 32px; }
  .player-copy strong { font-size: 10px; }
  .player-copy small { font-size: 8px; }
  .opponent-fan i { width: 10px; height: 15px; margin-left: -5px; }
  .seat-west .opponent-fan i, .seat-east .opponent-fan i { width: 9px; height: 13px; margin-left: -5px; }
  .center-play { top: 49%; width: 205px; }
  .center-label { margin-bottom: 7px; }
  .piles { gap: 15px; }
  .pile-card-back, .discard-playing-card { width: 48px; height: 68px; border-radius: 10px; }
  .turn-callout { margin-top: 8px; padding: 4px 11px; }
  .felt-bottom-note { display: none; }
  .hand-section { position: static; padding: 0; }
  .hand-heading { position: fixed; z-index: 30; bottom: calc(13px + env(safe-area-inset-bottom)); left: 12px; margin: 0; pointer-events: none; }
  .hand-heading > div:first-child { display: none; }
  .points-chip { min-height: 42px; padding: 4px 10px; gap: 4px; border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--line)); border-radius: 999px; box-shadow: 0 5px 15px rgba(44, 33, 64, .16); backdrop-filter: blur(12px); pointer-events: auto; }
  .points-chip span { font-size: 10px; }
  .points-chip strong { font-size: 20px; }
  .hand-privacy-row { position: fixed; z-index: 31; right: 12px; bottom: calc(13px + env(safe-area-inset-bottom)); min-height: 0; margin: 0; }
  .hand-privacy-status { display: none; }
  .privacy-toggle { width: 42px; height: 42px; min-height: 42px; padding: 0; border-radius: 50%; box-shadow: 0 5px 15px rgba(44, 33, 64, .14); }
  .privacy-toggle span { display: none; }
  .hand-tray { position: absolute; inset: 0; margin: 0; pointer-events: none; }
  .hand-cards { position: absolute; z-index: 8; bottom: calc(59px + env(safe-area-inset-bottom)); left: 50%; width: 100vw; height: clamp(215px, 31svh, 280px); min-height: 215px; padding: 0; align-items: flex-end; overflow: visible; transform: translateX(-50%); pointer-events: auto; }
  .playing-card { --hand-card-width: clamp(150px, min(54vw, 22.6svh), 200px); width: var(--hand-card-width); height: clamp(215px, 31svh, 280px); margin-left: calc(min(10.8vw, 4.52svh) - var(--hand-card-width)); padding: 12px; border-radius: 22px; box-shadow: 0 -3px 18px rgba(44, 33, 64, .17); }
  .playing-card:first-child { margin-left: 0; }
  .playing-card.is-selected:not(.is-dragging) { transform: translate(var(--drag-x, 0px), calc(-34px + var(--drag-y, 0px))) rotate(0deg); box-shadow: 0 16px 34px rgba(44, 33, 64, .28); }
  .playing-card.is-dragging { box-shadow: 0 18px 36px rgba(44, 33, 64, .34); }
  .playing-card.is-dragging.is-selected { transform: translate(var(--drag-x, 0px), calc(-34px + var(--drag-y, 0px))) rotate(0deg); }
  .card-corner { top: 15px; left: 22px; font-size: 31px; }
  .card-corner i { margin-top: 5px; font-size: 24px; }
  .card-corner-bottom { right: 22px; bottom: 15px; }
  .card-center-suit { font-size: clamp(96px, 32vw, 130px); }
  .hand-hint, .demo-disclaimer { display: none; }
  .hand-actions { position: fixed; z-index: 32; bottom: calc(13px + env(safe-area-inset-bottom)); left: 50%; margin: 0; gap: 8px; transform: translateX(-50%); }
  .action-button { min-width: 0; min-height: 46px; padding: 0 10px; flex: 0 0 auto; }
  .toss-button, #draw-discard, #draw-stock { width: 46px; height: 46px; min-height: 46px; padding: 0; border-radius: 50%; box-shadow: 0 5px 14px rgba(44, 33, 64, .2); }
  .toss-button { font-size: 0; }
  .toss-button { position: relative; }
  .toss-button .selected-count:not([hidden]) { position: absolute; top: -4px; right: -3px; min-width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%; background: var(--tertiary); color: var(--tertiary-ink); font-size: 11px; font-weight: 700; }
  .toss-button svg, #draw-discard svg, #draw-stock svg { width: 19px; height: 19px; }
  #draw-discard span, #draw-stock span { display: none; }
  #discard-selected:disabled, #call-dhumbal:disabled { display: none; }
  .dhumbal-button { min-height: 42px; padding: 0 11px; border-radius: 999px; background: var(--tertiary); color: var(--tertiary-ink); box-shadow: 0 5px 14px rgba(44, 33, 64, .18); font-size: 12px; }
  .dhumbal-button small { color: inherit; font-size: 10px; }
  .score-card { padding: 0 12px; }
  .score-row { min-height: 54px; grid-template-columns: minmax(0, 1fr) 40px 48px 48px; gap: 5px; font-size: 12px; }
  .score-header { min-height: 36px; font-size: 9px; }
  .score-row > span:first-child { gap: 6px; }
  .score-dot { width: 24px; height: 24px; }
  .score-player strong { font-size: 12px; }
  .score-player small { font-size: 9px; }
  .score-total { font-size: 17px; }
  .score-reveal { margin: -5px 0 9px 30px; font-size: 10px; }
  .score-row.is-you { margin: 0 -12px; padding: 0 12px; }
  .round-summary { margin: 0 -12px; padding: 11px 12px; font-size: 12px; }
}

.game-layout.is-dealing .seat { animation: seat-arrive 560ms var(--ease-out) both; }
.game-layout.is-dealing .seat-nw { animation-delay: 70ms; }
.game-layout.is-dealing .seat-ne { animation-delay: 150ms; }
.game-layout.is-dealing .seat-west { animation-delay: 230ms; }
.game-layout.is-dealing .seat-east { animation-delay: 310ms; }
.game-layout.is-dealing .center-play { animation: center-deal 520ms var(--ease-out) both; animation-delay: 370ms; }
@keyframes seat-arrive { from { opacity: 0; translate: 0 8px; scale: .88; } to { opacity: 1; translate: 0 0; scale: 1; } }
@keyframes center-deal { from { opacity: 0; scale: .84; } to { opacity: 1; scale: 1; } }
.turn-dot { animation: none; }
.turn-callout { animation: none; }
@keyframes turn-beat { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--success) 22%, transparent); } }
@keyframes callout-bob { 50% { translate: 0 -2px; } }

html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }

/* Physical card travel uses the existing Lounge standard curve. */
.bot-flight-card { position: fixed; z-index: 1000; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 3px; padding: 9px; border-radius: 12px; border: 1px solid var(--line); pointer-events: none; transform-origin: center; box-shadow: 0 5px 10px rgba(0,0,0,.16); }
.seat.is-thinking .opponent-fan { animation: none; }
.seat.is-thinking .player-copy small::after { content: " · thinking"; }
@keyframes bot-consider { 0%,100% { transform: rotate(-3deg); } 45% { transform: translateY(-3px) rotate(3deg); } 70% { transform: translateY(-1px) rotate(-1deg); } }
@media (prefers-reduced-motion: reduce) { .seat.is-thinking .opponent-fan { animation: none; } }

/* Flights alone receive compositor hints, released when each ghost is removed. */
.bot-flight-card, .toss-flight-card, .draw-flight-card { will-change: transform, opacity; }

/* Turn text never changes the pile geometry. Previous pickup has its own slot. */
.center-play { height: 224px; }
.center-label { flex: 0 0 12px; }
.piles { flex: 0 0 100px; }
.turn-callout { flex: 0 0 25px; max-width: 100%; white-space: nowrap; }
.previous-discard { height: 50px; min-height: 50px; margin-top: 7px; padding: 4px 12px 4px 5px; display: flex; align-items: center; gap: 9px; border: 1px solid color-mix(in srgb, var(--table-ink) 30%, transparent); border-radius: 12px; background: var(--table-surface); color: var(--table-ink); font: 600 11px var(--font-text); cursor: pointer; }
.previous-discard .discard-playing-card { width: 28px; height: 40px; padding: 4px; border-radius: 5px; font-size: 12px; }
.previous-discard .discard-playing-card i { font-size: 12px; }
.previous-discard.is-empty, .bot-activity.is-empty { visibility: hidden; pointer-events: none; }
.bot-activity { position: absolute; top: 100%; margin-top: 4px; width: 100%; min-height: 28px; }
.toss-flight-card { outline: none !important; box-shadow: 0 3px 8px rgba(44,33,64,.12); }
@media (max-width: 760px) { .center-play { height: 212px; } .piles { flex-basis: 88px; } }

.playing-card.red-suit, .toss-flight-card.red-suit { color: var(--primary); }

/* Selected cards share one flight and stay visibly fanned at the landing. */
.group-flight { position: fixed; z-index: 1000; pointer-events: none; transform-origin: 0 0; will-change: transform; }
.group-flight .toss-flight-card { position: absolute !important; z-index: auto !important; }

.group-flight { color: var(--card-ink); }
.toss-flight-card.black-suit { color: var(--card-ink); }

/* Keep mobile card motion on transform layers, with a fixed paint cost. */
@media (max-width: 760px) {
  .points-chip { backdrop-filter: none; }
  .playing-card, .playing-card.is-selected:not(.is-dragging), .playing-card.is-dragging {
    box-shadow: 0 3px 8px rgba(44, 33, 64, .16);
    transition-property: transform;
  }
  .playing-card.is-dragging { transition: none; }
  .playing-card.is-dragging.is-going-up { filter: none; }
  .hand-cards { contain: layout style; }
  /* The hand has at most five cards. Keep their layers ready before touch. */
  .hand-cards > .playing-card { will-change: transform; backface-visibility: hidden; }
  .toss-flight-card, .draw-flight-card, .bot-flight-card { box-shadow: none; backface-visibility: hidden; }
}

/* The result, rather than the local player, gets the strongest score emphasis. */
.score-card { padding: 0; }
.score-row, .score-row.is-you { margin: 0; padding: 12px 18px; background: transparent; }
.score-header { padding-top: 10px; padding-bottom: 10px; }
.score-entry.is-winner { background: var(--tertiary-soft); border-left: 3px solid var(--tertiary); padding-left: 15px; }
.score-entry.is-winner .score-player small { color: var(--ink); font-weight: 600; }
.score-reveal { margin: 0 0 0 36px; line-height: 1.5; }
.round-summary { margin: 0; padding: 16px 18px; }
.round-summary strong { display: block; margin-bottom: 6px; font-size: 18px; line-height: 1.2; }
.round-summary span { display: block; color: var(--ink-2); font-size: 13px; font-weight: 400; }
@media (max-width: 760px) {
  .score-row, .score-row.is-you { grid-template-columns: minmax(0, 1fr) 42px 50px 50px; gap: 6px; padding: 12px; }
  .score-entry.is-winner { padding-left: 9px; }
  .score-player strong { overflow-wrap: anywhere; }
  .score-reveal { margin-left: 30px; }
  .round-summary { padding: 15px 12px; }
}

.motion-settings { margin-bottom: 18px; }
.motion-settings h2 { margin: 0 0 16px; font: 400 24px/1.2 var(--font-display); }
.motion-settings select { width: 100%; min-height: 48px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 10px 12px; background: var(--bg); color: var(--ink); font: inherit; font-size: 16px; }
.toast { pointer-events: none; }
