/* Poker Night — card-room look: walnut rail, green felt, brass accents. One deliberate dark theme. */
:root {
  --bg: #0b1512; --panel: #12211c; --panel-2: #192d26; --line: #2a4239;
  --felt: #1d5040; --felt-hi: #29694f; --felt-lo: #12382b; --felt-line: rgba(240, 232, 210, .2);
  --rail: #2a1c14; --rail-hi: #4a3224;
  --brass: #d6ad52; --brass-ink: #1d1608;
  --card: #f7f1e3; --ink: #1c1b18; --red: #be342b; --back1: #7c2b29; --back2: #93403a;
  --text: #ede7d7; --muted: #9db3a9;
  --good: #7cc79a; --bad: #e48f84; --warn: #e7a35a; --info: #8fb6e0;
  --f-display: "Young Serif", Georgia, "Times New Roman", serif;
  --f-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font-family: var(--f-body); font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button, input, select { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, .opt input:focus-visible + span { outline: 2px solid var(--brass); outline-offset: 2px; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-weight: 500; font-size: .85em; }
[hidden] { display: none !important; }
.boot { text-align: center; padding: 40vh 0; color: var(--muted); }

/* ---------- pages (home, join, lobby) ---------- */
.page { max-width: 560px; margin: 0 auto; display: grid; gap: 14px;
  padding: calc(18px + var(--sat)) max(16px, var(--sar)) calc(32px + var(--sab)) max(16px, var(--sal)); }
.hero { text-align: center; display: grid; justify-items: center; gap: 4px; padding-block: 10px 4px; }
.hero h1, .lobby-head h1 { font-family: var(--f-display); font-weight: 400; font-size: clamp(30px, 8vw, 40px); margin: 0; line-height: 1.05; }
.hero p { margin: 0; color: var(--muted); max-width: 32ch; }
.logo { border-radius: 14px; box-shadow: 0 8px 20px rgba(0, 0, 0, .4); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: grid; gap: 14px; }
.card h2 { font-family: var(--f-display); font-weight: 400; font-size: 20px; margin: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.msg { background: #3a2320; border: 1px solid #6b3a33; color: #f4c9c1; padding: 10px 14px; border-radius: 12px; margin: 0; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > legend, .lab { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 0; margin-bottom: 6px; }
.field input[type=text], .field input:not([type]), #nm { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-size: 17px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.code-in { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-family: var(--f-mono); font-size: 22px; letter-spacing: .3em; text-transform: uppercase; }
.segs { display: grid; gap: 6px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.segs.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.opt span { display: grid; place-items: center; text-align: center; min-height: 44px; padding: 8px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; font-size: 14.5px; line-height: 1.2; cursor: pointer; }
.opt span small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); margin-top: 2px; }
.opt input:checked + span { border-color: var(--brass); background: rgba(214, 173, 82, .14); color: var(--brass); }
.opt input:checked + span small { color: var(--text); }
.stepper { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; width: max-content; }
.stepper button { width: 48px; height: 44px; border: 0; background: var(--panel-2); font-size: 22px; }
.stepper b { min-width: 52px; text-align: center; font-family: var(--f-mono); font-size: 18px; }
.hint { color: var(--muted); font-size: 14px; margin: 0; }
.btn { padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; font-size: 15px; min-height: 44px; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn.primary { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 8px 10px; min-height: 0; }
.btn.wide { width: 100%; }
.btn.big { min-height: 54px; font-size: 17px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; justify-self: center; padding: 10px; min-height: 44px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 100; background: var(--card); color: var(--ink); padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.lobby-head { text-align: center; display: grid; gap: 2px; padding-top: 6px; }
.lobby-head p { margin: 0; color: var(--muted); font-size: 14px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; }
.code { letter-spacing: .18em; color: var(--brass); font-family: var(--f-mono) !important; font-weight: 700 !important; }
.invite { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.qr { width: 132px; height: 132px; background: #fff; border-radius: 10px; padding: 4px; flex: none; }
.qr svg { width: 100%; height: 100%; display: block; }
.inv-body { flex: 1; min-width: 200px; display: grid; gap: 10px; }
.link { background: var(--panel-2); border: 1px dashed var(--line); border-radius: 10px; padding: 9px 12px; font-size: 13px; overflow-wrap: anywhere; user-select: all; }
.seatlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.srow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--panel-2); min-height: 48px; }
.srow.empty { color: var(--muted); font-size: 14px; border: 1px dashed var(--line); background: transparent; justify-content: center; }
.sname { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.sname em { color: var(--muted); font-style: normal; font-weight: 500; }
.badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 999px; background: rgba(214, 173, 82, .16); color: var(--brass); white-space: nowrap; }
.badge.dim { background: rgba(255, 255, 255, .06); color: var(--muted); }
.lvl { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.x { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: transparent; font-size: 20px; line-height: 1; color: var(--muted); flex: none; }
.addbots { display: grid; gap: 8px; }
.botbtns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.botbtns .btn { display: grid; gap: 2px; text-align: center; }
.botbtns small { font-weight: 500; font-size: 11.5px; color: var(--muted); line-height: 1.25; }
.waitmsg { text-align: center; color: var(--muted); margin: 6px 0; }
.ava { --hue: 160; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #11120f; background: hsl(var(--hue) 55% 72%); flex: none; position: relative; }
.ava.sm { width: 30px; height: 30px; font-size: 14px; }

/* ---------- menu sheet & overlay ---------- */
.sheet-wrap { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: min(560px, 100%); max-height: 88dvh; overflow-y: auto; background: var(--panel); border-radius: 20px 20px 0 0; border-top: 1px solid var(--line);
  padding: 16px max(16px, var(--sar)) calc(24px + var(--sab)) max(16px, var(--sal)); display: grid; gap: 16px; animation: up .25s ease-out; overscroll-behavior: contain; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sh-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sh-head h2 { font-family: var(--f-display); font-weight: 400; margin: 0; font-size: 22px; }
.sheet section { display: grid; gap: 10px; }
.sheet h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.btngrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.explain { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 14.5px; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: 13.5px; max-height: 260px; overflow-y: auto; }
.log li.hand { color: var(--brass); font-weight: 700; margin-top: 6px; }
.log li.street { color: var(--info); }
.log li.win { color: var(--good); font-weight: 600; }
.log li.sys { color: var(--muted); font-style: italic; }
.overlay { position: fixed; inset: 0; background: rgba(5, 10, 8, .72); z-index: 40; display: grid; place-items: center; padding: 16px; }
.ov-card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--brass); border-radius: 18px; padding: 20px; display: grid; gap: 12px; text-align: center; }
.ov-card h2 { font-family: var(--f-display); font-weight: 400; margin: 0; font-size: 26px; }
.standings { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; text-align: left; }
.standings li { display: grid; grid-template-columns: 3.2em minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 9px 12px; border-radius: 10px; background: var(--panel-2); }
.standings li.me { outline: 1.5px solid var(--brass); }
.standings .who small { color: var(--muted); }
.standings .pos { color: var(--good); } .standings .neg { color: var(--bad); }
.ov-card .row { justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.segs.n6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.segs.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 380px) { .segs.n6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
