:root {
  --bg: #f4f2ec; --panel: #ffffff; --ink: #1d232a; --muted: #6b7280; --line: #d9d5ca;
  --accent: #1f6f5c; --accent-ink: #ffffff; --soft: #e8f1ee;
  --cell: #ebe7dd; --visited: #fdfcf8; --hunter: #1f6f5c;
  --creature: #b42318; --pit: #1d4ed8; --mover: #7e22ce; --warn: #b45309;
  --air-bg: #fffaf0; --air-line: #f0c36d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b; --panel: #1b2128; --ink: #e8e6e1; --muted: #9aa3ad; --line: #2c343d;
    --accent: #3fb68f; --accent-ink: #0d1512; --soft: #1d2f2a;
    --cell: #232a32; --visited: #2e3842; --hunter: #3fb68f;
    --creature: #f97066; --pit: #60a5fa; --mover: #c084fc; --warn: #f59e0b;
    --air-bg: #241f14; --air-line: #a87b25;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
header h1 { font-size: 18px; margin: 0; letter-spacing: .04em; }
.stat { color: var(--muted); font-size: 14px; }
.stat b { color: var(--ink); }
.spacer { flex: 1; }
button { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .35; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  font-weight: 600; }
button.big { padding: 12px 18px; font-size: 17px; width: 100%; }
label.toggle { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; cursor: pointer; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
main { display: grid; grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 1fr) minmax(300px, .9fr);
  gap: 16px; padding: 16px 20px; align-items: start; }
@media (max-width: 1100px) { main { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { main { grid-template-columns: 1fr; padding: 12px 16px; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  margin: 0 0 10px; font-weight: 600; }

/* map */
.board { display: grid; gap: 6px; }
.axis { text-align: center; font-weight: 700; color: var(--muted); align-self: center; }
.cell { position: relative; aspect-ratio: 1; border-radius: 8px; background: var(--cell);
  border: 2px solid transparent; display: flex; align-items: center; justify-content: center; }
.cell.visited { background: var(--visited); border-color: var(--line); }
.cell.here { border-color: var(--hunter); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hunter) 25%, transparent); }
.cell .lbl { position: absolute; top: 4px; left: 6px; font-size: 11px; color: var(--muted); font-weight: 600; }
.cell .step { position: absolute; top: 4px; right: 6px; font-size: 10px; color: var(--muted); }
.token { width: 46%; aspect-ratio: 1; border-radius: 50%; background: var(--hunter); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: clamp(11px, 2vw, 18px); }
.sense { position: absolute; bottom: 4px; left: 0; right: 0; display: flex; justify-content: center; gap: 3px; }
.dot { font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 6px; color: #fff; line-height: 16px; }
.dot.creature { background: var(--creature); } .dot.pit { background: var(--pit); } .dot.mover { background: var(--mover); }
.gm { position: absolute; inset: 3px; border-radius: 6px; border: 2px dashed; display: flex;
  align-items: center; justify-content: center; font-weight: 800; font-size: clamp(14px, 2.4vw, 22px); }
.gm.creature { border-color: var(--creature); color: var(--creature); }
.gm.pit { border-color: var(--pit); color: var(--pit); }
.gm.mover { border-color: var(--mover); color: var(--mover); }
.gm.creature { inset: 22%; font-size: clamp(12px, 2vw, 18px); }   /* nests inside a hazard's box */
.gm.shared { align-items: flex-end; justify-content: flex-end; padding: 0 5px 2px 0;
  font-size: clamp(10px, 1.4vw, 13px); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.shots { display: inline-flex; gap: 4px; vertical-align: middle; }
.shots i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.shots i.used { background: var(--line); }

/* read aloud */
.air { background: var(--air-bg); border-left: 4px solid var(--air-line); border-radius: 8px;
  padding: 12px 14px; min-height: 96px; }
.air p { margin: 0 0 6px; font-size: 18px; line-height: 1.4; }
.air p.ncs { font-size: 14px; color: var(--muted); font-style: italic; }
.air p:last-child { margin-bottom: 0; }
.notice { color: var(--warn); font-weight: 600; margin-top: 8px; min-height: 1em; }

/* turn controls */
.upnow { font-size: 26px; font-weight: 800; letter-spacing: .03em; }
.upnow small { display: block; font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em; }
.pads { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 12px 0; }
.seglabel { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.seg { display: flex; gap: 8px; margin-bottom: 12px; }
.seg button { flex: 1; padding: 10px 8px; font-size: 18px; font-weight: 800; line-height: 1.2; }
.seg button small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.seg button.on { border: 2px solid var(--accent); background: var(--soft); color: var(--accent); }
.seg button:disabled { opacity: 1; cursor: default; }
.pads.one { grid-template-columns: minmax(0, 280px); justify-content: center; }
.step-tag { display: inline-block; margin-left: 8px; font-size: 12px; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; background: var(--soft); color: var(--accent); vertical-align: middle; letter-spacing: 0; }
.step-tag.fire { background: color-mix(in srgb, var(--creature) 18%, transparent); color: var(--creature); }
button.firebtn { background: var(--creature); border-color: var(--creature); color: #fff; }
.pad h3 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; text-align: center; }
.compass { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.compass button { padding: 10px 0; font-weight: 700; }
.compass button.sel { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.compass .fire.sel { background: var(--creature); border-color: var(--creature); color: #fff; }
.compass .mid { font-size: 12px; font-weight: 600; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* lottery / moved */
.twolists { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.twolists h3 { margin: 0 0 6px; font-size: 13px; font-weight: 700; display: flex; justify-content: space-between; }
.twolists h3 span { color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-direction: column; gap: 4px; min-height: 32px; }
.chip { font-family: ui-monospace, Menlo, Consolas, monospace; padding: 4px 8px; border-radius: 6px;
  background: var(--soft); display: flex; justify-content: space-between; align-items: center; }
.chip.moved { background: var(--cell); color: var(--muted); }
.chip.current { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.chip small { font-family: system-ui, sans-serif; font-size: 11px; }
.empty { color: var(--muted); font-size: 13px; font-style: italic; padding: 4px 0; }

/* master list */
.addrow { display: flex; gap: 6px; align-items: center; }
.addrow input[type=text] { flex: 1; min-width: 0; font: inherit; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); text-transform: uppercase; }
.addopts { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.counts { font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.counts b { color: var(--ink); }
table.master { width: 100%; border-collapse: collapse; }
table.master th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  font-weight: 600; text-align: center; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.master th:first-child { text-align: left; }
table.master td { padding: 5px 4px; border-bottom: 1px dashed var(--line); text-align: center; }
table.master td.cs { text-align: left; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; }
table.master tr.inout td.cs { color: var(--muted); }
table.master tr.player td.cs { font-weight: 700; }
table.master td button { padding: 0 8px; border: none; color: var(--muted); background: none; }

/* tabs */
nav.tabs { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 10px;
  border: 1px solid var(--line); }
nav.tabs button { border: none; background: none; padding: 5px 14px; border-radius: 7px; font-weight: 600;
  color: var(--muted); }
nav.tabs button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
[hidden] { display: none !important; }

/* check-in form */
.addrow input.name { text-transform: none; }
.addrow input.callsign { flex: 0 1 130px; }
table.master td.cs .nm { display: block; font-family: system-ui, sans-serif; font-size: 13px;
  font-weight: 400; color: var(--muted); }
table.master td.cs .nm button { font-size: 12px; padding: 0 4px; }
table.master td.tm { font-size: 12px; color: var(--muted); text-align: left; width: 44px; }

/* preamble */
#preambleView { padding: 16px 20px; display: grid; grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px; align-items: start; max-width: 1300px; }
@media (max-width: 900px) { #preambleView { grid-template-columns: 1fr; padding: 12px 16px; } }
.field { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.field input { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 15px; color: var(--ink);
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.preamble-read { font-size: 20px; line-height: 1.6; white-space: pre-wrap; background: var(--air-bg);
  border-left: 4px solid var(--air-line); border-radius: 8px; padding: 18px 22px; }
.preamble-read mark { background: color-mix(in srgb, var(--warn) 25%, transparent); color: inherit;
  border-radius: 4px; padding: 0 3px; }
textarea#preambleText { width: 100%; min-height: 60vh; font: 15px/1.55 ui-monospace, Menlo, Consolas, monospace;
  padding: 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  resize: vertical; }
.ph { font-size: 12px; color: var(--muted); line-height: 1.7; }
.ph code { background: var(--cell); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.saved { font-size: 12px; color: var(--accent); min-height: 1em; }
.cardhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.cardhead h2 { margin: 0; }

/* transcript */
.log { max-height: 300px; overflow-y: auto; font-size: 13px; }
.log div { padding: 2px 0; border-bottom: 1px dashed var(--line); }
.log .t { color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; margin-right: 6px; }
.log .ncs { color: var(--muted); font-style: italic; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink);
  padding: 18px 20px; max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .grid { display: grid; grid-template-columns: 1fr 90px; gap: 8px 12px; align-items: center; }
dialog input { font: inherit; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); width: 100%; }
dialog p { color: var(--muted); font-size: 13px; }

button.small { font-size: 12px; padding: 2px 8px; white-space: nowrap; }
.banner { background: var(--soft); border: 1px solid var(--accent); color: var(--ink); border-radius: 10px;
  padding: 10px 14px; margin: 12px 20px 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner .spacer { flex: 1; }
