/* Home and lobby share a dark card-room look; the table screen is painted by the room itself. */
:root {
  --bg: #0E1311;
  --panel: #151B18;
  --panel-2: #1B231F;
  --line: #2A3530;
  --fg: #E9E6DD;
  --muted: #8F978F;
  --accent: #C9A24B;
  --accent-ink: #14110A;
  --danger: #F07A7A;
  --display: 'Bodoni Moda', Didot, Georgia, serif;
  --body: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; line-height: 1.5; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); font-size: 13px; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.error { color: var(--danger); min-height: 1.5em; margin: 8px 0 0; font-size: 14px; }

input, select { font: inherit; color: var(--fg); background: #0B0F0D; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; }
input:focus-visible, select:focus-visible, button:focus-visible, .pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="number"] { width: 90px; }

.btn { appearance: none; font: 600 15px var(--body); color: var(--fg); background: #222A26; border: 1px solid #3A4640; border-radius: 8px; padding: 10px 18px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: #8D7134; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 14px 18px; font-size: 16px; width: 100%; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--fg); border-color: var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack label { font-size: 13px; color: var(--muted); }

/* ---------- Home ---------- */
#home { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.home-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px 24px; text-align: center; }
.home-card form { text-align: left; }
.suits { color: var(--accent); letter-spacing: .5em; font-size: 16px; opacity: .8; }
.logo { font-family: var(--display); font-weight: 700; font-size: 72px; line-height: 1; margin: 8px 0 4px; color: var(--accent); letter-spacing: .02em; }
.sub { font-family: var(--mono); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin: 0 0 24px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 22px 0 14px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.hint { color: var(--muted); font-size: 13px; margin: 14px 0 0; text-align: left; }

/* ---------- Lobby ---------- */
#lobby { max-width: 1200px; margin: 0 auto; padding-inline: clamp(16px, 3vw, 32px); padding-block: 24px 48px; }
.lobby-head { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: flex-end; justify-content: space-between; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.code { font-family: var(--mono); font-weight: 800; font-size: 40px; letter-spacing: .12em; line-height: 1.1; }
.invite { flex: 1 1 320px; max-width: 520px; display: flex; flex-direction: column; gap: 6px; }
.invite input { font-family: var(--mono); font-size: 13px; }
.banner { margin-top: 16px; padding: 12px 16px; border: 1px solid var(--accent); border-radius: 10px; background: rgba(201,162,75,.08); }
.lobby-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(0, 2.4fr); gap: 20px; margin-top: 20px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 18px 20px; min-width: 0; }
.panel h2 { font-family: var(--display); font-size: 24px; margin: 0 0 12px; }
.seat-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.seat-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.seat-list .medal { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #232B27; border: 1px solid #3A4640; font-family: var(--display); font-weight: 700; flex: none; }
.seat-list .who { flex: 1; min-width: 0; }
.seat-list .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-list .who small { color: var(--muted); }
.seat-list li.empty { border-style: dashed; background: none; }
.seat-list li.empty .medal { background: none; color: var(--muted); }
.tag { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; padding: 3px 7px; border-radius: 4px; background: rgba(201,162,75,.15); color: var(--accent); }
.tag.you { background: rgba(255,255,255,.08); color: var(--fg); }
#seat-note { margin: 0 0 12px; }
.seats-panel .btn.ghost { width: 100%; margin-top: 6px; }

.settings-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.settings { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.settings:disabled .picker, .settings:disabled .segmented, .settings:disabled .toggle { opacity: .75; }
.setting h3 { font-size: 13px; font-family: var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin: 0 0 10px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; }
.picker { display: grid; gap: 10px; }
.picker.rooms { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.picker.decks { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.pick { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 6px 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); cursor: pointer; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick:hover { border-color: #4A5750; }
.pick.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pick span { font-size: 13px; font-weight: 600; padding-inline: 4px; }
.pick small { font-size: 11px; color: var(--muted); padding-inline: 4px; line-height: 1.3; }
.room-preview { display: block; width: 100%; height: auto; border-radius: 6px; }
.fan { position: relative; height: 92px; }
.fan svg { position: absolute; width: 50px; top: 10px; left: 50%; transform-origin: 50% 130%; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: 9px 14px; cursor: pointer; font-size: 14px; border-right: 1px solid var(--line); }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--fg); outline-offset: -3px; }
.mode-extra { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; font-size: 14px; }
#mode-single { margin: 12px 0 0; }
.toggle { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.toggle:first-of-type { border-top: 0; padding-top: 0; }
.toggle input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.toggle b { display: block; font-weight: 600; }
.toggle small { color: var(--muted); font-size: 13px; }

/* ---------- Table ---------- */
#table { position: fixed; inset: 0; overflow: hidden; background: #000; }
#stage { position: absolute; inset: 0; display: grid; place-items: center; }
#stage .scene { width: 100%; height: 100%; display: block; }
.hc { cursor: pointer; }
.hc .lift { transition: transform .12s ease; }
.hc:hover .lift { transform: translateY(-10px); }
.hc .lift.sel { transform: translateY(-30px); }
.sbtn { cursor: pointer; }
.sbtn:hover { filter: brightness(1.12); }
.sbtn.off { opacity: .32; pointer-events: none; }

#hud { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; pointer-events: none; }
#hud > * { pointer-events: auto; }
.chip { background: rgba(8,10,9,.72); border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: 8px 12px; font-size: 13px; backdrop-filter: blur(6px); }
.chip .code { font-size: 15px; letter-spacing: .1em; }
.scoreboard { display: grid; grid-template-columns: auto auto; gap: 2px 14px; font-variant-numeric: tabular-nums; }
.scoreboard .me { color: var(--accent); }
.hud-left { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.hud-right { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.chip .btn { padding: 4px 10px; font-size: 12px; }

#overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); padding: 16px; }
.result { width: min(460px, 100%); background: rgba(14,19,17,.96); border: 1px solid var(--accent); border-radius: 14px; padding: 22px 22px 20px; }
.result h2 { font-family: var(--display); font-size: 30px; margin: 4px 0 14px; text-wrap: balance; }
.result table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.result th, .result td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.result th { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.result td.num, .result th.num { text-align: right; }
.result tr.win td { color: var(--accent); font-weight: 600; }
.result .foot { margin-top: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

#rotate-hint { display: none; position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); font-size: 12px; background: rgba(0,0,0,.7); padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
@media (orientation: portrait) and (max-width: 700px) { #rotate-hint { display: block; } }

#toasts { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 10; pointer-events: none; width: min(92vw, 520px); }
.toast { background: rgba(10,13,12,.94); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; font-size: 14px; text-align: center; animation: toast-in .18s ease-out; }
.toast.error { border-color: var(--danger); color: #FFD9D9; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 860px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .hc .lift, .toast { transition: none; animation: none; }
}
