/* Card Parlor — Kahoot-inspired design system */
:root {
  --purple: #46178f;
  --purple-dark: #2e0e6b;
  --purple-deep: #25076b;
  --red: #e21b3c;
  --red-dark: #b8102d;
  --blue: #1368ce;
  --blue-dark: #0d4f9e;
  --yellow: #ffa602;
  --yellow-dark: #d68a00;
  --green: #26890c;
  --green-dark: #1c6909;
  --white: #ffffff;
  --ink: #333333;
  --muted: #6e6e6e;
  --felt: #2e0e6b;
  --radius: 12px;
  --shadow-btn: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
  --font: 'Montserrat', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
/* kill the mobile double-tap-to-zoom delay on everything interactive */
button, .card { touch-action: manipulation; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-weight: 500;
  background: var(--purple);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.06) 0 120px, transparent 120px),
    radial-gradient(circle at 85% 70%, rgba(255, 255, 255, 0.05) 0 160px, transparent 160px),
    radial-gradient(circle at 60% 10%, rgba(255, 255, 255, 0.04) 0 90px, transparent 90px);
  color: var(--white);
  min-height: 100vh;
  min-height: 100dvh;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; }
input { font-family: inherit; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; padding: 12px 20px;
  font-weight: 800; font-size: 1rem; color: var(--white);
  border-radius: 8px; box-shadow: var(--shadow-btn);
  transition: transform 0.06s ease, filter 0.15s ease;
  user-select: none; text-align: center; line-height: 1.2;
}
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(0,0,0,0.25); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn-green { background: var(--green); }
.btn-red { background: var(--red); }
.btn-blue { background: var(--blue); }
.btn-yellow { background: var(--yellow); color: #4a3200; }
.btn-ghost { background: rgba(255, 255, 255, 0.14); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18); }
.btn-big { padding: 16px 28px; font-size: 1.15rem; width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; }
.btn .vn { display: block; font-size: 0.65rem; font-weight: 700; opacity: 0.75; text-transform: none; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; gap: 10px;
}
.logo { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.5px; color: var(--white); text-decoration: none; }
.logo span { color: var(--yellow); }
.logo:hover span { text-decoration: underline; }
.topbar-right { display: flex; gap: 8px; align-items: center; }

/* ---------- home ---------- */
.home-main { max-width: 960px; margin: 0 auto; padding: 8px 16px 40px; display: flex; flex-direction: column; gap: 18px; }
.hero { text-align: center; padding: 18px 0 6px; }
.hero h1 { font-size: clamp(1.9rem, 6vw, 3rem); font-weight: 800; letter-spacing: -1px; }
.hero .accent { color: var(--yellow); }
.tagline { margin-top: 8px; opacity: 0.85; font-size: 1rem; max-width: 480px; margin-inline: auto; }

.home-cards { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 720px) { .home-cards { grid-template-columns: 1fr 1fr; } }

.panel {
  background: var(--white); color: var(--ink);
  border-radius: var(--radius); padding: 20px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2);
}
.panel h2 { font-size: 1.15rem; font-weight: 800; margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-head h2 { margin-bottom: 0; }
.panel .btn-ghost { background: rgba(70, 23, 143, 0.1); color: var(--purple); }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 0.8rem; font-weight: 700; margin-bottom: 5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.field em { text-transform: none; font-weight: 500; }
.field input {
  width: 100%; padding: 12px 14px; font-size: 1rem; font-weight: 700;
  border: 2px solid #d5d5e2; border-radius: 8px; color: var(--ink); background: #fafaff;
}
.field input:focus { outline: none; border-color: var(--purple); }
#join-code, #name-input { text-transform: uppercase; letter-spacing: 3px; }

.pill-row { display: flex; gap: 6px; }
.pill {
  flex: 1; padding: 9px 4px; border-radius: 8px; background: #ececf4;
  font-weight: 800; color: var(--muted); font-size: 0.85rem;
  border: 2px solid transparent;
}
.pill.active { background: var(--purple); color: var(--white); }

.toggle-row { display: flex; align-items: center; gap: 10px; margin: 14px 0 16px; cursor: pointer; }
.toggle-row input { display: none; }
.toggle {
  flex: none; width: 46px; height: 26px; border-radius: 13px; background: #ccc; position: relative; transition: background 0.15s;
}
.toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--white); transition: left 0.15s;
}
.toggle-row input:checked + .toggle { background: var(--green); }
.toggle-row input:checked + .toggle::after { left: 23px; }
.toggle-label { font-size: 0.9rem; font-weight: 700; }
.toggle-label em { font-weight: 500; font-size: 0.78rem; color: var(--muted); font-style: normal; }

