:root {
  --paper: #EDE8DD; --app: #FBF9F4; --ink: #232838; --muted: #5C6170;
  --line: #E5E0D4; --card: #FFFFFF; --card-line: #E9E4D9;
  --accent: #C43A31; --accent-soft: #F7E5E3;
  --b: #2B6CB0; --i: #C43A31; --n: #4A5568; --g: #2F7D52; --o: #C0871B;
  --good-bg: #E7F1EA; --good-ink: #24603F; --gold-bg: #FBF0DC; --gold-ink: #8A5B12;
  --shadow: rgba(35,40,56,0.14);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F1117; --app: #16181F; --ink: #E9E7DF; --muted: #A3A7B3;
    --line: #2E3140; --card: #1D2029; --card-line: #323648;
    --accent: #E06055; --accent-soft: #3A2523;
    --b: #6FA8DC; --i: #E06055; --n: #9AA3B5; --g: #6FBF92; --o: #DCA843;
    --good-bg: #1E2F26; --good-ink: #8FCFAA; --gold-bg: #332A18; --gold-ink: #E0B96A;
    --shadow: rgba(0,0,0,0.5);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--app); color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 16px; line-height: 1.5;
}
#app { max-width: 460px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; }
.brand .logo { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 900; box-shadow: inset -2px -3px 0 rgba(0,0,0,0.18); }
.topbar .right { display: flex; align-items: center; gap: 10px; }
.chip { background: var(--accent-soft); color: var(--accent); padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; border: none; cursor: pointer; }

.screen { flex: 1; padding: 16px; }
.hidden { display: none !important; }
h2 { font-size: 20px; margin: 6px 0 10px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.btn { border: none; border-radius: 12px; padding: 13px 16px; font-size: 15px; font-weight: 600; cursor: pointer; width: 100%; background: var(--accent); color: #fff; }
.btn:active { transform: scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--card-line); }
.btn.small { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 10px; }
.btn.gold { background: var(--gold-ink); color: var(--app); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 10px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field input, .field select { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--card-line); background: var(--app); color: var(--ink); font-size: 15px; }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; font-size: 14px; }

