/* =========================================================
   Up the River - table styles
   Tokens first, then themes, then components.
   ========================================================= */
:root {
  /* type */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-xs: 11px; --fs-sm: 13px; --fs-md: 15px; --fs-lg: 18px; --fs-xl: 24px; --fs-2xl: 34px;

  /* palette */
  --gold: #e8b64a;
  --gold-hi: #f8dc8e;
  --gold-lo: #a8741a;
  --ink: #f4ecd8;
  --ink-dim: #c9b894;
  --panel: #1b1109;
  --panel-2: #2a190c;
  --good: #7ee2a0;
  --bad: #ff8f84;

  /* table theme (green felt default) */
  --felt-1: #1f8556; --felt-2: #0e5a3a; --felt-3: #06301e;
  --rail-1: #8a5530; --rail-2: #5a3418; --rail-3: #2e1809;
  --brass: #d9a22f;
  --room-1: #2a190c; --room-2: #120a05;

  /* deck theme (classic) */
  --paper-1: #fffdf6; --paper-2: #efe6cf; --card-line: rgba(0,0,0,.35);
  --face-bg: #fff8e6;
  --c-S: #17171c; --c-C: #17171c; --c-H: #c2352b; --c-D: #c2352b;

  /* sizing */
  --cw: clamp(42px, min(12.5vw, 7.6vh), 72px);
  --ch: calc(var(--cw) * 1.4);
  --hw: clamp(52px, min(15.5vw, 9.6vh), 92px);
  --hand-h: calc(var(--hw) * 1.4 + 46px);
}

/* ----- table themes ----- */
html[data-table="midnight"] {
  --felt-1: #2f4f94; --felt-2: #19305f; --felt-3: #0a1633;
  --rail-1: #5b6277; --rail-2: #353b4f; --rail-3: #171a28; --brass: #c8d2ee;
  --room-1: #0f1424; --room-2: #070a14;
}
html[data-table="burgundy"] {
  --felt-1: #9a2c3e; --felt-2: #681828; --felt-3: #350812;
  --rail-1: #6a4a2a; --rail-2: #3e2812; --rail-3: #1e1006; --brass: #e0b25a;
  --room-1: #2a0e14; --room-2: #12050a;
}
html[data-table="wood"] {
  --felt-1: #c58b4f; --felt-2: #9a6430; --felt-3: #5c3416;
  --rail-1: #3b2a20; --rail-2: #231710; --rail-3: #0f0905; --brass: #e8b64a;
  --room-1: #22160e; --room-2: #0e0803;
}

