/* ============================================================
   The teacher's page. A plain, professional dashboard: this is a
   tool an adult uses on a laptop between lessons, so it reads like
   one. It does not load the game's stylesheet.

   The one exception is the full-screen board view (.projector):
   the join code and the scoreboard are what the class looks at, so
   those keep the game's colors and pixel font.
   ============================================================ */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #1c2330;
  --text-2: #5b6576;
  --primary: #3457d5;
  --primary-hover: #2a47b3;
  --primary-soft: #e9eefc;
  --success: #1f8a4c;
  --success-soft: #e5f5ec;
  --danger: #c43a3a;
  --danger-soft: #fbeaea;
  --warning: #b86e00;
  --focus: 0 0 0 3px rgba(52, 87, 213, .28);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* The game's palette, for the board view only. */
  --game-bg: #160f28;
  --game-panel: #2d1b5c;
  --game-line: #6650a9;
  --game-text: #f8f4ff;
  --game-muted: #b7abda;
  --game-gold: #f6c453;
  --game-green: #62e5a0;
  --pixel-font: 'Press Start 2P', 'Courier New', ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1e24;
    --surface-2: #22272e;
    --border: #2e343d;
    --border-strong: #3d444f;
    --text: #e8ebf0;
    --text-2: #9aa3b2;
    --primary: #6d8bff;
    --primary-hover: #8aa2ff;
    --primary-soft: #232c4a;
    --success: #4cc27f;
    --success-soft: #16301f;
    --danger: #f07171;
    --danger-soft: #3a1f22;
    --warning: #f0a53a;
    --focus: 0 0 0 3px rgba(109, 139, 255, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.teach {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.teach [hidden] { display: none !important; }
.teach a { color: var(--primary); }

/* ---------- top bar ---------- */
.teach-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.teach .teach-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 16px; color: var(--text); text-decoration: none;
}
.teach-brand img { border-radius: 6px; image-rendering: pixelated; }
.teach-brand span { font-weight: 500; color: var(--text-2); }
.teach-who { display: flex; gap: 14px; align-items: center; font-size: 14px; color: var(--text-2); }

.teach-main { max-width: 1080px; margin: 0 auto; padding: 28px 20px 64px; }

/* ---------- type ---------- */
.teach h1 { font-size: 24px; line-height: 1.25; font-weight: 700; margin: 0 0 6px; letter-spacing: -.01em; }
.teach h2 { font-size: 16px; line-height: 1.35; font-weight: 600; margin: 0 0 10px; }
.teach p { margin: 0 0 12px; }
.muted { color: var(--text-2); }
.small-note { font-size: 13px; margin: 6px 0 0; }
.problem { color: var(--danger); min-height: 1.3em; margin: 6px 0; font-size: 14px; }
.problem:empty { min-height: 0; margin: 0; }

/* ---------- layout ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card.narrow { max-width: 480px; margin: 40px auto; padding: 28px; }
.card.narrow h1 { font-size: 22px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.view-head h1, .view-head h2 { margin: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row.center { justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.two-col .card { margin-bottom: 20px; }

/* ---------- forms ---------- */
.teach label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; color: var(--text); }
.teach label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.teach input[type=text], .teach input[type=email], .teach input[type=password], .teach input:not([type]), .teach select {
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 9px 12px; width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
.teach label.inline select { width: auto; }
.teach input:focus, .teach select:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.teach input::placeholder { color: var(--text-2); opacity: .7; }
.teach input[type=radio], .teach input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
  padding: 9px 16px; border-radius: 8px; cursor: pointer; text-decoration: none;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.small { font-size: 13px; padding: 6px 12px; }
.btn.big { width: 100%; font-size: 15px; padding: 13px; margin-top: 12px; }
.teach a.btn { color: var(--text); }
.teach a.btn-primary { color: #fff; }
.teach a.btn-ghost { color: var(--text-2); }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; font-size: 14px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.icon-btn {
  font: inherit; font-size: 13px; font-weight: 500; line-height: 1;
  padding: 6px 10px; min-width: 32px; border-radius: 6px; cursor: pointer;
  color: var(--text-2); background: var(--surface); border: 1px solid var(--border);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.privacy { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-2); }
.privacy summary { cursor: pointer; color: var(--text); font-weight: 500; }
.privacy p { margin-top: 10px; }

/* ---------- games list ---------- */
.game-list { display: flex; flex-direction: column; gap: 10px; }
.game-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 20px; align-items: center;
  padding: 16px 20px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--text) !important; text-decoration: none;
  transition: border-color .12s;
}
.game-row:hover { border-color: var(--primary); }
.gr-title { font-weight: 600; }
.gr-title small { display: block; font-weight: 400; font-size: 13px; color: var(--text-2); margin-top: 2px; }
.gr-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; letter-spacing: .08em;
  font-size: 14px; padding: 4px 10px; border-radius: 999px;
  background: var(--success-soft); color: var(--success);
}
.game-row.closed .gr-code { background: var(--surface-2); color: var(--text-2); letter-spacing: 0; font-family: var(--font); font-weight: 500; }
.gr-count { color: var(--text-2); font-size: 14px; white-space: nowrap; }

