/* ============================================================
   Lecture Quiz — DITIB Nürnberg design system
   Brand (ditibnuernberg.de): maroon #911915, crimson #A10F2B,
   dark #222222, warm white. Gold kept as a quiet secondary accent.
   ============================================================ */
:root {
  --bg: #F6F4F1;
  --card: #FFFFFF;
  --card2: #F4F1ED;
  --line: #E4DED8;
  --ink: #222222;
  --muted: #6D6560;
  --petrol: #911915;
  --petrol-2: #A10F2B;
  --teal: #A10F2B;
  --red: #911915;
  --red-2: #6E100D;
  --gold: #C9A227;
  --gold-deep: #8F721A;
  --gold-soft: rgba(201, 162, 39, 0.16);
  --good: #0B8A4C;
  --warn: #D9A514;
  --blue: #2B5FD9;
  --shadow-sm: 0 1px 2px rgba(21, 36, 44, 0.06), 0 2px 10px rgba(21, 36, 44, 0.05);
  --shadow-md: 0 2px 6px rgba(21, 36, 44, 0.07), 0 10px 28px rgba(21, 36, 44, 0.09);
  --shadow-lg: 0 8px 24px rgba(21, 36, 44, 0.14), 0 24px 64px rgba(21, 36, 44, 0.14);
  --radius: 16px;
  --font-ui: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-arabic: "Amiri", "Times New Roman", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background-color: var(--bg);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><g fill='none' stroke='%23911915' stroke-opacity='0.04' stroke-width='1.5'><rect x='54' y='54' width='52' height='52'/><rect x='54' y='54' width='52' height='52' transform='rotate(45 80 80)'/><circle cx='80' cy='80' r='10'/></g></svg>");
  color: var(--ink);
  font: 16px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
}
a, button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: var(--petrol-2); text-decoration: none; }
a:hover { text-decoration: underline; }
b, strong { font-weight: 700; }

