:root {
  --brand: #3168e0;
  --brand-dark: #173c8e;
  --brand-ink: #ffffff;
  --ink: #152036;
  --muted: #657187;
  --paper: #f5f7fb;
  --line: #d8deea;
  --success: #147a4b;
  --danger: #c73737;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.shell { width: min(1180px, calc(100% - 24px)); margin: 0 auto; padding: 18px 0 40px; }
.topbar { display: flex; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.brand-lockup { display: flex; gap: 12px; align-items: center; min-width: 0; }
.brand-logo { width: 48px; height: 48px; border-radius: 12px; object-fit: contain; background: white; padding: 4px; border: 1px solid var(--line); }
.brand-logo:empty, .brand-logo[src=""] { display: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.35rem, 4vw, 2rem); margin-bottom: 3px; }
h2 { font-size: 1.05rem; }
.eyebrow { color: var(--muted); font-weight: 700; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: #e7ebf3; font-weight: 800; font-size: .8rem; }
.badge.live { background: #d9f7e8; color: var(--success); }
.badge.warn { background: #fff0d1; color: #8a5700; }
.badge.danger { background: #fee5e5; color: var(--danger); }
.grid { display: grid; gap: 14px; }
.two-col { grid-template-columns: minmax(0, 1.25fr) minmax(310px, .75fr); }
.card-panel { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: 0 8px 30px rgba(24, 41, 78, .06); }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-title h2 { margin: 0; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { border: 0; border-radius: 11px; min-height: 42px; padding: 9px 14px; background: #e8ecf4; color: var(--ink); font-weight: 800; }
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: white; }
.btn.success { background: var(--success); color: white; }
.btn.danger { background: var(--danger); color: white; }
.btn.ghost { background: white; border: 1px solid var(--line); }
label { display: grid; gap: 5px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.check input[type="checkbox"] { width: auto; min-height: 0; flex: 0 0 auto; }
input, select { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; color: var(--ink); background: white; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.full { grid-column: 1 / -1; }
.message { display: none; border-radius: 12px; padding: 12px; margin-bottom: 12px; font-weight: 700; }
.message.show { display: block; }
.message.error { display: block; background: #fee5e5; color: #9a1d1d; }
.message.success { display: block; background: #dff7e9; color: #11623d; }
.render-error { position: fixed; inset: 0 0 auto; z-index: 100; margin: 0; border-radius: 0; padding: 18px; text-align: center; font-size: 1.1rem; box-shadow: 0 4px 18px rgba(0,0,0,.3); }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stat { padding: 12px; border-radius: 12px; background: #f3f5fa; }
.stat strong { display: block; font-size: 1.35rem; }
.stat span { color: var(--muted); font-size: .75rem; }
.list { margin: 0; padding: 0; list-style: none; max-height: 280px; overflow: auto; }
.list li { display: flex; gap: 10px; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid #edf0f5; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hidden { display: none !important; }
.test-mode-banner { margin-bottom: 12px; padding: 11px 14px; border: 1px solid #e8b94e; border-radius: 12px; background: #fff3c4; color: #755000; font-weight: 800; }
.readonly-note { display: inline-flex; align-items: center; min-height: 42px; padding: 9px 12px; border-radius: 10px; background: #f3f5fa; color: var(--muted); font-weight: 800; }

.bingo-wrap { position: relative; width: min(100%, 560px); margin: 0 auto; overflow: hidden; border-radius: 24px; padding: 18px; background: linear-gradient(135deg, color-mix(in srgb, var(--brand), white 28%), color-mix(in srgb, var(--brand-dark), #7788a5 40%)); box-shadow: 0 18px 50px rgba(16, 31, 65, .22); }
.bingo-wrap::before { content: ""; position: absolute; inset: 0; opacity: .2; background: repeating-linear-gradient(35deg, transparent 0 70px, rgba(255,255,255,.4) 70px 125px); pointer-events: none; }
.bingo-head, .bingo-columns, .bingo-grid, .card-code { position: relative; }
.bingo-head { background: rgba(255,255,255,.88); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; text-align: center; }
.bingo-head .event { font-size: .76rem; font-weight: 800; color: var(--muted); text-align: left; }
.bingo-head .title { font-size: clamp(1.15rem, 5vw, 1.8rem); font-weight: 900; }
.bingo-columns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin: 6px 0; color: #0c5fff; font-size: clamp(1.25rem, 6vw, 2rem); font-weight: 950; text-align: center; }
.bingo-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.bingo-cell { position: relative; aspect-ratio: .88; min-width: 0; border: 2px solid rgba(25, 43, 75, .22); border-radius: 12px; padding: 4px; display: grid; place-items: center; text-align: center; overflow-wrap: anywhere; background: #fff; color: #0d1320; font-family: Arial, Helvetica, sans-serif; font-size: clamp(.7rem, calc(5vw - 4.8px), 1.56rem); line-height: 1.05; font-weight: 650; transition: .2s ease; }
.bingo-cell.marked { background: var(--brand); color: var(--brand-ink); border-color: currentColor; transform: scale(.97); }
.bingo-cell.marked::after { content: "✓"; position: absolute; right: 4px; bottom: 2px; font-size: 1rem; font-weight: 1000; opacity: .9; }
.bingo-cell.free { font-weight: 950; background: rgba(255,255,255,.92); color: var(--ink); }
.bingo-cell.free.marked::after { display: none; }
.free-logo { max-width: 100%; max-height: 100%; object-fit: contain; }
.contrast-preview { min-height: 58px; border-radius: 12px; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-weight: 900; }
.logo-size-preview { height: 90px; border: 1px solid var(--line); border-radius: 12px; display: grid; place-items: center; overflow: hidden; }
.logo-size-preview span { width: 70%; height: 70%; max-width: 100%; max-height: 100%; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); border-radius: 8px; }
.import-report { margin-top: 10px; padding: 10px; border-radius: 10px; background: #fff4db; }
.product-long { color: var(--danger); font-weight: 800; }
.card-code { margin-top: 7px; background: rgba(255,255,255,.75); border-radius: 6px; padding: 4px 7px; color: #70809b; font-size: .65rem; }
.recovery-box { position: relative; margin-top: 10px; padding: 10px; border-radius: 10px; background: rgba(255,255,255,.94); text-align: center; }
.recovery-box span { display: block; color: var(--muted); font-size: .78rem; font-weight: 700; }
.recovery-box strong { display: block; margin-top: 3px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: clamp(1.8rem, 9vw, 2.8rem); letter-spacing: .16em; color: var(--ink); }
.recovery-code-small { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.1rem; font-weight: 900; letter-spacing: .08em; }
.player-notice { width: min(100%, 560px); margin: 12px auto; text-align: center; border-radius: 14px; padding: 13px; background: white; font-weight: 850; border: 1px solid var(--line); }
.player-notice.qualified { background: #fff3ce; color: #744900; }
.player-notice.winner { background: #dff7e9; color: #0d6b40; font-size: 1.15rem; }
.join-box { width: min(440px, calc(100% - 24px)); margin: 12vh auto; }
.sync { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: .75rem; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #aeb7c7; }
.sync.online .sync-dot { background: #26a269; box-shadow: 0 0 0 4px #d9f7e8; }

@media (max-width: 820px) {
  .two-col { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .bingo-wrap { border-radius: 16px; padding: 11px; }
}
