:root {
  color-scheme: light dark;
  --bg: #0f1720; --fg: #e8edf2; --muted: #93a1b0; --card: #18222e; --line: #2a3645;
  --accent: #3d8bfd; --ok: #2ea043; --warn: #d29922;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f6f8; --fg: #17202a; --muted: #5b6876; --card: #fff; --line: #d8dee4; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); }
header { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--line); }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0; }
main { max-width: 880px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: grid; gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.pill { font-size: 12px; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.pill.on { color: var(--ok); border-color: var(--ok); }
label { display: grid; gap: 4px; }
label.check { display: flex; gap: 6px; align-items: center; }
input, select, button, .button { font: inherit; color: inherit; }
input, select { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
button, .button { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 7px 14px; cursor: pointer; display: inline-block; }
button:disabled { opacity: .45; cursor: default; }
button.link { background: none; color: var(--accent); padding: 0; }
#rom-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tr.mine td { font-weight: 600; }
td.ok { color: var(--ok); }
dialog { background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; width: min(420px, 92vw); }
dialog form { display: grid; gap: 12px; }
#chat-log { height: 160px; overflow-y: auto; font-size: 14px; }
#chat-log .sys { color: var(--muted); }
#chat-form { display: flex; gap: 8px; }
#chat-form input { flex: 1; }
#game-view { max-width: none; justify-items: center; }
#canvas { width: min(96vw, calc(88vh * 4 / 3)); aspect-ratio: 4 / 3; background: #000; image-rendering: pixelated; outline: none; }
footer { text-align: center; padding: 16px; }
/* In a match the canvas fills the window; the runner letterboxes inside its own
   size and object-fit keeps that aspect (as on offline.html). */
body.playing header, body.playing footer { display: none; }
body.playing #canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; aspect-ratio: auto; object-fit: contain; image-rendering: auto; }
body.playing #game-status { position: fixed; left: 12px; top: 8px; z-index: 1; }
body.playing #game-view details { display: none; }
