/* Faerûn Bingo: a tavern-table scoreboard over one shared 5×5 card */
:root {
  --bg: #eef1f4; --surface: #ffffff; --surface-2: #e4e8ee; --fg: #1b1e2b;
  --muted: #5b6175; --line: #cdd3dd; --gold: #9a6e16; --danger: #c0392b; --ok: #12827c;
  --font-display: "Grenze", "Palatino Linotype", Georgia, serif;
  --font-body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c; --surface: #1c1f2b; --surface-2: #252937; --fg: #ebe8e1;
    --muted: #9aa0b2; --line: #313647; --gold: #d9ae52; --danger: #f07a6a; --ok: #3cc2b9;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font: 15px/1.45 var(--font-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 32px;
}
.wrap { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
main { display: flex; flex-direction: column; gap: 16px; }
[hidden] { display: none !important; }

header.top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }
.brand { color: inherit; text-decoration: none; }
h1 { font: 700 clamp(30px, 6vw, 44px)/1 var(--font-display); margin: 0; }
h1 span { color: var(--gold); }
h2 { font: 700 26px/1.1 var(--font-display); margin: 0; text-wrap: balance; }
.status { font: 500 12px var(--font-mono); color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--ok); }
.dot.warn { background: var(--danger); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; min-width: 0; }
.opt { color: var(--muted); font-weight: 400; }
input, select {
  font: 15px var(--font-body); color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; min-width: 0;
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
fieldset.colors { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
fieldset.colors legend { font-weight: 500; margin-bottom: 6px; padding: 0; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; }
.swatch[aria-checked="true"] { border-color: var(--fg); }
.swatch:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.err { color: var(--danger); font-size: 14px; margin: 0; }

.btn {
  font: 500 14px var(--font-body); color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--surface); font-weight: 700; align-self: flex-start; }
.btn.armed { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }

.myrooms { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.myrooms a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; color: inherit; text-decoration: none; }
.myrooms a:hover { border-color: var(--muted); }
.myrooms .sub { color: var(--muted); font: 500 12px var(--font-mono); white-space: nowrap; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 20; max-width: calc(100% - 32px); }

.roomhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 8px 16px; }
.meta { color: var(--muted); font: 500 12px var(--font-mono); margin-top: 4px; }
.timer { font: 700 28px var(--font-mono); font-variant-numeric: tabular-nums; color: var(--gold); }
.banner { text-align: center; font: 700 clamp(24px, 5vw, 34px) var(--font-display); color: var(--gold); }

.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.player { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--pc); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.player.me { box-shadow: 0 0 0 2px var(--pc) inset; }
.player .pname { font-weight: 700; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.player .pname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .tag { font: 500 11px var(--font-mono); color: var(--muted); }
.player .stats { font: 500 13px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.player .stats b { color: var(--fg); font-weight: 500; }
.kick { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; padding: 0 2px; }
.kick:hover { color: var(--danger); }

.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.cell {
  position: relative; aspect-ratio: 1 / 1; min-width: 0; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--fg);
  font: 500 clamp(10px, 1.9vw, 14px)/1.2 var(--font-body); padding: 6px 6px 18px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  cursor: pointer; overflow: hidden; overflow-wrap: anywhere; hyphens: auto; transition: background-color .15s;
}
.cell:hover:not(:disabled) { border-color: var(--muted); }
.cell:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; z-index: 1; }
.cell:disabled { cursor: default; }
.cell.mine { border-color: var(--myc); border-width: 2px; }
.cell.owned { background: color-mix(in srgb, var(--oc) 28%, var(--surface)); border-color: var(--oc); }
.cell.free { font: 700 clamp(14px, 3vw, 22px) var(--font-display); color: var(--gold); }
.cell.line { box-shadow: 0 0 0 2px var(--gold) inset; }
.pips { position: absolute; bottom: 5px; left: 4px; right: 4px; display: flex; justify-content: center; flex-wrap: wrap; gap: 3px; }
.pip { width: 8px; height: 8px; border-radius: 50%; }

.foot { color: var(--muted); font-size: 12px; text-align: center; margin-top: 8px; }
.foot a { color: var(--gold); }

.exit { display: none; }
body.overlay header.top, body.overlay .toolbar > :not(.exit), body.overlay .hint, body.overlay .foot, body.overlay .kick { display: none !important; }
body.overlay .exit { display: inline-flex; }

@media (max-width: 560px) {
  .row2 { grid-template-columns: 1fr; }
  .board { gap: 4px; padding: 4px; }
  .cell { padding: 4px 3px 15px; border-radius: 6px; }
  .pip { width: 6px; height: 6px; }
  .players { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { .cell { transition: none; } }
