:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --ink: #1f1d1a;
  --muted: #6b665d;
  --accent: #d8521f;
  --accent-ink: #fff;
  --mark: #ffd24d;
  --line: #2e9e6b;
  --border: #d9d3c6;
  --free: #e8e2d4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a;
    --panel: #221f27;
    --ink: #f1ede6;
    --muted: #a39d93;
    --accent: #ff7a45;
    --mark: #c9a227;
    --line: #35c488;
    --border: #3a3640;
    --free: #2f2b36;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding: 0 16px 48px;
  line-height: 1.45;
}
#confetti {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 50;
}
.top {
  max-width: 820px; margin: 0 auto; padding: 20px 0 8px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
h1 { margin: 0; font-size: 2rem; letter-spacing: -0.02em; }
h1 span { color: var(--accent); }
h2 { margin: 0 0 12px; font-size: 1.15rem; }
.who { display: flex; gap: 10px; align-items: baseline; font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; font-size: 0.92rem; }
main { max-width: 820px; margin: 0 auto; display: grid; gap: 18px; }
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px;
}
form { display: grid; gap: 8px; max-width: 360px; }
label { font-weight: 600; }
input[type=text] {
  font: inherit; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--ink);
}
button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 10px 16px; border-radius: 8px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink);
}
button.secondary { background: transparent; color: var(--ink); border-color: var(--border); }
button.link { background: none; border: none; color: var(--muted); padding: 0; font-weight: 400; text-decoration: underline; }
.game-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.board {
  --n: 3;
  display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 8px;
  max-width: 520px;
}
.cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 8px; font-size: clamp(0.8rem, 3vw, 1.15rem); font-weight: 600;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--ink);
  overflow-wrap: anywhere; hyphens: auto; transition: transform .08s, background .15s;
  user-select: none;
}
.cell:not(.free):hover { transform: scale(1.03); }
.cell.marked { background: var(--mark); color: #1f1d1a; }
.cell.free { background: var(--free); cursor: default; color: var(--muted); }
.cell.line { background: var(--line); color: #fff; border-color: var(--line); }
.bingo-msg {
  margin-top: 14px; padding: 12px 14px; border-radius: 10px;
  background: var(--line); color: #fff; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  font-size: 1.1rem;
}
.bingo-msg button { background: #fff; color: #1f1d1a; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr.me td { font-weight: 700; color: var(--accent); }
td.num, th.num { text-align: right; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  margin: 0; z-index: 60; max-width: 90vw;
}

.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
textarea {
  font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--ink); resize: vertical;
  margin-bottom: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem;
}
input[type=password] {
  font: inherit; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--ink);
}
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 18px 0 12px; }
.danger-row { justify-content: space-between; }
button.danger { background: #b3261e; color: #fff; }
.problem { grid-column: 1 / -1; padding: 16px; border-radius: 10px; background: #b3261e; color: #fff; margin: 0; font-weight: 600; }
