:root {
  --felt-1: #2f8a5b;
  --felt-2: #1b5c3b;
  --felt-3: #0b2d1d;
  --wood-1: #5a3420;
  --wood-2: #3a1f12;
  --gold: #f2c14e;
  --gold-2: #c9952e;
  --ink: #0d1a14;
  --text: #f6f1e4;
  --muted: #b9c7bd;
  --panel: rgba(12, 28, 21, 0.82);
  --panel-solid: #132a20;
  --line: rgba(242, 193, 78, 0.25);
  --team-a: #5fb3e6;
  --team-b: #f08c5a;
  --red: #d4373a;
  --yellow: #e3a512;
  --green: #23935a;
  --black: #2a2d36;
  --hand-w: clamp(64px, 9.2vw, 112px);
  --trick-w: clamp(58px, 8.4vw, 100px);
  --fan-w: clamp(30px, 4.2vw, 52px);
  --radius: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --font-ui: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: Fraunces, Georgia, 'Times New Roman', serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(ellipse at 50% 0%, #1f3a2c 0%, #0a1510 70%) fixed, #0a1510;
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: manipulation;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.screen { display: none; position: fixed; inset: 0; }
.screen.active { display: block; }

/* ---------- buttons & fields ---------- */
.btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.04));
  padding: 10px 16px; border-radius: 12px; cursor: pointer; font-weight: 600;
  transition: transform .12s ease, background .2s, box-shadow .2s, opacity .2s;
  box-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.btn:hover:not(:disabled) { background: linear-gradient(180deg, rgba(255,255,255,.2), rgba(255,255,255,.08)); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #3fbf7f, #1f8a55); border-color: #6be0a2; color: #04140b; }
.btn.gold { background: linear-gradient(180deg, #ffd978, #d39b2c); border-color: #ffe7a3; color: #2a1a00; }
.btn.danger { background: linear-gradient(180deg, #e46a6a, #b03030); border-color: #ff9a9a; }
.btn.ghost { background: transparent; }
.btn.big { padding: 14px 22px; font-size: 1.05rem; }
.btn.wide { width: 100%; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.link { background: none; border: 0; color: var(--gold); cursor: pointer; text-decoration: underline; margin-top: 10px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.35); cursor: pointer; font-size: 18px; font-weight: 700;
  display: grid; place-items: center; backdrop-filter: blur(6px);
}
.icon-btn.off { opacity: .45; text-decoration: line-through; }
input, select {
  background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.18); border-radius: 10px; padding: 10px 12px;
}
.field { display: grid; gap: 6px; text-align: left; font-size: .85rem; color: var(--muted); }
.error { color: #ff9a8a; min-height: 1.3em; margin: 8px 0 0; }
.hint { color: var(--muted); font-size: .85rem; }
.text-center { text-align: center; }
.eyebrow { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ---------- home ---------- */
#home { display: none; place-items: center; overflow: auto; padding: 16px;
  background: radial-gradient(ellipse at 50% 30%, rgba(47,138,91,.55), transparent 60%), radial-gradient(ellipse at 50% 120%, rgba(242,193,78,.18), transparent 60%); }
#home.active { display: grid; grid-template-columns: minmax(0, 1fr); }
.home-card {
  width: min(440px, 100%); min-width: 0; text-align: center; padding: 28px 26px; border-radius: 22px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(10px);
}
.logo { width: 132px; height: 132px; margin: -8px auto 0; filter: drop-shadow(0 10px 20px rgba(0,0,0,.5)); animation: float 6s ease-in-out infinite; }
.logo svg { width: 100%; height: 100%; }
@keyframes float { 50% { transform: translateY(-6px) rotate(-2deg); } }
.title { font-family: var(--font-display); font-weight: 900; font-size: 3.4rem; letter-spacing: .3em; margin: 0 0 4px .3em;
  background: linear-gradient(180deg, #ffe7a3, #c9952e); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--muted); margin: 0 0 20px; line-height: 1.45; }
.home-card .field { grid-template-columns: minmax(0, 1fr); }
.home-card input, .home-card select { min-width: 0; width: 100%; }
.home-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin: 16px 0 12px; }
.join-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
#codeInput { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 700; }
.install-app { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.install-help { text-align: left; font-size: .8rem; line-height: 1.5; color: var(--muted); }
.install-help b { color: var(--text); }
.install-app .hint:empty { display: none; }

/* ---------- lobby ---------- */
#lobby { overflow: auto; padding: 16px; }
.lobby-wrap { max-width: 1080px; margin: 0 auto; }
.lobby-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.room-code { font-family: var(--font-display); font-size: 2.6rem; font-weight: 900; letter-spacing: .25em; color: var(--gold); }
.invite { display: flex; gap: 8px; flex: 1; min-width: 240px; max-width: 560px; }
.invite input { flex: 1; min-width: 0; }
.lobby-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); }
.panel h2 { font-family: var(--font-display); margin: 0 0 6px; font-size: 1.4rem; }
.seat-table {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "s2 s2" "s1 s3" "mid mid" "s0 s0"; gap: 10px;
  margin: 16px 0; padding: 18px; border-radius: 48px;
  background: radial-gradient(ellipse at 50% 45%, var(--felt-1), var(--felt-2) 60%, var(--felt-3)); border: 6px solid var(--wood-1);
}
.seat-table .table-mid { grid-area: mid; display: grid; place-items: center; text-align: center; font-size: .75rem; color: rgba(255,255,255,.7); }
.seat-card { background: rgba(0,0,0,.45); border-radius: 14px; padding: 10px; display: grid; gap: 6px; align-content: start; border: 2px solid transparent; min-width: 0; }
.seat-card.team0 { border-color: color-mix(in srgb, var(--team-a) 70%, transparent); }
.seat-card.team1 { border-color: color-mix(in srgb, var(--team-b) 70%, transparent); }
.seat-card.s0 { grid-area: s0; justify-self: center; width: min(100%, 300px); }
.seat-card.s1 { grid-area: s1; }
.seat-card.s2 { grid-area: s2; justify-self: center; width: min(100%, 300px); }
.seat-card.s3 { grid-area: s3; }
.seat-card .who { display: flex; align-items: center; gap: 6px; font-weight: 700; min-width: 0; flex-wrap: wrap; }
.seat-card .who span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-card select, .seat-card .btn { padding: 6px 8px; font-size: .8rem; width: 100%; }
.seat-card .row { display: flex; gap: 6px; }
.seat-card .bio { font-size: .72rem; color: var(--muted); line-height: 1.3; }
.tag { font-size: .65rem; font-weight: 700; padding: 2px 6px; border-radius: 999px; background: rgba(255,255,255,.14); white-space: nowrap; }
.tag.you { background: var(--gold); color: #2a1a00; }
.tag.host { background: #7c5cff; }
.tag.away { background: #b03030; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; flex: none;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.35), transparent 60%), var(--av, #567); box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.spectators { font-size: .8rem; color: var(--muted); margin-bottom: 10px; }
.settings-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.settings-form .full { grid-column: 1 / -1; }
.settings-form label { display: grid; gap: 4px; font-size: .78rem; color: var(--muted); }
.settings-form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .85rem; }
.settings-form select, .settings-form input[type=number] { padding: 7px 9px; }
.settings-form .note { font-size: .72rem; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; font-size: .85rem; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }

/* ---------- table ---------- */
#game, .table { overflow: clip; }
html, body { overflow: clip; }
.table { position: absolute; inset: 0; }
.table-felt {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 46%, rgba(255,240,200,.16), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 85% 75% at 50% 48%, var(--felt-1) 0%, var(--felt-2) 55%, var(--felt-3) 100%);
  border: clamp(8px, 1.6vw, 18px) solid var(--wood-1);
  border-image: linear-gradient(135deg, #7b4a2c, #3a1f12 30%, #6e3f24 55%, #2e170c 80%, #6b3c22) 1;
  box-shadow: inset 0 0 120px rgba(0,0,0,.65), inset 0 0 0 2px rgba(242,193,78,.25);
}
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20; display: flex; gap: 10px; align-items: flex-start;
  justify-content: space-between; padding: max(10px, env(safe-area-inset-top)) clamp(10px, 2vw, 22px) 0;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.scores { display: flex; gap: 8px; }
.score {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; min-width: 104px;
  box-shadow: 0 8px 18px rgba(0,0,0,.35); border-left: 4px solid var(--team-a);
}
.score.team1 { border-left-color: var(--team-b); }
.score .lbl { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.score .val { font-family: var(--font-display); font-size: 1.6rem; font-weight: 900; line-height: 1.1; }
.score .val small { font-size: .7rem; font-family: var(--font-ui); color: var(--muted); font-weight: 500; margin-left: 4px; }
.score.bump .val { animation: bump .6s ease; }
@keyframes bump { 40% { transform: scale(1.25); color: var(--gold); } }
.contract { display: flex; gap: 8px; align-items: stretch; }
.chip-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; text-align: center; box-shadow: 0 8px 18px rgba(0,0,0,.35); }
.chip-box .lbl { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.chip-box .val { font-weight: 800; font-size: 1.05rem; display: flex; align-items: center; gap: 6px; justify-content: center; white-space: nowrap; }
.trump-chip { --c: #888; border-color: var(--c); box-shadow: 0 0 0 1px var(--c), 0 0 22px color-mix(in srgb, var(--c) 45%, transparent); }
.hud-buttons { display: flex; gap: 6px; }

/* seats */
.seat { position: absolute; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.seat.pos2 { top: clamp(64px, 9vh, 92px); left: 50%; transform: translateX(-50%); }
.seat.pos1 { left: clamp(14px, 3vw, 40px); top: 44%; transform: translateY(-50%); }
.seat.pos3 { right: clamp(14px, 3vw, 40px); top: 44%; transform: translateY(-50%); }
.seat.pos0 { left: clamp(14px, 3vw, 40px); bottom: calc(var(--hand-w) * 1.4 + 26px); z-index: 12; }
.plate {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; position: relative;
  background: var(--panel); border: 2px solid rgba(255,255,255,.12); box-shadow: 0 10px 22px rgba(0,0,0,.4);
  transition: box-shadow .3s, border-color .3s, transform .3s; max-width: 240px;
}
.plate.team0 { border-color: color-mix(in srgb, var(--team-a) 60%, transparent); }
.plate.team1 { border-color: color-mix(in srgb, var(--team-b) 60%, transparent); }
.plate.turn { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(242,193,78,.25), 0 0 30px rgba(242,193,78,.55); transform: scale(1.05); }
.plate .meta { display: grid; line-height: 1.15; min-width: 0; }
.plate .nm { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plate .sub { font-size: .7rem; color: var(--muted); white-space: nowrap; }
.plate .bidchip { position: absolute; top: -10px; right: -8px; background: var(--gold); color: #2a1a00; font-weight: 800; font-size: .75rem; padding: 2px 8px; border-radius: 999px; box-shadow: 0 4px 10px rgba(0,0,0,.4); animation: pop .3s ease; }
.plate .bidchip.pass { background: #555; color: #ddd; }
.plate .bidchip.win { background: linear-gradient(180deg, #ffe7a3, #d39b2c); }
.plate .dealer { position: absolute; bottom: -8px; left: -6px; width: 22px; height: 22px; border-radius: 50%; background: #fff; color: #111; font-weight: 900; font-size: .7rem; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.plate .thinking { display: inline-flex; gap: 3px; margin-left: 4px; }
.plate .thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); animation: dots 1s infinite; }
.plate .thinking i:nth-child(2) { animation-delay: .15s; } .plate .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes dots { 50% { transform: translateY(-4px); opacity: .4; } }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.fan { position: relative; height: calc(var(--fan-w) * 1.4); display: flex; justify-content: center; }
.seat.pos1 .fan, .seat.pos3 .fan { height: auto; }
.fan .card { width: var(--fan-w); margin-left: calc(var(--fan-w) * -0.72); transition: transform .3s; }
.fan .card:first-child { margin-left: 0; }
.seat.pos1 .fan, .seat.pos3 .fan { flex-direction: column; align-items: center; }
.seat.pos1 .fan .card, .seat.pos3 .fan .card { margin-left: 0; margin-top: calc(var(--fan-w) * -1.18); transform: rotate(90deg); }
.seat.pos1 .fan .card:first-child, .seat.pos3 .fan .card:first-child { margin-top: 0; }
.seat.pos1 .fan { padding-top: calc(var(--fan-w) * .2); }

.card { position: relative; aspect-ratio: 200 / 280; border-radius: 8%/6%; user-select: none; -webkit-user-select: none; }
.card .card-img { display: block; width: 100%; height: 100%; border-radius: inherit; box-shadow: 0 6px 14px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.4); pointer-events: none; }

/* my hand */
.hand {
  position: absolute; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); height: calc(var(--hand-w) * 1.4 + 14px);
  display: flex; justify-content: center; align-items: flex-end; z-index: 10; padding: 0 12px;
}
.hand .card {
  width: var(--hand-w); flex: none; margin-left: var(--overlap, -20px); cursor: default;
  transform: translateY(calc(var(--arc, 0px) + var(--lift, 0px))) rotate(var(--rot, 0deg));
  transform-origin: 50% 120%; transition: transform .18s ease, filter .2s, opacity .2s;
}
.hand .card:first-child { margin-left: 0; }
.hand.active .card.legal { cursor: pointer; }
.hand.active .card.legal:hover, .hand.active .card.legal:focus-visible { --lift: -22px; outline: none; }
.hand.active .card.legal .card-img { box-shadow: 0 0 0 2px rgba(242,193,78,.85), 0 10px 22px rgba(0,0,0,.5); }
.hand.active .card.illegal { filter: brightness(.48) saturate(.45); }
.hand .card.selected { --lift: -30px; }
.hand .card.selected .card-img { box-shadow: 0 0 0 3px #ff6b6b, 0 12px 24px rgba(0,0,0,.55); }
.hand .card.selected::after { content: 'BURY'; position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: #ff6b6b; color: #fff; font-size: .6rem; font-weight: 800; padding: 2px 6px; border-radius: 6px; letter-spacing: .08em; }
.hand .card.nest-new .card-img { box-shadow: 0 0 0 2px #7fd6ff, 0 0 18px rgba(127,214,255,.7); }
.hand .card.nest-new.intro { animation: nestIn .6s ease both; animation-delay: calc(var(--i) * 25ms); }
@keyframes nestIn { from { transform: translateY(-80px) rotateY(90deg); opacity: 0; } }
.hand .card.dealt { animation: dealIn .35s ease both; animation-delay: calc(var(--i) * 30ms); }
@keyframes dealIn { from { opacity: 0; transform: translateY(40px) scale(.8); } }

/* center */
.center { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); width: calc(var(--trick-w) * 4.2); height: calc(var(--trick-w) * 3.3); z-index: 4; }
.trick .slot { position: absolute; width: var(--trick-w); aspect-ratio: 200/280; left: 50%; top: 50%; }
.trick .slot.pos0 { transform: translate(-50%, -4%) rotate(-3deg); }
.trick .slot.pos2 { transform: translate(-50%, -96%) rotate(4deg); }
.trick .slot.pos1 { transform: translate(-140%, -50%) rotate(-8deg); }
.trick .slot.pos3 { transform: translate(40%, -50%) rotate(7deg); }
.trick .slot .card { width: 100%; }
.trick .slot.winner .card .card-img { box-shadow: 0 0 0 3px var(--gold), 0 0 26px rgba(242,193,78,.8); }
.deck-spot, .nest-pile { position: absolute; left: 50%; top: 50%; width: var(--trick-w); aspect-ratio: 200/280; transform: translate(-50%, -50%); }
.deck-spot .card, .nest-pile .card { position: absolute; inset: 0; width: 100%; }
.nest-pile .label, .deck-spot .label { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: rgba(255,255,255,.75); white-space: nowrap; }
.nest-pile.small { width: calc(var(--trick-w) * .55); left: auto; right: -6%; top: auto; bottom: -4%; transform: none; opacity: .9; }
.nest-pile.reveal { width: auto; display: flex; gap: 6px; left: 50%; transform: translate(-50%, -50%); }
.nest-pile.reveal .card { position: relative; width: calc(var(--trick-w) * .85); animation: flipIn .5s ease both; animation-delay: calc(var(--i) * 90ms); }
@keyframes flipIn { from { transform: rotateY(90deg); } }
.deck-spot.shuffling .card:nth-child(1) { animation: riffleL .7s ease-in-out; }
.deck-spot.shuffling .card:nth-child(2) { animation: riffleR .7s ease-in-out; }
@keyframes riffleL { 30% { transform: translateX(-70%) rotate(-12deg); } 60% { transform: translateX(-20%) rotate(-4deg); } }
@keyframes riffleR { 30% { transform: translateX(70%) rotate(12deg); } 60% { transform: translateX(20%) rotate(4deg); } }
.center-note { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 18px; font-size: .9rem; color: rgba(255,255,255,.85); white-space: nowrap; text-shadow: 0 2px 6px rgba(0,0,0,.6); }

/* action panel */
.action-panel {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--hand-w) * 1.4 + 30px); z-index: 15;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px 14px; box-shadow: var(--shadow);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 24px);
  backdrop-filter: blur(8px); animation: rise .25s ease;
}
.action-panel:empty { display: none; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } }
.action-panel .ap-title { font-weight: 700; font-size: .95rem; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper .amt { font-family: var(--font-display); font-weight: 900; font-size: 1.7rem; min-width: 64px; text-align: center; color: var(--gold); }
.stepper .btn { width: 40px; height: 40px; padding: 0; font-size: 1.3rem; }
.trump-btns { display: flex; gap: 6px; }
.trump-btn { display: grid; place-items: center; gap: 2px; padding: 6px 10px; border-radius: 12px; border: 2px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06); cursor: pointer; font-size: .72rem; font-weight: 700; min-width: 60px; }
.trump-btn.on { border-color: var(--gold); background: rgba(242,193,78,.18); box-shadow: 0 0 18px rgba(242,193,78,.4); }
.trump-btn .cnt { color: var(--muted); font-weight: 500; }

/* bubbles */
.bubbles { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; z-index: 30; }
.seat.pos2 .bubbles { bottom: auto; top: 100%; margin-top: 6px; }
.seat.pos0 .bubbles { left: 0; transform: none; align-items: flex-start; }
.bubble { background: #fffdf6; color: #1a1a1a; padding: 7px 12px; border-radius: 14px; font-weight: 600; font-size: .85rem; box-shadow: 0 8px 20px rgba(0,0,0,.4); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; animation: bubbleIn .25s ease, bubbleOut .4s ease forwards; animation-delay: 0s, var(--life, 2.6s); }
.bubble.emote { font-size: 2rem; background: transparent; box-shadow: none; padding: 0; animation: emoteIn .5s cubic-bezier(.2,1.6,.4,1), bubbleOut .4s ease forwards; animation-delay: 0s, var(--life, 2.2s); }
.bubble.voice { border: 2px solid var(--gold); }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px) scale(.9); } }
@keyframes emoteIn { from { opacity: 0; transform: scale(.2); } }
@keyframes bubbleOut { to { opacity: 0; transform: translateY(-8px); } }

/* fx layer */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.fly { position: absolute; left: 0; top: 0; will-change: transform; }
.fly .card { width: 100%; }
.floater { position: absolute; font-family: var(--font-display); font-weight: 900; font-size: 1.8rem; color: var(--gold); text-shadow: 0 3px 10px rgba(0,0,0,.6); animation: floatUp 1.3s ease forwards; transform: translate(-50%, -50%); }
@keyframes floatUp { to { opacity: 0; transform: translate(-50%, -160%); } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

.toast { position: fixed; left: 50%; top: 28vh; transform: translate(-50%, -20px); background: var(--panel-solid); border: 1px solid var(--line); padding: 10px 18px; border-radius: 999px; opacity: 0; transition: .3s; z-index: 80; box-shadow: var(--shadow); max-width: calc(100vw - 32px); text-align: center; font-weight: 600; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.banner { position: fixed; left: 50%; top: 44%; transform: translate(-50%, -50%) scale(.6); opacity: 0; z-index: 60; pointer-events: none; padding: 16px 34px; border-radius: 20px; background: var(--panel-solid); border: 2px solid var(--c, var(--gold)); box-shadow: 0 0 60px color-mix(in srgb, var(--c, var(--gold)) 55%, transparent), var(--shadow); display: flex; align-items: center; gap: 14px; font-family: var(--font-display); font-weight: 900; font-size: clamp(1.6rem, 4vw, 2.6rem); transition: transform .35s cubic-bezier(.2,1.4,.4,1), opacity .3s; white-space: nowrap; }
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.kibitzer { position: fixed; right: clamp(12px, 3vw, 40px); bottom: calc(var(--hand-w) * 1.4 + 40px); z-index: 75; display: flex; align-items: center; gap: 10px;
  background: #fffdf6; color: #1a1a1a; padding: 8px 14px 8px 8px; border-radius: 18px; box-shadow: 0 10px 24px rgba(0,0,0,.45); border: 2px solid #9c8a6b;
  opacity: 0; transform: translateY(16px) scale(.9); transition: opacity .25s, transform .3s cubic-bezier(.2,1.4,.4,1); pointer-events: none; max-width: calc(100vw - 24px); }
.kibitzer.show { opacity: 1; transform: none; }
.kibitzer .kb-face { font-size: 2rem; line-height: 1; }
.kibitzer .kb-text { display: grid; font-weight: 700; font-size: 1rem; }
.kibitzer .kb-text b { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7a6a4d; }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 65; background: rgba(4, 10, 7, .62); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.overlay-card { position: relative; width: min(720px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: linear-gradient(180deg, #17352a, #0f2219); border: 1px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: var(--shadow); animation: rise2 .35s ease; }
@keyframes rise2 { from { transform: translateY(20px); opacity: 0; } }
.overlay-card h2 { font-family: var(--font-display); margin: 0 0 6px; font-size: 1.8rem; }
.overlay-card h3 { margin: 18px 0 6px; font-size: 1rem; color: var(--gold); }
.overlay-card p, .overlay-card li { line-height: 1.5; color: #e6e1d3; }
.overlay-card .close { position: absolute; top: 10px; right: 12px; background: none; border: 0; font-size: 1.8rem; cursor: pointer; color: var(--muted); }
.result-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.badge { padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: .85rem; }
.badge.made { background: #2fae6b; color: #04140b; }
.badge.set { background: #d24a4a; }
.recap { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: .9rem; }
.recap th, .recap td { padding: 7px 8px; text-align: right; border-bottom: 1px solid rgba(255,255,255,.08); }
.recap th:first-child, .recap td:first-child { text-align: left; }
.recap th { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.recap .tot { font-weight: 800; color: var(--gold); }
.recap tr.team0 td:first-child { border-left: 4px solid var(--team-a); padding-left: 8px; }
.recap tr.team1 td:first-child { border-left: 4px solid var(--team-b); padding-left: 8px; }
.mini-cards { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-cards .card { width: 46px; }
.history { max-height: 180px; overflow: auto; }
.table-wrap { overflow-x: auto; }
.ready-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.win-hero { text-align: center; }
.win-hero .trophy { font-size: 4rem; animation: float 3s ease-in-out infinite; }
.win-hero h2 { font-size: 2.4rem; background: linear-gradient(180deg, #ffe7a3, #c9952e); -webkit-background-clip: text; background-clip: text; color: transparent; }
.c-R { color: #ff6a6a; } .c-Y { color: #ffd04a; } .c-G { color: #4fd18a; } .c-B { color: #c9ccd8; }
.howto .rules-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .9rem; background: rgba(0,0,0,.25); padding: 12px; border-radius: 12px; }
.howto .rules-list dt { color: var(--muted); }
.howto .rules-list dd { margin: 0; font-weight: 600; }
.howto a { color: var(--gold); }

.chat-palette, .menu { position: absolute; top: 62px; right: clamp(10px, 2vw, 22px); z-index: 50; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); width: min(320px, calc(100vw - 24px)); display: grid; gap: 8px; animation: rise2 .2s ease; }
.chat-palette .phrases { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-palette .phrases .btn { padding: 6px 10px; font-size: .8rem; }
.chat-palette .emotes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.chat-palette .emotes button { font-size: 1.5rem; background: rgba(255,255,255,.06); border: 0; border-radius: 10px; padding: 6px; cursor: pointer; }
.chat-palette .emotes button:hover { background: rgba(255,255,255,.16); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .settings-form { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  :root { --hand-w: clamp(52px, 14vw, 80px); --trick-w: clamp(50px, 14vw, 74px); --fan-w: 26px; }
  .scores { flex: 1; min-width: 0; gap: 6px; }
  .score { min-width: 0; flex: 1; padding: 4px 8px; }
  .score .val { font-size: 1.2rem; }
  .score .lbl { max-width: none; }
  .chip-box { padding: 4px 8px; }
  .chip-box .val { font-size: .9rem; }
  .hud { flex-wrap: wrap; }
  .contract { order: 3; width: 100%; justify-content: center; }
  .hud-buttons { gap: 3px; }
  .icon-btn { width: 30px; height: 30px; font-size: 14px; }
  .seat.pos2 { top: 112px; }
  .seat.pos2 .fan { display: none; }
  .seat.pos1 .fan, .seat.pos3 .fan { display: none; }
  .seat.pos1, .seat.pos3 { top: 40%; }
  .plate { padding: 4px 8px 4px 4px; max-width: 130px; }
  .plate .nm { font-size: .78rem; }
  .avatar { width: 28px; height: 28px; font-size: 15px; }
  .seat.pos0 { bottom: calc(var(--hand-w) * 1.4 + 18px); }
  .action-panel { bottom: calc(var(--hand-w) * 1.4 + 64px); padding: 8px 10px; }
  .trump-btn { min-width: 50px; padding: 4px 6px; }
  .center { top: 47%; }
  .title { font-size: 2.6rem; }
  .room-code { font-size: 2rem; }
  .seat-card .bio { display: none; }
  .overlay-card { padding: 16px; }
  .recap { font-size: .74rem; }
  .recap th, .recap td { padding: 5px 4px; }
  .recap th { font-size: .6rem; letter-spacing: .02em; }
  .win-hero h2 { font-size: 1.9rem; }
}
@media (max-height: 560px) and (orientation: landscape) {
  :root { --hand-w: clamp(48px, 7vw, 74px); --trick-w: clamp(44px, 6.5vw, 66px); --fan-w: 24px; }
  .seat.pos2 { top: 56px; }
  .seat.pos2 .fan { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