/* ---------------- top bar ---------------- */
#topbar {
  display: flex; align-items: center; gap: 16px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 22px 10px;
  background: linear-gradient(180deg, #7E1410 0%, #5C0D0A 100%);
  border-bottom: 2px solid #A10F2B;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 4px 18px rgba(92, 13, 10, 0.25);
}
.brand { font-weight: 800; font-size: 17px; color: #fff; letter-spacing: 0.2px; display: flex; align-items: center; }
.brand:hover { text-decoration: none; }
.brand .ditib-badge {
  background: var(--red); color: #fff; font-size: 11px; font-weight: 800;
  letter-spacing: 1.6px; padding: 3px 9px; border-radius: 7px; margin-left: 10px;
  box-shadow: 0 2px 8px rgba(227, 0, 11, 0.4);
}
#topbar nav { display: flex; gap: 18px; margin-left: 12px; align-items: center; }
#topbar nav a { color: rgba(255, 255, 255, 0.68); font-size: 14px; font-weight: 600; transition: color .15s; }
#topbar nav a.active, #topbar nav a:hover { color: #fff; text-decoration: none; }
.lang-toggle {
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff; font-size: 12px; font-weight: 800; letter-spacing: 1px;
  padding: 5px 11px; border-radius: 8px; min-height: 0; box-shadow: none; cursor: pointer;
}
.lang-toggle:hover { background: rgba(255, 255, 255, 0.22); filter: none; }
.badge {
  margin-left: auto; font-size: 12px; font-weight: 700;
  padding: 4px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.28); color: #DCEBEE;
}
.badge.ok { color: var(--petrol); border-color: #DDB2AC; background: #F7ECEA; }
.badge.warn { color: var(--gold-deep); border-color: #DCC98B; background: #FBF4DC; }
.badge.ditib { background: var(--red); color: #fff; border-color: var(--red); margin-left: 8px; }
/* lecture status badge — default .badge is made for the dark topbar, so
   give it visible light-theme colors here (color-coded per status) */
#st-status { background: var(--card2); border-color: var(--line); color: var(--muted); }
#st-status.status-recording { background: #FDECEE; border-color: #F0C4C4; color: var(--red-2); animation: pulse 1.4s infinite; }
#st-status.status-transcribed { background: #E9F6EF; border-color: #BCE3CF; color: var(--good); }
#st-status.status-quiz_ready { background: #FBF4DC; border-color: #E4D29A; color: var(--gold-deep); }
#st-status.status-live { background: #EAF1FD; border-color: #C3D4F5; color: var(--blue); }
#st-status.status-done { background: var(--card2); border-color: var(--line); color: var(--muted); }
#h-players { background: var(--card2); border-color: var(--line); color: var(--petrol); }

/* ---------------- layout ---------------- */
#view { max-width: 1180px; margin: 0 auto; padding: 26px 22px calc(70px + env(safe-area-inset-bottom, 0px)); }

h1 { font-family: var(--font-display); font-weight: 700; font-size: 30px; letter-spacing: -0.01em; margin: 8px 0 16px; color: var(--petrol); line-height: 1.2; }
h2 { font-size: 16px; margin: 0 0 12px; color: var(--petrol); font-weight: 800; letter-spacing: 0.2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------------- hero ---------------- */
.hero { text-align: center; padding: 10px 0 22px; }
.bismillah {
  font-family: var(--font-arabic);
  font-size: 21px; color: var(--gold-deep); text-align: center;
  margin: 2px 0 8px; letter-spacing: 0.5px;
}

/* ---------------- cards ---------------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.card::before {
  content: ""; position: absolute; top: -1px; left: 22px; right: 22px; height: 3px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, var(--petrol), rgba(145, 25, 21, 0.08));
}
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------------- forms ---------------- */
input, select, textarea {
  background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 11px;
  padding: 10px 13px; font-size: 16px; font-family: inherit;
  outline: none; min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(161, 15, 43, 0.14);
}
input[type="date"] { color-scheme: light; }

/* ---------------- buttons ---------------- */
button {
  background: linear-gradient(135deg, #A10F2B, #7E1410);
  color: #fff; border: 0; border-radius: 12px;
  padding: 11px 20px; font-size: 15px; font-weight: 800; letter-spacing: 0.2px;
  font-family: inherit;
  cursor: pointer; transition: transform .06s ease, filter .15s ease, box-shadow .15s ease;
  min-height: 44px;
  box-shadow: 0 2px 8px rgba(110, 16, 13, 0.25);
}
button:hover { filter: brightness(1.07); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: not-allowed; filter: none; box-shadow: none; }
button:focus-visible { outline: 3px solid rgba(161, 15, 43, 0.35); outline-offset: 2px; }
button.secondary {
  background: #fff; border: 1px solid var(--line); color: var(--petrol);
  box-shadow: var(--shadow-sm);
}
button.secondary:hover { background: #F7ECEA; }
button.danger { background: linear-gradient(135deg, var(--red), var(--red-2)); box-shadow: 0 2px 8px rgba(158, 0, 8, 0.25); }
button.big { padding: 14px 28px; font-size: 16px; border-radius: 14px; }
button.small { min-height: 34px; padding: 6px 13px; font-size: 12.5px; border-radius: 10px; }
button.record {
  background: linear-gradient(135deg, #B41230, #8C0E24);
  box-shadow: 0 4px 16px rgba(140, 14, 36, 0.35);
  letter-spacing: 0.4px;
}
button.record.recording { animation: recGlow 1.5s ease-in-out infinite; }
@keyframes recGlow {
  0%, 100% { box-shadow: 0 4px 16px rgba(140, 14, 36, 0.35); }
  50% { box-shadow: 0 4px 26px rgba(140, 14, 36, 0.65); }
}

/* ---------------- recording ---------------- */
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #C2CCC9; display: inline-block; margin-right: 9px;
  transition: background .2s;
}
.status-dot.live { background: var(--red); animation: pulse 1.2s infinite; box-shadow: 0 0 0 4px rgba(145, 25, 21, 0.18); }
@keyframes pulse { 50% { opacity: 0.35; } }

.live-badge {
  font-size: 11px; font-weight: 800; letter-spacing: 0.3px;
  padding: 3px 10px; border-radius: 999px; margin-left: 10px;
  vertical-align: 2px; white-space: nowrap;
}
.live-badge.ok { color: var(--petrol); background: #F7ECEA; border: 1px solid #DDB2AC; }
.live-badge.warn { color: var(--gold-deep); background: #FBF4DC; border: 1px solid #E4D29A; }

.rec-timer { font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 800; letter-spacing: 1px; color: var(--red); }
.level-meter { height: 8px; background: var(--card2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-top: 14px; }
.level-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--petrol-2), #D98A94);
  transition: width 0.09s linear;
}
.rec-note { font-size: 13px; color: var(--muted); margin: 10px 0 0; font-weight: 500; }
.rec-note b { color: var(--petrol); }
.notice {
  margin-top: 12px; padding: 10px 14px; font-size: 13px; font-weight: 600;
  background: #FBF4DC; border: 1px solid #E4D29A; color: #6B5615; border-radius: 10px;
}
.notice a { color: var(--gold-deep); text-decoration: underline; font-weight: 800; }

/* ---------------- transcript ---------------- */
.transcript-box {
  background: #FDFCFA; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; height: 440px; overflow-y: auto;
  font-size: 14px; line-height: 1.7; white-space: pre-wrap;
}
@media (max-width: 900px) { .transcript-box { height: 320px; } }
.transcript-chip {
  display: inline-block; background: #F7ECEA; border: 1px solid #DDB2AC;
  color: var(--petrol); font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 6px; margin: 0 3px;
}

/* ---------------- quiz questions (review) ---------------- */
.q-card { border-left: 4px solid var(--petrol); }
.q-card .q-num { color: var(--petrol-2); font-weight: 800; font-size: 12px; letter-spacing: 1.5px; }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* editable quiz title */
.title-input {
  flex: 1; min-width: 220px;
  font: 700 27px/1.25 var(--font-display); color: var(--petrol);
  background: transparent; border: 1.5px dashed transparent; border-radius: 12px;
  padding: 6px 12px;
}
.title-input:hover { border-color: var(--line); background: var(--card); }
.title-input:focus { outline: none; border-style: solid; border-color: var(--petrol); background: var(--card); box-shadow: 0 0 0 3px rgba(145, 25, 21, 0.12); }

/* factoid panel */
.factoid-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 13px; margin-top: 8px;
  background: var(--card2); border: 1.5px solid var(--line); border-radius: 12px;
  cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s;
}
.factoid-row:hover { border-color: #CBB9B4; }
.factoid-row.selected { border-color: var(--petrol); background: #F9EFEA; box-shadow: 0 0 0 3px rgba(145, 25, 21, 0.1); }
.factoid-row .factoid-text { flex: 1; font-size: 13.5px; font-weight: 600; }
.factoid-row .f-add { white-space: nowrap; }
.options-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
@media (max-width: 700px) { .options-list { grid-template-columns: 1fr; } }
.option {
  border: 1px solid var(--line); background: var(--card2); border-radius: 11px;
  padding: 10px 13px; font-size: 14px; text-align: left; color: var(--ink); font-weight: 600;
  font-family: inherit; transition: background .15s, border-color .15s;
}
.option:hover { background: #F7ECEA; }
.option.correct { border-color: var(--good); background: rgba(11, 138, 76, 0.08); }
.option .tick { color: var(--good); font-weight: 800; margin-right: 6px; }

/* question edit form */
.q-edit { margin-top: 6px; }
.q-edit textarea, .q-edit input[type=text] {
  width: 100%; font: 600 15px/1.45 var(--font-ui); color: var(--ink);
  background: var(--card); border: 1.5px solid var(--line); border-radius: 11px;
  padding: 10px 12px; margin-bottom: 8px; resize: vertical;
}
.q-edit textarea:focus, .q-edit input[type=text]:focus { outline: none; border-color: var(--petrol); box-shadow: 0 0 0 3px rgba(145, 25, 21, 0.1); }
.q-opt-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.q-opt-row .q-opt-letter {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px;
  background: var(--petrol); color: #fff; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.q-opt-row select {
  font: 600 13px var(--font-ui); color: var(--good); background: var(--card);
  border: 1.5px solid var(--good); border-radius: 8px; padding: 4px 6px; max-width: 150px;
}
.q-edit-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---------------- live quiz board (host) ---------------- */
.host-grid { display: grid; grid-template-columns: 380px 1fr; gap: 16px; }
@media (max-width: 980px) { .host-grid { grid-template-columns: 1fr; } }
.qr-card { text-align: center; }
.qr-card img { width: 100%; max-width: 320px; border-radius: 14px; background: #fff; padding: 12px; border: 2px solid var(--petrol); box-shadow: var(--shadow-sm); }
.code-big { font-family: var(--font-display); font-size: 38px; font-weight: 700; letter-spacing: 12px; margin: 10px 0 2px; color: var(--petrol); text-indent: 12px; }

.host-timer {
  font-variant-numeric: tabular-nums;
  font-size: 26px; font-weight: 800; letter-spacing: 1px;
  color: var(--petrol); line-height: 1;
}
.host-timer.urgent { color: var(--red); animation: pulse 1s infinite; }
.host-timer.up { color: var(--red); }
.h-qbar { margin: 10px 0 0; height: 8px; }
button.cta-pulse { animation: recGlow 1s ease-in-out infinite; }

/* QR card collapses to a compact players card while the game is running */
.qr-card.mini { padding: 14px 16px; }
.qr-card.mini .qr-big-only { display: none; }
.qr-card.mini h2 { margin-bottom: 8px; }
.qr-card.mini .participant-list { max-height: 420px; }

/* ---------------- presenter mode (fullscreen, PowerPoint-style) ---------------- */
.h-qtext { font-size: 20px; font-weight: 700; margin: 0 0 16px; line-height: 1.35; }
.h-qtext-sm { font-size: 18px; font-weight: 600; margin: 10px 0 14px; }
body.presenting #topbar { display: none; }
body.presenting #view { max-width: none; padding: 26px 4vw; }
body.presenting .host-top .back { display: none; }
body.presenting .host-grid { grid-template-columns: 1fr; gap: 0; }
body.presenting .qr-card { display: none; }
body.presenting #h-game { padding: 36px 44px; margin-bottom: 0; }
body.presenting #h-game h2 { font-size: 24px; }
body.presenting .h-qtext { font-size: clamp(28px, 3.6vw, 46px); }
body.presenting .h-qtext-sm { font-size: clamp(22px, 2.6vw, 34px); }
body.presenting .live-option { font-size: clamp(18px, 1.9vw, 27px); padding: 20px 28px; margin-bottom: 14px; border-radius: 16px; }
body.presenting .live-option .pct { font-size: 1.05em; }
body.presenting .host-timer { font-size: clamp(42px, 4.6vw, 68px); }
body.presenting .h-qbar { height: 10px; }
body.presenting #h-game p.small { font-size: 18px; }
body.presenting #h-game button { font-size: 18px; padding: 14px 28px; }
body.presenting .lobby-wait { padding: 9vh 16px; }
body.presenting .lobby-wait h1 { font-size: 42px; }
body.presenting .lobby-wait p { font-size: 20px; }
/* listener screen: no top bar, no navigation */
body.player-mode #topbar { display: none; }
/* live standings — hidden in normal mode (side card covers it),
   visible in presenter fullscreen where the side card is hidden */
.present-standings { display: none; }
body.presenting .present-standings {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line);
}
.stand-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: clamp(14px, 1.25vw, 19px); font-weight: 700;
  background: var(--card2); border: 1px solid var(--line);
  padding: 8px 15px; border-radius: 999px;
}
.stand-pill .rank { color: var(--muted); font-weight: 800; }
.stand-pill .pts { color: var(--petrol); font-variant-numeric: tabular-nums; }
.stand-pill .gain { color: var(--good); font-weight: 800; font-variant-numeric: tabular-nums; }
.stand-pill.first { background: var(--gold-soft); border-color: #DCC98B; }

.live-option {
  position: relative; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 10px; background: #fff;
  overflow: hidden; font-size: 15px; font-weight: 700; box-shadow: var(--shadow-sm);
}
.live-option .fill {
  position: absolute; inset: 0 auto 0 0; opacity: 0.18; width: 0%;
  transition: width 0.4s ease;
}
.live-option.o0 .fill { background: var(--blue); }
.live-option.o1 .fill { background: var(--red); }
.live-option.o2 .fill { background: var(--warn); }
.live-option.o3 .fill { background: var(--good); }
.live-option .pct { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-weight: 800; }
.live-option.reveal-correct { border-color: var(--good); box-shadow: 0 0 0 2px rgba(11, 138, 76, 0.4); }
.live-option.reveal-wrong { opacity: 0.45; }

.participant-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 260px; overflow-y: auto; text-align: left; }
.participant-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.participant-list li:last-child { border-bottom: 0; }
.pname { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.pname span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #C2CCC9; flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px rgba(11, 138, 76, 0.15); }
.streak-pill {
  font-size: 11px; font-weight: 800; color: var(--gold-deep);
  background: var(--gold-soft); border: 1px solid rgba(201, 162, 39, 0.4);
  padding: 1px 8px; border-radius: 999px; flex: none;
}
.pscore { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); flex: none; }
.kick-btn {
  flex: none; min-height: 26px; padding: 2px 10px; font-size: 11px; font-weight: 800;
  border-radius: 8px; background: #fff; border: 1px solid #F0C4C4; color: var(--red-2);
  box-shadow: none;
}
.kick-btn:hover { background: #FDECEE; filter: none; }

/* ---------------- leaderboard ---------------- */
table.lb { width: 100%; border-collapse: collapse; font-size: 14px; }
table.lb th {
  color: var(--muted); text-align: left; font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1.2px;
  padding: 8px 10px; border-bottom: 2px solid var(--petrol);
}
table.lb td { padding: 10px; border-bottom: 1px solid var(--line); }
table.lb tbody tr { transition: background .12s; }
table.lb tbody tr:hover { background: #F8F2EF; }
table.lb tr.me td { background: rgba(145, 25, 21, 0.07); font-weight: 700; }
table.lb tr.top1 td { background: var(--gold-soft); }
.rank-medal { font-size: 17px; }

/* ---------------- player screen ---------------- */
.player-screen { max-width: 720px; margin: 0 auto; }
.name-box { text-align: center; padding: 44px 24px; }
.name-box input { font-size: 18px; font-weight: 600; text-align: center; width: 280px; max-width: 100%; padding: 13px; }
.name-fields { display: flex; gap: 10px; justify-content: center; margin: 0 auto 16px; max-width: 420px; }
.name-fields input { flex: 1; width: auto; min-width: 0; }
.lobby-wait { text-align: center; padding: 48px 16px; }
.lobby-crest { margin-bottom: 6px; filter: drop-shadow(0 4px 10px rgba(161, 15, 43, 0.35)); }

.timer-wrap { height: 12px; background: var(--card2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 18px; box-shadow: inset 0 1px 3px rgba(21, 36, 44, 0.08); }
.timer-bar {
  height: 100%; width: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--red));
  box-shadow: 0 0 12px rgba(145, 25, 21, 0.35);
}

.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .answer-grid { gap: 10px; } }
.answer-btn {
  border: 0; border-radius: 18px; min-height: 118px;
  font-size: 16px; font-weight: 800; color: #fff; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 14px 14px 16px; cursor: pointer;
  transition: transform .06s ease, filter .15s ease;
  box-shadow: 0 10px 26px rgba(21, 36, 44, 0.3);
  line-height: 1.3;
}
.answer-btn .ab-top { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.answer-btn .ab-shape { font-size: 20px; line-height: 1; opacity: 0.95; }
.answer-btn .ab-letter {
  font-size: 12px; font-weight: 800; letter-spacing: 1px;
  background: rgba(255, 255, 255, 0.22); border-radius: 7px; padding: 2px 8px;
}
.answer-btn:active { transform: scale(0.97); }
.answer-btn.a0 { background: linear-gradient(160deg, #3E71E8, #2449B8); }
.answer-btn.a1 { background: linear-gradient(160deg, #B41230, #8C0E24); }
.answer-btn.a2 { background: linear-gradient(160deg, #EFB100, #D18F00); color: #241A00; }
.answer-btn.a2 .ab-letter { background: rgba(0, 0, 0, 0.14); }
.answer-btn.a3 { background: linear-gradient(160deg, #17A35D, #0A7A43); }
.answer-btn:disabled { cursor: default; }
.answer-btn.picked { outline: 4px solid #fff; }
.answer-btn.dimmer { filter: brightness(0.5); }
.answer-btn.show-correct { outline: 5px solid #fff; animation: bounce .5s ease; }
.answer-btn.show-wrong { filter: brightness(0.32); }
@keyframes bounce { 30% { transform: scale(1.05); } }

.gain-banner {
  text-align: center; font-size: 22px; font-weight: 800; margin: 14px 0;
  color: var(--petrol); font-family: var(--font-display);
}

/* ---------------- QR presentation ---------------- */
.qr-present {
  background: radial-gradient(130% 130% at 50% 0%, #7E1410 0%, #330604 68%);
  z-index: 300;
}
.qr-present-card {
  color: #fff; text-align: center; max-width: 92vw;
  display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 26px 16px;
}
.qr-present-kicker { font-size: 18px; font-weight: 700; color: #E3B8B2; letter-spacing: 0.3px; }
.qr-present-code {
  font-family: var(--font-display); font-weight: 700;
  font-size: min(22vw, 88px); letter-spacing: 0.32em; text-indent: 0.32em; line-height: 1;
  color: #fff; text-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}
.qr-present-frame {
  background: #fff; padding: 16px; border-radius: 24px;
  border: 4px solid var(--gold);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.3), 0 24px 70px rgba(0, 0, 0, 0.5);
}
.qr-present-frame img { display: block; width: min(74vw, 430px); height: auto; }
.qr-present-url { color: #DCAFA8; font-size: 14px; word-break: break-all; font-weight: 600; }
.qr-present-hint { color: rgba(255, 255, 255, 0.85); font-size: 15px; font-weight: 600; }

/* ---------------- overlay / modal ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(246, 244, 241, 0.82); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
}
.overlay-card, .modal-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px;
  padding: 36px 42px; text-align: center; max-width: 90vw;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.overlay-card::before, .modal-card::before {
  content: ""; position: absolute; top: -1px; left: 30px; right: 30px; height: 4px;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(90deg, var(--petrol), rgba(145, 25, 21, 0.12));
}
.modal-card { max-width: 640px; text-align: left; max-height: min(86vh, 86dvh); overflow-y: auto; }
.modal-card textarea { width: 100%; min-height: 240px; font-size: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 16px;
  border: 4px solid var(--card2); border-top-color: var(--teal);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.overlay-text { font-size: 16px; font-weight: 700; color: var(--petrol); }

/* ---------------- confetti ---------------- */
.confetti-piece {
  position: fixed; top: -12px; width: 9px; height: 14px; z-index: 99;
  animation: fall linear forwards; pointer-events: none;
  border-radius: 2px;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: 0.6; }
}

/* ---------------- toast ---------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--petrol); color: #fff; border: 1px solid #A10F2B;
  padding: 13px 22px; border-radius: 13px; z-index: 200; font-weight: 700; font-size: 14px;
  box-shadow: var(--shadow-lg); max-width: 92vw;
}
.toast.err { background: #FDECEE; color: #8F0812; border-color: var(--red); }
.terr { background: #FDECEE; border: 1px solid var(--red); color: #8F0812; border-radius: 10px; padding: 8px 12px; }

/* ---------------- misc ---------------- */
.progress-outer { height: 8px; background: var(--card2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress-inner { height: 100%; width: 0%; background: linear-gradient(90deg, var(--petrol), var(--petrol-2)); transition: width .3s; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; font-weight: 500; }
.kv:last-child { border-bottom: 0; }

/* ============================================================
   Mobile (phones)
   ============================================================ */
table.lb { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
.row h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 700px) {
  #topbar { gap: 10px; padding-left: 14px; padding-right: 14px; }
  .brand { font-size: 15px; }
  .brand svg { width: 24px; height: 24px; margin-right: 7px; }
  .brand .ditib-badge { margin-left: 7px; padding: 2px 6px; font-size: 10px; }
  #topbar nav { gap: 12px; }
  #topbar nav a { font-size: 13px; }

  #view { padding: 16px 13px calc(56px + env(safe-area-inset-bottom, 0px)); }
   h1 { font-size: 23px; margin: 6px 0 12px; }
   h2 { font-size: 15px; }
   .hero { padding-bottom: 14px; }
   .bismillah { font-size: 18px; }
  .card { padding: 15px; margin-bottom: 13px; }
  .row { gap: 8px; }
  .grid-2 { gap: 13px; }

  button { font-size: 14px; padding: 11px 15px; }
  button.big { font-size: 15px; padding: 13px 20px; }
  input, select, textarea { padding: 11px 12px; }

  .code-big { font-size: 32px; letter-spacing: 8px; text-indent: 8px; }
  .rec-timer { font-size: 22px; }
  .level-meter { margin-top: 10px; }
  .transcript-box { height: 330px; }
  .option { font-size: 14px; }
  .live-option { font-size: 14px; padding: 10px 12px; }
  .participant-list li { font-size: 13px; }
  .kv { font-size: 13px; }
  .gain-banner { font-size: 19px; }

  .answer-grid { gap: 10px; }
  .answer-btn { min-height: 100px; font-size: 14px; border-radius: 14px; padding: 12px 10px 14px; }
  .timer-wrap { margin-bottom: 14px; }

  table.lb { font-size: 13px; }
  table.lb th, table.lb td { padding: 8px; }

  .overlay-card, .modal-card { padding: 26px 18px; }
  .toast { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 20px); }

  .qr-present-card { gap: 13px; padding: 18px 12px; }
  .qr-present-kicker { font-size: 15px; }
  .qr-present-frame { padding: 11px; border-radius: 18px; }
  .qr-present-frame img { width: min(82vw, 380px); }
  .qr-present-code { font-size: min(16vh, 56px); }

  /* studio (lecture) page */
  #st-title { flex: 1 1 100%; order: 3; }
  #st-status { margin-left: auto; }
  #del-btn { padding: 10px 13px; }
  #rec-btn { flex: 1; }
  #rec-timer { margin-left: auto; padding-right: 2px; }
  .up-label {
    flex-direction: column; align-items: stretch; gap: 6px;
    padding: 13px; border: 1px dashed var(--line); border-radius: 12px; background: var(--card2);
  }
  .up-label input[type="file"] { width: 100%; padding: 10px; font-size: 14px; }
  #gen-btn { width: 100%; }
  .transcript-box { height: 280px; }
  #st-terr { margin-top: 10px; }
}

/* landscape phone: compact vertical rhythm */
@media (orientation: landscape) and (max-height: 560px) {
   #view { padding-top: 10px; }
   h1 { font-size: 18px; margin: 2px 0 8px; }
   .card { padding: 11px 13px; margin-bottom: 9px; }
  .lobby-wait, .name-box { padding: 20px 10px; }
  .answer-btn { min-height: 80px; }
  .transcript-box { height: 44vh; }
  .qr-present-frame img { width: min(40vh, 320px); }
  .qr-present-code { font-size: min(16vh, 56px); }
  .host-grid { gap: 10px; }
}
