/* ============================================================ Twenty-Eight */
:root {
  --bg: #071a12;
  --felt-1: #1c7a4d;
  --felt-2: #0e4a2f;
  --felt-3: #08301f;
  --rim: #c9a24b;
  --gold: #f0c96a;
  --gold-soft: rgba(240, 201, 106, .18);
  --ink: #f5efe2;
  --ink-dim: rgba(245, 239, 226, .62);
  --ink-faint: rgba(245, 239, 226, .35);
  --panel: rgba(6, 22, 15, .78);
  --line: rgba(245, 239, 226, .12);
  --us: #f0c96a;
  --them: #8fd3e8;
  --red: #c8372d;
  --black: #1a1c22;
  --card-face: #fffcf5;
  --danger: #ef7b6c;
  --ok: #7fd49a;
  --cw: min(19vw, 86px);           /* hand card width */
  --tw: min(16.5vw, 76px);         /* table card width */
  --radius: 16px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 var(--font);
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-font-smoothing: antialiased;
}
input, button { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; touch-action: manipulation; }
#app { min-height: 100dvh; }

/* ------------------------------------------------------------ shared bits */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: 0 1.3em; border-radius: 14px;
  font-weight: 650; letter-spacing: .01em;
  background: linear-gradient(180deg, #f6d98b, #d9a944);
  color: #2a1d05;
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 6px 18px rgba(0,0,0,.35);
  transition: transform .08s ease, filter .15s ease, opacity .2s;
}
.btn:active { transform: translateY(1px) scale(.98); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn.ghost {
  background: rgba(255,255,255,.06); color: var(--ink);
  box-shadow: 0 0 0 1px var(--line) inset;
}
.btn.danger { background: linear-gradient(180deg, #f39a8d, #d0594a); color: #2b0a06; }
.btn.small { min-height: 38px; padding: 0 .9em; border-radius: 11px; font-size: 14px; }
.btn.block { width: 100%; }

.field {
  width: 100%; min-height: 52px; padding: 0 16px; border-radius: 14px;
  background: rgba(255,255,255,.07); border: 1px solid var(--line);
  font-size: 17px; outline: none; transition: border-color .2s, background .2s;
  -webkit-user-select: text; user-select: text;
}
.field:focus { border-color: var(--gold); background: rgba(255,255,255,.1); }
.field.code { text-transform: uppercase; letter-spacing: .35em; text-align: center; font-weight: 700; }

.label { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); font-weight: 600; }
.muted { color: var(--ink-dim); }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

.felt-bg {
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(240,201,106,.10), transparent 60%),
    radial-gradient(140% 90% at 50% 40%, var(--felt-2), var(--felt-3) 70%, #04140c);
}

/* ------------------------------------------------------------ home / join / lobby */
.screen {
  min-height: 100dvh;
  padding: calc(var(--sat) + 28px) 20px calc(var(--sab) + 28px);
  display: flex; flex-direction: column; align-items: center;
}
.screen > .inner { width: 100%; max-width: 440px; }

.brand { text-align: center; margin: 8px 0 26px; }
.brand h1 {
  font-family: var(--display); font-weight: 800; font-size: 44px; line-height: 1;
  margin: 18px 0 6px; letter-spacing: -.01em;
}
.brand h1 em { font-style: normal; color: var(--gold); }
.brand p { margin: 0; color: var(--ink-dim); }

.hero-fan { position: relative; height: 128px; width: 220px; margin: 0 auto; }
.hero-fan .card { position: absolute; left: 50%; bottom: 0; --cw: 74px; transform-origin: 50% 120%; }
.hero-fan .card:nth-child(1) { transform: translateX(-50%) rotate(-24deg); }
.hero-fan .card:nth-child(2) { transform: translateX(-50%) rotate(-8deg); }
.hero-fan .card:nth-child(3) { transform: translateX(-50%) rotate(8deg); }
.hero-fan .card:nth-child(4) { transform: translateX(-50%) rotate(24deg); }

.glass {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-faint); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.toggle-list { display: grid; gap: 2px; }
.toggle {
  display: flex; align-items: center; gap: 12px; padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.toggle:last-child { border-bottom: 0; }
.toggle .txt { flex: 1; }
.toggle .txt b { display: block; font-weight: 600; }
.toggle .txt small { color: var(--ink-dim); font-size: 13px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 30px; background: rgba(255,255,255,.15);
  transition: background .2s; pointer-events: none;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; transition: transform .2s; box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.switch input:checked + span { background: #d9a944; }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .55; }

.code-big {
  font-family: var(--display); font-size: 40px; letter-spacing: .22em; font-weight: 800;
  color: var(--gold); text-align: center; margin: 4px 0 0;
}
.qr {
  width: min(62vw, 230px); aspect-ratio: 1; margin: 14px auto 6px; padding: 12px;
  background: #fff; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.qr img { width: 100%; height: 100%; display: block; }

.lobby-table {
  position: relative; width: 100%; aspect-ratio: 1.15; margin: 8px 0 4px;
}
.lobby-table .oval {
  position: absolute; inset: 18% 20%; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, var(--felt-1), var(--felt-2) 70%);
  box-shadow: 0 0 0 5px #5a3b1c, 0 0 0 7px var(--rim), 0 18px 40px rgba(0,0,0,.5) ;
  display: grid; place-items: center; text-align: center; font-size: 12px; color: var(--ink-dim);
}
.lobby-seat {
  position: absolute; width: 34%; transform: translate(-50%, -50%);
  padding: 10px 8px; border-radius: 16px; text-align: center;
  background: rgba(0,0,0,.35); border: 1.5px dashed var(--ink-faint);
  transition: background .2s, border-color .2s, transform .15s;
}
.lobby-seat:active { transform: translate(-50%, -50%) scale(.97); }
.lobby-seat.filled { border-style: solid; background: rgba(0,0,0,.5); }
.lobby-seat.team-us { border-color: var(--us); }
.lobby-seat.team-them { border-color: var(--them); }
.lobby-seat.mine { box-shadow: 0 0 0 3px var(--gold-soft); }
.lobby-seat .nm { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lobby-seat .tm { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim); }
.lobby-seat.p0 { left: 50%; top: 90%; }
.lobby-seat.p1 { left: 83%; top: 50%; }
.lobby-seat.p2 { left: 50%; top: 10%; }
.lobby-seat.p3 { left: 17%; top: 50%; }

/* ------------------------------------------------------------ cards */
.card {
  --w: var(--cw);
  position: relative; width: var(--w); aspect-ratio: 5 / 7; flex: none;
  border-radius: calc(var(--w) * .1);
  background: linear-gradient(160deg, #ffffff, var(--card-face) 60%, #f2ead8);
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 0 0 1px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.35);
  color: var(--black);
  font-family: var(--display);
  overflow: hidden;
}
.card.red { color: var(--red); }
.card .ix {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  line-height: .9; font-weight: 800; font-size: calc(var(--w) * .26);
}
.card .ix i { font-style: normal; font-size: .78em; margin-top: 1px; font-family: var(--font); }
.card .ix.tl { top: 5%; left: 7%; }
.card .ix.br { bottom: 5%; right: 7%; transform: rotate(180deg); }
.card .mid {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: calc(var(--w) * .52); font-family: var(--font);
}
.card .mid.face {
  font-family: var(--display); font-weight: 800; font-size: calc(var(--w) * .5);
  inset: 20% 18%; border-radius: calc(var(--w) * .06);
  background: linear-gradient(180deg, rgba(240,201,106,.28), rgba(240,201,106,.08));
  box-shadow: 0 0 0 1px rgba(170,130,40,.45) inset;
}
.card .mid.face small { position: absolute; bottom: 4%; font-size: .38em; font-family: var(--font); }
.card .pts {
  position: absolute; top: 40%; left: 6%;
  min-width: calc(var(--w) * .2); height: calc(var(--w) * .2); padding: 0 2px;
  border-radius: 99px; background: #1b6b44; color: #fff; display: grid; place-items: center;
  font: 700 calc(var(--w) * .13)/1 var(--font);
}
.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(240,201,106,.22) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(-45deg, rgba(240,201,106,.22) 0 2px, transparent 2px 9px),
    linear-gradient(160deg, #7b1e2a, #4a0f19);
  box-shadow: 0 0 0 2px #fff inset, 0 0 0 3px rgba(0,0,0,.25), 0 4px 10px rgba(0,0,0,.35);
}
.card.back::after {
  content: "28"; position: absolute; inset: 0; display: grid; place-items: center;
  font: 800 calc(var(--w) * .3) var(--display); color: rgba(240,201,106,.75);
}

/* ------------------------------------------------------------ game layout */
.game {
  height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  padding-top: var(--sat);
}

.topbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px;
}
.score {
  display: flex; flex-direction: column; gap: 3px; padding: 6px 10px; border-radius: 12px;
  background: rgba(0,0,0,.3); border: 1px solid var(--line); min-width: 92px;
}
.score .t { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 12px; }
.score .t b { font-size: 17px; font-variant-numeric: tabular-nums; }
.score.us .t span { color: var(--us); }
.score.them .t span { color: var(--them); }
.pips { display: flex; gap: 3px; }
.pip { width: 9px; height: 9px; border-radius: 3px; background: rgba(255,255,255,.12); }
.pip.pos { background: var(--red); box-shadow: 0 0 6px rgba(200,55,45,.6); }
.pip.neg { background: #000; box-shadow: 0 0 0 1px rgba(255,255,255,.35) inset; }
.topbar .mid { flex: 1; text-align: center; min-width: 0; }
.topbar .mid .deal { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); }
.topbar .mid .room { font-family: var(--display); font-weight: 800; color: var(--gold); letter-spacing: .12em; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: rgba(0,0,0,.3); border: 1px solid var(--line); font-size: 18px;
}

.contract {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
  padding: 0 10px 4px; min-height: 28px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border-radius: 99px; font-size: 12.5px; font-weight: 600;
  background: rgba(0,0,0,.32); border: 1px solid var(--line); white-space: nowrap;
}
.chip.gold { border-color: rgba(240,201,106,.55); color: var(--gold); }
.chip.hot { background: rgba(200,55,45,.25); border-color: rgba(239,123,108,.6); color: #ffc4bb; }
.chip .suit { font-size: 15px; line-height: 1; }
.chip .suit.red { color: #ff7a6e; }
.chip .mini-back {
  width: 12px; height: 16px; border-radius: 2px;
  background: linear-gradient(160deg, #7b1e2a, #4a0f19); box-shadow: 0 0 0 1px #fff;
}

/* the table */
.table {
  position: relative; flex: 1; min-height: 190px; margin: 2px 8px;
}
.table .oval {
  position: absolute; inset: 9% 4% 6%; border-radius: 46% / 40%;
  background:
    radial-gradient(60% 50% at 50% 42%, rgba(255,255,255,.08), transparent 70%),
    radial-gradient(circle at 50% 45%, var(--felt-1), var(--felt-2) 62%, var(--felt-3));
  box-shadow:
    0 0 0 6px #4a2f15, 0 0 0 8px var(--rim), 0 0 0 9px rgba(0,0,0,.4),
    inset 0 10px 40px rgba(0,0,0,.45), 0 24px 50px rgba(0,0,0,.55);
}
.table .oval::after {
  content: "TWENTY · EIGHT"; position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  text-align: center; font: 800 13px var(--display); letter-spacing: .5em; color: rgba(255,255,255,.06);
}

.seat {
  position: absolute; display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 92px; z-index: 3; transform: translate(-50%, -50%);
}
.seat.r1 { left: calc(100% - 44px); top: 45%; }
.seat.r2 {
  left: 50%; top: 2px; transform: translateX(-50%);
  flex-direction: row; width: auto; gap: 8px; align-items: center;
}
.seat.r2 .bubble { top: 48px; left: 0; }
.seat.r3 { left: 44px; top: 45%; }
.avatar {
  position: relative; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; font: 800 19px var(--display);
  background: linear-gradient(160deg, #24493a, #10281e);
  border: 2px solid var(--line);
  box-shadow: 0 6px 14px rgba(0,0,0,.45);
  transition: box-shadow .3s, border-color .3s;
}
.seat.us .avatar { border-color: var(--us); color: var(--us); }
.seat.them .avatar { border-color: var(--them); color: var(--them); }
.seat.turn .avatar { animation: glow 1.4s ease-in-out infinite; }
@keyframes glow {
  0%,100% { box-shadow: 0 0 0 3px rgba(240,201,106,.35), 0 0 18px rgba(240,201,106,.45); }
  50% { box-shadow: 0 0 0 6px rgba(240,201,106,.15), 0 0 28px rgba(240,201,106,.7); }
}
.seat.offline .avatar { opacity: .45; filter: grayscale(1); }
.seat.sitout { opacity: .45; }
.seat .nm {
  max-width: 92px; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.seat .sub { font-size: 11px; color: var(--ink-dim); height: 14px; }
.badge {
  position: absolute; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px;
  display: grid; place-items: center; font: 800 11px var(--font);
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.badge.dealer { left: -6px; top: -4px; background: #f5efe2; color: #10281e; }
.badge.bid { right: -8px; top: -4px; background: var(--gold); color: #2a1d05; }
.badge.off { right: -4px; bottom: -2px; background: #666; color: #fff; }
.seat .backs { display: flex; height: 18px; margin-top: 1px; }
.seat .backs .card { --cw: 13px; margin-left: -8px; box-shadow: 0 0 0 1px #fff inset; }
.seat .backs .card::after { display: none; }
.seat .backs .card:first-child { margin-left: 0; }
.seat .tcard {
  position: absolute; top: 4px; --cw: 24px; transform: rotate(12deg);
}
.seat.r1 .tcard { left: -18px; }
.seat.r2 .tcard { left: -26px; top: 6px; }
.seat.r3 .tcard { right: -18px; }
.seat .tcard .card::after { font-size: 8px; }
.seat .bubble {
  position: absolute; top: 52px; z-index: 5;
  padding: 3px 9px; border-radius: 10px; font-size: 12px; font-weight: 700;
  background: #fff; color: #10281e; white-space: nowrap;
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* trick on the table */
.trick { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.tslot {
  position: absolute; left: 50%; top: 56%; --cw: var(--tw);
  transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .45s;
}
.tslot.r0 { transform: translate(-50%, -18%) rotate(-3deg); }
.tslot.r1 { transform: translate(-6%, -62%) rotate(6deg); }
.tslot.r2 { transform: translate(-50%, -106%) rotate(2deg); }
.tslot.r3 { transform: translate(-94%, -62%) rotate(-7deg); }
.tslot.enter.r0 { animation: in0 .38s cubic-bezier(.2,.8,.2,1); }
.tslot.enter.r1 { animation: in1 .38s cubic-bezier(.2,.8,.2,1); }
.tslot.enter.r2 { animation: in2 .38s cubic-bezier(.2,.8,.2,1); }
.tslot.enter.r3 { animation: in3 .38s cubic-bezier(.2,.8,.2,1); }
@keyframes in0 { from { transform: translate(-50%, 160%) rotate(-3deg) scale(1.15); opacity: .3; } }
@keyframes in1 { from { transform: translate(140%, -62%) rotate(30deg); opacity: .3; } }
@keyframes in2 { from { transform: translate(-50%, -260%) rotate(2deg); opacity: .3; } }
@keyframes in3 { from { transform: translate(-240%, -62%) rotate(-30deg); opacity: .3; } }
.tslot .card.trumped { box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(240,201,106,.8), 0 4px 12px rgba(0,0,0,.35); }
.tslot.win .card { box-shadow: 0 0 0 3px #fff, 0 0 22px rgba(255,255,255,.75), 0 6px 16px rgba(0,0,0,.4); }
.tslot .tag {
  position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%);
  font: 800 9px var(--font); letter-spacing: .08em; padding: 2px 5px; border-radius: 5px;
  background: var(--gold); color: #2a1d05;
}
.trick.collect-r0 .tslot { transform: translate(-50%, 250%) scale(.4) !important; opacity: 0; }
.trick.collect-r1 .tslot { transform: translate(260%, -60%) scale(.4) !important; opacity: 0; }
.trick.collect-r2 .tslot { transform: translate(-50%, -320%) scale(.4) !important; opacity: 0; }
.trick.collect-r3 .tslot { transform: translate(-360%, -60%) scale(.4) !important; opacity: 0; }

.table-msg {
  position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%);
  width: 62%; text-align: center; z-index: 1;
}
.table-msg .big { font: 800 26px var(--display); color: var(--gold); }
.table-msg .small { font-size: 13px; color: var(--ink-dim); }
.history { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin-top: 8px; }
.history .h {
  font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: rgba(0,0,0,.35);
}
.history .h b { color: var(--gold); }

/* bottom: me, actions, hand */
.me-bar {
  display: flex; align-items: center; gap: 8px; padding: 2px 12px 4px;
}
.me-bar .avatar { width: 34px; height: 34px; font-size: 15px; }
.me-bar .nm { font-weight: 650; font-size: 14px; }
.me-bar.turn .avatar { animation: glow 1.4s ease-in-out infinite; }
.pts-chip {
  margin-left: auto; display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 12px;
  background: rgba(240,201,106,.12); border: 1px solid rgba(240,201,106,.4); font-size: 12.5px;
}
.pts-chip b { font-size: 16px; color: var(--gold); font-variant-numeric: tabular-nums; }
.pts-chip .lock { font-size: 11px; opacity: .7; }

.panel {
  margin: 0 10px; padding: 10px 12px; border-radius: 18px;
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  min-height: 54px;
}
.panel .prompt { font-weight: 650; text-align: center; margin-bottom: 8px; }
.panel .prompt.only { margin: 6px 0; }
.panel .prompt small { display: block; font-weight: 500; color: var(--ink-dim); font-size: 12.5px; margin-top: 2px; }
.panel.your-turn { border-color: rgba(240,201,106,.55); box-shadow: 0 0 24px rgba(240,201,106,.15); }
.bid-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.bid-grid button {
  height: 40px; border-radius: 11px; font-weight: 750; font-size: 16px;
  background: rgba(255,255,255,.08); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.bid-grid button.honours { border-color: rgba(240,201,106,.35); }
.bid-grid button.senior { border-color: rgba(239,123,108,.45); }
.bid-grid button:active { background: var(--gold); color: #2a1d05; }
.actions { display: flex; gap: 8px; margin-top: 8px; }
.actions .btn { flex: 1; }

.hand-wrap { padding: 8px 8px calc(var(--sab) + 10px); }
.hand {
  --step: 40px;
  display: flex; justify-content: center; align-items: flex-end;
  height: calc(var(--cw) * 1.4 + 16px); padding-top: 14px;
}
.hand .card {
  margin-left: calc(var(--step) - var(--cw));
  transition: transform .18s cubic-bezier(.2,.8,.2,1), filter .2s, opacity .2s;
}
.hand .card:first-child { margin-left: 0; }
.hand .card.dim { filter: brightness(.55) saturate(.6); }
.hand .card.legal { cursor: pointer; }
.hand .card.sel { transform: translateY(-16px); box-shadow: 0 0 0 3px var(--gold), 0 12px 24px rgba(0,0,0,.5); }
.hand.deal-in .card { animation: dealin .45s cubic-bezier(.2,.8,.2,1) backwards; }
@keyframes dealin { from { transform: translateY(-60vh) rotate(-20deg); opacity: 0; } }
.hand-hint { text-align: center; font-size: 12px; color: var(--ink-faint); height: 16px; margin-top: 2px; }

.indicator-slot { display: flex; align-items: center; gap: 10px; justify-content: center; }
.indicator-slot .card { --cw: 46px; }

/* ------------------------------------------------------------ overlays */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fade .25s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 520px; max-height: 92dvh; overflow: auto;
  background: linear-gradient(180deg, #123a28, #0a2419);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 26px 26px 0 0;
  padding: 18px 18px calc(var(--sab) + 18px);
  box-shadow: 0 -20px 60px rgba(0,0,0,.5);
  animation: up .35s cubic-bezier(.2,.8,.2,1);
  -webkit-user-select: text; user-select: text;
}
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
.sheet h2 { font: 800 26px var(--display); margin: 4px 0 4px; text-align: center; }
.sheet h3 { font: 700 13px var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim); margin: 18px 0 8px; }
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 10px; }
.result-banner { text-align: center; margin: 6px 0 14px; }
.result-banner .delta { font: 800 44px var(--display); line-height: 1.1; }
.result-banner .delta.good { color: var(--ok); }
.result-banner .delta.bad { color: var(--danger); }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-box {
  padding: 12px; border-radius: 16px; background: rgba(0,0,0,.3); border: 1px solid var(--line);
  text-align: center;
}
.team-box.us { border-color: rgba(240,201,106,.5); }
.team-box.them { border-color: rgba(143,211,232,.45); }
.team-box .nm { font-size: 12.5px; color: var(--ink-dim); }
.team-box .pts { font: 800 34px var(--display); }
.team-box.us .pts { color: var(--us); }
.team-box.them .pts { color: var(--them); }
.team-box .mini { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; margin-top: 8px; }
.team-box .mini .card { --cw: 26px; }
.team-box .mini .card .ix.br { display: none; }
.team-box .mini .card .mid { display: none; }
.team-box .mini .card .ix.tl { top: 4%; left: 0; right: 0; font-size: 10px; }
.rules-text p, .rules-text li { color: var(--ink-dim); font-size: 14.5px; }
.rules-text b { color: var(--ink); }
.rules-text table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rules-text td { padding: 5px 4px; border-bottom: 1px solid var(--line); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; width: 8px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* toasts */
#toasts {
  position: fixed; left: 0; right: 0; top: calc(var(--sat) + 64px); z-index: 70;
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
}
.toast {
  max-width: 88vw; padding: 10px 16px; border-radius: 14px; font-weight: 600; font-size: 14px;
  background: rgba(10, 20, 15, .92); border: 1px solid rgba(240,201,106,.5);
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  animation: toastin .3s cubic-bezier(.2,.8,.2,1);
}
.toast.err { border-color: rgba(239,123,108,.7); }
.toast.big { font: 800 20px var(--display); padding: 14px 22px; color: var(--gold); }
.toast.out { opacity: 0; transform: translateY(-10px); transition: all .3s; }
@keyframes toastin { from { opacity: 0; transform: translateY(-14px) scale(.96); } }

/* reactions */
.react-tray {
  position: absolute; right: 10px; top: 52px; z-index: 40; display: flex; gap: 4px; padding: 6px;
  border-radius: 16px; background: rgba(10,20,15,.95); border: 1px solid var(--line);
  animation: pop .2s ease-out;
}
.react-tray button { font-size: 24px; width: 42px; height: 42px; border-radius: 12px; }
.react-tray button:active { background: rgba(255,255,255,.1); }
.float-emoji {
  position: fixed; z-index: 65; font-size: 40px; pointer-events: none;
  animation: floatup 2.2s ease-out forwards;
}
@keyframes floatup {
  0% { transform: translate(-50%, 0) scale(.5); opacity: 0; }
  15% { transform: translate(-50%, -10px) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -120px) scale(1); opacity: 0; }
}

.conn-banner {
  position: fixed; left: 50%; bottom: calc(var(--sab) + 12px); transform: translateX(-50%); z-index: 80;
  padding: 8px 14px; border-radius: 99px; background: #4a1d18; border: 1px solid var(--danger);
  font-size: 13px; font-weight: 600;
}

/* short phones (iPhone SE etc.) */
@media (max-height: 700px) {
  :root { --cw: min(17vw, 70px); --tw: min(14.5vw, 60px); }
  .avatar { width: 40px; height: 40px; font-size: 17px; }
  .topbar { padding-top: 4px; }
  .panel { padding: 8px 10px; }
  .bid-grid button { height: 38px; }
}
/* ------------------------------------------------------------ v2: avatars, lobby, approvals */
.game > .topbar { order: 1; }
.game .contract { order: 2; }
.game > .table { order: 3; }
.game > .me-bar { order: 4; }
.game .panel { order: 5; }
.game > .hand-wrap { order: 6; }
.side { display: contents; }
.log { display: none; }

.avatar.emoji { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: 24px; }
.me-bar .avatar.emoji { font-size: 19px; }
.seat .tag-bot { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-dim); }

.avatar-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.avatar-grid button {
  aspect-ratio: 1; border-radius: 12px; font-size: 22px; display: grid; place-items: center;
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
}
.avatar-grid button.on { background: var(--gold-soft); border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.me-pick { display: flex; align-items: center; gap: 12px; }
.me-pick .big-av {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; flex: none;
  background: linear-gradient(160deg, #24493a, #10281e); border: 2px solid var(--gold);
}

.seg { display: flex; background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 13px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 40px; border-radius: 10px; font-weight: 650; color: var(--ink-dim); }
.seg button.on { background: linear-gradient(180deg, #f6d98b, #d9a944); color: #2a1d05; }
.seg[aria-disabled="true"] { opacity: .6; pointer-events: none; }
.setting { display: grid; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting small { color: var(--ink-dim); }

.lobby-seat .av { font-size: 26px; line-height: 1.1; }
.lobby-seat.bot { border-style: dotted; opacity: .85; }
.lobby-seat .kick {
  position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%;
  background: #4a1d18; border: 1px solid var(--danger); font-size: 13px; display: grid; place-items: center;
}

.requests {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--sat) + 8px); z-index: 75;
  width: min(94vw, 440px); display: grid; gap: 8px;
}
.request {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px;
  background: rgba(10, 24, 17, .96); border: 1px solid rgba(240,201,106,.6);
  box-shadow: 0 12px 30px rgba(0,0,0,.5); animation: toastin .3s ease-out;
}
.request .av { font-size: 28px; }
.request .txt { flex: 1; font-size: 14px; line-height: 1.3; }
.request .txt small { display: block; color: var(--ink-dim); font-size: 12px; }
.request .txt .warn { color: #ffc4bb; }

.waiting-dots::after { content: "…"; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1em; text-align: left; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.players-list { display: grid; gap: 8px; }
.players-list .pl { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(0,0,0,.25); }
.players-list .pl .av { font-size: 22px; }
.players-list .pl .nm { flex: 1; }

.peek { position: relative; height: 230px; }
.peek .tslot { --tw: 70px; }
.peek .who { position: absolute; font-size: 12px; color: var(--ink-dim); transform: translate(-50%, -50%); white-space: nowrap; }

.rotate-hint { display: none; }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .rotate-hint {
    display: grid; place-items: center; text-align: center; position: fixed; inset: 0; z-index: 100;
    background: var(--bg); font: 700 18px var(--font); padding: 20px;
  }
}

/* ------------------------------------------------------------ trump visibility */
.trump-medal {
  position: absolute; left: 2px; top: 2px; z-index: 4;
  width: 70px; padding: 6px 0 7px; border-radius: 16px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: radial-gradient(circle at 50% 35%, #fffaf0, #f3e3b6);
  color: var(--black); box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgba(240,201,106,.55), 0 8px 18px rgba(0,0,0,.45);
  animation: medal-in .6s cubic-bezier(.2,.8,.2,1);
}
.trump-medal.red { color: var(--red); }
.trump-medal .lbl { font: 800 9.5px var(--font); letter-spacing: .16em; text-transform: uppercase; color: #7a5a12; }
.trump-medal .sym { font-size: 34px; line-height: 1; }
.trump-medal .nm { font: 700 11px var(--font); }
@keyframes medal-in { from { transform: scale(2.2); opacity: 0; } }

.hand .card.trump-card {
  background: linear-gradient(160deg, #fffdf3, #fbefc6 70%, #f5e1a4);
  box-shadow: 0 0 0 2px var(--gold), 0 0 12px rgba(240,201,106,.55), 0 4px 12px rgba(0,0,0,.35);
}
.hand .card.trump-card::after {
  content: "TRUMP"; position: absolute; left: 4%; bottom: 4%;
  font: 800 calc(var(--cw) * .1) var(--font); letter-spacing: .04em;
  padding: 1px 3px; border-radius: 3px; background: var(--gold); color: #3a2804;
}
.hand .card.trump-card.dim { filter: brightness(.7) saturate(.8); }

.trump-reveal {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: radial-gradient(circle, rgba(0,0,0,.55), rgba(0,0,0,.8));
  animation: fade .25s ease-out; cursor: pointer;
}
.trump-reveal.out { opacity: 0; transition: opacity .35s; }
.tr-box { text-align: center; }
.tr-flip { perspective: 900px; width: 120px; margin: 0 auto 18px; --cw: 120px; }
.tr-inner {
  position: relative; width: 120px; aspect-ratio: 5 / 7; transform-style: preserve-3d;
  animation: flip 0.9s .25s cubic-bezier(.2,.8,.2,1) both;
}
.tr-back, .tr-front { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.tr-front { transform: rotateY(180deg); }
.tr-front .card { box-shadow: 0 0 0 4px var(--gold), 0 0 40px rgba(240,201,106,.9), 0 14px 30px rgba(0,0,0,.6); }
@keyframes flip { from { transform: rotateY(0deg) scale(.8); } to { transform: rotateY(180deg) scale(1); } }
.tr-label { font: 700 13px var(--font); letter-spacing: .3em; text-transform: uppercase; color: var(--gold); }
.tr-suit {
  font: 800 44px var(--display); color: #fff; margin: 2px 0 6px;
  text-shadow: 0 2px 12px rgba(0,0,0,.6); animation: pop .4s 1s both;
}
.tr-suit.red { color: #ff8a7e; }
.tr-who { color: var(--ink-dim); font-size: 14px; }

/* ------------------------------------------------------------ tablets */
@media (min-width: 600px) {
  :root { --cw: min(12.5vw, 100px); --tw: min(11vw, 92px); }
  .game { max-width: 780px; margin: 0 auto; }
  .avatar { width: 54px; height: 54px; }
  .avatar.emoji { font-size: 28px; }
  .seat { width: 110px; }
  .seat .nm { max-width: 110px; font-size: 14px; }
  .seat.r1 { left: calc(100% - 56px); }
  .seat.r3 { left: 56px; }
  .screen > .inner { max-width: 480px; }
}

/* ------------------------------------------------------------ desktop / landscape tablets */
@media (min-width: 960px) and (min-height: 600px) {
  :root { --cw: clamp(84px, 6.4vw, 116px); --tw: clamp(80px, 6vw, 108px); }
  .game {
    display: grid; max-width: 1440px; margin: 0 auto;
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "top side" "table side" "me side" "hand side";
    column-gap: 18px; padding: calc(var(--sat) + 10px) 20px 0;
  }
  .game > .topbar { grid-area: top; }
  .game > .table { grid-area: table; margin: 18px 30px 8px; }
  .game > .me-bar { grid-area: me; justify-content: center; }
  .game > .hand-wrap { grid-area: hand; }
  .side {
    grid-area: side; display: flex; flex-direction: column; gap: 12px; min-height: 0;
    padding: 6px 0 16px;
  }
  .side .contract { justify-content: flex-start; padding: 0; order: 1; }
  .side .panel { margin: 0; order: 2; }
  .side .log { order: 3; }
  .log {
    display: block; flex: 1; min-height: 0; overflow: auto; padding: 12px 14px; border-radius: 18px;
    background: rgba(0,0,0,.25); border: 1px solid var(--line); font-size: 13.5px;
    -webkit-user-select: text; user-select: text;
  }
  .log h4 { margin: 0 0 8px; font: 700 12px var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); }
  .log div { padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.05); color: var(--ink-dim); }
  .log div b { color: var(--ink); font-weight: 600; }
  .avatar { width: 64px; height: 64px; }
  .avatar.emoji { font-size: 34px; }
  .seat { width: 140px; }
  .seat .nm { max-width: 140px; font-size: 15px; }
  .seat .backs .card { --cw: 18px; margin-left: -11px; }
  .seat .backs { height: 26px; }
  .seat.r1 { left: calc(100% - 50px); }
  .seat.r3 { left: 50px; }
  .seat.r2 { top: -10px; }
  .table .oval { inset: 6% 6% 4%; }
  .me-bar .avatar { width: 44px; height: 44px; }
  .hand { height: calc(var(--cw) * 1.4 + 22px); }
  .hand-wrap { padding-bottom: 16px; }
  .bid-grid button { height: 44px; }
  .lobby-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
  .screen > .inner.wide { max-width: 940px; }
  #toasts { top: 20px; }
}
@media (hover: hover) and (pointer: fine) {
  .hand .card.legal:hover:not(.sel) { transform: translateY(-10px); }
  .btn:hover { filter: brightness(1.07); }
  .bid-grid button:hover, .avatar-grid button:hover, .seg button:hover:not(.on) { background: rgba(255,255,255,.14); }
  .lobby-seat:hover { background: rgba(0,0,0,.6); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