.card { background: var(--card); border: 1px solid var(--card-line); border-radius: 14px; padding: 14px; }
.roomcard { margin-bottom: 10px; cursor: pointer; }
.roomcard h3 { margin: 0; font-size: 16px; }
.roomcard .meta { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.badge { font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 99px; }
.badge.live { background: var(--accent); color: #fff; }
.badge.lobby { background: var(--good-bg); color: var(--good-ink); }
.badge.lock, .badge.sched { background: var(--gold-bg); color: var(--gold-ink); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.infocard .line { display: flex; justify-content: space-between; font-size: 13.5px; margin: 5px 0; gap: 10px; }
.infocard .line span:first-child { color: var(--muted); }
.infocard .line b { text-align: right; }

.stepper { display: flex; align-items: center; gap: 14px; justify-content: center; margin: 12px 0; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--card-line); background: var(--card); color: var(--ink); font-size: 22px; cursor: pointer; }
.stepper .count { font-weight: 800; font-size: 26px; min-width: 34px; text-align: center; }

.cards-wrap { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 10px; }
.bcard { flex: none; background: var(--card); border: 1px solid var(--card-line); border-radius: 12px; padding: 8px; }
.bgrid { display: grid; grid-template-columns: repeat(5, 44px); gap: 3px; }
.bgrid .h { height: 26px; border-radius: 6px; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.bgrid .c { height: 44px; border-radius: 6px; border: 1px solid var(--card-line); display: flex; align-items: center; justify-content: center; font-size: 14px; font-variant-numeric: tabular-nums; background: var(--app); cursor: default; }
.bgrid .c.hit { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.bgrid .c.free { font-size: 9px; color: var(--muted); }
.bgrid .c.tap { cursor: pointer; }

.caller { display: flex; align-items: center; gap: 16px; }
.bigball { width: 90px; height: 90px; border-radius: 50%; background: var(--muted); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: inset -4px -6px 0 rgba(0,0,0,0.2); flex: none; }
.bigball .l { font-weight: 800; font-size: 15px; }
.bigball .n { font-weight: 900; font-size: 34px; line-height: 1; }
.potbar { display: flex; justify-content: space-between; background: var(--gold-bg); color: var(--gold-ink); border-radius: 10px; padding: 8px 12px; margin: 10px 0; font-size: 13px; }
.potbar b { font-size: 16px; }
.board { background: var(--card); border: 1px solid var(--card-line); border-radius: 12px; padding: 8px; margin: 8px 0; overflow-x: auto; }
.brow { display: flex; gap: 3px; align-items: center; margin: 2px 0; }
.brow .lbl { width: 20px; height: 20px; border-radius: 50%; flex: none; color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.brow .bn { width: 20px; height: 20px; border-radius: 4px; flex: none; background: var(--app); border: 1px solid var(--card-line); font-size: 8.5px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.brow .bn.called { color: #fff; border-color: transparent; }
.brow .bn.tap { cursor: pointer; }
.bingo { background: var(--accent); color: #fff; border: none; border-radius: 14px; width: 100%; padding: 16px; font-weight: 900; font-size: 22px; letter-spacing: 0.04em; cursor: pointer; margin-top: 8px; opacity: 0.4; pointer-events: none; }
.bingo.ready { opacity: 1; pointer-events: auto; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(196,58,49,0.5); } 50% { box-shadow: 0 0 0 12px rgba(196,58,49,0); } }

.chatlist { background: var(--card); border: 1px solid var(--card-line); border-radius: 12px; padding: 8px; height: 130px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.chatlist .m { font-size: 12.5px; } .chatlist .m b { font-weight: 700; }
.chatinput { display: flex; gap: 6px; }
.chatinput input { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--card-line); background: var(--card); color: var(--ink); }
.chatinput button { border: none; background: var(--accent); color: #fff; border-radius: 10px; padding: 0 16px; font-weight: 600; }
.reacts { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.reacts button { border: 1px solid var(--card-line); background: var(--card); border-radius: 99px; padding: 5px 10px; font-size: 15px; cursor: pointer; }

.prow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.prow:last-child { border-bottom: none; }
.prow .who { flex: 1; min-width: 0; }
.prow .who small { display: block; color: var(--muted); font-size: 11.5px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.pill { font-size: 10px; padding: 2px 7px; border-radius: 99px; background: var(--good-bg); color: var(--good-ink); }
.pill.pending { background: var(--gold-bg); color: var(--gold-ink); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--card-line); border-radius: 12px; padding: 10px 12px; }
.stat .v { font-weight: 800; font-size: 20px; } .stat .k { font-size: 11px; color: var(--muted); }

.peditor { display: grid; grid-template-columns: repeat(5, 46px); gap: 4px; justify-content: center; }
.pcell { width: 46px; height: 46px; border-radius: 8px; background: var(--app); border: 1px solid var(--card-line); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 9px; color: var(--muted); }
.pcell.on { background: var(--accent); border-color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--app); padding: 11px 18px; border-radius: 10px; font-size: 14px; opacity: 0; transition: all 0.3s; z-index: 100; max-width: 90%; text-align: center; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center; padding: 24px; z-index: 60; }
.overlay.show { display: flex; }
.modal { background: var(--card); border-radius: 18px; padding: 22px; width: 100%; max-width: 380px; }
.win { text-align: center; }
.win .big { font-weight: 900; font-size: 34px; color: var(--accent); }
.prize { background: var(--good-bg); color: var(--good-ink); padding: 10px; border-radius: 10px; font-size: 13px; margin: 12px 0; }

.center { min-height: 80dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; padding: 24px; }
.balls { display: flex; gap: 8px; }
.balls div { width: 40px; height: 40px; border-radius: 50%; color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: inset -3px -4px 0 rgba(0,0,0,0.18); }
