:root {
  --accent: #fcba03;
  --accent-soft: #fff3c4;
  --accent-tint: #fffbeb;
  --bg: #fafaf7;
  --surface: #ffffff;
  --ink: #18181b;
  --text-2: #3f3f46;
  --text-3: #52525b;
  --muted: #71717a;
  --line: #ececE6;
  --line-2: #e4e4e0;
  --line-3: #d4d4d0;
  --subtle: #f4f4f0;
  --ok: #166534;
  --ok-dot: #16a34a;
  --ok-bg: #e9f7ee;
  --bad: #991b1b;
  --bad-line: #b91c1c;
  --bad-bg: #fdeceb;
  --silver: #e4e4e7;
  --bronze: #f3d9c4;
  --shadow: 0 1px 2px rgba(24, 24, 27, 0.04), 0 12px 32px rgba(24, 24, 27, 0.06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: Figtree, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- Kopbalk ---- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--line);
}
.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-text { font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.spacer { flex: 1; }
.badge { font-size: 14px; font-weight: 600; color: var(--muted); padding: 4px 10px; background: var(--subtle); border-radius: 999px; }
.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok);
  font-size: 14px;
  font-weight: 700;
}
.badge-live::before { content: ''; width: 8px; height: 8px; border-radius: 999px; background: var(--ok-dot); }
.topbar-name { font-weight: 700; font-size: 16px; }

.pills { display: flex; gap: 8px; align-items: center; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  background: var(--surface);
  border: 1px solid var(--line-2);
}
.pill-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill-bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

.timebar { height: 4px; background: var(--line); }
.timebar > div { height: 4px; background: var(--accent); transition: width 0.5s linear; }

footer { padding: 20px; text-align: center; font-size: 13px; color: var(--muted); }

/* ---- Pagina ---- */
.center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 48px 16px; }
.card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.stack { display: flex; flex-direction: column; }
.title { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -0.02em; }
.subtitle { margin: 0; font-size: 16px; color: var(--text-3); }

/* ---- Formulieren ---- */
.label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.input {
  height: 52px;
  padding: 0 16px;
  font: inherit;
  font-size: 18px;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line-3);
  border-radius: 12px;
  outline: none;
  width: 100%;
}
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(252, 186, 3, 0.35); }
.help { margin: 0; font-size: 13px; color: var(--muted); }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 8px; }

.btn {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 24px;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  background: var(--ink);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: #27272a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn:focus-visible, .icon-btn:focus-visible, .link-btn:focus-visible, .text-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-block { width: 100%; }
.btn-accent { color: var(--ink); background: var(--accent); font-weight: 800; }
.btn-accent:hover { background: #f0b000; }
.btn-light { color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); }
.btn-light:hover { background: var(--subtle); }
.btn-danger { background: var(--bad-line); }
.btn-danger:hover { background: var(--bad); }

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--subtle); }
.text-btn {
  height: 44px;
  padding: 0 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-3);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
.text-btn:hover { background: var(--subtle); color: var(--ink); }
.link-btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 10px 12px;
  min-height: 44px;
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.link-btn:hover { color: var(--ink); }

.hint { margin: 0; font-size: 14px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
kbd {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border: 1px solid var(--line-3);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-2);
}
.message { margin: 0; min-height: 1.3em; font-size: 15px; font-weight: 600; text-align: center; color: var(--text-2); }
.message.error { color: var(--bad); }
.message:empty { display: none; }

@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.shake { animation: shake 0.25s ease-in-out 2; }

/* ---- Aanmelden ---- */
.join-card { max-width: 460px; padding: 40px; gap: 28px; }
.tutor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tutor {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1.5px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}
.tutor:hover { border-color: var(--line-3); }
.tutor input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tutor .avatar { background: var(--subtle); color: var(--text-3); }
.tutor .name { font-weight: 600; font-size: 16px; flex: 1; overflow-wrap: anywhere; }
.tutor .check { visibility: hidden; }
.tutor:has(input:checked) { border-color: var(--ink); background: var(--accent-tint); }
.tutor:has(input:checked) .avatar { background: var(--accent); color: var(--ink); }
.tutor:has(input:checked) .check { visibility: visible; }
.tutor:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.empty { margin: 0; padding: 16px; text-align: center; font-size: 15px; color: var(--muted); border: 1.5px dashed var(--line-3); border-radius: 12px; }

.avatar {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  background: var(--accent);
  color: var(--ink);
}