/* lobby list */
.lobby-list { display: flex; flex-direction: column; gap: 8px; }
.lobby-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #f4f2fb; border-radius: 8px; padding: 10px 14px;
}
.lobby-row .lr-name { font-weight: 800; }
.lobby-row .lr-meta { font-size: 0.8rem; color: var(--muted); }
.lobby-row .lr-game { display: inline-block; background: var(--purple); color: #fff; font-weight: 800; font-size: 0.66rem; border-radius: 5px; padding: 2px 7px; margin-right: 6px; }
.lobby-row .lr-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.lobby-row .lr-share { background: #fff; color: var(--purple); box-shadow: inset 0 0 0 2px rgba(70, 23, 143, 0.18); padding: 8px 11px; }
.lobby-row .lr-share:hover:not(:disabled) { filter: none; background: #f4f2fb; }

/* live counter (home screens) */
.live-counter { display: inline-flex; gap: 16px; margin-top: 16px; background: rgba(0,0,0,0.22); border-radius: 20px; padding: 8px 18px; font-size: 0.9rem; font-weight: 700; }
.live-counter .lc-item { display: inline-flex; align-items: center; gap: 6px; }
.live-counter b { color: var(--yellow); font-weight: 800; }
.live-counter .live-dot { width: 9px; height: 9px; border-radius: 50%; background: #6ee26a; animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.empty { color: var(--muted); font-size: 0.9rem; padding: 8px 0; }

.lb-list { display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #f4f2fb; border-radius: 8px; }
.lb-row .rank { font-weight: 800; width: 28px; color: var(--purple); }
.lb-row .lb-name { font-weight: 700; flex: 1; }
.lb-row .lb-stat { font-size: 0.85rem; color: var(--muted); }

.rules { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; font-size: 0.92rem; line-height: 1.5; }
.panel-rules summary { font-weight: 700; cursor: pointer; color: var(--purple); }
.footer { text-align: center; padding: 20px; opacity: 0.6; font-size: 0.8rem; }
.footer a { color: var(--white); font-weight: 700; text-decoration: none; }
.footer a:hover { color: var(--yellow); }

/* ---------- room screen ---------- */
/* svh = smallest visible height, so the action bar never hides behind the
   browser toolbar on iPhone Chrome/Safari */
#screen-room { display: flex; flex-direction: column; height: 100vh; height: 100dvh; height: 100svh; overflow: hidden; }
.room-topbar { flex: none; padding: 8px 12px; }
.room-title { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.room-name { font-weight: 800; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50vw; }
.room-title-sub { display: flex; align-items: center; gap: 8px; }
.room-code {
  background: rgba(255, 255, 255, 0.15); color: var(--yellow);
  font-weight: 800; letter-spacing: 2px; font-size: 0.85rem;
  border-radius: 6px; padding: 3px 10px;
}
.spec-badge {
  background: rgba(255, 255, 255, 0.12); color: #fff; font-weight: 700;
  font-size: 0.72rem; border-radius: 10px; padding: 3px 9px; white-space: nowrap;
}

.table-area { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 8px 8px; gap: 6px; }

/* square table: opponents around the play area, you at the bottom */
.play-area { position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; gap: 4px; }
.seat-pos { display: flex; align-items: flex-start; justify-content: center; min-height: 48px; }
.pos-top { flex: none; }
.table-mid { flex: 1; display: flex; align-items: flex-start; gap: 4px; min-height: 0; padding-top: 6px; }
.pos-side { flex: none; width: 80px; }
.center-col {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; align-self: stretch;
  overflow: hidden;
}
/* seat labels: no pill — just avatar, name and card count */
.seat-pos .player-chip {
  flex-direction: column; padding: 2px;
  gap: 3px; max-width: 92px; text-align: center;
}
.seat-pos .player-chip .pc-info { width: 100%; }
.seat-pos .player-chip .pc-name { font-size: 0.75rem; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.seat-pos .player-chip .pc-sub { font-size: 0.7rem; opacity: 0.9; }
.seat-pos .player-chip.passed { opacity: 0.5; }

/* cards a player put down this round, shown at their seat */
.pc-played { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.pc-played-label {
  font-size: 0.52rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.2px; color: rgba(255, 255, 255, 0.65);
}
.pc-played-cards { display: flex; align-items: center; }
.pc-played-cards .card { margin-left: -9px; }
.pc-played-cards .card:first-child { margin-left: 0; }
.pc-more { font-size: 0.62rem; font-weight: 800; margin-left: 3px; color: rgba(255, 255, 255, 0.8); }

.card.tiny { width: 22px; height: 31px; border-radius: 3px; border-width: 1px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }
.card.tiny .c-corner { font-size: 0.5rem; top: 1px; left: 2px; }
.card.tiny .c-pip { font-size: 0.62rem; bottom: 1px; right: 2px; }
.player-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px;
  position: relative; max-width: 46vw;
}
/* soft animated glow behind whoever's turn it is */
@keyframes glow-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.18); }
}
.player-chip.turn::before {
  content: ''; position: absolute; inset: -12px -20px;
  background: radial-gradient(ellipse at center, rgba(255, 166, 2, 0.4), transparent 70%);
  border-radius: 50%; z-index: -1; pointer-events: none;
  animation: glow-pulse 1.6s ease-in-out infinite;
}
.player-chip.turn .avatar { box-shadow: 0 0 0 3px var(--yellow); }
.player-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.95rem; color: var(--white);
}
.player-chip .pc-info { min-width: 0; }
.player-chip .pc-name { font-weight: 800; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-chip .pc-sub { font-size: 0.72rem; opacity: 0.8; }
.player-chip.passed { opacity: 0.55; }
.player-chip.offline .pc-name::after { content: ' 📴'; }
.player-chip .badge {
  position: absolute; top: -8px; right: -4px; font-size: 0.9rem;
}
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 166, 2, 0.5); } 50% { box-shadow: 0 0 0 7px rgba(255, 166, 2, 0); } }

/* table center */
.table-center {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.07), rgba(0,0,0,0.12));
  border: 2px solid rgba(255, 255, 255, 0.12); border-radius: 18px;
  padding: 12px; overflow-y: auto;
}
.waiting-panel { text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; width: 100%; max-width: 420px; }
.waiting-panel h2 { font-size: 1.2rem; font-weight: 800; }
.seat-list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.seat-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.1); border-radius: 10px; padding: 8px 12px; text-align: left;
}
.seat-row .avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem; flex: none; }
.seat-row .sr-name { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-row .sr-tag { font-size: 0.7rem; background: rgba(255,255,255,0.2); border-radius: 6px; padding: 2px 7px; font-weight: 700; }
.seat-row.empty-seat { opacity: 0.5; border: 2px dashed rgba(255,255,255,0.3); background: none; justify-content: center; font-size: 0.85rem; }
.seat-kick { background: rgba(226, 27, 60, 0.85); color: white; border-radius: 6px; font-weight: 800; padding: 4px 9px; font-size: 0.75rem; }
.waiting-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.waiting-hint { font-size: 0.82rem; opacity: 0.75; }

/* waitlist panel */
.waitlist-panel { flex: none; background: rgba(0, 0, 0, 0.25); border-radius: 12px; padding: 8px 12px; }
.waitlist-panel .wl-head { font-weight: 800; font-size: 0.85rem; margin-bottom: 6px; }
.waitlist-panel .wl-head #wl-count { color: var(--yellow); }
.wl-names { display: flex; flex-wrap: wrap; gap: 6px; max-height: 84px; overflow-y: auto; }
.wl-chip { display: inline-flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, 0.12); border-radius: 16px; padding: 4px 10px; font-size: 0.8rem; font-weight: 700; }
.wl-chip.me { background: rgba(255, 166, 2, 0.28); border: 1px solid var(--yellow); }
.wl-pos { color: var(--yellow); font-weight: 800; font-size: 0.72rem; }
.wl-bump { background: var(--blue); color: #fff; border-radius: 8px; font-weight: 800; font-size: 0.66rem; padding: 3px 8px; }
.wl-note { font-size: 0.72rem; opacity: 0.78; margin-top: 6px; }

/* trick display */
.trick-plays { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.trick-play { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.trick-play .tp-name { font-size: 0.75rem; font-weight: 700; opacity: 0.8; }
.trick-play .tp-played {
  font-size: 0.55rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: rgba(255, 255, 255, 0.6); margin: -1px 0 2px;
}
.trick-play.older .tp-played { display: none; }
.trick-play.latest .tp-name { opacity: 1; color: var(--yellow); }
.trick-play.older { opacity: 0.4; transform: scale(0.72); margin-bottom: -8px; }
.tp-cards { display: flex; flex-wrap: wrap; justify-content: center; row-gap: 4px; max-width: 100%; }
.table-msg { font-weight: 700; font-size: 0.95rem; text-align: center; min-height: 1.4em; }
.table-msg .big { font-size: 1.15rem; color: var(--yellow); }

/* cards */
.card {
  width: 52px; height: 74px; border-radius: 7px; background: var(--white);
  color: #16161d; position: relative; flex: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  border: 2px solid #e8e8ef;
  font-weight: 800;
}
.card .c-corner { position: absolute; top: 4px; left: 6px; font-size: 0.95rem; line-height: 1; }
.card .c-corner small { display: block; font-size: 0.85em; }
.card .c-pip { position: absolute; bottom: 4px; right: 6px; font-size: 1.5rem; line-height: 1; }
.card.red { color: var(--red); }
.card.mini { width: 38px; height: 54px; border-radius: 5px; }
.card.mini .c-corner { font-size: 0.75rem; top: 3px; left: 4px; }
.card.mini .c-pip { font-size: 1.05rem; bottom: 3px; right: 4px; }
.tp-cards .card { margin-left: -14px; }
.tp-cards .card:first-child { margin-left: 0; }

/* discard pile: hold to peek at played cards */
.pile-btn {
  position: absolute; right: 4px; bottom: 4px; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  background: rgba(0, 0, 0, 0.3); border-radius: 12px; padding: 6px 10px;
  color: var(--white); font-weight: 800;
  border: 2px solid rgba(255, 255, 255, 0.2);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.pile-btn:active { background: rgba(0, 0, 0, 0.5); border-color: var(--yellow); }
.pile-stack { font-size: 1.5rem; line-height: 1; }
.pile-count { font-size: 0.8rem; color: var(--yellow); }
.pile-hint { font-size: 0.55rem; font-weight: 700; opacity: 0.6; text-transform: uppercase; letter-spacing: 1px; }
.pile-peek {
  position: absolute; right: 4px; bottom: 68px; z-index: 6;
  width: min(290px, calc(100% - 12px)); max-height: min(46%, 300px);
  background: rgba(20, 5, 50, 0.96); border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  padding: 10px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  pointer-events: none; /* never steal the pointer from the held button */
}
.pile-peek-title { font-weight: 800; font-size: 0.8rem; color: var(--yellow); }
.pile-peek-cards { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.pile-peek .card.mini { width: 30px; height: 42px; border-radius: 4px; }
.pile-peek .card.mini .c-corner { font-size: 0.62rem; top: 2px; left: 3px; }
.pile-peek .card.mini .c-pip { font-size: 0.8rem; bottom: 2px; right: 3px; }
.pile-peek .empty-pile { opacity: 0.7; font-size: 0.85rem; }

/* my area */
.me-area { flex: none; display: flex; flex-direction: column; gap: 5px; }
.rank-help {
  align-self: center; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  background: rgba(0, 0, 0, 0.25); border-radius: 14px; padding: 3px 12px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.3px; white-space: nowrap;
}
.rank-help b { color: var(--yellow); font-weight: 800; margin-right: 2px; }
.rank-help .rh-group { display: inline-flex; align-items: center; gap: 3px; }
.rank-help .rh-black { color: #cfc6ea; }
.rank-help .rh-red { color: #ff7d94; }
.rank-help .rh-lt { opacity: 0.55; font-weight: 500; }
.rank-help .rh-sep { opacity: 0.4; }
.me-info { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; }
.me-chip { padding: 4px 12px 4px 4px; }
.me-chip .avatar { width: 26px; height: 26px; font-size: 0.8rem; }
.combo-hint { font-size: 0.8rem; font-weight: 700; color: var(--yellow); text-align: right; }
.combo-hint.ok { color: #8be26a; }
.combo-hint.bad { color: #ff8fa3; }
.hand {
  display: flex; padding: 15px 10px 8px; overflow-x: auto; overflow-y: visible;
  min-height: 97px; align-items: flex-end;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.3) transparent;
}
.hand .card { margin-left: -18px; cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s; }
.hand .card:first-child { margin-left: 0; }
.hand .card.selected {
  transform: translateY(-14px);
  border-color: var(--yellow); box-shadow: 0 4px 12px rgba(255, 166, 2, 0.5);
}
.action-bar { display: flex; gap: 10px; padding-bottom: env(safe-area-inset-bottom); }
.action-bar .btn { flex: 1; padding: 10px 8px; font-size: 1rem; }

/* turn countdown */
.turn-timer { font-weight: 800; font-size: 0.72rem; color: var(--yellow); }
@keyframes timer-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.turn-timer.urgent { color: #ff8fa3; animation: timer-blink 0.9s ease-in-out infinite; }
.table-msg .turn-timer { font-size: 1rem; margin-left: 6px; }

/* waiting room rule line */
.waiting-rule { font-size: 0.85rem; font-weight: 700; color: var(--yellow); opacity: 0.9; }

/* floating chat bubbles — rise up near the chat button, then fade away */
.chat-float {
  position: fixed; right: 12px; z-index: 35;
  bottom: calc(280px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
  max-width: min(78vw, 320px); pointer-events: none;
}
.float-msg {
  background: rgba(20, 5, 50, 0.92); color: #fff; border: 1px solid rgba(255,255,255,0.18);
  border-radius: 14px; padding: 8px 13px; font-size: 0.88rem; line-height: 1.3;
  box-shadow: 0 4px 14px rgba(0,0,0,0.45); word-break: break-word;
  opacity: 1; /* visible on arrival — no entrance animation to get stuck on in a hidden tab */
}
.float-msg.out { opacity: 0; transform: translateY(-30px); transition: opacity 0.7s ease, transform 0.7s ease; }
.float-msg .fm-name { font-weight: 800; color: var(--yellow); }
@media (min-width: 900px) { .chat-float { bottom: calc(96px + env(safe-area-inset-bottom)); } }

/* chat */
.chat-toggle { position: relative; flex-direction: row; }
@keyframes chat-bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-7px); }
  55% { transform: translateY(0); }
  75% { transform: translateY(-3px); }
}
.chat-toggle.bounce { animation: chat-bounce 0.8s ease; }
.chat-badge {
  position: absolute; top: -6px; right: -6px; background: var(--red); color: white;
  border-radius: 10px; font-size: 0.7rem; font-weight: 800; padding: 2px 7px;
}
.chat-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--white); color: var(--ink);
  border-radius: 16px 16px 0 0; box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.45);
  height: min(60vh, 480px); height: min(60dvh, 480px); display: flex; flex-direction: column;
  transform: translateY(105%); transition: transform 0.25s ease;
}
.chat-sheet.open { transform: translateY(0); }
@media (min-width: 900px) {
  .chat-sheet { left: auto; width: 380px; right: 12px; border-radius: 16px 16px 0 0; }
}
.chat-tabs { display: flex; gap: 4px; padding: 10px 10px 0; align-items: center; }
.chat-tab {
  flex: 1; padding: 9px; font-weight: 800; font-size: 0.9rem;
  background: #eee; border-radius: 8px 8px 0 0; color: var(--muted);
}
.chat-tab.active { background: var(--purple); color: var(--white); }
.chat-close { width: 34px; height: 34px; border-radius: 8px; background: #eee; font-weight: 800; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 7px; font-size: 0.9rem; }
.chat-msg .cm-name { font-weight: 800; color: var(--purple); margin-right: 6px; }
.act-row { color: #444; font-size: 0.85rem; padding: 3px 6px; border-left: 3px solid #ddd; }
.act-row.play { border-left-color: var(--blue); }
.act-row.chop { border-left-color: var(--red); font-weight: 700; background: #fdecef; }
.act-row.game { border-left-color: var(--green); font-weight: 700; }
.act-row.pass { opacity: 0.7; }
.chat-input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #eee; }
.chat-input-row input { flex: 1; border: 2px solid #d5d5e2; border-radius: 8px; padding: 9px 12px; font-size: 16px; }
.chat-input-row input:focus { outline: none; border-color: var(--purple); }

/* ---------- modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 5, 50, 0.7); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--white); color: var(--ink); border-radius: var(--radius);
  padding: 22px; width: 100%; max-width: 380px; position: relative;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.25);
  display: flex; flex-direction: column; gap: 12px;
  max-height: 85vh; max-height: 85dvh; overflow-y: auto;
}
.modal h2 { font-size: 1.2rem; font-weight: 800; }
.modal h3 { font-size: 0.95rem; font-weight: 800; margin-top: 4px; }
.modal-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 8px; background: #eee; font-weight: 800; }
.auth-tabs { display: flex; gap: 8px; }
.auth-tab { flex: 1; padding: 10px; font-weight: 800; border-radius: 8px; background: #eee; color: var(--muted); }
.auth-tab.active { background: var(--purple); color: var(--white); }
.auth-blurb { font-size: 0.85rem; color: var(--muted); }
.form-error { color: var(--red); font-size: 0.85rem; font-weight: 700; min-height: 1.2em; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-box { background: #f4f2fb; border-radius: 10px; padding: 12px; text-align: center; }
.stat-box .sb-num { font-size: 1.5rem; font-weight: 800; color: var(--purple); }
.stat-box .sb-label { font-size: 0.75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.results-list { display: flex; flex-direction: column; gap: 8px; }
.result-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: #f4f2fb; border-radius: 10px; font-weight: 700;
}
.result-row.first { background: linear-gradient(90deg, #fff3d6, #ffe9b3); }
.result-row .rr-medal { font-size: 1.3rem; }
.result-row .rr-place { color: var(--muted); font-size: 0.8rem; margin-left: auto; }
.settings-players { display: flex; flex-direction: column; gap: 8px; }
.settings-player { display: flex; align-items: center; gap: 10px; background: #f4f2fb; border-radius: 8px; padding: 8px 12px; font-weight: 700; }
.settings-player .sp-name { flex: 1; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: #16161d; color: var(--white); font-weight: 700; font-size: 0.9rem;
  padding: 12px 20px; border-radius: 10px; z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4); max-width: 90vw; text-align: center;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* confetti */
.confetti {
  position: fixed; top: -30px; z-index: 300; font-size: 1.4rem; pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.6; }
}

/* larger screens: bigger cards */
@media (min-width: 700px) {
  .card { width: 62px; height: 88px; }
  .card .c-pip { font-size: 1.8rem; }
  .hand .card { margin-left: -20px; }
  .hand { justify-content: center; }
  .me-area { max-width: 760px; width: 100%; margin: 0 auto; }
  .action-bar .btn { flex: initial; min-width: 160px; }
  .action-bar { justify-content: center; }
}
