:root {
  --bg: #0C447C;
  --card-bg: #ffffff;
  --accent: #E87A00;
  --accent2: #2FA84F;
  --danger: #E24B4A;
  --text-dark: #1a2a3a;
  --text-mid: #4a5568;
  --text-light: #718096;
  --blue-panel: #E6F1FB;
  --blue-border: #378ADD;
  --green-panel: #EAF3DE;
  --green-border: #639922;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.13);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  font-family: 'Georgia', 'Times New Roman', serif;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}
.floating-symbols {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; overflow: hidden;
}
.sym {
  position: absolute;
  color: rgba(255,255,255,0.06);
  font-size: 3rem;
  font-family: 'Georgia', serif;
  animation: floatSym 18s linear infinite;
  user-select: none;
}
@keyframes floatSym {
  0% { transform: translateY(110vh) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}
.page-wrap {
  position: relative; z-index: 1;
  max-width: 820px; margin: 0 auto;
  padding: 2rem 1rem 4rem;
}
.site-header { text-align: center; padding: 2rem 0 1.5rem; }
.site-header .logo-text { font-size: 2rem; font-weight: 700; color: #fff; font-family: 'Georgia', serif; }
.site-header .logo-text span { color: var(--accent); }
.site-header .sub { color: rgba(255,255,255,0.7); font-size: 0.9rem; margin-top: 4px; font-family: Arial, sans-serif; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.login-title { font-size: 1.5rem; color: var(--text-dark); margin-bottom: 0.5rem; }
.login-sub { color: var(--text-mid); font-size: 0.9rem; font-family: Arial, sans-serif; margin-bottom: 1.5rem; }
.quiz-meta { background: #f0f6ff; border-radius: 8px; padding: 1rem; margin-bottom: 1.5rem; font-family: Arial, sans-serif; font-size: 0.85rem; color: var(--text-mid); }
.quiz-meta strong { color: var(--text-dark); }
.input-label { font-size: 0.85rem; color: var(--text-mid); font-family: Arial, sans-serif; margin-bottom: 6px; display: block; }
.name-input {
  width: 100%; padding: 12px 16px;
  border: 2px solid #e2e8f0; border-radius: 8px;
  font-size: 1rem; font-family: Arial, sans-serif;
  outline: none; transition: border-color 0.2s;
}
.name-input:focus { border-color: var(--bg); }
.btn-start {
  display: block; width: 100%; margin-top: 1rem;
  padding: 14px; background: var(--bg);
  color: #fff; border: none; border-radius: 8px;
  font-size: 1rem; font-family: Arial, sans-serif;
  font-weight: 700; cursor: pointer; transition: background 0.2s;
}
.btn-start:hover { background: #0a3a6a; }

.progress-bar-wrap {
  background: rgba(255,255,255,0.15);
  border-radius: 999px; height: 8px;
  margin-bottom: 1.2rem; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--accent);
  border-radius: 999px; transition: width 0.4s ease;
}
.progress-label { font-family: Arial, sans-serif; font-size: 0.8rem; color: rgba(255,255,255,0.8); text-align: right; margin-bottom: 4px; }

.q-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.q-badge { background: var(--bg); color: #fff; font-family: Arial, sans-serif; font-size: 0.75rem; padding: 4px 10px; border-radius: 999px; font-weight: 700; }
.q-topic { font-family: Arial, sans-serif; font-size: 0.78rem; color: var(--text-light); margin-bottom: 0.8rem; }
.q-text { font-size: 1rem; color: var(--text-dark); line-height: 1.7; margin-bottom: 1.2rem; }

.q-diagram { display: flex; justify-content: center; margin-bottom: 1.2rem; }
.q-diagram svg { max-width: 100%; height: auto; }

.options-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.opt-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left; padding: 13px 16px;
  border: 2px solid #e2e8f0; border-radius: 8px;
  background: #fff; cursor: pointer;
  font-family: Arial, sans-serif; font-size: 0.92rem; color: var(--text-dark);
  transition: border-color 0.15s, background 0.15s; line-height: 1.5;
}
.opt-btn:hover:not(:disabled) { border-color: var(--bg); background: #f0f6ff; }
.opt-btn .opt-letter {
  min-width: 28px; height: 28px; border-radius: 50%;
  background: #f0f4f8; color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}
.opt-btn.correct { border-color: var(--accent2); background: #f0faf5; }
.opt-btn.correct .opt-letter { background: var(--accent2); color: #fff; }
.opt-btn.wrong { border-color: var(--danger); background: #fff5f5; }
.opt-btn.wrong .opt-letter { background: var(--danger); color: #fff; }
.opt-btn:disabled { cursor: default; }

.feedback-banner {
  margin-top: 1rem; padding: 10px 14px; border-radius: 8px;
  font-family: Arial, sans-serif; font-size: 0.9rem; font-weight: 600;
}
.feedback-banner.correct-fb { background: #f0faf5; color: #27C07A; border: 1.5px solid #27C07A; }
.feedback-banner.wrong-fb { background: #fff5f5; color: #E24B4A; border: 1.5px solid #E24B4A; }

.workings {
  margin-top: 1.2rem;
  background: var(--blue-panel); border: 1.5px solid var(--blue-border);
  border-radius: 10px; padding: 1.2rem 1.4rem;
}
.workings-title {
  font-family: Arial, sans-serif; font-size: 0.78rem; font-weight: 700;
  color: #185FA5; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 0.8rem;
}
.step {
  font-family: Arial, sans-serif; font-size: 0.88rem; color: var(--text-dark);
  padding: 4px 0; border-bottom: 1px solid rgba(55,138,221,0.15); line-height: 1.7;
}
.step:last-of-type { border-bottom: none; }
.final {
  margin-top: 0.8rem; background: var(--green-panel);
  border: 1.5px solid var(--green-border); border-radius: 8px;
  padding: 0.7rem 1rem; font-family: Arial, sans-serif;
  font-size: 0.9rem; font-weight: 700; color: #27500A;
}

.q-nav { display: flex; justify-content: flex-end; gap: 10px; margin-top: 1.4rem; }
.btn-next {
  padding: 11px 28px; background: var(--bg); color: #fff; border: none;
  border-radius: 8px; font-family: Arial, sans-serif; font-size: 0.92rem;
  font-weight: 700; cursor: pointer; transition: background 0.2s;
}
.btn-next:hover { background: #0a3a6a; }
.btn-next:disabled { background: #a0aec0; cursor: default; }

#results-screen { animation: fadeIn 0.5s ease; }
.results-header { text-align: center; margin-bottom: 1.5rem; }
.results-score-big { font-size: 3.5rem; font-weight: 700; color: var(--bg); line-height: 1; }
.results-pct { font-size: 1.1rem; color: var(--text-mid); font-family: Arial, sans-serif; }
.results-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 1.5rem 0; }
.stat-box { background: #f8fafc; border-radius: 10px; padding: 1rem; text-align: center; }
.stat-box .val { font-size: 1.6rem; font-weight: 700; color: var(--bg); }
.stat-box .lbl { font-family: Arial, sans-serif; font-size: 0.78rem; color: var(--text-light); margin-top: 2px; }
.guest-prompt {
  background: #FFF8E1; border: 1.5px solid #F5A623; border-radius: 8px;
  padding: 1rem; font-family: Arial, sans-serif; font-size: 0.88rem;
  color: #7a5a00; margin-top: 1rem;
}
.guest-prompt a { color: var(--bg); font-weight: 700; }
.btn-try-again {
  display: block; width: 100%; margin-top: 0.8rem; padding: 13px;
  background: #f0f4f8; color: var(--text-dark); border: 2px solid #e2e8f0;
  border-radius: 8px; font-family: Arial, sans-serif; font-size: 0.95rem;
  font-weight: 700; cursor: pointer; text-align: center; text-decoration: none;
}
.btn-try-again:hover { background: #e2e8f0; }

.btn-review {
  display: block; width: 100%; margin-top: 0.8rem; padding: 13px;
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; font-family: Arial, sans-serif; font-size: 0.95rem;
  font-weight: 700; cursor: pointer; text-align: center;
}
.btn-review:hover { background: #d06d00; }

.next-card { border-radius: 12px; padding: 14px 16px; text-align: left; margin: 0.4rem 0 1rem; }
.next-card.study { background: #fdf3e7; border: 1px solid #f0c98a; }
.next-card.review { background: #E6F1FB; border: 1px solid #b9d3ef; }
.next-card.advance { background: #EAF3DE; border: 1px solid #a9dcbd; }
.next-head { font-weight: 800; font-size: 1rem; color: var(--text-dark); margin-bottom: 3px; font-family: Arial, sans-serif; }
.next-sub { font-size: 0.85rem; color: var(--text-mid); line-height: 1.45; margin-bottom: 10px; font-family: Arial, sans-serif; }
.next-cta { display: inline-block; background: var(--bg); color: #fff; text-decoration: none; font-weight: 700; font-size: 0.85rem; padding: 9px 15px; border-radius: 8px; border: none; cursor: pointer; font-family: Arial, sans-serif; }
.next-card.study .next-cta { background: var(--accent); }
.next-card.advance .next-cta { background: var(--accent2); }
.next-cta:hover { opacity: .92; }
.review-summary { font-size: 1rem; font-weight: 700; color: var(--bg); margin-bottom: 1rem; font-family: Arial, sans-serif; }
.review-item { border: 1px solid #e3e9f2; border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; background: #fff; }
.review-item.correct { border-color: #bfe6cd; background: #f6fcf8; }
.review-item.wrong   { border-color: #f3c9c9; background: #fdf6f6; }
.review-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.review-topic { font-family: Arial, sans-serif; font-size: 0.74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-light); }
.review-badge { font-size: 0.74rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; white-space: nowrap; color: #fff; font-family: Arial, sans-serif; }
.review-badge.ok { background: var(--accent2); }
.review-badge.no { background: var(--danger); }
.review-q { font-size: 0.98rem; color: var(--text-dark); margin-bottom: 10px; font-weight: 600; line-height: 1.5; }
.review-opt { padding: 7px 11px; border-radius: 8px; margin: 4px 0; border: 1px solid #e3e9f2; color: var(--text-dark); font-size: 0.9rem; }
.review-opt.opt-correct { background: #f0faf5; border-color: var(--accent2); font-weight: 700; }
.review-opt.opt-wrong   { background: #fff5f5; border-color: var(--danger); }
.review-opt .marker { font-weight: 700; margin-right: 6px; }
.review-sol { margin-top: 10px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
#ding { display: none; }
@media (max-width: 600px) { .results-stats { grid-template-columns: 1fr 1fr; } .card { padding: 1.3rem; } }

#calcFAB {
  position: fixed; bottom: 20px; right: 18px; z-index: 8888;
  border: none; cursor: pointer; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: transparent; -webkit-tap-highlight-color: transparent;
  transition: transform .12s; filter: drop-shadow(0 4px 14px rgba(0,0,0,.45));
}
#calcFAB:active { transform: scale(.88); }
#calcFAB .fab-icon { width: 56px; height: 56px; border-radius: 13px; overflow: hidden; display: block; }
#calcFAB .fab-label { font-family: -apple-system,"SF Pro Text","Segoe UI",Arial,sans-serif; font-size: 11px; font-weight: 500; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.65); letter-spacing: .1px; line-height: 1; }
#calcModal { position: fixed; inset: 0; z-index: 9999; background: rgba(6,20,50,.82); display: none; align-items: center; justify-content: center; }
#calcModal.open { display: flex; }
#calcClose { position: fixed; top: 10px; right: 14px; z-index: 10001; width: 36px; height: 36px; border-radius: 50%; border: none; background: rgba(255,255,255,.2); color: #fff; font-size: 1.05rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
#calcModal { --blue:#0C447C;--orange:#F5A623;--shift:#f0b429;--alpha:#e25b78; --body1:#3a3f47;--body2:#23272d;--bezel1:#cfd3d1;--bezel2:#a7aca8; --lcd1:#c4cbb6;--lcd2:#b6bda6;--lcdink:#16190f; --keydk1:#41464e;--keydk2:#2c3037;--keyline:#1a1d22; --pad:#4a3f7a;--pad2:#3a3162; }
#calcModal .fitwrap { transform-origin: top left; }
#calcModal .device { position: relative; z-index: 1; width: 360px; background: linear-gradient(170deg,var(--body1),var(--body2)); border-radius: 22px; padding: 9px 9px 11px; box-shadow: 0 24px 56px rgba(0,0,0,.45),inset 0 1px 0 rgba(255,255,255,.08); border: 1px solid #16191e; font-family: "Segoe UI",system-ui,-apple-system,sans-serif; color: #fff; }
#calcModal .brandrow { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 5px; color: #aeb4bd; }
#calcModal .brandrow .mm { font-family: "Playfair Display",serif; font-weight: 800; font-size: .88rem; color: #e9edf2; letter-spacing: .3px; }
#calcModal .brandrow .model { font-size: .54rem; letter-spacing: .8px; color: #8a909a; }
#calcModal .bezel { background: linear-gradient(160deg,var(--bezel1),var(--bezel2)); border-radius: 10px; padding: 6px; box-shadow: inset 0 2px 6px rgba(0,0,0,.35),0 1px 0 rgba(255,255,255,.15); }
#calcModal .lcd { background: repeating-linear-gradient(0deg,rgba(0,0,0,.05) 0 1px,transparent 1px 7px),repeating-linear-gradient(90deg,rgba(0,0,0,.05) 0 1px,transparent 1px 7px),linear-gradient(180deg,var(--lcd1),var(--lcd2)); color: var(--lcdink); border-radius: 5px; padding: 6px 8px; height: 92px; display: flex; flex-direction: column; box-shadow: inset 0 1px 3px rgba(0,0,0,.3); font-family: "Cambria Math","Times New Roman",Georgia,serif; overflow: hidden; position: relative; }
#calcModal .lcd-status { display: flex; justify-content: space-between; align-items: center; font-family: "Segoe UI",sans-serif; font-size: .6rem; font-weight: 700; letter-spacing: .5px; color: #2a2f1f; height: 13px; }
#calcModal .lcd-status .left { display: flex; gap: 6px; align-items: center; }
#calcModal .lcd-status .ind { opacity: .25; }
#calcModal .lcd-status .ind.on { opacity: 1; }
#calcModal .lcd-status .modetag { cursor: pointer; user-select: none; }
#calcModal .lcd-expr { flex: 1; display: flex; align-items: center; overflow-x: auto; overflow-y: hidden; font-size: 1.1rem; line-height: 1.12; padding-top: 1px; white-space: nowrap; }
#calcModal .lcd-expr::-webkit-scrollbar { height: 0; }
#calcModal .lcd-ans { height: 32px; display: flex; align-items: center; justify-content: flex-end; font-size: 1.2rem; font-weight: 500; overflow-x: auto; overflow-y: hidden; white-space: nowrap; }
#calcModal .lcd-ans::-webkit-scrollbar { height: 0; }
#calcModal .lcd-ans .frac { font-size: .62em; }
#calcModal .mlist { display: inline-flex; align-items: center; }
#calcModal .matom { display: inline-block; }
#calcModal .sqrt { display: inline-flex; align-items: flex-start; margin: 0 1px; }
#calcModal .sqrt .radsym { font-size: 1.25em; line-height: .9; transform: translateY(-1px); }
#calcModal .sqrt .radbody { border-top: 1.6px solid currentColor; padding: 1px 4px 0 2px; margin-top: 2px; }
#calcModal .sqrt .radindex { font-size: .55em; align-self: flex-start; margin-right: -3px; margin-top: -1px; }
#calcModal .msup { font-size: .7em; vertical-align: super; margin-left: 1px; }
#calcModal .field { display: inline-flex; align-items: center; justify-content: center; min-width: .55em; min-height: 1em; }
#calcModal .ebox { display: inline-block; width: .62em; height: .92em; border: 1.3px dashed rgba(20,25,15,.55); border-radius: 2px; vertical-align: middle; }
#calcModal .caret { display: inline-block; width: 2px; height: 1.05em; background: var(--lcdink); vertical-align: -0.16em; margin: 0 -1px; animation: blink 1.05s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
#calcModal .topcluster { display: grid; grid-template-columns: 1fr 1fr 64px 1fr 1fr; gap: 6px; align-items: center; margin: 8px 2px 6px; }
#calcModal .pill { border: none; border-radius: 8px; padding: 6px 0; font-size: .64rem; font-weight: 700; cursor: pointer; color: #1c1f24; font-family: inherit; letter-spacing: .4px; background: linear-gradient(180deg,#e6e9d0,#d0d4b8); box-shadow: 0 2px 3px rgba(0,0,0,.3); }
#calcModal .pill.shiftbtn { background: linear-gradient(180deg,#f7c948,#e6a817); color: #3a2b00; }
#calcModal .pill.alphabtn { background: linear-gradient(180deg,#ef7a93,#d8506e); color: #43101f; }
#calcModal .pill.dark { background: linear-gradient(180deg,var(--keydk1),var(--keydk2)); color: #e7ebf0; border: 1px solid var(--keyline); }
#calcModal .pill.active { outline: 2px solid #fff; outline-offset: 1px; }
#calcModal .pad { position: relative; width: 64px; height: 64px; border-radius: 50%; justify-self: center; background: radial-gradient(circle at 35% 30%,#5b4f93,var(--pad) 55%,var(--pad2)); box-shadow: 0 4px 10px rgba(0,0,0,.4),inset 0 2px 4px rgba(255,255,255,.18); }
#calcModal .pad .hub { position: absolute; inset: 21px; border-radius: 50%; background: radial-gradient(circle at 40% 35%,#6155a0,#473c7c); display: flex; align-items: center; justify-content: center; font-size: .32rem; color: #cdc7e8; font-weight: 700; letter-spacing: .2px; box-shadow: inset 0 1px 3px rgba(0,0,0,.4); }
#calcModal .pad button { position: absolute; border: none; background: transparent; color: #efeaff; font-size: .62rem; cursor: pointer; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
#calcModal .pad .up { top: 0; left: 21px; } #calcModal .pad .down { bottom: 0; left: 21px; }
#calcModal .pad .left { left: 0; top: 21px; } #calcModal .pad .right { right: 0; top: 21px; }
#calcModal .pad button:active { color: #fff; transform: scale(.85); }
#calcModal .grid { display: grid; gap: 5px; margin: 0 2px; }
#calcModal .grid.func { grid-template-columns: repeat(6,1fr); }
#calcModal .grid.num { grid-template-columns: repeat(5,1fr); margin-top: 5px; }
#calcModal .keywrap { display: flex; flex-direction: column; align-items: center; }
#calcModal .label { height: 9px; font-size: .46rem; font-weight: 700; line-height: 1; display: flex; gap: 4px; justify-content: center; width: 100%; margin-bottom: 2px; letter-spacing: .1px; }
#calcModal .label .s { color: var(--shift); }
#calcModal .label .a { color: var(--alpha); }
#calcModal .key { width: 100%; border: 1px solid var(--keyline); border-radius: 8px; cursor: pointer; background: linear-gradient(180deg,var(--keydk1),var(--keydk2)); color: #eef1f5; font-family: inherit; font-weight: 600; padding: 5px 0; font-size: .74rem; box-shadow: 0 2px 0 #15181d,0 3px 5px rgba(0,0,0,.3); transition: transform .06s,box-shadow .06s; line-height: 1.05; }
#calcModal .grid.num .key { padding: 7px 0; font-size: .92rem; border-radius: 8px; }
#calcModal .key:active { transform: translateY(2px); box-shadow: 0 0 0 #15181d,0 1px 2px rgba(0,0,0,.3); }
#calcModal .key.lite { background: linear-gradient(180deg,#5a6069,#454b54); }
#calcModal .key.num { background: linear-gradient(180deg,#52585f,#3c424a); font-weight: 700; }
#calcModal .key.orange { background: linear-gradient(180deg,#ffb648,#ef9213); color: #3a2400; box-shadow: 0 2px 0 #b96d00,0 3px 5px rgba(0,0,0,.3); }
#calcModal .key.orange:active { box-shadow: 0 0 0 #b96d00; }
#calcModal .key sup { font-size: .6em; } #calcModal .key sub { font-size: .6em; }
#calcModal .key .frico { display: inline-flex; flex-direction: column; line-height: .7; font-size: .7em; }
#calcModal .key .frico .t { border-bottom: 1.4px solid currentColor; padding-bottom: 1px; }

/* NEED A TUTOR? - the standing Maths Maestri closing ask ---------------------
   Same navy/gold shapes as the lesson-video outro so the two surfaces read as
   one brand. Rendered once by quiz-engine.js; never pasted into a quiz file. */
.tutor-cta {
  margin-top: 1.2rem; padding: 1.3rem 1.1rem;
  background: #0A1A33; border: 2px solid #F4C430;
  border-radius: var(--radius); text-align: center;
}
.tutor-cta h3 {
  font-family: Arial, sans-serif; font-size: 1.15rem; font-weight: 700;
  letter-spacing: 0.04em; color: #F4C430; margin-bottom: 0.4rem;
}
.tutor-cta p {
  font-family: Arial, sans-serif; font-size: 0.9rem; line-height: 1.5;
  color: #E9F1FC; margin-bottom: 1rem;
}
.tutor-cta .wa {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 48px; padding: 12px 14px;      /* >= 44px touch target */
  background: #F4C430; color: #0A1A33; border-radius: 10px;
  font-family: Arial, sans-serif; font-weight: 700; font-size: 1.05rem;
  text-decoration: none; min-width: 0;
}
.tutor-cta .wa:hover { background: #FFD54A; }
.tutor-cta .wa svg { width: 20px; height: 20px; flex: none; }
.tutor-cta .wa span { min-width: 0; }   /* flex item must be allowed to shrink */
/* The label may wrap on a 320px phone, but the NUMBER must never split across
   lines - "081" on one line and "437 2577" on the next is unreadable and
   untappable. Caught by screenshotting at 320px; no gate would have flagged it. */
.tutor-cta .wa .num { white-space: nowrap; font-weight: 700; }
.tutor-cta .site {
  display: inline-block; margin-top: 0.75rem;
  font-family: Arial, sans-serif; font-size: 0.82rem;
  color: #C3D4EA; text-decoration: none; word-break: break-word;
}
.tutor-cta .site:hover { color: #FFFFFF; text-decoration: underline; }
@media (max-width: 380px) {
  .tutor-cta { padding: 1.1rem 0.85rem; }
  .tutor-cta .wa { font-size: 0.95rem; gap: 0.4rem; }
}