/* ---- Wachtkamer ---- */
.wait-card { max-width: 520px; padding: 48px 40px; align-items: center; gap: 24px; text-align: center; }
.avatar-xl { width: 88px; height: 88px; font-size: 36px; font-weight: 800; }
.wait-name { margin: 0; font-size: 44px; font-weight: 800; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.waiting {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--subtle);
  border-radius: 999px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-2);
}
.waiting strong { color: var(--ink); }
.dots { display: flex; gap: 6px; }
.dots span { width: 8px; height: 8px; border-radius: 999px; background: var(--ink); animation: pulse 1.2s ease-in-out infinite; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1); } }
.wait-away { margin: 0; padding: 12px 16px; max-width: 380px; font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--accent-soft); border-radius: 12px; }
.wait-note { margin: 0; font-size: 14px; color: var(--muted); max-width: 340px; line-height: 1.5; }

/* ---- Rekenen ---- */
.play { width: 100%; max-width: 640px; display: flex; flex-direction: column; align-items: center; gap: 32px; text-align: center; }
.eyebrow { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.sum { font-size: clamp(56px, 9vw, 104px); font-weight: 800; letter-spacing: -0.03em; line-height: 1; min-height: 1em; }
.answer-row { display: flex; gap: 12px; align-items: stretch; }
.answer {
  width: 200px;
  height: 80px;
  padding: 0 16px;
  font: inherit;
  font-size: 48px;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--line-3);
  border-radius: 16px;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
.answer::-webkit-outer-spin-button, .answer::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.answer:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(252, 186, 3, 0.35); }
.answer.correct { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-dot); box-shadow: none; }
.answer.wrong { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); box-shadow: none; }
.answer-row .btn { height: 80px; padding: 0 32px; font-size: 22px; border-radius: 16px; }
.feedback {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 700;
  min-height: 52px;
  visibility: hidden;
}
.feedback.correct { visibility: visible; background: var(--ok-bg); color: var(--ok); }
.feedback.wrong { visibility: visible; background: var(--bad-bg); color: var(--bad); }
.feedback.done { visibility: visible; background: var(--accent-soft); color: var(--ink); }

