/* Layout: one centred column on phones; teacher screens widen to 960px with tabs. */
:root {
  --bg: #f4f6f5; --surface: #ffffff; --surface-2: #eef2f0; --fg: #16201b; --muted: #5b6a63; --line: #d6dfda;
  --accent: #1f6f5c; --accent-ink: #ffffff; --accent-soft: #e0efe9;
  --good: #1d7a3e; --good-bg: #e3f3e8; --warn: #9a6200; --warn-bg: #fbefd8; --bad: #b42318; --bad-bg: #fbe5e2;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #101513; --surface: #18201c; --surface-2: #1f2925; --fg: #e7eeea; --muted: #98a79f; --line: #2b3631;
  --accent: #4fbf9f; --accent-ink: #0b1411; --accent-soft: #1b3a31;
  --good: #6fd391; --good-bg: #183324; --warn: #f0b54a; --warn-bg: #352812; --bad: #ff8a7a; --bad-bg: #3a1a16;
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #101513; --surface: #18201c; --surface-2: #1f2925; --fg: #e7eeea; --muted: #98a79f; --line: #2b3631;
  --accent: #4fbf9f; --accent-ink: #0b1411; --accent-soft: #1b3a31;
  --good: #6fd391; --good-bg: #183324; --warn: #f0b54a; --warn-bg: #352812; --bad: #ff8a7a; --bad-bg: #3a1a16;
  color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 var(--font); }
main { max-width: 560px; margin: 0 auto; display: grid; gap: 16px;
  padding-block: 16px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
main.wide { max-width: 960px; }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0; text-wrap: balance; }
h2 { font-size: 1.1rem; margin: 0; }
h3 { font-size: 1rem; margin: 0; }
p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .85rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 180px; min-width: 0; }
.between { justify-content: space-between; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { font-weight: 700; letter-spacing: .01em; }

label { font-size: .85rem; font-weight: 600; display: grid; gap: 4px; }
input, select, textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); width: 100%; }
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: .95rem; }

button { font: inherit; font-weight: 600; border-radius: 8px; padding: 11px 16px; border: 1px solid var(--accent); cursor: pointer; background: transparent; color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.link { border: 0; padding: 4px 0; background: none; text-decoration: underline; font-weight: 500; }
button.big { padding: 16px; font-size: 1.05rem; width: 100%; }
button:disabled { opacity: .5; cursor: not-allowed; }
:is(button, input, select, textarea, a):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.good { color: var(--good); background: var(--good-bg); }
.warn { color: var(--warn); background: var(--warn-bg); }
.bad  { color: var(--bad);  background: var(--bad-bg); }
.note { padding: 10px 12px; border-radius: 8px; font-size: .95rem; }
.error { color: var(--bad); font-size: .9rem; }

/* Hunt screen */
.hud { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; }
.hud .num { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.15rem; }
.hud .lbl { display: block; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.timer.low { color: var(--bad); }
.clue { font-size: 1.15rem; line-height: 1.55; white-space: pre-wrap; }
.question { font-size: 1.15rem; white-space: pre-wrap; }
.options { display: grid; gap: 10px; }
.option { text-align: left; display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); color: var(--fg); background: var(--surface); font-weight: 500; }
.option .key { font-weight: 700; color: var(--accent); min-width: 1.2em; }
.option[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-soft); }
.option.wrong { text-decoration: line-through; color: var(--muted); background: var(--bad-bg); border-color: transparent; }
.dots { display: flex; gap: 6px; }
.dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.dots span.done { background: var(--accent); }
.dots span.now { background: transparent; border: 2px solid var(--accent); }

/* Tables and lists */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
tr.me td { background: var(--accent-soft); font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; color: var(--muted); padding: 10px 14px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 8px 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.item { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 6px; }
.item:first-child { border-top: 0; padding-top: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.toast { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 600; z-index: 50; max-width: calc(100% - 32px); }
.qr img { width: 160px; height: 160px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; }

@media print {
  body { background: #fff; color: #000; }
  .no-print { display: none !important; }
  .print-card { break-inside: avoid; border: 1px solid #000; padding: 16px; margin-bottom: 16px; text-align: center; }
}
