:root {
  --bg: #14161a;
  --panel: #242830;
  --ink: #f6f3ec;
  --muted: #d5cfc3;
  --line: #4c5460;
  --gold: #e0b93a;
  --gold-ink: #1a1404;
  --ok: #8fd49a;
  --err: #f0a3a3;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 "Segoe UI", system-ui, sans-serif; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.env-banner { background: #0e7490; color: #e0f2fe; text-align: center; padding: 8px 12px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.env-pill { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: #22d3ee; color: #082f49; font-size: 10px; letter-spacing: .08em; vertical-align: middle; }
body.env-testing { --bg: #0e1a22; --panel: #13232d; --line: #155e75; --gold: #22d3ee; --gold-ink: #082f49; }
body.env-testing .top { background: #082f49; border-bottom-color: #155e75; }
body.env-testing .brand { color: #e0f2fe; }
.shadow-1 { box-shadow: 0 2px 5px 0 rgba(0,0,0,.16), 0 2px 10px 0 rgba(0,0,0,.12); }
.shadow-2 { box-shadow: 0 4px 8px 0 rgba(0,0,0,.18), 0 3px 10px 0 rgba(0,0,0,.14); }
.shadow-3 { box-shadow: 0 6px 12px 0 rgba(0,0,0,.2), 0 4px 14px 0 rgba(0,0,0,.16); }
.shadow-5 { box-shadow: 0 16px 28px 0 rgba(0,0,0,.24), 0 8px 20px 0 rgba(0,0,0,.18); }
.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #0c0e10; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .04em; color: var(--ink); text-transform: uppercase; font-size: 13px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-logo { height: 28px; width: auto; max-width: 72px; object-fit: contain; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
.top-tools { display: flex; gap: 4px; margin-left: auto; order: 3; }
.navbar-collapse.main-nav,
.main-nav { display: flex !important; gap: 12px; align-items: center; flex-wrap: wrap; flex: 1 1 auto; order: 2; }
.brand { order: 1; }
.main-nav a { display: inline-flex; align-items: center; gap: 6px; }
.top nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.wrap { width: min(1100px, calc(100% - 32px)); margin: 20px auto; flex: 1; }
.foot { display: flex; justify-content: space-between; padding: 10px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 16px; box-shadow: 0 4px 8px 0 rgba(0,0,0,.18), 0 3px 10px 0 rgba(0,0,0,.12); }
.navbar-nav { list-style: none; display: flex; gap: 10px; margin: 0; padding: 0; align-items: center; flex-wrap: wrap; }
.navbar-nav .nav-link { display: inline-flex; align-items: center; gap: 6px; color: inherit; }
.popconfirm { display: inline-flex; gap: 8px; align-items: center; margin-left: 8px; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.placeholder { display: inline-block; min-height: 1em; background: var(--line); border-radius: 4px; }
.placeholder.col-8 { width: 80%; }
.placeholder.col-6 { width: 60%; }
.placeholder-glow .placeholder { animation: ph 1s linear infinite alternate; }
@keyframes ph { from { opacity: .4; } to { opacity: 1; } }
.nav-help { background: transparent; border: 0; color: var(--gold); cursor: pointer; }
.score-pop { position: absolute; left: 50%; top: 20%; transform: translateX(-50%); color: #f3a0a0; font-weight: 800; animation: pop 1s ease-out forwards; pointer-events: none; }
.cell { position: relative; }
.cell.bad-mark { outline: 2px solid #c45; background: #4a1c1c; }
@keyframes pop { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -18px); } }
body.win-flash { animation: winpulse .9s ease; }
@keyframes winpulse { 0%,100% { box-shadow: none; } 40% { box-shadow: inset 0 0 0 8px var(--gold); } }
.card.slim { max-width: 460px; }
h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }
.flash-ok { background: #1c3322; }
.flash-error { background: #3a1c1c; }
.flash-info { background: #243044; }
label { display: block; margin: 10px 0; }
input, select, button, textarea,
.form-control, .form-select {
  font: inherit; color: var(--ink) !important; background: #2c323c !important; border: 1px solid var(--line) !important; border-radius: 6px; padding: 8px 10px;
}
[data-mdb-theme="dark"] .form-control,
[data-mdb-theme="dark"] .form-select,
html.theme-dark .form-control,
html.theme-dark .form-select {
  background-color: #2c323c !important;
  color: #f6f3ec !important;
}
html.theme-light .form-control,
html.theme-light .form-select,
body.theme-light .form-control,
body.theme-light .form-select {
  background: #fff !important;
  color: #1a1712 !important;
}
input, select { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row input { width: auto; flex: 1; }
.row.tight { gap: 6px; }
.btn { display: inline-block; cursor: pointer; background: #3a424c; color: #f6f3ec; border: 1px solid #6a7380; padding: 8px 12px; }
.btn:hover { background: #3a4048; color: #fff; text-decoration: none; }
.btn-gold { background: var(--gold); color: var(--gold-ink); border-color: #a8871c; font-weight: 700; }
.btn-gold:hover { filter: brightness(1.08); color: var(--gold-ink); }
.top .inner, .foot .inner { width: min(1100px, calc(100% - 32px)); margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; }
.wiz-actions { display: flex; gap: 16px; margin-top: 18px; }
.wiz-actions .btn { min-width: 120px; }
body.is-fs .top, body.is-fs .foot, body.is-fs .env-banner { display: none; }
body.is-fs .wrap { width: calc(100% - 12px); margin: 8px auto; }
.session-settings { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; padding: 0; }
.flash-ok { background: #1c3322; color: #d7f0d9; }
.flash-error { background: #3a1c1c; color: #f3d0d0; }
.flash-info { background: #243044; color: #d6e4f7; }
html.theme-light .flash-ok { background: #d9f0dc; color: #14331a; }
html.theme-light .flash-error { background: #f6d4d4; color: #4a1414; }
html.theme-light .flash-info { background: #d6e6f8; color: #13233a; }
html.theme-light .btn { background: #ece6db; color: #1a1712; border-color: #b9b0a2; }
html.theme-light .btn:hover { background: #ddd5c8; color: #1a1712; }
html.theme-light .muted { color: #4d473e; }
.btn-lg { font-size: 20px; padding: 12px 24px; width: 100%; margin-top: 12px; }
.bingo-claim { position: sticky; bottom: 8px; z-index: 6; margin-top: 16px; }
.chk { display: flex; gap: 8px; align-items: center; }
.chk input { width: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.plan, .stat { background: #121416; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.stat b { display: block; font-size: 28px; }
.game-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.call-focus { min-width: 160px; text-align: center; background: #121416; border: 1px solid var(--gold); border-radius: 10px; padding: 12px; }
.call-piece { font-size: 28px; font-weight: 700; padding: 10px; }
.call-piece.drag { outline: 1px dashed var(--gold); }
.share { width: min(420px, 100%); }
.game-grid { display: grid; grid-template-columns: 1.3fr .7fr; gap: 16px; }
@media (max-width: 800px) { .game-grid { grid-template-columns: 1fr; } }
.bingo-board { display: grid; gap: 6px; }
.bingo-board[data-size="3"] { grid-template-columns: repeat(3, 1fr); }
.bingo-board[data-size="4"] { grid-template-columns: repeat(4, 1fr); }
.bingo-board[data-size="5"] { grid-template-columns: repeat(5, 1fr); }
.bingo-board[data-size="6"] { grid-template-columns: repeat(6, 1fr); }
.cell { aspect-ratio: 1; display: grid; place-items: center; text-align: center; background: #1c2026; color: #f4f0e6; border: 2px solid #5a616b; border-radius: 6px; padding: 4px; font-size: 16px; font-weight: 800; letter-spacing: .02em; word-break: break-word; cursor: grab; }
.cell.marked { background: #2d4a28; border-color: #4d7a44; }
.cell.drop { outline: 2px dashed var(--gold); }
.archive { display: flex; flex-wrap: wrap; gap: 6px; min-height: 40px; }
.chip { background: #121416; border: 1px solid var(--line); border-radius: 999px; width: 48px; height: 48px; min-width: 48px; padding: 0 4px; display: inline-flex; align-items: center; justify-content: center; cursor: grab; font-size: 11px; font-weight: 700; text-align: center; line-height: 1.1; overflow: hidden; }
.match-hud { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 15; font-size: 13px; }
.lobby-cd { text-align: center; padding: 12px; border: 1px solid var(--gold); border-radius: 10px; margin: 8px 0; }
.cd-num { font-size: 28px; font-weight: 800; letter-spacing: .04em; }
.play-tabs { display: flex; gap: 8px; margin: 8px 0; }
.archive { display: flex; flex-wrap: wrap; gap: 6px; min-height: 40px; }
.plist { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.tag { font-size: 11px; background: #2a2e33; padding: 2px 6px; border-radius: 4px; }
.inline { display: inline; }
.linkish { background: none; border: 0; color: var(--gold); padding: 0; cursor: pointer; }
.stack label { margin-top: 8px; }
.hero .row { margin-top: 12px; }
body.font-sm { font-size: 14px; }
body.font-md { font-size: 16px; }
body.font-lg { font-size: 18px; }
body.font-xl { font-size: 21px; }
.font-ctl select { width: auto; padding: 4px; }
.wiz-nav { display: flex; gap: 8px; list-style: none; padding: 0; flex-wrap: wrap; }
.wiz-nav li { padding: 6px 10px; border-radius: 999px; background: #121416; color: var(--muted); }
.wiz-nav li.on { background: var(--gold); color: var(--gold-ink); }
.cell.selected, .chip.selected, .call-piece.selected { outline: 2px solid var(--gold); }
@media (max-width: 800px) {
  .top { flex-direction: column; align-items: flex-start; }
  .wrap { width: calc(100% - 16px); margin: 12px auto; }
  .game-top { flex-direction: column; }
  .call-piece { font-size: 22px; min-height: 48px; }
  .cell { font-size: 12px; min-height: 48px; }
  .btn, .btn-lg { min-height: 44px; }
  .share { width: 100%; }
  .nav-toggle { display: inline-block; }
  .brand-text { max-width: 36vw; font-size: 12px; }
  .navbar-collapse.main-nav,
  .main-nav { display: none !important; width: 100%; flex-direction: column; flex-wrap: wrap; gap: 8px; }
  .main-nav.open, .main-nav.show { display: flex !important; }
  .navbar-nav { flex-direction: column; align-items: stretch; width: 100%; }
  .dropdown-menu { position: static; box-shadow: none; border: 0; }
  .hamburger { display: inline-block; }
  body.nav-open { overflow: hidden; }
  .main-nav.open, .main-nav.show {
    position: fixed; top: 56px; left: 0; right: 0; bottom: 0;
    background: var(--panel); z-index: 26; padding: 16px;
    overflow: auto;
  }
  .main-nav a { font-size: 12px; padding: 6px 8px; background: #16191d; border-radius: 8px; }
  .main-nav a span { display: inline; }
  .archive-panel { display: none; }
  .archive-panel.open { display: block; position: fixed; left: 0; right: 0; bottom: 0; max-height: 42vh; z-index: 30; margin: 0; border-radius: 16px 16px 0 0; overflow: auto; box-shadow: 0 -8px 24px rgba(0,0,0,.4); }
  .call-focus { position: sticky; top: 42px; z-index: 12; }
  .archive-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 29; }
  .archive-back[hidden] { display: none !important; }
}
.nav-toggle { display: none; }
.hamburger { display: none; width: 44px; height: 44px; padding: 8px; background: #1c1f24; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.hamburger span { display: block; height: 2px; margin: 7px 4px; background: #e8e4d9; border-radius: 1px; transition: transform .15s ease, opacity .15s ease; }
.hamburger.is-open span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.hamburger.is-open span:nth-child(2) { opacity: 0; }
.hamburger.is-open span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }
.nav-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 25; }
.nav-back[hidden] { display: none !important; }
.icon-btn { width: auto; padding: 6px 8px; min-height: 36px; }
.font-icons { display: inline-flex; gap: 4px; align-items: center; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 40; }
.modal[hidden] { display: none !important; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: min(420px, calc(100% - 24px)); position: relative; }
.modal-x { position: absolute; right: 8px; top: 8px; }
[data-wiz-next], [data-wiz-prev], [data-wiz-go] { min-height: 44px; min-width: 88px; touch-action: manipulation; }
html.theme-light, body.theme-light { --bg: #f3efe6; --panel: #fffaf1; --ink: #1a1712; --muted: #5c564c; --line: #d9d0c2; --gold-ink: #1a1404; background: var(--bg); color: var(--ink); }
body.theme-light .top, body.theme-light input, body.theme-light select, body.theme-light button, body.theme-light textarea { background: #fff; color: var(--ink); }
body.theme-light .cell { background: #fff; color: #141414; border-color: #8a8378; }
body.theme-light .call-focus, body.theme-light .chip, body.theme-light .plan { background: #fff; }
.hero-actions { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin: 16px 0; }
.hero-join { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.hero-join input { min-width: 180px; }
.jumbotron { padding: 28px 22px; }
.jumbotron .lead { font-size: 18px; max-width: 40rem; }
.dropdown { position: relative; }
.dropdown-toggle { background: transparent; border: 0; cursor: pointer; color: inherit; font: inherit; }
.dropdown-menu { display: none; position: absolute; right: 0; top: 100%; min-width: 160px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 0; z-index: 40; list-style: none; margin: 0; }
.dropdown-menu.show { display: block; }
.dropdown-item { display: block; padding: 8px 14px; color: var(--ink); }
.dropdown-item:hover { background: #2a2e33; text-decoration: none; }
.navbar { background: #0c0e10; }
.navbar .container-fluid { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 1100px; margin: 0 auto; }
.navbar-brand { order: 0; margin-right: 8px; }
.navbar-toggler { order: 2; margin-left: 8px; border: 1px solid rgba(255,255,255,.4); padding: 8px 10px; background: transparent; color: #fff; }
.navbar-toggler-icon { display: block; width: 1.25em; height: 2px; background: currentColor; box-shadow: 0 6px currentColor, 0 12px currentColor; margin-bottom: 12px; }
.navbar-collapse { order: 3; flex-grow: 0; }
.navbar .d-flex.align-items-center { order: 1; margin-left: auto; gap: 18px; }
.font-btns { display: inline-flex; gap: 12px; margin-right: 12px; }
.nav-login { margin-left: 6px; }
.auth-card { padding: 28px; }
.auth-form .mb-4, .auth-form .form-outline { margin-bottom: 22px; }
.auth-links { margin-top: 22px; }
.field-hint { min-height: 1.2em; margin: 0 0 12px; }
.pw-meter { height: 6px; background: #3a414b; border-radius: 99px; margin: 0 0 10px; overflow: hidden; }
.pw-meter span { display: block; height: 100%; width: 0; background: #e08a8a; }
.pw-meter.pw-2 span { background: #e0b93a; }
.pw-meter.pw-3 span, .pw-meter.pw-4 span, .pw-meter.pw-5 span { background: #8fd49a; }
.navbar-nav { flex-direction: row; flex-wrap: wrap; gap: 2px; }
.navbar .nav-link { color: #e8e4d9; padding: 6px 10px; white-space: nowrap; }
@media (min-width: 992px) {
  .navbar-expand-lg .navbar-collapse { display: flex !important; flex-basis: auto; align-items: center; order: 1; }
  .navbar .d-flex.align-items-center { order: 2; }
  .navbar-toggler { display: none; }
}
@media (max-width: 991.98px) {
  .navbar-toggler { display: inline-block !important; }
  .navbar-collapse { flex-basis: 100%; }
  .navbar-collapse.collapse:not(.show) { display: none !important; }
  .navbar-collapse.collapse.show,
  .navbar-collapse.show {
    display: flex !important;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 8px 0 12px;
  }
}
.host-actions { display: flex; flex-direction: column; gap: 14px; margin: 16px 0; }
.host-actions .btn { width: 100%; }
.host-pane .stack { margin-top: 20px; }