/* ---- Leerkracht: start ---- */
.start-wrap { width: 100%; max-width: 920px; display: flex; flex-wrap: wrap; gap: 48px; align-items: center; }
.start-intro { flex: 1 1 340px; gap: 24px; }
.start-intro h1 { margin: 0; font-size: 44px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 16px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.step-no {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--line);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}
.steps li:first-child .step-no { background: var(--ink); color: #ffffff; }
.steps .step-text { font-size: 17px; line-height: 1.5; color: var(--text-3); padding-top: 4px; }
.steps li:first-child .step-text { color: var(--text-2); }
.steps strong { color: var(--ink); }
.start-card { flex: 1 1 360px; padding: 36px; gap: 20px; }

/* ---- Leerkracht: wachtrij en scorebord ---- */
.board-main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 40px 32px; display: flex; flex-direction: column; gap: 24px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 24px; align-items: stretch; }
.address {
  flex: 1 1 520px;
  background: var(--ink);
  color: #ffffff;
  border-radius: 20px;
  padding: 32px 36px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
}
.address .small { margin: 0; font-size: 16px; font-weight: 600; color: #a1a1aa; }
.address .url { margin: 0; font-size: clamp(32px, 4.5vw, 56px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; color: var(--accent); overflow-wrap: anywhere; }
.address .with { margin: 0; font-size: 18px; color: #d4d4d8; }
.address .with strong { color: #ffffff; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }
.start-panel { flex: 1 1 380px; padding: 28px; display: flex; flex-direction: column; gap: 20px; justify-content: center; }
.start-panel .btn { height: 60px; font-size: 20px; border-radius: 14px; }

.segmented { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--subtle); border-radius: 12px; }
.segmented label {
  position: relative;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  white-space: nowrap;
}
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label:has(input:checked) { font-weight: 700; color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px rgba(24, 24, 27, 0.12); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--accent); }
.segmented label:has(input:disabled) { cursor: default; opacity: 0.6; }

.players { flex: 1; padding: 28px 32px; display: flex; flex-direction: column; gap: 20px; }
.players-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.players-head h2 { margin: 0; font-size: 24px; font-weight: 800; }
.players-head span { font-size: 16px; font-weight: 600; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 18px 0 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 18px;
  font-weight: 600;
  animation: pop 0.25s ease-out;
}
.chip .avatar { background: var(--accent-soft); }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.status { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; padding: 20px 28px; }
.status-time { display: flex; flex-direction: column; gap: 2px; }
.status-time .eyebrow { font-size: 13px; }
.timer { font-size: 48px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.timer.ending { color: var(--bad-line); }
.progress { flex: 1 1 240px; height: 10px; background: var(--subtle); border-radius: 999px; overflow: hidden; }
.progress > div { height: 10px; background: var(--accent); border-radius: 999px; transition: width 0.5s linear; }
.status-flex { flex: 1 1 240px; }
.status-info { font-size: 16px; font-weight: 600; color: var(--text-3); }
.status-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.status-actions .btn { height: 52px; font-size: 17px; }
.status-actions .segmented { min-width: 360px; }
.ops { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--subtle); border-radius: 12px; }
.ops label {
  position: relative;
  height: 40px;
  min-width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 22px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.ops input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ops label:has(input:checked) { color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px rgba(24, 24, 27, 0.12); }
.ops label:has(input:focus-visible) { outline: 3px solid var(--accent); }
.metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metrics.wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metrics label { font-size: 14px; font-weight: 600; padding: 0 8px; white-space: nowrap; }
.metrics label:has(input:checked) { font-weight: 700; }
.metrics label { height: auto; min-height: 48px; flex-direction: column; gap: 2px; padding: 6px 8px; text-align: center; white-space: normal; }
.metrics label small { font-size: 11px; font-weight: 500; line-height: 1.2; color: var(--muted); }
.ranking-row { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.ranking-row legend { float: left; margin: 0; }
.ranking-row .metrics { flex: 1 1 480px; }
.custom-dur { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; color: var(--text-3); }
.custom-min { width: 96px; height: 44px; font-size: 18px; font-weight: 700; text-align: center; -moz-appearance: textfield; appearance: textfield; }
.custom-min::-webkit-outer-spin-button, .custom-min::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#againGroup { gap: 8px; }

.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: end; }
.place {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  text-align: center;
}
.place .avatar { width: 56px; height: 56px; font-size: 22px; font-weight: 800; }
.place .pname { font-size: 24px; font-weight: 800; overflow-wrap: anywhere; }
.place .pscore { font-size: 16px; color: var(--text-3); }
.place .pscore strong { color: var(--ink); font-size: 20px; }
.place .rank { margin-top: 6px; height: 32px; min-width: 32px; padding: 0 12px; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.place-1 { background: var(--ink); color: #ffffff; border: 0; padding: 28px 24px; min-height: 260px; box-shadow: 0 16px 40px rgba(24, 24, 27, 0.18); }
.place-1 .avatar { width: 72px; height: 72px; font-size: 28px; background: var(--accent); }
.place-1 .pname { font-size: 32px; }
.place-1 .pscore { color: #d4d4d8; }
.place-1 .pscore strong { color: #ffffff; font-size: 24px; }
.place-1 .rank { background: var(--accent); color: var(--ink); }
.place-2 { min-height: 200px; }
.place-2 .avatar, .place-2 .rank { background: var(--silver); }
.place-3 { min-height: 170px; }
.place-3 .avatar, .place-3 .rank { background: var(--bronze); }

.table-panel { overflow-x: auto; }
.scores { width: 100%; border-collapse: collapse; font-size: 18px; min-width: 560px; }
.scores th { text-align: left; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 14px 12px; }
.scores td { padding: 14px 12px; border-top: 1px solid #f0f0ea; }
.scores th:first-child, .scores td:first-child { padding-left: 24px; width: 64px; }
.scores th:last-child, .scores td:last-child { padding-right: 24px; text-align: right; width: 140px; }
.scores .c-rank { font-weight: 700; color: var(--muted); }
.scores .c-name { font-weight: 700; overflow-wrap: anywhere; }
.scores .c-correct { width: 240px; }
.scores .c-wrong { text-align: right; width: 90px; color: var(--bad); font-weight: 600; }
.scores .c-avg { color: var(--text-3); }
.bar-cell { display: flex; align-items: center; gap: 12px; }
.bar-cell b { width: 28px; font-weight: 800; }
.bar { flex: 1; height: 8px; background: var(--subtle); border-radius: 999px; overflow: hidden; }
.bar > div { height: 8px; background: var(--ink); border-radius: 999px; transition: width 0.3s; }

/* Volledig scherm op het digibord: iets groter. */
:fullscreen .board-main { max-width: none; }

@media (max-width: 720px) {
  .topbar { padding: 16px; }
  .join-card, .wait-card, .start-card { padding: 28px 20px; }
  .answer { width: 140px; }
  .podium { grid-template-columns: 1fr; }
  .place-1 { order: -1; }
  .board-main { padding: 24px 16px; }
}