/* ---------- new game ---------- */
.board-choice { border: 0; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 8px; }
.board-choice legend { font-size: 14px; font-weight: 600; margin-bottom: 8px; padding: 0; }
.count-pill {
  display: inline-block; margin-left: 8px; padding: 2px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--text-2);
}

.q-list { list-style: none; counter-reset: q; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.q-list li {
  counter-increment: q; display: flex; gap: 14px; justify-content: space-between; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px;
}
.q-list li::before {
  content: counter(q);
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--text-2);
}
.q-body { flex: 1; min-width: 0; }
.q-prompt { margin: 2px 0 8px !important; font-weight: 600; overflow-wrap: anywhere; }
.q-opts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px !important; }
.opt {
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 10px;
  font-size: 14px; background: var(--surface-2); overflow-wrap: anywhere;
}
.opt.right { border-color: var(--success); background: var(--success-soft); color: var(--success); font-weight: 600; }
.opt.right::before { content: '✓ '; }
.tag-rec, .tag-own { font-size: 12px; font-weight: 500; }
.tag-rec { color: var(--primary); }
.tag-own { color: var(--text-2); }
.q-tools { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- one game ---------- */
.code-card { text-align: center; padding: 28px 20px; }
.code-card p { color: var(--text-2); }
.code-card .join-big {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700;
  font-size: 48px; letter-spacing: .18em; color: var(--text); margin: 8px 0 20px !important;
  overflow-wrap: anywhere;
}
.closed-note { color: var(--text-2); }
.board-card { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.board-card .small-note { flex: 1 1 260px; margin: 0; }
.switch { font-weight: 600 !important; }

.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.stat-box b { display: block; font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-box span { color: var(--text-2); font-size: 13px; }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.results { border-collapse: collapse; width: 100%; font-size: 14px; }
.results th, .results td { border-bottom: 1px solid var(--border); padding: 10px 8px; text-align: center; white-space: nowrap; }
.results th { color: var(--text-2); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.results tbody tr:hover td { background: var(--surface-2); }
.results .name { text-align: left; position: sticky; left: 0; background: var(--surface); font-weight: 500; }
.results .score { font-weight: 600; }
.results .time { color: var(--text-2); font-variant-numeric: tabular-nums; }
.results .done { color: var(--success); }
.mark.yes { color: var(--success); font-weight: 600; }
.mark.no { color: var(--danger); font-weight: 600; }
.mark.none { color: var(--border-strong); }

.q-results { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.q-results li { border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.q-results li.low { border-color: var(--danger); background: var(--danger-soft); }
.qr-head { display: flex; gap: 10px; align-items: baseline; }
.qr-num { font-weight: 600; color: var(--text-2); font-size: 13px; }
.qr-prompt { flex: 1; font-weight: 500; overflow-wrap: anywhere; }
.qr-acc { font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); margin: 10px 0 8px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--success); border-radius: 3px; }
.q-results li.low .bar { background: var(--surface); }
.q-results li.low .bar span { background: var(--danger); }
.qr-detail { margin: 0 !important; font-size: 13px; color: var(--text-2); }
.danger-zone { text-align: center; margin-top: 32px; }

/* ---------- plans and billing ---------- */
.teach .nav-link { color: var(--text); font-weight: 500; text-decoration: none; }
.teach .nav-link:hover { color: var(--primary); }

.plan-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; margin-bottom: 20px; border-radius: var(--radius);
  background: var(--primary-soft); color: var(--text); font-size: 14px;
}
.plan-banner.warn { background: #fff4e0; }
@media (prefers-color-scheme: dark) { .plan-banner.warn { background: #3a2c12; } }

.notice { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.notice p { margin: 4px 0 0; }
.notice.success { background: var(--success-soft); border-color: var(--success); justify-content: flex-start; gap: 8px; }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 0 0 4px !important; }
.access-state { font-size: 20px; font-weight: 700; margin: 0 0 2px !important; }
.section-title { margin: 28px 0 12px !important; }

.plans { display: grid; grid-template-columns: 1fr 1.4fr; gap: 20px; align-items: stretch; }
.plan { display: flex; flex-direction: column; gap: 12px; margin-bottom: 0; }
.plan .btn-primary { margin-top: auto; }
.price { font-size: 34px; font-weight: 700; margin: 0 !important; letter-spacing: -.02em; }
.price small { font-size: 14px; font-weight: 500; color: var(--text-2); margin-left: 6px; letter-spacing: 0; }
.features { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 14px; }
.features li { margin: 4px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.teach input[type=number] {
  font: inherit; font-size: 15px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 9px 12px; width: 100%;
}
.total { margin: 0 !important; font-size: 15px; }
.total b { font-size: 18px; }
.invoice-note { margin-top: 14px !important; font-size: 14px; }

.license { margin-top: 0; }
.license-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.license h3 { font-size: 16px; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.license-head p { margin: 0 !important; font-size: 14px; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.pill.ok { background: var(--success-soft); color: var(--success); }
.seats { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.seat-list { list-style: none; margin: 0 0 12px; padding: 0; max-height: 320px; overflow-y: auto; }
.seat-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.seat-list li:last-child { border-bottom: 0; }
.seat-add { display: flex; gap: 8px; }
.seat-add input { flex: 1; }

/* ---------- the board view: the class sees this, so it is the game's style ---------- */
.projector {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  padding: 16px; text-align: center;
  background: var(--game-bg); color: var(--game-text);
  background-image: repeating-linear-gradient(180deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 3px);
}
.projector p { font-size: clamp(18px, 3vw, 34px); margin: 0 0 12px; }
.projector-code { font-family: var(--pixel-font); font-size: clamp(48px, 13vw, 180px) !important; color: var(--game-gold); letter-spacing: .12em; }
.projector-count { color: var(--game-muted); }
.projector .btn {
  font-family: var(--pixel-font); font-size: 11px; border-radius: 0;
  color: var(--game-text); background: var(--game-panel); border: 3px solid var(--game-line);
  box-shadow: 0 4px 0 #120a29; padding: 12px 16px;
}
.projector .btn:hover { background: #3a2570; }
.projector-board { width: min(900px, 100%); max-height: 78vh; overflow-y: auto; }
.projector-board h2 { font-family: var(--pixel-font); color: var(--game-gold); font-size: clamp(14px, 2.4vw, 24px); margin: 0 0 8px; }
.board-rows { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 8px; }
.board-rows li {
  display: grid; grid-template-columns: 3em 1fr auto auto 1.5em; gap: 16px; align-items: center;
  padding: 10px 16px; background: var(--game-panel); border: 3px solid var(--game-line);
  font-size: clamp(16px, 2.6vw, 28px); text-align: left;
}
.br-rank { font-family: var(--pixel-font); color: var(--game-gold); font-size: .7em; }
.br-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.br-name.anon { color: var(--game-line); }
.br-score { font-weight: 700; }
.br-time { color: var(--game-muted); }
.br-done { color: var(--game-green); }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .teach-bar { padding: 10px 16px; }
  .teach-main { padding: 20px 16px 48px; }
  .grid3, .two-col, .plans, .grid2 { grid-template-columns: 1fr; }
  .seat-add { flex-direction: column; }
  .game-row { grid-template-columns: 1fr auto; gap: 10px; }
  .gr-count { grid-column: 1 / -1; }
  .code-card .join-big { font-size: 34px; }
  .stat-strip { gap: 10px; }
  .stat-box { padding: 12px; }
  .stat-box b { font-size: 20px; }
  .q-list li { flex-wrap: wrap; }
  .q-tools { width: 100%; justify-content: flex-start; padding-left: 40px; }
}
