:root {
  --bg: #0a2a20;
  --bg2: #0f3a2c;
  --felt: #12513c;
  --panel: rgba(0, 0, 0, .28);
  --line: rgba(255, 255, 255, .14);
  --text: #eef5f0;
  --muted: #9db8ac;
  --accent: #f2c14e;
  --accent-text: #2a1d00;
  --danger: #d9534f;
  --pos: #62d98b;
  --neg: #ff7b72;
  --cw: 54px;
}
@media (min-width: 720px) { :root { --cw: 66px; } }

* { box-sizing: border-box; }
html, body { margin: 0; }
html { background-color: #0a2a20; color-scheme: dark; } /* no white flash when the page rubber-bands on iOS */
body {
  background: radial-gradient(1200px 700px at 50% -10%, var(--bg2), var(--bg));
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", Tahoma, sans-serif;
  min-height: 100vh;
  min-height: 100dvh; /* the visible height on phones (Safari/Chrome toolbars come and go) */
  -webkit-text-size-adjust: 100%;
}
h2, h3, h4 { margin: 0 0 .4em; }
h2 { font-size: 1.35rem; }
a { color: var(--accent); }
hr { border: 0; border-top: 1px solid var(--line); width: 100%; }
input, select, button { font: inherit; }
input, select {
  width: 100%; padding: .6em .7em; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, .35); color: var(--text);
}
input[type=checkbox] { width: auto; }
input[type=range] { padding: 0; }
label { display: grid; gap: .3em; font-size: .9rem; color: var(--muted); }
label.check { display: flex; align-items: center; gap: .4em; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.strong { font-weight: 700; }
.center { text-align: center; }
.stack { display: grid; gap: .8em; }
.row { display: flex; gap: .5em; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grid2 { display: grid; gap: 1em; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid3 { display: grid; gap: .6em; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.zero { color: var(--muted); }

/* ---- shell ---- */
.shell { max-width: 1000px; margin: 0 auto; padding: 0 16px 60px; }
.topbar { display: flex; align-items: center; gap: 1em; padding: 12px 0; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.logo { font-weight: 800; letter-spacing: .02em; color: var(--accent); text-decoration: none; font-size: 1.15rem; }
.logo.big { font-size: 2rem; text-align: center; }
.topbar nav { display: flex; gap: .8em; flex: 1; }
.topbar nav a { color: var(--muted); text-decoration: none; padding: .2em .1em; }
.topbar nav a.on { color: var(--text); border-bottom: 2px solid var(--accent); }
.who { display: flex; gap: .6em; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }
.banner { position: sticky; top: 0; z-index: 50; background: var(--danger); color: #fff; text-align: center; padding: 6px; font-size: .9rem; }

.login { max-width: 380px; margin: 8vh auto; padding: 0 16px; display: grid; gap: 1em; }
.card-panel, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.form-error { color: var(--neg); min-height: 1.2em; font-size: .9rem; }

/* ---- buttons / tags ---- */
.btn {
  background: rgba(255, 255, 255, .1); color: var(--text); border: 1px solid var(--line);
  padding: .6em 1.1em; border-radius: 10px; cursor: pointer; font-weight: 600; min-height: 42px;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, .18); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.primary:hover:not(:disabled) { background: #ffd36b; }
.btn.danger { background: var(--danger); border-color: transparent; }
.btn.small { padding: .3em .8em; min-height: 34px; font-size: .88rem; }
.btn.big { padding: .8em 1.6em; font-size: 1.1rem; }
.tag { display: inline-block; font-size: .7rem; padding: .05em .5em; border-radius: 99px; background: rgba(255, 255, 255, .14); margin-left: .4em; vertical-align: middle; font-weight: 600; }
.tag.live { background: #2f8f5b; }
.tag.off { background: #7a3b3b; }

#toasts { position: fixed; left: 0; right: 0; bottom: 18px; display: grid; gap: 6px; justify-items: center; z-index: 100; pointer-events: none; padding: 0 12px; }
.toast { background: #3a1f1f; border: 1px solid var(--danger); padding: .6em 1em; border-radius: 10px; max-width: 460px; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); }
.toast.ok { background: #14352a; border-color: #2f8f5b; }

.dialog { background: #12382b; color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 18px; width: min(420px, 92vw); }
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog > * + * { margin-top: .8em; }
.dialog .btn { width: 100%; }

/* ---- lobby ---- */
.room-list { display: grid; gap: 8px; }
.room-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.room-row.dim { opacity: .55; }
.room-name { font-weight: 700; }

/* ---- room ---- */
.room-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 8px; }
.scoreboard { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; }
.score { flex: none; min-width: 96px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.score.me { border-color: var(--accent); }
.score.turn { box-shadow: 0 0 0 2px #7ee0a5, 0 0 16px rgba(126, 224, 165, .5); }
.score.away { opacity: .55; }
.score-name { font-size: .85rem; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.score-chips { font-weight: 800; font-size: 1.1rem; }
.score-net { font-size: .8rem; }
.score-pending { font-size: .7rem; color: var(--accent); white-space: nowrap; }
.buyin summary { cursor: pointer; font-weight: 600; }
.buyin.attention { border-color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #666; display: inline-block; }
.dot.on { background: #43d17a; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { background: none; border: 0; color: var(--muted); padding: .6em 1em; cursor: pointer; border-bottom: 3px solid transparent; font-weight: 600; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.status { text-align: center; color: var(--muted); padding: 6px; }
.status.strong { color: var(--accent); }
.controls { justify-content: center; margin-top: 4px; }
.rules { margin: 0; padding-left: 1.2em; color: var(--muted); }
.rules li { margin: .3em 0; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table tfoot td { font-weight: 700; border-bottom: 0; }
.table.small { font-size: .8rem; }
.result-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; align-items: center; }
details.hist { border-top: 1px solid var(--line); padding: 6px 0; }
details.hist summary { cursor: pointer; padding: 4px 0; }
details > summary { cursor: pointer; }

/* ---- games ---- */
.game { display: grid; gap: 12px; }
.table-felt {
  background: radial-gradient(ellipse at center, #1a6b50, var(--felt));
  border: 2px solid rgba(0, 0, 0, .35); border-radius: 18px; padding: 14px; text-align: center;
  display: grid; gap: 10px; justify-items: center; box-shadow: inset 0 0 40px rgba(0, 0, 0, .35);
}
.pot { font-size: 1.1rem; }
.board, .cards { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.slave-center { min-height: 140px; align-content: center; }

.seats { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.seats.compact { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.seat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: grid; gap: 6px; justify-items: center; text-align: center; }
.seat.wide { grid-column: span 1; }
.seat.me { border-color: var(--accent); }
.seat.turn { box-shadow: 0 0 0 2px #7ee0a5, 0 0 14px rgba(126, 224, 165, .45); }
.seat.folded { opacity: .45; }
.seat.done { opacity: .6; }
.seat.ready { border-color: #43d17a; }
.seat-head { display: flex; gap: 4px; align-items: center; justify-content: center; flex-wrap: wrap; }
.seat-name { font-weight: 700; }
.seat-cards { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.seat-info { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; font-size: .85rem; }
.badge { background: #fff; color: #222; font-size: .65rem; font-weight: 800; padding: 0 .4em; border-radius: 99px; margin-left: 3px; }
.badge.d { background: var(--accent); }
.bet { color: var(--accent); }
.delta { font-weight: 800; }
.mini-stack { font-size: .85rem; color: var(--muted); }
.actions { display: grid; gap: 10px; justify-items: center; text-align: center; }
.actions .row { justify-content: center; }
.raise { width: 100%; max-width: 420px; }
.log { font-size: .78rem; color: var(--muted); max-height: 110px; overflow: auto; }
.result h4 { margin-bottom: .5em; }
.stage-bar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.step { font-size: .8rem; padding: .25em .7em; border-radius: 99px; background: rgba(255, 255, 255, .08); color: var(--muted); }
.step.on { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.step.past { color: var(--text); }
.stage-sum { border-top: 1px solid var(--line); padding: 6px 0; }

.pile-row { background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 8px; cursor: pointer; }
.pile-row.active { border-color: var(--accent); }
.pile-row.full { background: rgba(47, 143, 91, .18); }
.pile-label { font-size: .85rem; margin-bottom: 4px; }
.piles-result { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.pile-result { padding: 4px 0; border-top: 1px solid var(--line); }

/* ---- cards ---- */
.card {
  position: relative; flex: none; width: var(--cw); height: calc(var(--cw) * 1.45);
  border-radius: calc(var(--cw) * .12); background: #fbfbf7; overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45); font-size: calc(var(--cw) * .34);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.card.sm { --cw: 40px; }
.card.holdable { touch-action: none; cursor: grab; }
.card.tappable { cursor: pointer; }
.card.held { z-index: 20; transform: translateY(-8px); box-shadow: 0 8px 18px rgba(0, 0, 0, .6); }
.card.selected { transform: translateY(-14px); outline: 3px solid var(--accent); }
.card.selected.held { transform: translateY(-20px); }
.card.slot { background: rgba(255, 255, 255, .05); box-shadow: none; border: 2px dashed rgba(255, 255, 255, .22); }
.face { position: absolute; top: 0; right: 0; bottom: 0; left: 0; color: #15151a; }
.face.red { color: #c4162b; }
.corner { position: absolute; top: 0; left: 1.5%; font-size: 1.15em; display: flex; flex-direction: column; align-items: center; line-height: .95; font-weight: 800; }
.corner .st { font-size: .82em; }
.corner.br { top: auto; left: auto; bottom: 0; right: 1.5%; transform: rotate(180deg); }
/* holding a card: the index corners stay hidden until the card is fully uncovered (and while the cover slides back) */
.card.held:not(.show-index) .corner, .card.peek-end .corner { visibility: hidden; }
.art { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }
.pp { position: absolute; transform: translate(-50%, -50%); font-size: .62em; line-height: 1; }
.pp.flip { transform: translate(-50%, -50%) rotate(180deg); }
.pp.ace { font-size: 2.4em; }
.pp.mini { font-size: .7em; }
.court-art .court { position: absolute; left: 19%; top: 5%; width: 64%; height: 90%; }
.back {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; border-radius: inherit; border: 3px solid #fff;
  background: repeating-linear-gradient(45deg, #1b3b8c 0 6px, #2b58bd 6px 12px);
}
.cover { z-index: 2; will-change: transform; }
.cards.hand { justify-content: center; padding-top: 18px; }
.cards.hand.dense { gap: 0; }
.cards.hand.dense .card + .card { margin-left: calc(var(--cw) * -.52); }
/* only a card being held is raised above its neighbours: a selected card must NOT cover the next card's tappable strip */
.cards.hand.dense .card.held { z-index: 20; }

@media (max-width: 480px) {
  .shell { padding: 0 10px 50px; }
  .btn { padding: .55em .9em; }
  .seats { grid-template-columns: repeat(2, 1fr); }
}

.warn { background: rgba(217, 83, 79, .18); border: 1px solid var(--danger); border-radius: 10px; padding: .5em .8em; font-size: .9rem; }

.warn.info { background: rgba(242, 193, 78, .12); border-color: var(--accent); }
.bots-strip { align-items: center; }
.chip-tag { display: inline-flex; align-items: center; gap: .35em; background: rgba(255, 255, 255, .1); border: 1px solid var(--line); border-radius: 99px; padding: .15em .3em .15em .7em; font-size: .85rem; }
.chip-tag .x { background: rgba(255, 255, 255, .15); border: 0; color: var(--text); width: 22px; height: 22px; border-radius: 50%; cursor: pointer; line-height: 1; }
.chip-tag .x:hover { background: var(--danger); }

.card.latched { outline: 2px solid rgba(242, 193, 78, .7); outline-offset: -2px; }

.reveal-bar { display: flex; flex-wrap: wrap; gap: .5em .8em; align-items: center; justify-content: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.segs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg { background: transparent; border: 0; color: var(--muted); padding: .3em .8em; cursor: pointer; font-size: .85rem; }
.seg.on { background: var(--accent); color: var(--accent-text); font-weight: 700; }

.game-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.game-btn { display: grid; gap: 2px; text-align: center; background: rgba(255, 255, 255, .08); color: var(--text); border: 2px solid var(--line); border-radius: 12px; padding: 10px 8px; cursor: pointer; }
.game-btn.on { border-color: var(--accent); background: rgba(242, 193, 78, .14); }
.table-scroll { overflow-x: auto; }

.vote { border-color: var(--accent); background: rgba(242, 193, 78, .1); margin-bottom: 10px; display: grid; gap: 6px; }
.vote-title { font-weight: 700; }

/* =====================================================================
   Mobile-first layer: comfortable on phones (320px and up), landscape and tablets
   ===================================================================== */
html { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior-y: contain; -webkit-text-size-adjust: 100%; }
.shell { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

/* every tappable thing is at least ~44px (Apple/Google guidance) */
.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.btn.small { min-height: 40px; padding: .4em .95em; }
input:not([type=checkbox]):not([type=range]), select { min-height: 44px; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
input[type=range] { min-height: 32px; accent-color: var(--accent); }
label.check { min-height: 40px; }
.tab { min-height: 46px; flex: 1; text-align: center; padding: .6em .4em; }
.topbar { gap: .4em 1em; }
.topbar .logo { display: inline-flex; align-items: center; min-height: 40px; }
.topbar nav a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 .4em; }
.link { min-height: 40px; padding: 0 .5em; display: inline-flex; align-items: center; }
details > summary { min-height: 44px; display: flex; align-items: center; }
.seg { min-height: 40px; padding: .3em 1em; }
.chip-tag .x { width: 32px; height: 32px; }
.tag { font-size: .75rem; padding: .1em .6em; }
.badge { font-size: .72rem; padding: .05em .5em; }
.small { font-size: .85rem; }
.room-head .btn { max-width: 100%; }
.score-name { overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.scoreboard { scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.score { scroll-snap-align: start; }
.dialog { width: min(420px, calc(100vw - 24px)); }
.table th, .table td { padding: 8px 8px; }
.table-scroll { -webkit-overflow-scrolling: touch; }

/* cards are sized from the screen width so a whole hand always fits without sideways scrolling */
.board { flex-wrap: nowrap; gap: 4px; }
.board .card { --cw: min(66px, calc((100vw - 84px) / 5.3)); }
.game.chicken .seat.me .seat-cards .card { --cw: min(66px, calc((100vw - 64px) / 5.5)); }
.game.poker .seat.me .seat-cards .card { --cw: min(66px, calc((100vw - 80px) / 2.4)); }
.cards.hand.dense { --cw: min(66px, calc((100vw - 32px) / (1 + (var(--n, 13) - 1) * .52))); }
.cards.hand.dense .card + .card { margin-left: calc(var(--cw) * -.5); }
.game.piles .pile-row .cards { flex-wrap: nowrap; gap: 4px; justify-content: center; }
.game.piles .card:not(.sm) { --cw: min(62px, calc((100vw - 64px) / 5.4)); }
.game.piles .cards.hand { gap: 5px; }

@media (max-width: 720px) {
  .seat.me { grid-column: 1 / -1; }
  .seats { gap: 6px; }
  .panel, .card-panel { padding: 12px; }
  .room-head h2 { font-size: 1.15rem; }
  .game-grid { grid-template-columns: repeat(2, 1fr); }

  /* the action buttons stay at the bottom of the screen while the table scrolls */
  .actions.panel {
    position: sticky; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 30;
    background: rgba(7, 30, 22, .94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-color: var(--accent); box-shadow: 0 -6px 22px rgba(0, 0, 0, .5);
  }
  .actions .btn { flex: 1 1 120px; }
  .actions .row { width: 100%; }
  .btn.big { padding: .7em 1.2em; width: 100%; }
  .controls .btn.big { width: auto; flex: 1 1 100%; }
  .reveal-bar { justify-content: space-between; }
  .raise input[type=number] { flex: 1; }
}

@media (max-width: 380px) {
  body { font-size: 15px; }
  .shell { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .logo { font-size: 1rem; }
  .score { min-width: 84px; padding: 5px 8px; }
  .score-chips { font-size: 1rem; }
  .seats, .seats.compact { grid-template-columns: 1fr 1fr; }
  .room-row { flex-direction: column; align-items: stretch; }
  .room-row .row { justify-content: flex-end; }
}

/* phones held sideways: little height, so squeeze the chrome and the cards */
@media (max-height: 480px) and (orientation: landscape) {
  :root { --cw: 44px; }
  .topbar { padding: 4px 0; margin-bottom: 6px; }
  .tabs { margin-bottom: 8px; }
  .tab { min-height: 40px; }
  .table-felt { padding: 8px; gap: 6px; }
  .seats { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .seat.me { grid-column: auto; }
  .board .card, .game.chicken .seat.me .seat-cards .card, .game.poker .seat.me .seat-cards .card { --cw: 44px; }
  .cards.hand.dense { --cw: min(48px, calc((100vw - 32px) / (1 + (var(--n, 13) - 1) * .52))); }
  .actions.panel { padding: 8px; gap: 6px; }
  .game.piles .card:not(.sm) { --cw: 42px; }
}

@media (min-width: 721px) {
  .cards.hand.dense { --cw: min(66px, calc((100vw - 32px) / (1 + (var(--n, 13) - 1) * .52))); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
.chip-tag .x { width: 40px; height: 40px; font-size: 1rem; }
.chip-tag { padding: 0 0 0 .8em; }
input[type=range] { min-height: 40px; }

.score-line { display: flex; align-items: baseline; gap: .5em; }
.score-line .score-chips { font-size: 1.05rem; }
.score { padding: 5px 10px; }
.reveal-bar { padding: 4px 10px; gap: .3em .8em; font-size: .85rem; }
.reveal-bar label.check { min-height: 40px; }
@media (max-width: 720px) {
  .room-head { gap: 6px; margin-bottom: 4px; }
  .room-head > div:first-child { min-width: 0; flex: 1 1 100%; }
  .room-head h2 { margin-bottom: 0; }
  .room-head .row { gap: 6px; }
  .room-head .btn.small { font-size: .82rem; padding: .25em .75em; }
  .topbar { padding: 6px 0; margin-bottom: 8px; }
  .tab { min-height: 42px; }
  .tabs { margin-bottom: 10px; }
  .actions.panel { padding: 8px 10px; gap: 6px; }
  .actions .status { padding: 0; font-size: .92rem; }
  .actions .btn { min-height: 46px; }
  .actions .raise { gap: 6px; }
  .seat { padding: 6px; }
  .seat-name { font-size: .92rem; }
}
@media (max-width: 720px) {
  .seats.compact { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 5px; }
  .seats.compact .seat.me { grid-column: auto; }
  .seats.compact .seat { padding: 4px 6px; gap: 2px; }
  .seats.compact .seat-name { font-size: .88rem; }
  .mini-stack { font-size: .78rem; }
  .slave-center { min-height: 96px; padding: 8px; }
}

.deal-wait { width: 100%; }

.score-banner { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; align-items: center; background: rgba(242, 193, 78, .12); border: 1px solid var(--accent); border-radius: 12px; padding: 8px 12px; }
.score-banner.secret { color: var(--muted); font-size: .9rem; background: var(--panel); border-color: var(--line); }
.sb-item { display: grid; justify-items: center; line-height: 1.15; }
.sb-label { font-size: .75rem; color: var(--muted); }
.sb-value { font-size: 1.5rem; color: var(--accent); }
.sb-value.small { font-size: 1rem; }
.sb-value.pos { color: var(--pos); }
.sb-value.neg { color: var(--neg); }
.seat-score { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; font-size: .9rem; }

/* lobby: create on the left, join with a code on the right (stacked on phones) */
.lobby-cols { display: grid; gap: 14px; grid-template-columns: 1fr; margin: 10px 0 18px; align-items: start; }
@media (min-width: 700px) { .lobby-cols { grid-template-columns: 1fr 1fr; } }
.code-input { text-align: center; font-size: 1.6rem; font-weight: 800; letter-spacing: .35em; text-transform: uppercase; font-family: ui-monospace, Menlo, Consolas, monospace; min-height: 56px; }
.code-input::placeholder { letter-spacing: .05em; font-size: 1rem; font-weight: 400; }
.join-panel { border-color: var(--accent); }

.poll { border-color: var(--accent); background: rgba(242, 193, 78, .08); margin-bottom: 12px; display: grid; gap: 8px; }
.poll-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.poll-opt { text-align: left; display: grid; gap: 4px; align-content: start; background: rgba(255, 255, 255, .07); color: var(--text); border: 2px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; min-height: 76px; }
.poll-opt.lead { border-color: rgba(242, 193, 78, .6); }
.poll-opt.mine { border-color: var(--accent); background: rgba(242, 193, 78, .18); }
.poll-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.poll-count { background: var(--accent); color: var(--accent-text); border-radius: 99px; min-width: 26px; height: 26px; display: inline-grid; place-items: center; font-weight: 800; font-size: .9rem; padding: 0 6px; }
.poll-who { display: flex; flex-wrap: wrap; gap: 4px; min-height: 22px; }
.chip-voter { background: rgba(255, 255, 255, .14); border-radius: 99px; padding: 1px 8px; font-size: .75rem; }
.chip-voter.me { background: var(--accent); color: var(--accent-text); font-weight: 700; }
@media (max-width: 720px) { .poll-grid { grid-template-columns: 1fr 1fr; } }

.summary-panel { border-color: var(--pos); background: rgba(98, 217, 139, .08); margin-bottom: 12px; display: grid; gap: 8px; }
.me-row td { font-weight: 800; }

/* ===== Safari (iPhone) and Chrome (Android) details ===== */
/* iOS zooms the page when a focused input is smaller than 16px: never inherit a smaller size from a label */
input, select, textarea { font-size: 16px; }
.shell { padding-top: max(0px, env(safe-area-inset-top)); } /* notch / status bar in landscape and when installed */
.topbar { padding-top: max(6px, env(safe-area-inset-top)); }
/* long-pressing the table must never select text or open the iOS magnifier / callout */
.game, .board, .cards, .seat-cards, .score, .pile-row, .poll, .stage-bar {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.card { -webkit-user-drag: none; -webkit-tap-highlight-color: transparent; }
button, .btn, .tab, .poll-opt, .game-btn { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.btn, button { -webkit-appearance: none; appearance: none; } /* iOS draws its own gradient on buttons otherwise */
input, select { -webkit-appearance: none; appearance: none; border-radius: 8px; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 32px; }
input[type=checkbox] { -webkit-appearance: auto; appearance: auto; }
input[type=range] { -webkit-appearance: auto; appearance: auto; }
@media (display-mode: standalone) { .topbar nav a.on { border-bottom-width: 3px; } } /* installed to the home screen */

.bounce-row.on { background: rgba(242, 193, 78, .22); border-radius: 6px; font-weight: 700; }
.my-window .result-row { padding: .25em .4em; }
.trick-earlier { display: grid; gap: 4px; justify-items: center; margin-bottom: 6px; opacity: .8; }
.trick-play { display: flex; align-items: center; gap: 8px; }
.trick-play .cards { gap: 2px; }
.rate-fields { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.reveal-mini { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; justify-content: center; margin: 4px 0; }
.reveal-mini .seg { padding: .25em .6em; font-size: .8rem; }

/* ---- brand, lobby and room headers (English UI) ---- */
.brand { display: flex; align-items: center; justify-content: center; gap: .45em; white-space: nowrap; font-weight: 800; letter-spacing: .02em; font-size: clamp(1rem, 5.6vw, 2.3rem); line-height: 1.2; }
.brand-name { background: linear-gradient(180deg, #ffe58a, #e8b923 55%, #b8841c); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45)); }
.brand .suit { font-size: 1.05em; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45)); }
.brand .suit.red { color: #ff5d6c; }
.brand .suit.dark { color: #f4f4ef; }
.page-title { font-size: 1.6rem; margin: 0 0 .5em; }
.auto-name { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: rgba(0, 0, 0, .25); border: 1px dashed var(--line); border-radius: 10px; padding: .55em .8em; }
.auto-name b { color: var(--accent); font-size: 1.05rem; }
.bot-count[hidden] { display: none; }
.room-title { display: grid; gap: 2px; min-width: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; color: var(--accent); font-weight: 800; }
.room-title h2 { font-size: 1.6rem; margin: 0; }
.head-actions { margin-top: 4px; }
.buyin-btn { align-self: flex-start; padding: .75em 1.2em; font-weight: 800; font-size: 1rem; box-shadow: 0 3px 10px rgba(0, 0, 0, .4); }
.buyin-btn.attention { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(242, 193, 78, .6); } 50% { box-shadow: 0 0 0 8px rgba(242, 193, 78, 0); } }
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .6); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { background: #12382b; border: 1px solid var(--line); border-radius: 14px; padding: 16px; width: min(420px, 100%); max-height: 92dvh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, .6); }
.modal.wide { width: min(720px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; }
.game-logo { display: inline-block; flex: none; line-height: 0; }
.game-banner { display: flex; align-items: center; justify-content: center; gap: 14px; }
.game-banner h3 { margin: 0; font-size: 1.5rem; }
.poll-opt { justify-items: center; text-align: center; }
.poll-opt .poll-top { width: 100%; }
.close-summary { max-height: 60vh; overflow-y: auto; }
@media (max-width: 480px) { .room-title h2 { font-size: 1.3rem; } .buyin-btn { padding: .65em .9em; } }
.form-error:empty { display: none; }
.room-head { flex-wrap: nowrap; align-items: flex-start; }
.room-title { flex: 1 1 auto; }
.buyin-btn { flex: none; white-space: nowrap; }
.tabs { overflow-x: auto; scrollbar-width: none; }
.tab { white-space: nowrap; }
@media (max-width: 480px) { .buyin-btn { padding: .6em .8em; font-size: .9rem; } }

/* ---- video / voice chat bar ---- */
.call-bar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px; background: rgba(8, 28, 22, .94); border: 1px solid var(--line); border-radius: 12px; padding: 6px; margin-bottom: 8px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.call-tiles { display: flex; gap: 6px; overflow-x: auto; flex: 1 1 auto; min-width: 0; scrollbar-width: none; }
.tile { position: relative; flex: none; width: 92px; height: 69px; border-radius: 10px; overflow: hidden; background: #0b1f19; border: 2px solid var(--line); }
.tile.me { border-color: var(--accent); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.tile.me video { transform: scaleX(-1); }
.tile:not(.hasvideo) video { visibility: hidden; }
.tile .avatar { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 1.7rem; color: var(--accent-text); background: linear-gradient(135deg, #f2c14e, #b8841c); }
.tile.hasvideo .avatar { display: none; }
.tile.offline { opacity: .45; }
.tile-name { position: absolute; left: 0; right: 0; bottom: 0; font-size: .72rem; line-height: 1.3; padding: 0 4px; background: rgba(0, 0, 0, .6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-badges { position: absolute; top: 2px; right: 3px; display: flex; gap: 2px; font-size: .8rem; text-shadow: 0 1px 2px #000; }
.call-controls { flex: none; display: flex; align-items: center; gap: 6px; }
.call-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; font-size: 1.2rem; cursor: pointer; display: grid; place-items: center; background: #2f8f5b; color: #fff; }
.call-btn.off { background: #7a3b3b; }
@media (max-width: 480px) { .tile { width: 76px; height: 57px; } }
