:root {
  --bg: #07100c; --panel: #101d17; --panel-2: #172a21; --line: #2c4437; --text: #f1ead9; --muted: #a9b8ac;
  --gold: #dcb45e; --gold-2: #f3d58e; --danger: #d9605a; --ok: #58c98a; --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", Georgia, serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(ellipse 80% 60% at 50% 0%, #1d3528 0%, transparent 70%), radial-gradient(circle at 85% 100%, #2a1b0e 0%, transparent 45%), var(--bg);
  background-attachment: fixed; color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, .brand p, .btn.primary { font-family: var(--serif); }
h1 { margin: .3em 0 .7em; font-weight: 600; color: var(--gold-2); }
h2 { font-size: 1.15rem; margin: 0 0 .7em; color: var(--gold-2); }
a { color: var(--gold-2); }
:focus-visible { outline: 3px solid var(--gold-2); outline-offset: 2px; }
.page { max-width: 640px; margin: 0 auto; padding: 20px 16px 60px; }
.page.wide { max-width: 1180px; }
.page.center { text-align: center; }
.page.center .panel { text-align: left; }
.back { text-decoration: none; }
.panel { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 16px; box-shadow: 0 14px 34px #0007; }
.brand { text-align: center; margin: 10px 0 20px; }
.brand h1 { font-size: clamp(1.8rem, 7vw, 2.7rem); margin: .2em 0 0; letter-spacing: .02em; }
.brand p { color: var(--muted); margin: 0; font-style: italic; }
.fan { display: flex; justify-content: center; height: 100px; }
.fan .card { width: 64px; margin: 0 -10px; transform: rotate(-14deg) translateY(10px); }
.fan .card:nth-child(2) { transform: translateY(0); z-index: 1; }
.fan .card:nth-child(3) { transform: rotate(14deg) translateY(10px); }
.auth { max-width: 400px; margin: 0 auto 14px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: .86rem; color: var(--muted); margin-bottom: 4px; }
input, select { width: 100%; min-height: 42px; padding: 8px 11px; border-radius: 9px; border: 1px solid var(--line); background: #0a1410; color: var(--text); font: inherit; }
input:disabled, select:disabled { opacity: .65; }
.check { display: flex; align-items: flex-start; gap: 10px; margin: 8px 0; cursor: pointer; }
.check input { width: 20px; min-height: 20px; margin: 1px 0 0; accent-color: var(--gold); }
.btn { display: inline-block; min-height: 42px; padding: 9px 18px; border-radius: 10px; border: 1px solid var(--line); background: #21382c; color: var(--text); font: inherit; cursor: pointer; text-decoration: none; text-align: center; }
.btn.primary { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #241a05; border-color: #f7e0a4; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 32px; padding: 4px 11px; font-size: .85rem; }
.btn.block { display: block; width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; padding: 4px; color: var(--gold-2); font: inherit; cursor: pointer; text-decoration: underline; }
.switch { text-align: center; color: var(--muted); }
.langs .link { text-decoration: none; opacity: .65; margin: 0 6px; }
.langs .link.active { opacity: 1; border-bottom: 2px solid var(--gold); }
.me { display: flex; gap: 10px; align-items: center; justify-content: center; margin-bottom: 14px; }
.menu { display: grid; gap: 9px; max-width: 360px; margin: 0 auto 22px; }
.menu-item { display: block; width: 100%; padding: 13px; border-radius: 11px; border: 1px solid #6b5a2e; background: linear-gradient(180deg, #1c3126, #12231b); color: var(--text); text-decoration: none; font: 600 1.05rem var(--serif); cursor: pointer; box-shadow: 0 5px 14px #0006; }
.menu-item:hover { border-color: var(--gold-2); background: #24402f; }
.hint { color: var(--muted); font-size: .9rem; }
.warning { background: #4a2d12; border: 1px solid #a8702a; border-radius: 9px; padding: 10px; font-size: .9rem; }
.lead { font-size: 1.15rem; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; background: #0b1611; border: 1px solid var(--line); font-size: .8rem; white-space: nowrap; }
.badge.gold { background: var(--gold); color: #241a05; border-color: var(--gold-2); font-weight: 700; }
.badge.sent { border-color: var(--ok); }
.badge.failed, .badge.not_configured { border-color: var(--danger); }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 15px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; color: var(--text); text-decoration: none; }
.row small { display: block; color: var(--muted); }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none; border: 2px solid var(--gold); box-shadow: 0 3px 9px #0008; }
.avatar.initials { display: inline-grid; place-items: center; background: radial-gradient(circle at 35% 30%, #3d6650, #193025); font: 700 1.25rem var(--serif); }
.avatar.small { width: 28px; height: 28px; font-size: .8rem; border-width: 1px; }
.avatar.large { width: 112px; height: 112px; font-size: 2.6rem; }
.photo-row { display: flex; align-items: center; gap: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 0 0 16px; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 10px; text-align: center; }
.stats dt { font-size: .78rem; color: var(--muted); }
.stats dd { margin: 4px 0 0; font: 700 1.6rem var(--serif); color: var(--gold-2); }
.rules section + section { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.rules h2 { margin-bottom: .2em; }
.modes { border: 0; padding: 0; margin: 0 0 8px; }
.house-rules { margin: 12px 0; }
.house-rules summary { cursor: pointer; color: var(--gold-2); }
.rule-grid { padding-top: 10px; }
.table-scroll { overflow-x: auto; max-width: 100%; }
.scores { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: .88rem; }
.scores th, .scores td { border: 1px solid var(--line); padding: 7px 8px; text-align: center; }
.scores thead th { font-size: .76rem; color: var(--gold-2); font-weight: 600; }
.scores .sticky { position: sticky; left: 0; background: var(--panel); text-align: left; z-index: 1; }
.scores .sub { background: #ffffff0a; font-weight: 700; }
.scores .total { color: var(--gold-2); font-size: 1.05rem; }
.scores td.won { color: var(--ok); font-weight: 700; }
.scores td.pending { color: var(--muted); }
.scores tr.winner { box-shadow: inset 0 0 0 2px var(--gold); }
.who { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.overlay, .summary-layer { position: fixed; inset: 0; background: #000b; display: grid; place-items: center; padding: 12px; z-index: 1200; }
.summary-layer { z-index: 1100; }
.modal { width: min(440px, 100%); max-height: 92dvh; overflow: auto; background: var(--panel); border: 1px solid #7d6a36; border-radius: 16px; padding: 18px; box-shadow: 0 24px 70px #000c; }
.modal.wide { width: min(1000px, 100%); }
.modal-actions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: flex-end; margin-top: 15px; position: sticky; bottom: -18px; background: var(--panel); padding: 10px 0; }
.choice-list { display: grid; gap: 6px; }
#toasts { position: fixed; top: 54px; left: 50%; transform: translateX(-50%); z-index: 2000; display: grid; gap: 7px; width: min(430px, calc(100% - 20px)); pointer-events: none; }
.toast { background: #f4eedc; color: #1c1a12; border-radius: 10px; padding: 10px 14px; box-shadow: 0 10px 26px #0009; border-left: 5px solid var(--gold); }
.toast.error { border-left-color: var(--danger); }
.toast.important { background: var(--gold-2); font-weight: 600; }
.connection-banner { position: fixed; inset: 0 0 auto 0; z-index: 2100; background: var(--danger); color: #fff; text-align: center; padding: 7px; font-weight: 600; }
.loading { text-align: center; padding: 60px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #6c746f; margin-right: 6px; }
.dot.on { background: var(--ok); box-shadow: 0 0 7px var(--ok); }

/* Lobby */
.lobby-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.lobby-felt { position: relative; min-height: 480px; border-radius: 46% / 40%; border: 16px solid #5a3519; background: radial-gradient(ellipse at 50% 40%, #1d6b45, #0c3a26 72%, #082a1b); box-shadow: inset 0 0 40px #000a, 0 0 0 3px #2c180a, 0 24px 50px #000b; }
.lobby-oval { position: absolute; inset: 27% 30%; border: 2px solid #dcb45e55; border-radius: 50%; display: grid; place-items: center; text-align: center; font: italic 600 1.1rem var(--serif); color: #dcb45e99; }
.lobby-seat { position: absolute; width: 160px; display: grid; justify-items: center; gap: 3px; text-align: center; background: #07130dd9; border: 1px solid var(--line); border-radius: 12px; padding: 9px; }
.lobby-seat small { color: var(--muted); }
.lobby-seat.ready { border-color: var(--ok); box-shadow: 0 0 16px #58c98a77; }
.lobby-seat.empty { border-style: dashed; }
.lobby-seat.bottom { bottom: 3%; left: 50%; transform: translateX(-50%); }
.lobby-seat.top { top: 3%; left: 50%; transform: translateX(-50%); }
.lobby-seat.left { left: 2%; top: 50%; transform: translateY(-50%); }
.lobby-seat.right { right: 2%; top: 50%; transform: translateY(-50%); }
.pending-note { position: absolute; top: 50%; left: 50%; transform: translate(-50%, 45px); font-size: .85rem; color: var(--gold-2); }
.inline { display: flex; gap: 8px; }
.inline .btn { white-space: nowrap; }
.invites { list-style: none; padding: 0; margin: 12px 0 0; }
.invites li { border-top: 1px solid var(--line); padding: 10px 0; }
.invite-row { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.email { overflow-wrap: anywhere; }
.manual { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-bottom: 7px; }
.manual small { grid-column: 1 / -1; color: var(--muted); }
@media (max-width: 860px) { .lobby-grid { grid-template-columns: 1fr; } }
@media (max-width: 520px) {
  .lobby-felt { min-height: 520px; border-width: 9px; border-radius: 34% / 22%; }
  .lobby-seat { width: 134px; font-size: .85rem; }
  .lobby-oval { inset: 36% 30%; font-size: .85rem; }
  .lobby-seat.left { top: 31%; } .lobby-seat.right { top: 69%; }
  .inline { flex-direction: column; }
}
