:root {
  --ink: #23324a; --muted: #66748b; --bg: #fff8ec; --card: #fff; --line: #e3e8f0;
  --brand: #3b6fe0; --ok: #1f8a4c; --bad: #c0392b;
  --a: #ff6b6b; --b: #4dabf7; --c: #51cf66; --d: #ffa94d;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.45; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
a { color: var(--brand); }
h1 { font-size: 1.8rem; margin: .4em 0; }
h1 small, h2 small { font-size: .55em; font-weight: normal; color: var(--muted); margin-left: .5em; }
.inline { display: inline; margin: 0; }
button { font: inherit; cursor: pointer; }
.linklike { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; }
.danger { color: var(--bad); }
.small { font-size: .85rem; } .muted { color: var(--muted); }
.alert, .ok { padding: 10px 14px; border-radius: 10px; }
.alert { background: #fdecea; color: var(--bad); } .ok { background: #e6f6ec; color: var(--ok); }

.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 12px; padding: 10px 18px; font-weight: bold; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn-alt { background: #5c6b82; } .btn-danger { background: var(--bad); }
.btn-big { font-size: 1.4rem; padding: 14px 32px; border-radius: 18px; }

/* ---- pupil side ---- */
.pupil .pupilbar { display: flex; justify-content: space-between; align-items: center; max-width: 760px; margin: 0 auto; padding: 12px 16px 0; font-size: 1.1rem; font-weight: bold; }
.card { background: var(--card); border-radius: 24px; padding: 28px 22px; box-shadow: 0 6px 0 rgba(35,50,74,.08); margin-top: 24px; }
.center { text-align: center; }
.big-emoji { font-size: 4rem; line-height: 1; }
.lead { font-size: 1.2rem; }
.stack { display: grid; gap: 14px; text-align: left; }
.stack label { font-weight: bold; display: grid; gap: 6px; }
.big-input { font-size: 1.3rem; padding: 12px 14px; border: 3px solid var(--line); border-radius: 14px; }
.big-input:focus { border-color: var(--brand); outline: none; }
.score { font-size: 3.5rem; font-weight: bold; margin: .2em 0; color: var(--brand); }
.score span { font-size: 1.2rem; color: var(--muted); }
.back { text-align: center; margin-top: 18px; }

.dots { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #e1e6ee; }
.dot.done { background: var(--c); } .dot.now { background: var(--brand); transform: scale(1.35); }
.qcount { text-align: center; color: var(--muted); font-weight: bold; margin: 10px 0 0; }
.qtext { font-size: 1.7rem; text-align: center; margin: .3em 0 .8em; }
.answers { display: grid; gap: 14px; }
.answer { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; font-size: 1.25rem; padding: 14px 16px; background: #fff; border: 4px solid var(--line); border-radius: 18px; color: var(--ink); box-shadow: 0 5px 0 rgba(35,50,74,.1); transition: transform .08s; }
.answer:active { transform: translateY(3px); box-shadow: none; }
.answer .letter { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: bold; font-size: 1.4rem; }
.a-a .letter { background: var(--a); } .a-b .letter { background: var(--b); } .a-c .letter { background: var(--c); } .a-d .letter { background: var(--d); }
.a-a:hover, .a-a.picked { border-color: var(--a); } .a-b:hover, .a-b.picked { border-color: var(--b); }
.a-c:hover, .a-c.picked { border-color: var(--c); } .a-d:hover, .a-d.picked { border-color: var(--d); }
.answer.picked { background: #fffbe6; }
.answer:focus-visible, .btn:focus-visible { outline: 4px solid #1c3d99; outline-offset: 2px; }

/* ---- teacher side ---- */
.teacher { background: #f4f6fa; font-size: 15px; }
.teacher main { max-width: 1100px; }
.topbar { background: #23324a; color: #fff; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 12px 20px; }
.topbar a, .topbar .linklike { color: #fff; text-decoration: none; margin-left: 16px; }
.topbar .brand { font-weight: bold; margin: 0; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin: 16px 0; overflow-x: auto; }
.panel.narrow { max-width: 380px; margin: 40px auto; }
.panel h2 { margin-top: 0; font-size: 1.15rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.grid2 .panel { margin: 0; }
.teacher label { display: grid; gap: 4px; font-weight: bold; }
.teacher input, .teacher select { font: inherit; padding: 8px 10px; border: 1px solid #c4cdda; border-radius: 8px; font-weight: normal; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.qcol { text-align: center; width: 2.5em; padding: 8px 4px; }
.tick { color: var(--ok); font-weight: bold; } .cross { color: var(--bad); font-weight: bold; }
.tag { display: inline-block; background: #eef2fb; color: #2b4aa0; border-radius: 6px; padding: 0 6px; font-size: .78rem; }
.wrong { margin-bottom: 6px; }
.filter { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; align-items: center; }
.filter a.on { font-weight: bold; text-decoration: none; color: var(--ink); border-bottom: 3px solid var(--brand); }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; }

@media (max-width: 520px) { .qtext { font-size: 1.4rem; } .answer { font-size: 1.1rem; } }

/* discern + teacher admin */
.discern td.opt, .discern th:not(:first-child) { text-align: center; width: 110px; }
.discern input[type=radio] { width: 22px; height: 22px; cursor: pointer; }
.discern tbody tr:hover { background: #f4f7fd; }
.teacher-form { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: end; }
.teacher-form fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0; padding: 4px 12px 8px; }
.teacher .check { display: inline-flex; align-items: center; gap: 6px; margin-right: 10px; font-weight: normal; }
.teacher .check input { width: auto; }

/* printable pupil list */
.btn-small { padding: 4px 12px; font-size: .85rem; margin-left: auto; }
.printtable { max-width: 640px; }
.printtable td, .printtable th { padding: 6px 10px; border: 1px solid #999; }
.printtable td:last-child { font-family: Consolas, monospace; }
@media print {
  .topbar, .noprint, .pupilbar { display: none !important; }
  body, .teacher { background: #fff; font-size: 12pt; }
  main { max-width: none; padding: 0; }
  .printpage { break-after: page; }
  .printpage:last-child { break-after: auto; }
  .printtable tr { break-inside: avoid; }
}

/* back links: a proper tappable button for pupils */
.pupil .back a { display: inline-block; padding: 10px 20px; border-radius: 999px; background: #fff; border: 3px solid var(--line); color: var(--ink); font-weight: bold; text-decoration: none; box-shadow: 0 3px 0 rgba(35,50,74,.1); }
.pupil .back a:hover { border-color: var(--brand); color: var(--brand); }
.pupil .back a:focus-visible { outline: 4px solid #1c3d99; outline-offset: 2px; }
.fa-arrow-left { margin-right: .35em; }

/* logo on the pupil login card (portrait JPG, 324x415) */
.logo { display: block; width: min(100%, 160px); height: auto; margin: 0 auto 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* pupil pages: soft sky-to-mint background to go with the navy/green logo */
body.pupil { background: #e8f4ff linear-gradient(180deg, #dcefff 0%, #e6f7ee 100%) fixed; min-height: 100vh; }

/* ====== phones and tablets ====== */
html { -webkit-text-size-adjust: 100%; }
button, .btn, .answer, a { touch-action: manipulation; -webkit-tap-highlight-color: rgba(59, 111, 224, .15); }
main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
@media (hover: hover) { .answer:hover { transform: translateY(-2px); } }

/* pupils: comfortable, fluid sizing from small phones up to tablets */
.answer { min-height: 68px; }
.qtext { font-size: clamp(1.35rem, 1rem + 2vw, 2.1rem); }
.answer { font-size: clamp(1.1rem, .9rem + 1.2vw, 1.55rem); }
.dot { width: clamp(12px, 2.4vw, 18px); height: clamp(12px, 2.4vw, 18px); }

@media (min-width: 700px) {            /* tablets */
  .pupil main { max-width: 860px; padding-top: 28px; }
  .card { padding: 40px 36px; border-radius: 32px; }
  .answers { gap: 18px; }
  .answer { padding: 18px 22px; min-height: 84px; }
  .answer .letter { width: 56px; height: 56px; font-size: 1.7rem; }
  .btn-big { font-size: 1.6rem; padding: 18px 44px; }
  .lead { font-size: 1.4rem; }
  .logo { width: min(100%, 210px); }
  .pupil .pupilbar { font-size: 1.3rem; max-width: 860px; }
}
@media (min-width: 700px) and (orientation: landscape) { .pupil main { max-width: 980px; } }

@media (max-width: 520px) {            /* phones */
  main { padding-top: 10px; }
  .card { padding: 20px 16px; border-radius: 20px; margin-top: 12px; }
  .big-emoji { font-size: 3rem; }
  .answer { gap: 12px; padding: 12px 14px; border-width: 3px; }
  .answer .letter { width: 42px; height: 42px; font-size: 1.25rem; }
  .btn-big { width: 100%; text-align: center; }
  .qcount { margin-top: 6px; }

  /* teachers */
  .teacher { font-size: 16px; }                      /* 16px inputs stop iOS zooming in on focus */
  .teacher input, .teacher select { font-size: 16px; padding: 10px 12px; }
  .teacher main { padding-top: 8px; }
  h1 { font-size: 1.45rem; }
  .topbar { padding: 10px 14px; gap: 6px; }
  .topbar nav { display: flex; flex-wrap: wrap; gap: 2px 4px; width: 100%; }
  .topbar a, .topbar .linklike { margin-left: 0; padding: 8px 10px; display: inline-block; }
  .topbar .brand { padding: 4px 0; }
  .panel { padding: 12px; margin: 12px 0; }
  .btn { padding: 12px 18px; }
  .btn-small { padding: 8px 14px; margin-left: 0; }
  .filter { gap: 4px 14px; }
  .filter a { padding: 6px 0; }
  .teacher-form { gap: 12px; }
  .teacher-form > * { flex: 1 1 100%; }
  th, td { padding: 8px 6px; }
  .discern td.opt, .discern th:not(:first-child) { width: 64px; }
  .discern input[type=radio] { width: 28px; height: 28px; }
  .printtable { max-width: none; }
}
@media (max-width: 900px) { .teacher main { padding-left: 14px; padding-right: 14px; } }