/* ----- deck themes ----- */
html[data-deck="fourcolor"] { --c-D: #1f62c8; --c-C: #1f8a3a; }
html[data-deck="dark"] {
  --paper-1: #2b2e42; --paper-2: #171926; --card-line: rgba(232,182,74,.6); --face-bg: #222538;
  --c-S: #ece6d4; --c-C: #ece6d4; --c-H: #ff7468; --c-D: #ff7468;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--room-2); overscroll-behavior: none; }
body {
  font-family: var(--font-ui); color: var(--ink); touch-action: manipulation;
  -webkit-user-select: none; user-select: none; -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
.hidden { display: none !important; }
.play { position: fixed; inset: 0; max-width: 640px; margin: 0 auto; overflow: hidden; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }

/* =========================================================
   Buttons
   ========================================================= */
.primary {
  font-weight: 800; font-size: var(--fs-lg); letter-spacing: .02em; color: #3a2605; border: 0; border-radius: 16px; padding: 15px 18px;
  background: linear-gradient(#fbe39a, #e1a93a 55%, #c28a22); cursor: pointer; position: relative;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), inset 0 -2px 0 rgba(120,70,0,.35), 0 5px 0 #8e5f12, 0 12px 20px rgba(0,0,0,.4);
  transition: transform .08s, box-shadow .08s;
}
.primary:active { transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 2px 0 #8e5f12, 0 6px 10px rgba(0,0,0,.4); }
.primary:disabled { filter: grayscale(.8) brightness(.7); }
.ghost {
  font-weight: 700; font-size: var(--fs-md); color: var(--ink); background: rgba(255,255,255,.05); border: 1px solid rgba(232,182,74,.45);
  border-radius: 14px; padding: 13px 16px; cursor: pointer; transition: background .15s, transform .08s;
}
.ghost:active { background: rgba(232,182,74,.18); transform: scale(.98); }
.chip-btn {
  font-size: var(--fs-sm); font-weight: 700; color: var(--ink); background: linear-gradient(rgba(255,255,255,.12), rgba(255,255,255,.04));
  border: 1px solid rgba(255,255,255,.2); border-radius: 11px; padding: 8px 11px; cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.chip-btn:active { transform: translateY(1px); box-shadow: none; }
.chip-btn.small { padding: 6px 9px; font-size: 12px; }
.chip-btn:disabled { opacity: .35; }
.hintbtn:not(:disabled) { border-color: var(--gold); color: var(--gold-hi); }
.linkish { background: none; border: 0; color: #bfe3cd; text-decoration: underline; font-size: var(--fs-md); cursor: pointer; }

/* =========================================================
   Title + setup screens
   ========================================================= */
.title, .setup {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,255,255,.14), transparent 55%),
    radial-gradient(ellipse at 50% 35%, var(--felt-1) 0%, var(--felt-2) 50%, var(--felt-3) 100%);
  padding: max(18px, env(safe-area-inset-top)) 20px max(18px, env(safe-area-inset-bottom)); overflow-y: auto;
}
.title::before, .setup::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5; mix-blend-mode: overlay;
  background-image: var(--felt-noise);
}
.title::after, .setup::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 45%, rgba(0,0,0,.55) 100%);
}
.title > *, .setup > * { position: relative; z-index: 1; }
.title { align-items: center; justify-content: center; text-align: center; gap: 0; }
.fan { position: relative; height: calc(var(--aw) * 1.4 + 40px); width: 100%; margin-bottom: 6px; --aw: 86px; }
.fan .fc-card { position: absolute; left: 50%; top: 22px; margin-left: calc(var(--aw) / -2); transform-origin: 50% 190%; animation: fanin .9s cubic-bezier(.2,.9,.3,1.2) backwards; }
.fan .card { --cw: var(--aw); --ch: calc(var(--aw) * 1.4); box-shadow: 0 10px 20px rgba(0,0,0,.55), 0 1px 0 #fff inset; }
@keyframes fanin { from { transform: rotate(0) translateY(60px) scale(.6); opacity: 0; } }
.logo {
  margin: 0; font-family: var(--font-display); font-size: clamp(38px, 12vw, 54px); line-height: .95; letter-spacing: -.5px; font-weight: 700;
  background: linear-gradient(#fff6d2, #f0c250 55%, #b57d1a); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.45)) drop-shadow(0 8px 14px rgba(0,0,0,.4));
}
.logo small { display: block; margin-top: 8px; font-size: .48em; font-style: italic; font-weight: 400; letter-spacing: .02em; }
.river-line { width: 150px; height: 14px; margin: 14px auto 22px; opacity: .9; }
.menu-col { display: grid; gap: 12px; width: min(340px, 100%); }
.menu-row { display: flex; gap: 10px; }
.menu-row > * { flex: 1; }
.record { text-align: center; color: #a9d4ba; font-size: var(--fs-sm); margin: 16px 0 0; min-height: 1.2em; }
.resume-card {
  display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 14px 18px; color: #3a2605; border: 0; border-radius: 16px;
  background: linear-gradient(#fbe39a, #e1a93a 55%, #c28a22); cursor: pointer; text-align: left; font-size: var(--fs-lg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 5px 0 #8e5f12, 0 12px 20px rgba(0,0,0,.4);
}
.resume-card span { display: grid; gap: 2px; }
.resume-card small { font-size: 12px; opacity: .8; font-weight: 600; }
.resume-card b { font-size: 26px; }

.back-link { color: #bfe3cd; text-decoration: none; font-size: var(--fs-md); display: inline-block; padding: 4px 0; background: none; border: 0; cursor: pointer; text-align: left; }
.setup h2 { font-family: var(--font-display); font-size: var(--fs-2xl); margin: 10px 0 14px; color: #fff4d6; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.setup-card {
  background: linear-gradient(rgba(0,0,0,.34), rgba(0,0,0,.24)); border: 1px solid rgba(232,182,74,.28); border-radius: 20px; padding: 18px;
  display: grid; gap: 16px; backdrop-filter: blur(4px); box-shadow: 0 14px 30px rgba(0,0,0,.35); max-width: 520px; width: 100%; margin: 0 auto;
}
.setup-card label { min-width: 0; display: grid; gap: 8px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #cfe8d8; }
.setup-card input#name { width: 100%; min-width: 0;
  font: inherit; font-size: var(--fs-lg); letter-spacing: 0; text-transform: none; color: #fff; font-weight: 600;
  background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.22); border-radius: 12px; padding: 12px 14px; -webkit-user-select: text; user-select: text;
}
.setup-card label.check { display: flex; align-items: center; gap: 12px; text-transform: none; letter-spacing: 0; font-size: var(--fs-md); color: #fff; font-weight: 600; }
.setup-card label.check span { display: grid; gap: 2px; }
.setup-card label.check small { color: #9fcbb2; font-size: 12px; font-weight: 400; }
.setup-card label.check input { width: 24px; height: 24px; accent-color: var(--gold); flex: none; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button, .segmented button {
  font-weight: 700; color: #fff; background: linear-gradient(rgba(255,255,255,.14), rgba(255,255,255,.05)); border: 1px solid rgba(255,255,255,.22);
  border-radius: 12px; cursor: pointer; box-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.stepper button { width: 46px; height: 46px; font-size: 22px; }
.stepper output { min-width: 42px; text-align: center; font-size: var(--fs-xl); font-weight: 800; letter-spacing: 0; color: #fff; font-family: var(--font-display); }
.segmented { display: flex; gap: 8px; }
.segmented button { flex: 1; padding: 12px 0; font-size: var(--fs-md); }
.segmented button.on { background: linear-gradient(#fbe39a, #d9a22f); color: #3a2605; border-color: var(--gold); box-shadow: 0 2px 0 #8e5f12; }
.hint { margin: 0; font-size: var(--fs-sm); color: #9fcbb2; min-height: 1.2em; }
.friends { font-weight: 800; font-size: var(--fs-md); color: var(--ink); background: rgba(255,255,255,.06); border: 1px solid rgba(232,182,74,.55); border-radius: 14px; padding: 13px; cursor: pointer; }

/* style picker */
.swatches { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0 14px; }
.swatch { width: 62px; text-align: center; font-size: 11px; color: var(--ink-dim); background: none; border: 0; padding: 0; cursor: pointer; }
.swatch i { display: block; width: 62px; height: 62px; border-radius: 50%; margin-bottom: 5px; border: 3px solid transparent; box-shadow: 0 4px 10px rgba(0,0,0,.5), inset 0 0 0 5px var(--r); background: radial-gradient(circle at 50% 40%, var(--f1), var(--f3)); }
.swatch.on i { border-color: var(--gold); box-shadow: 0 0 0 2px #000, 0 0 16px rgba(232,182,74,.7), inset 0 0 0 5px var(--r); }
.swatch.on { color: var(--gold-hi); font-weight: 700; }
.deckprev { display: flex; gap: 10px; flex-wrap: wrap; }
.deckopt { background: none; border: 2px solid transparent; border-radius: 14px; padding: 8px; cursor: pointer; color: var(--ink-dim); font-size: 11px; display: grid; gap: 6px; justify-items: center; }
.deckopt.on { border-color: var(--gold); color: var(--gold-hi); font-weight: 700; background: rgba(232,182,74,.08); }
.deckopt .pair { display: flex; }
.deckopt .card { --cw: 40px; --ch: 56px; margin-left: -10px; }
.deckopt .card:first-child { margin-left: 0; }

/* =========================================================
   Table screen
   ========================================================= */
.table-screen { background: var(--room-2); }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: max(8px, env(safe-area-inset-top)) 10px 8px; z-index: 5;
  background: linear-gradient(var(--panel-2), var(--panel)); border-bottom: 2px solid #000; box-shadow: 0 4px 14px rgba(0,0,0,.45);
}
.round-info { flex: 1; min-width: 0; display: grid; line-height: 1.15; }
.round-info strong { font-family: var(--font-display); font-size: var(--fs-lg); white-space: nowrap; }
.round-info span { font-size: 12px; color: var(--ink-dim); white-space: nowrap; }
.trump { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); line-height: 1.1; color: var(--ink-dim); white-space: nowrap; }
.trump b { color: #fff4d6; font-size: 12px; }
.trump .card { --cw: 30px; --ch: 42px; }
.trump.flip .card { animation: flip .7s ease-out; }
@keyframes flip { 0% { transform: rotateY(90deg) scale(.7); } 60% { transform: rotateY(-12deg) scale(1.15); } 100% { transform: none; } }

.table-wrap { position: relative; flex: 1; min-height: 0; padding: 10px 10px 2px; background: radial-gradient(ellipse at 50% 100%, var(--room-1), var(--room-2)); }
.table {
  position: relative; width: 100%; height: 100%; border-radius: 46% / 40%;
  border: 15px solid transparent;
  background:
    radial-gradient(ellipse at 50% 28%, rgba(255,255,255,.16), transparent 62%) padding-box,
    radial-gradient(ellipse at 50% 46%, var(--felt-1) 0%, var(--felt-2) 58%, var(--felt-3) 100%) padding-box,
    repeating-linear-gradient(97deg, rgba(255,255,255,.07) 0 2px, rgba(0,0,0,.09) 2px 5px, transparent 5px 9px) border-box,
    linear-gradient(160deg, var(--rail-1), var(--rail-2) 55%, var(--rail-3)) border-box;
  box-shadow:
    0 0 0 2px #000,
    inset 0 0 0 2px rgba(0,0,0,.5), inset 0 0 0 4px color-mix(in srgb, var(--brass) 55%, transparent),
    0 20px 34px rgba(0,0,0,.6), 0 4px 0 rgba(0,0,0,.5);
  transition: box-shadow .2s;
}
.table > .felt-fx {
  position: absolute; inset: 0; border-radius: 46% / 40%; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse at 50% 50%, transparent 38%, rgba(0,0,0,.55) 100%),
    var(--felt-noise);
  mix-blend-mode: multiply; opacity: .9;
  box-shadow: inset 0 14px 38px rgba(0,0,0,.55), inset 0 -6px 22px rgba(0,0,0,.35);
}
.table.drop-ready { box-shadow: 0 0 0 2px #000, inset 0 0 0 4px var(--gold), 0 20px 34px rgba(0,0,0,.6); }
.table.shake { animation: shake .55s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 10%,90% { transform: translate3d(-2px,0,0); } 20%,80% { transform: translate3d(4px,2px,0); } 30%,50%,70% { transform: translate3d(-7px,-2px,0); } 40%,60% { transform: translate3d(7px,2px,0); } }
.felt-ring { position: absolute; inset: 9%; border-radius: 46% / 40%; border: 1.5px solid color-mix(in srgb, var(--brass) 38%, transparent); pointer-events: none; z-index: 1; }
.suit-mark { position: absolute; left: 50%; top: 50%; width: 38%; max-width: 160px; aspect-ratio: 1; transform: translate(-50%, -50%); pointer-events: none; z-index: 1; opacity: .16; fill: #000; transition: opacity .4s; }
.suit-mark.red { fill: #5a0a05; opacity: .22; }
.seats, .center { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.center { z-index: 4; }
.confetti { position: absolute; inset: -14px; width: calc(100% + 28px); height: calc(100% + 28px); pointer-events: none; z-index: 9; }
.spot {
  position: absolute; width: 46%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none; z-index: 0;
  background: radial-gradient(circle, rgba(255,225,150,.34), rgba(255,225,150,.1) 45%, transparent 70%); mix-blend-mode: screen;
  transition: left .55s cubic-bezier(.3,.8,.3,1), top .55s cubic-bezier(.3,.8,.3,1), opacity .3s;
}
.deck { position: absolute; left: 50%; top: 40%; z-index: 3; width: var(--cw); height: var(--ch); transform: translate(-50%, -50%); pointer-events: none; opacity: 0; transition: opacity .25s; }
.deck.on { opacity: 1; }
.deck .card { position: absolute; inset: 0; width: 100%; height: 100%; }
.deck .card:nth-child(1) { transform: translate(-2px, 3px) rotate(-3deg); }
.deck .card:nth-child(2) { transform: translate(-1px, 1.5px) rotate(1deg); }

/* seats */
.seat { position: absolute; transform: translate(-50%, -50%); width: 90px; text-align: center; transition: filter .3s; }
.avatar {
  position: relative; width: 50px; height: 50px; margin: 0 auto; border-radius: 50%; overflow: visible;
  background: radial-gradient(circle at 35% 28%, var(--c1), var(--c2)); border: 2.5px solid rgba(255,255,255,.85);
  box-shadow: 0 4px 9px rgba(0,0,0,.55), inset 0 -4px 8px rgba(0,0,0,.25);
}
.avatar .av-svg { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; overflow: hidden; }
.avatar.pop { animation: avpop .5s ease-out; }
@keyframes avpop { 40% { transform: scale(1.22) rotate(-4deg); } }
.seat.active .avatar { box-shadow: 0 0 0 3px var(--gold), 0 0 20px 5px rgba(232,182,74,.8); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 28px 9px rgba(232,182,74,.95); } }
.dealer-dot {
  position: absolute; right: -7px; bottom: -5px; width: 20px; height: 20px; border-radius: 50%; z-index: 2;
  background: radial-gradient(circle at 35% 30%, #fff, #e8d9ae); color: #5a3a08; font-size: 11px; font-weight: 900; display: grid; place-items: center;
  border: 1.5px solid var(--gold); box-shadow: 0 2px 4px rgba(0,0,0,.5);
}
.plate {
  margin-top: 5px; padding: 3px 6px 4px; border-radius: 11px; line-height: 1.15;
  background: linear-gradient(rgba(10,6,2,.72), rgba(10,6,2,.55)); border: 1px solid rgba(255,255,255,.14); box-shadow: 0 3px 8px rgba(0,0,0,.4);
}
.plate .nm { display: block; font-size: var(--fs-xs); font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: .02em; }
.plate .bt { display: block; font-size: var(--fs-xs); color: #e8d9ae; white-space: nowrap; }
.plate .bt b { color: #fff; display: inline-block; }
.plate .bt.ok b { color: var(--good); }
.plate .bt.over b { color: var(--bad); }
.plate .bt.dim { color: #9fb5a6; }
.plate .bt.bidpop b { animation: bidpop .55s ease-out; }
@keyframes bidpop { 0% { transform: scale(2.4); opacity: 0; } 60% { transform: scale(.9); } 100% { transform: scale(1); opacity: 1; } }
.plate .sc { display: block; font-size: 10px; color: #9fcbb2; }
.backs { display: flex; justify-content: center; height: 14px; margin-top: 3px; }
.backs i { width: 10px; height: 14px; margin-left: -5px; border-radius: 2px; border: 1px solid #fff; background: var(--card-back) center / 100% 100%; }
.backs i:first-child { margin-left: 0; }
.backs span { font-size: 10px; margin-left: 4px; align-self: center; color: #bcd; }
.seats.compact .seat { width: 72px; }
.seats.compact .avatar { width: 38px; height: 38px; border-width: 2px; }
.seats.compact .plate .sc, .seats.compact .backs { display: none; }
.seats.compact .plate .nm, .seats.compact .plate .bt { font-size: 10px; }

.bubble {
  position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); margin-bottom: 2px; z-index: 6; white-space: nowrap;
  background: #fff4d6; color: #2b1c08; font-size: 12px; font-weight: 800; padding: 5px 10px; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,.5);
  animation: bub 1.9s ease-out forwards;
}
.bubble::after { content: ""; position: absolute; left: 50%; top: 100%; margin-left: -5px; border: 5px solid transparent; border-top-color: #fff4d6; }
@keyframes bub { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.7); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 20% { transform: translate(-50%, 0) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -6px); } }
.float { position: absolute; transform: translate(-50%, -50%); font-family: var(--font-display); font-weight: 900; font-size: 30px; text-shadow: 0 2px 6px rgba(0,0,0,.7); animation: floatup 1.2s ease-out forwards; z-index: 7; }
.float.plus { color: #8ff0b0; }
@keyframes floatup { from { opacity: 0; margin-top: 10px; scale: .6; } 15% { opacity: 1; scale: 1.2; } to { opacity: 0; margin-top: -54px; scale: 1; } }
.status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 66%; text-align: center; font-family: var(--font-display); font-style: italic; font-size: var(--fs-md); color: rgba(255,244,214,.82); pointer-events: none; text-shadow: 0 2px 4px rgba(0,0,0,.6); transition: opacity .2s; z-index: 3; }
.status.hide { opacity: 0; }
.round-banner {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%) scale(.8); text-align: center; opacity: 0; pointer-events: none; z-index: 8; white-space: nowrap;
  background: linear-gradient(rgba(10,6,2,.86), rgba(10,6,2,.74)); border: 1px solid rgba(232,182,74,.7); border-radius: 18px; padding: 14px 28px;
  box-shadow: 0 0 0 4px rgba(0,0,0,.3), 0 14px 30px rgba(0,0,0,.6);
}
.round-banner strong { display: block; font-family: var(--font-display); font-size: var(--fs-2xl); color: #fff4d6; }
.round-banner span { color: var(--gold); font-size: var(--fs-sm); letter-spacing: .06em; text-transform: uppercase; font-weight: 700; }
.round-banner.show { animation: banner 1.6s ease-out forwards; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); } 28% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -64%) scale(1); } }

/* =========================================================
   Cards
   ========================================================= */
.card {
  position: relative; width: var(--cw); height: var(--ch); border-radius: calc(var(--cw) * .11); flex: none; overflow: hidden;
  background: linear-gradient(160deg, var(--paper-1), var(--paper-2)); color: var(--sc, var(--c-S)); font-family: var(--font-display);
  border: 1px solid var(--card-line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), inset 0 -2px 3px rgba(0,0,0,.08), 0 2px 5px rgba(0,0,0,.5);
}
.card[data-suit="S"] { --sc: var(--c-S); } .card[data-suit="C"] { --sc: var(--c-C); }
.card[data-suit="H"] { --sc: var(--c-H); } .card[data-suit="D"] { --sc: var(--c-D); }
.card svg.sx { fill: var(--sc); display: block; }
.card.tr { box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 2px 5px rgba(0,0,0,.5), inset 0 0 0 2px color-mix(in srgb, var(--brass) 65%, transparent); }
.cn { position: absolute; left: 4%; top: 2.5%; display: grid; justify-items: center; gap: calc(var(--cw) * .02); line-height: 1; font-size: calc(var(--cw) * .3); font-weight: 700; z-index: 2; width: calc(var(--cw) * .24); }
.cn .sx { width: calc(var(--cw) * .18); height: calc(var(--cw) * .18); }
.cn.br { left: auto; right: 5%; top: auto; bottom: 3%; transform: rotate(180deg); }
.pp { position: absolute; width: calc(var(--cw) * .2); height: calc(var(--cw) * .2); transform: translate(-50%, -50%); }
.pp.dn { transform: translate(-50%, -50%) rotate(180deg); }
.pp.ace { width: calc(var(--cw) * .56); height: calc(var(--cw) * .56); filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
.card .face { position: absolute; left: 15%; top: 5%; width: 70%; height: 90%; }
.card.back {
  background: var(--card-back) center / 100% 100% no-repeat; border: 1px solid rgba(0,0,0,.5); color: transparent;
}
.card.back > * { display: none; }
.tcard {
  position: absolute; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); z-index: var(--z, 1);
  transition: left .44s cubic-bezier(.2,.8,.25,1), top .44s cubic-bezier(.2,.8,.25,1), opacity .4s, transform .44s;
}
.tcard .card { box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 10px 14px rgba(0,0,0,.45), 0 2px 3px rgba(0,0,0,.5); }
.tcard.win .card { box-shadow: 0 0 0 3px var(--gold), 0 0 26px rgba(248,220,142,.95), 0 10px 14px rgba(0,0,0,.45); }
.tcard.gone { opacity: 0; transform: translate(-50%, -50%) scale(.5) rotate(calc(var(--rot, 0deg) + 160deg)); transition-duration: .46s; }
.flyer { position: absolute; z-index: 5; pointer-events: none; will-change: transform; left: 0; top: 0; }
.flyer .card { --cw: 22px; --ch: 31px; }
.spark { position: absolute; z-index: 8; pointer-events: none; width: 8px; height: 8px; border-radius: 50%; background: var(--gold-hi); box-shadow: 0 0 8px 2px rgba(248,220,142,.9); will-change: transform, opacity; left: 0; top: 0; }

/* =========================================================
   Me bar, hand, bid panel
   ========================================================= */
.me-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--panel); font-size: var(--fs-sm); z-index: 4; border-top: 1px solid rgba(232,182,74,.25); }
.me-bar .avatar { width: 38px; height: 38px; margin: 0; border-width: 2px; }
.me-bar .who { flex: 1; min-width: 0; line-height: 1.2; }
.me-bar .who strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 800; }
.me-bar .who span { color: var(--ink-dim); font-size: 12px; }
.me-bar.active { background: linear-gradient(90deg, #4f3607, var(--panel)); }
.me-bar.active .avatar { box-shadow: 0 0 0 3px var(--gold), 0 0 14px rgba(232,182,74,.7); }
.me-bar .tally { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 800; white-space: nowrap; }
.me-bar .tally small { font-family: var(--font-ui); font-size: var(--fs-xs); font-weight: 600; color: var(--ink-dim); margin-left: 3px; }
.me-bar .tally.pop { animation: bidpop .5s ease-out; }

.hand {
  --cw: var(--hw); --ch: calc(var(--hw) * 1.4);
  position: relative; height: var(--hand-h); padding-bottom: env(safe-area-inset-bottom); overflow: hidden; touch-action: none;
  background: radial-gradient(ellipse at 50% 120%, #2c1a0b, var(--room-2) 70%);
}
.hand.lifting { overflow: visible; z-index: 20; }
.hand .hc { position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); left: 0; transform-origin: 50% 150%; transition: transform .2s cubic-bezier(.2,.8,.25,1), filter .2s; cursor: pointer; }
.hand .hc .card { box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 -2px 8px rgba(0,0,0,.35), 0 3px 6px rgba(0,0,0,.55); }
.hand.lifting .hc { transition: none; }
.hand.dealing .hc { animation: deal .62s cubic-bezier(.25,.9,.3,1.1) backwards; animation-delay: calc(var(--i) * 70ms + 200ms); }
@keyframes deal {
  0% { opacity: 0; translate: 0 -330px; scale: .35; rotate: -40deg; }
  55% { opacity: 1; translate: 0 -90px; scale: 1.08; rotate: 8deg; }
}
.hand .hc.dim { filter: brightness(.55) saturate(.55); }
.hand .hc.sel .card { box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(248,220,142,.7), 0 10px 18px rgba(0,0,0,.6); }
.hand .hc.hint .card { animation: hintglow 1s ease-in-out infinite; }
@keyframes hintglow { 50% { box-shadow: 0 0 0 4px #7ee2a0, 0 0 22px rgba(126,226,160,.9); } }

.bid-panel {
  position: absolute; left: 8px; right: 8px; bottom: calc(var(--hand-h) + 50px); z-index: 8; padding: 11px 12px;
  background: linear-gradient(rgba(30,18,8,.95), rgba(14,8,3,.94)); border: 1px solid rgba(232,182,74,.6); border-radius: 18px;
  box-shadow: 0 14px 34px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.08); animation: rise .28s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.97); } }
.bid-panel h3 { margin: 0 0 3px; font-family: var(--font-display); font-size: var(--fs-lg); }
.bid-panel p { margin: 0 0 8px; font-size: 12px; color: var(--ink-dim); line-height: 1.4; }
.bid-panel p b { color: #fff; }
.bid-panel p.pressure { color: var(--gold-hi); }
.bid-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.bid-grid button {
  min-width: 38px; height: 42px; font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 800; color: #fff;
  background: linear-gradient(rgba(255,255,255,.16), rgba(255,255,255,.05)); border: 1px solid rgba(255,255,255,.25); border-radius: 12px; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.45); transition: transform .08s;
}
.bid-grid button.suggest { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 3px 0 rgba(0,0,0,.45); color: var(--gold-hi); }
.bid-grid button.board { background: linear-gradient(#f0675a, #a52f25); border-color: #ffb0a8; padding: 0 12px; font-size: var(--fs-md); font-family: var(--font-ui); letter-spacing: .04em; text-transform: uppercase; }
.bid-grid button:disabled { opacity: .25; text-decoration: line-through; }
.bid-grid button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.45); }

/* =========================================================
   Sheets
   ========================================================= */
.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.62); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet-body {
  width: 100%; max-width: 640px; max-height: 88dvh; display: flex; flex-direction: column; border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom);
  background: linear-gradient(#241509, #150c05); border-top: 2px solid var(--gold); box-shadow: 0 -10px 40px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.1);
  animation: rise .3s cubic-bezier(.2,.9,.3,1.1);
}
.sheet-body::before { content: ""; display: block; width: 44px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.22); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 18px 6px; min-height: 48px; }
.sheet-head h2 { margin: 0; font-family: var(--font-display); font-size: var(--fs-xl); color: #fff4d6; }
.sheet-content { overflow: auto; padding: 4px 18px 20px; }
.scroll-x { overflow-x: auto; }
.sheet-content table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.sheet-content th, .sheet-content td { padding: 6px 5px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.08); white-space: nowrap; }
.sheet-content th { color: var(--ink-dim); font-weight: 700; font-size: var(--fs-xs); position: sticky; top: 0; background: #1b1109; }
.sheet-content td:first-child, .sheet-content th:first-child { text-align: left; }
.pos { color: var(--good); } .neg { color: var(--bad); }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid rgba(255,255,255,.08); }
.rank-row.res { animation: slidein .4s cubic-bezier(.2,.9,.3,1) backwards; animation-delay: var(--d, 0ms); }
.rank-row.me { background: linear-gradient(90deg, rgba(232,182,74,.18), rgba(232,182,74,.04)); border-radius: 12px; }
@keyframes slidein { from { opacity: 0; transform: translateX(-20px); } }
.rank-row .n { width: 30px; font-weight: 800; color: var(--gold); font-size: var(--fs-lg); }
.rank-row .mark { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 900; flex: none; }
.mark.ok { background: linear-gradient(#2fa564, #1a6a3d); color: #fff; animation: popin .45s ease-out backwards; animation-delay: calc(var(--d, 0ms) + 250ms); box-shadow: 0 0 10px rgba(126,226,160,.5); }
.mark.no { background: linear-gradient(#a8382c, #6a1c14); color: #fff; }
@keyframes popin { from { transform: scale(0); } 70% { transform: scale(1.3); } }
.rank-row .nm { flex: 1; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .d { font-size: 12px; color: var(--ink-dim); white-space: nowrap; }
.rank-row .s { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 800; min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }
.medal { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-family: var(--font-display); font-weight: 900; font-size: 15px; color: #3a2605; box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 2px 4px rgba(0,0,0,.5); }
.medal.m1 { background: linear-gradient(#fbe39a, #c28a22); } .medal.m2 { background: linear-gradient(#f2f4f8, #98a2b3); } .medal.m3 { background: linear-gradient(#f0c09a, #a8642c); }
.leader { text-align: center; color: var(--ink-dim); margin: 14px 0 0; font-size: var(--fs-md); }
.sheet-actions { display: grid; gap: 10px; margin-top: 16px; position: sticky; bottom: -2px; padding-top: 12px; background: linear-gradient(rgba(21,12,5,0), #150c05 28%); }
.banner { text-align: center; font-family: var(--font-display); font-size: 34px; margin: 4px 0 10px; background: linear-gradient(#fff6d2, #f0c250, #b57d1a); -webkit-background-clip: text; background-clip: text; color: transparent; animation: bidpop .7s ease-out; }
.last-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 8px 0; }
.last-card { display: grid; gap: 6px; justify-items: center; font-size: 12px; color: var(--ink-dim); --cw: 58px; --ch: 81px; }
.last-card.w .card { box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(232,182,74,.8); }
.last-card.w span { color: var(--gold-hi); font-weight: 800; }
.rules h3 { margin: 14px 0 4px; color: var(--gold); font-size: var(--fs-md); font-family: var(--font-display); }
.rules p, .rules li { font-size: 14px; line-height: 1.5; color: #e8dcc0; margin: 0 0 6px; }
.rules ul { margin: 0; padding-left: 18px; }
.code-big { text-align: center; font-family: var(--font-display); font-size: 48px; letter-spacing: .18em; margin: 4px 0 2px; background: linear-gradient(#fff6d2, #f0c250, #b57d1a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.seat-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid rgba(255,255,255,.08); }
.seat-row .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); flex: none; box-shadow: 0 0 8px var(--good); }
.seat-row .dot.off { background: #777; box-shadow: none; }
.seat-row .nm { flex: 1; font-weight: 700; }
.seat-row .tag { font-size: var(--fs-xs); color: var(--gold); letter-spacing: .1em; text-transform: uppercase; font-weight: 700; }
.seat-row .avatar { width: 30px; height: 30px; margin: 0; border-width: 2px; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; min-width: 0; font: inherit; font-size: 22px; letter-spacing: .2em; text-transform: uppercase; text-align: center; color: #fff; background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.25); border-radius: 12px; padding: 10px; -webkit-user-select: text; user-select: text; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; font-size: 14px; }
.mini-row .stepper button { width: 38px; height: 38px; font-size: 18px; }
.mini-row .stepper output { font-size: 20px; min-width: 32px; }
.mini-row .segmented button { padding: 8px 10px; font-size: 13px; }
.err { color: var(--bad); font-size: var(--fs-sm); min-height: 1.2em; text-align: center; margin: 8px 0 0; }

/* =========================================================
   Responsive: small phones, tablets, landscape
   ========================================================= */
@media (max-width: 360px) {
  :root { --cw: 40px; --hw: 50px; }
  .seat { width: 76px; }
  .avatar { width: 42px; height: 42px; }
  .seats.compact .seat { width: 62px; }
  .seats.compact .avatar { width: 32px; height: 32px; }
  .seats.compact .plate .nm, .seats.compact .plate .bt { font-size: 9px; }
  .round-info strong { font-size: var(--fs-md); }
  .trump span { display: none; }
  .chip-btn { padding: 7px 9px; }
  .me-bar .tally small { display: none; }
  .rank-row { flex-wrap: wrap; row-gap: 0; }
  .rank-row .d { order: 9; flex-basis: 100%; padding-left: 38px; margin-top: -4px; }
  .setup-card { padding: 14px; }
}
@media (max-height: 700px) and (orientation: portrait) {
  .seat { width: 80px; }
  .avatar { width: 42px; height: 42px; }
}
@media (min-width: 700px) and (orientation: portrait) {
  :root { --cw: 70px; --hw: 88px; }
  .seat { width: 110px; }
  .avatar { width: 62px; height: 62px; }
  .plate .nm, .plate .bt { font-size: var(--fs-sm); }
  .plate .sc { font-size: var(--fs-xs); }
  .seats.compact .seat { width: 90px; }
  .seats.compact .avatar { width: 48px; height: 48px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  :root { --cw: clamp(36px, 10vh, 54px); --hw: clamp(44px, 12.5vh, 64px); --hand-h: calc(var(--hw) * 1.4 * .72); }
  .play { max-width: 900px; }
  .topbar { padding: 4px 10px; }
  .round-info span { display: none; }
  .table-wrap { padding: 6px 10px 6px; }
  .me-bar { position: absolute; left: 10px; bottom: calc(var(--hw) * 1.3 + 8px); pointer-events: none; border-radius: 12px; border: 1px solid rgba(232,182,74,.3); z-index: 12; max-width: 260px; }
  .me-bar .chip-btn { pointer-events: auto; }
  .hand { position: absolute; left: 0; right: 0; bottom: 0; background: none; z-index: 10; }
  .hand .hc { bottom: -10%; }
  .title { justify-content: flex-start; }
  .fan { --aw: 50px; margin-bottom: 0; }
  .logo { font-size: 32px; }
  .logo small { margin-top: 4px; }
  .river-line { margin: 6px auto 10px; }
  .menu-col { gap: 8px; }
  .primary { padding: 11px 16px; }
  .ghost { padding: 9px 14px; }
  .rank-row { padding: 5px 6px; }
  .banner { font-size: 26px; margin: 0 0 4px; }
  .bid-panel { bottom: auto; top: 50%; transform: translateY(-50%); left: 50%; right: auto; width: min(560px, 92%); margin-left: calc(min(560px, 92%) / -2); animation: none; }
  .seat { width: 84px; }
  .avatar { width: 38px; height: 38px; }
  .seats.compact .seat { width: 66px; }
  .seats.compact .avatar { width: 30px; height: 30px; }
  .plate .sc { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01s !important; animation-delay: 0s !important; transition-duration: .01s !important; }
}

/* light effects: no blend modes, glows or heavy shadows (set automatically on slow devices, or from the menu) */
html[data-fx="low"] .spot, html[data-fx="low"] .table > .felt-fx { mix-blend-mode: normal; }
html[data-fx="low"] .spot { opacity: .5 !important; }
html[data-fx="low"] .seat.active .avatar { animation: none; }
html[data-fx="low"] .tcard .card, html[data-fx="low"] .hand .hc .card { box-shadow: 0 3px 5px rgba(0,0,0,.5); }
html[data-fx="low"] .sheet, html[data-fx="low"] .setup-card { backdrop-filter: none; }
html[data-fx="low"] .logo { filter: none; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; max-width: 90%; padding: 10px 16px; border-radius: 14px; background: rgba(10,6,2,.92); border: 1px solid rgba(232,182,74,.6); color: var(--ink); font-size: var(--fs-sm); text-align: center; animation: bub 3.6s ease-out forwards; }
