/* =========================================================================
   A1 ARENA — mobile-first stylesheet, no external dependencies
   ========================================================================= */
:root {
  --bg: #06120d;
  --bg2: #0a1a13;
  --card: #0e2118;
  --card2: #12291f;
  --line: #1d3b2c;
  --ink: #eaf6ef;
  --ink2: #a8c4b4;
  --ink3: #8aa89a;
  --green: #22c55e;
  --green-d: #16a34a;
  --gold: #fbbf24;
  --red: #ef4444;
  --blue: #38bdf8;
  --violet: #a78bfa;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
  --tab-h: 62px;

  /* ---------------------------------------------------------------------
     READING SURFACES

     These were missing. Every rule that wanted a slightly raised panel
     inside a card wrote `var(--soft, #f7f9fc)` — and because --soft was
     never defined anywhere, the fallback won every time. #f7f9fc is almost
     white, and the body text on it is --ink, which is also almost white.
     So Key terms, Worked example, In the exam and the whole literature
     shelf rendered as white on white: there, selectable, and invisible.

     Defining them here fixes every one of those rules at once. Anything
     that needs a raised panel uses --soft; nothing hard-codes a colour.
     --------------------------------------------------------------------- */
  --soft: #12291f;          /* raised panel inside a card */
  --soft2: #0a1c14;         /* recessed panel: quotations, extracts */
  --read: 1.02rem;          /* body size in the reading lane */
  --read-lh: 1.68;          /* line height for sustained reading */
  --measure: 68ch;          /* longest comfortable line */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(34, 197, 94, .14), transparent 60%),
    radial-gradient(900px 420px at -10% 10%, rgba(56, 189, 248, .10), transparent 55%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-wrap: break-word;
  word-break: break-word;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, .option, .chip, .tab, .qdot, .subject, .qcard { touch-action: manipulation; }
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .35em; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .6em; }
code { background: #0b1d15; border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; font-size: .85em; }
.muted { color: var(--ink2); }
.sm { font-size: .82rem; }
.centre { text-align: center; }
.hide { display: none !important; }
.row { display: flex; align-items: center; }
.row.end { justify-content: flex-end; }
.gap { gap: 10px; }
.wrap { flex-wrap: wrap; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.link { color: var(--green); font-size: .85rem; font-weight: 600; }

/* ------------------------------- shell ------------------------------- */
.app { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(6, 18, 13, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(150deg, var(--green), #0f7a3d);
  color: #04140c; font-weight: 900; font-size: .95rem; letter-spacing: -.5px;
  box-shadow: 0 4px 14px rgba(34, 197, 94, .35);
}
.brand-text { display: flex; flex-direction: column; font-weight: 800; letter-spacing: -.3px; }
.brand-text small { font-weight: 600; font-size: .62rem; color: var(--gold); letter-spacing: 1.6px; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 7px; }
.track-switch {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 4px 10px; cursor: pointer;
}
.ts-label { font-size: .56rem; letter-spacing: 1.4px; text-transform: uppercase; color: var(--ink3); }
.ts-value { font-size: .82rem; font-weight: 800; color: var(--gold); }
.icon-btn {
  position: relative; width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 11px; cursor: pointer;
}
.icon-btn svg { width: 19px; height: 19px; fill: var(--ink2); }
.icon-btn .dot { position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.avatar-btn { font-weight: 800; font-size: .78rem; color: var(--green); }
.avatar {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px;
  background: linear-gradient(150deg, #1d6a41, #0e3b25); border: 1px solid var(--line);
  font-weight: 800; font-size: .82rem; color: #c9ffe0; flex: none;
}
.avatar.lg { width: 52px; height: 52px; font-size: .95rem; }
.avatar.xl { width: 56px; height: 56px; font-size: 1rem; border-radius: 17px; }

.view { padding: 14px 14px calc(var(--tab-h) + 28px); max-width: 860px; margin: 0 auto; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around; align-items: stretch;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(8, 20, 15, .96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--ink3); font-size: .66rem; font-weight: 700; padding-top: 4px;
}
.tabbar a svg { width: 21px; height: 21px; fill: currentColor; }
.tabbar a.active { color: var(--green); }
.tabbar a.tab-fame.active { color: var(--gold); }

@media (min-width: 820px) {
  .view { padding: 24px 28px 60px; }
  .tabbar { display: none; }
  .topbar { padding: 12px 28px; }
  .brand-text { font-size: 1.05rem; }
}

/* ------------------------------- cards ------------------------------- */
.card {
  background: linear-gradient(180deg, var(--card), var(--card2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px; margin: 0 0 14px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.card h4 { margin: 14px 0 6px; }
.section-title { margin: 20px 0 10px; font-size: 1rem; color: var(--ink2); text-transform: uppercase; letter-spacing: 1px; }
.page-head { margin-bottom: 14px; }
.page-head h1 { margin-bottom: 4px; }
.page-head .back { color: var(--ink2); font-size: .85rem; display: inline-block; margin-bottom: 6px; }

/* ------------------------------- buttons ------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 11px 16px; border-radius: 12px; font-weight: 700; cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
  min-height: 44px;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(150deg, var(--green), var(--green-d)); border-color: transparent; color: #04150c; }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .4); color: #fca5a5; }
.btn.sm { padding: 7px 11px; font-size: .82rem; min-height: 34px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.ok-static { background: rgba(34, 197, 94, .16); border-color: rgba(34, 197, 94, .4); color: #86efac; }
.btn.file { position: relative; overflow: hidden; }
.big-btn { padding: 16px; font-size: 1.05rem; }

/* -------------------------------- forms ------------------------------- */
label { display: block; margin: 0 0 11px; font-size: .82rem; font-weight: 700; color: var(--ink2); }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 11px 12px;
  background: #0a1a13; border: 1px solid var(--line); border-radius: 11px;
  color: var(--ink); outline: none; min-height: 44px;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(34, 197, 94, .15); }
textarea { min-height: 80px; resize: vertical; }
select[multiple] { min-height: 110px; }
.search { max-width: 240px; }
.chk { display: flex; align-items: center; gap: 11px; font-weight: 600; color: var(--ink); }
.chk input { width: 22px; height: 22px; min-width: 22px; min-height: 22px; margin: 0; flex: none; accent-color: var(--green); }
.inline { display: flex; align-items: center; gap: 8px; margin: 0; }
.inline input { width: 74px; margin: 0; }

/* ------------------------------- pills -------------------------------- */
.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line);
  font-size: .7rem; font-weight: 700; color: var(--ink2);
}
.pill.live, .pill.ok { background: rgba(34, 197, 94, .16); border-color: rgba(34, 197, 94, .35); color: #86efac; }
.pill.warn { background: rgba(251, 191, 36, .14); border-color: rgba(251, 191, 36, .35); color: var(--gold); }
.pill.timer { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--ink); }
.pill.timer.danger { background: rgba(239, 68, 68, .18); border-color: rgba(239, 68, 68, .45); color: #fca5a5; }
.pill.streak { color: var(--gold); border-color: rgba(251, 191, 36, .35); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.seg.scroll { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.seg button {
  flex: none; padding: 8px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--ink2); font-size: .8rem; font-weight: 700; cursor: pointer;
  white-space: nowrap;
}
.seg button.on { background: var(--green); border-color: var(--green); color: #04150c; }

/* ------------------------------- auth --------------------------------- */
.auth { max-width: 760px; margin: 0 auto; }
.auth-hero { text-align: center; padding: 22px 8px 20px; }
.auth-logo {
  width: 62px; height: 62px; margin: 0 auto 12px; display: grid; place-items: center;
  border-radius: 19px; font-weight: 900; font-size: 1.5rem; color: #04140c;
  background: linear-gradient(150deg, var(--green), #0f7a3d);
  box-shadow: 0 10px 30px rgba(34, 197, 94, .4);
}
.auth-hero h1 { font-size: 1.9rem; letter-spacing: -1px; }
.tagline { color: var(--ink2); font-size: 1rem; max-width: 46ch; margin: 0 auto 14px; }
.hero-points { list-style: none; padding: 0; margin: 0 auto 12px; max-width: 400px; text-align: left; }
.hero-points li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.mini-note { font-size: .76rem; color: var(--ink3); }
.auth-card { background: linear-gradient(180deg, var(--card), var(--card2)); border: 1px solid var(--line); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); }
.tabs { display: flex; gap: 6px; background: #08150f; padding: 5px; border-radius: 13px; margin-bottom: 16px; }
.tab { flex: 1; padding: 10px; border: 0; background: transparent; color: var(--ink3); font-weight: 700; border-radius: 10px; cursor: pointer; }
.tab.active { background: var(--green); color: #04150c; }
.pane { display: none; }
.pane.active { display: block; }
.backend-note {
  margin-top: 14px; padding: 11px 13px; border-radius: 12px; font-size: .8rem;
  background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .25); color: #fde68a;
}
.backend-note.ok { background: rgba(34, 197, 94, .1); border-color: rgba(34, 197, 94, .3); color: #bbf7d0; }

/* ------------------------------- home --------------------------------- */
.hero {
  background: linear-gradient(160deg, rgba(34, 197, 94, .18), rgba(10, 26, 19, .4));
  border: 1px solid var(--line); border-radius: 20px; padding: 16px; margin-bottom: 14px;
}
.hero-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hi { margin: 0; color: var(--ink2); font-size: .86rem; }
.h-title { font-size: 1.25rem; margin: 2px 0 2px; }
.level-line { margin: 0; font-size: .84rem; color: var(--ink2); }
.level-line b { color: var(--gold); }
.xp { margin: 14px 0 12px; }
.xp-bar, .progress { height: 8px; border-radius: 999px; background: #0a1a13; border: 1px solid var(--line); overflow: hidden; }
.xp-bar i, .progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); }
.xp-meta { display: flex; justify-content: space-between; font-size: .74rem; color: var(--ink3); margin-top: 5px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { text-align: center; background: rgba(0, 0, 0, .2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; }
.stat b { display: block; font-size: 1.05rem; color: var(--ink); }
.stat small { font-size: .62rem; color: var(--ink3); line-height: 1.2; display: block; }
@media (max-width: 400px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }

.strip { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.strip-l h3 { margin: 0 0 2px; }
.strip-l p { margin: 0; font-size: .82rem; }
.ring {
  --p: 0; width: 62px; height: 62px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), #0a1a13 0);
  display: grid; place-items: center; position: relative;
}
.ring::after { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--card); }
.ring span { position: relative; z-index: 1; font-weight: 800; font-size: .8rem; }

.countdown .dates { list-style: none; margin: 8px 0; padding: 0; }
.countdown .dates li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.countdown .dates em { grid-column: 1; font-style: normal; font-size: .76rem; color: var(--ink3); }
.countdown .dates b { font-size: .82rem; color: var(--green); }
.countdown .dates b.soon { color: var(--gold); }
.countdown .dates b.past { color: var(--ink3); }

.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.qcard {
  background: linear-gradient(180deg, var(--card), var(--card2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 3px; min-height: 104px;
}
.qcard:active { transform: scale(.985); }
.qcard .qi { font-size: 1.35rem; }
.qcard b { font-size: .95rem; }
.qcard small { color: var(--ink3); font-size: .74rem; line-height: 1.3; }
.qcard.hot { border-color: rgba(251, 191, 36, .4); background: linear-gradient(180deg, rgba(251, 191, 36, .12), var(--card2)); }
@media (min-width: 700px) { .quick { grid-template-columns: repeat(4, 1fr); } }

.mini-board, .board { list-style: none; margin: 0; padding: 0; }
.mini-board li { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.mini-board li:last-child, .board li:last-child { border-bottom: 0; }
.rank { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 8px; background: #0a1a13; font-size: .78rem; font-weight: 800; color: var(--ink3); }
.nm { font-size: .9rem; }
.sc { font-weight: 800; color: var(--gold); }
.board li { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.board .pos { font-size: 1rem; font-weight: 800; text-align: center; color: var(--ink3); }
.board .who b { display: block; font-size: .92rem; }
.board .who small { color: var(--ink3); font-size: .74rem; }
.board .pts { font-weight: 800; font-size: 1.02rem; color: var(--green); }
.board.me, .mini-board .me { background: rgba(34, 197, 94, .09); border-radius: 12px; padding-left: 8px; padding-right: 8px; }
.board.big .pts { color: var(--gold); }

.weak-row { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.weak-row:last-child { border-bottom: 0; }
.wi { font-size: 1.1rem; }
.wn { font-size: .9rem; }
.wp { font-weight: 800; font-size: .86rem; color: var(--gold); }
.wp.bad { color: var(--red); }

.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.badge { text-align: center; padding: 9px 4px; border-radius: 12px; border: 1px dashed var(--line); opacity: .4; }
.badge.got { opacity: 1; border-style: solid; border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .07); }
.badge span { display: block; font-size: 1.3rem; }
.badge small { font-size: .6rem; color: var(--ink2); display: block; line-height: 1.15; margin-top: 3px; }
@media (min-width: 700px) { .badges { grid-template-columns: repeat(6, 1fr); } }

.subj-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 8px 12px;
  background: #0a1a13; border: 1px solid var(--line); border-radius: 999px;
  font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--ink);
}
.chip .tick { color: var(--green); font-style: normal; }

.exam-info .facts { padding-left: 18px; margin: 8px 0; }
.exam-info .facts li { margin-bottom: 6px; font-size: .88rem; }
.facts { padding-left: 18px; }
.facts li { margin-bottom: 6px; font-size: .88rem; }
.rules { padding-left: 18px; }
.rules li { margin-bottom: 6px; font-size: .88rem; }
.steps li { margin-bottom: 8px; font-size: .9rem; }

/* ------------------------------ practice ------------------------------ */
.subject-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.subject {
  text-align: left; background: #0a1a13; border: 1px solid var(--line);
  border-left: 3px solid var(--c, var(--green)); border-radius: 13px; padding: 12px;
  display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-height: 84px;
  min-width: 0;
}
.subject:active { transform: scale(.98); }
.s-ico { font-size: 1.2rem; }
.s-name {
  font-weight: 700;
  font-size: .9rem;
  line-height: 1.2;
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
  white-space: normal;
}
.s-count { font-size: .68rem; color: var(--ink3); }
a.subject { color: inherit; }
@media (min-width: 700px) { .subject-grid { grid-template-columns: repeat(3, 1fr); } }

.paper-opts { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 9px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .86rem; }
.hist.long li { grid-template-columns: 1fr auto auto auto auto; }
.h-sub { font-weight: 600; }
.h-mode { font-size: .72rem; color: var(--ink3); text-transform: capitalize; }
.h-score { font-weight: 800; }
.h-score.good { color: var(--green); }
.h-score.bad { color: var(--red); }
.h-grade { font-size: .78rem; color: var(--gold); font-weight: 800; }
.h-when { font-size: .72rem; color: var(--ink3); }
@media (max-width: 480px) { .hist.long li { grid-template-columns: 1fr auto auto; } .h-mode, .h-when { display: none; } }

/* -------------------------------- quiz -------------------------------- */
.quiz-shell { max-width: 720px; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.quiz-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.progress { margin-bottom: 16px; }
.quiz-body { position: relative; }
.q-topic { font-size: .72rem; letter-spacing: 1px; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; }
.q-text { font-size: 1.12rem; line-height: 1.4; margin-bottom: 16px; }
.options { display: flex; flex-direction: column; gap: 9px; }
.option {
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 11px;
  text-align: left; background: #0a1a13; border: 1.5px solid var(--line);
  border-radius: 13px; padding: 13px; cursor: pointer; min-height: 52px;
  transition: border-color .12s ease, background .12s ease;
}
.option:active { transform: scale(.99); }
.option.picked { border-color: var(--green); background: rgba(34, 197, 94, .1); }
.option.right { border-color: var(--green); background: rgba(34, 197, 94, .16); }
.option.wrong { border-color: var(--red); background: rgba(239, 68, 68, .12); }
.opt-letter {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px;
  background: #12291f; font-weight: 800; font-size: .8rem; color: var(--ink2);
}
.option.right .opt-letter { background: var(--green); color: #04150c; }
.option.wrong .opt-letter { background: var(--red); color: #fff; }
.opt-text { font-size: .95rem; }
.tick { color: var(--green); font-weight: 900; }
.cross { color: var(--red); font-weight: 900; }
.feedback { margin-top: 14px; padding: 13px; border-radius: 13px; font-size: .9rem; border: 1px solid var(--line); }
.feedback.good { background: rgba(34, 197, 94, .1); border-color: rgba(34, 197, 94, .3); }
.feedback.bad { background: rgba(239, 68, 68, .08); border-color: rgba(239, 68, 68, .3); }
.feedback strong { display: block; margin-bottom: 4px; }
.feedback p { margin: 0; color: var(--ink2); }
.fame-hud { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.fame-hud div { text-align: center; background: #0a1a13; border: 1px solid var(--line); border-radius: 12px; padding: 9px; }
.fame-hud b { display: block; font-size: 1.15rem; color: var(--gold); }
.fame-hud small { font-size: .64rem; color: var(--ink3); }
.pop {
  position: absolute; top: 4px; right: 4px; font-weight: 900; font-size: 1.15rem;
  color: var(--gold); animation: pop .9s ease forwards; pointer-events: none;
}
.pop.bad { color: var(--red); }
@keyframes pop { 0% { opacity: 0; transform: translateY(6px) scale(.9); } 25% { opacity: 1; transform: translateY(-6px) scale(1.05); } 100% { opacity: 0; transform: translateY(-26px) scale(1); } }

.quiz-nav { display: flex; gap: 8px; margin-top: 16px; }
.quiz-nav .btn { flex: 1; }
.quiz-nav .flag { flex: 0 0 auto; padding: 11px 13px; }
.quiz-nav .flag.on { color: var(--gold); border-color: rgba(251, 191, 36, .4); }
.quiz-nav .skip { flex: 1; border-color: rgba(251, 191, 36, .35); }
.quiz-nav .skip .skip-cost {
  font-size: .74rem; font-weight: 800; color: var(--gold);
  background: rgba(251, 191, 36, .14); border-radius: 7px; padding: 1px 6px;
}
.qmap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; align-items: center; }
.qdot {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: #0a1a13; color: var(--ink3); font-size: .78rem; font-weight: 700; cursor: pointer;
}
.qdot.done { background: rgba(34, 197, 94, .18); border-color: rgba(34, 197, 94, .4); color: #bbf7d0; }
.qdot.flag { border-color: var(--gold); color: var(--gold); }
.qdot.now { outline: 2px solid var(--green); }
.qmap-submit { margin-left: auto; }

.result { max-width: 720px; margin: 0 auto; }
.result-head { text-align: center; padding: 22px 16px; border-radius: 18px; margin-bottom: 14px; border: 1px solid var(--line); }
.result-head.good { background: linear-gradient(160deg, rgba(34, 197, 94, .2), var(--card2)); }
.result-head.bad { background: linear-gradient(160deg, rgba(239, 68, 68, .14), var(--card2)); }
.grade { font-size: 2.6rem; font-weight: 900; color: var(--gold); line-height: 1; }
.result-head .big { font-size: 2.2rem; font-weight: 900; line-height: 1.1; }
.result-head .sub { color: var(--ink2); font-size: .86rem; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 108px 1fr 54px; align-items: center; gap: 9px; font-size: .82rem; }
.bar-label { color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 8px; border-radius: 999px; background: #0a1a13; border: 1px solid var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; }
.bar-val { text-align: right; color: var(--ink3); font-size: .76rem; }
.review-list details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.review-list summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.review-list p { margin: 7px 0 0; font-size: .86rem; color: var(--ink2); }
.review-list .expl { color: var(--ink); background: #0a1a13; padding: 9px 11px; border-radius: 10px; }
.celebrate { text-align: center; }

/* -------------------------------- learn ------------------------------- */
.link-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
.lcard { display: flex; gap: 9px; align-items: center; background: #0a1a13; border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: .84rem; }
.lcard span:first-child { font-size: 1.1rem; }
.lcard b { display: block; font-size: .82rem; }
.lcard small { color: var(--ink3); font-size: .68rem; }
@media (min-width: 700px) { .link-grid { grid-template-columns: repeat(3, 1fr); } }
.link-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.rlink { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; background: #0a1a13; border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; }
.rlink b { font-size: .9rem; }
.rlink small { grid-column: 1; color: var(--ink3); font-size: .76rem; line-height: 1.35; }
.rlink .ext { grid-row: 1 / span 2; align-self: center; color: var(--green); }
.note-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
/* The body of a lesson. This is the text a student actually sits and reads,
   so it is set at reading size, not at the .9rem used for interface labels. */
.points { padding-left: 20px; margin: 10px 0; }
.points li {
  margin-bottom: 10px;
  font-size: var(--read);
  line-height: var(--read-lh);
  color: var(--ink);
}
.points li::marker { color: var(--green); }
.trap { margin-top: 10px; padding: 10px 12px; border-radius: 11px; background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .28); font-size: .86rem; }
.formula { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .84rem; }
.topic-head { border-left: 3px solid var(--c, var(--green)); padding-left: 12px; }

.grade-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.grade-table th, .grade-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.grade-table th { color: var(--ink3); font-size: .74rem; text-transform: uppercase; letter-spacing: .6px; }
.grade-table tr.credit td { color: #bbf7d0; }
.grade-table tr.fail td { color: #fca5a5; }

/* -------------------------------- fame -------------------------------- */
.fame-head h1 { color: var(--gold); }
.fame-rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 8px; margin-bottom: 12px; }
.fame-rules div { text-align: center; background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .22); border-radius: 12px; padding: 9px 4px; }
.fame-rules b { display: block; font-size: 1.15rem; color: var(--gold); }
.fame-rules small { font-size: .6rem; color: var(--ink3); line-height: 1.2; display: block; }
.fame-done { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.fame-done div { text-align: center; background: #0a1a13; border: 1px solid var(--line); border-radius: 12px; padding: 10px 4px; }
.fame-done b { display: block; font-size: 1.25rem; color: var(--green); }
.fame-done small { font-size: .62rem; color: var(--ink3); }
@media (max-width: 400px) { .fame-rules, .fame-done { grid-template-columns: repeat(2, 1fr); } }
.topic-card { background: rgba(251, 191, 36, .07); border: 1px solid rgba(251, 191, 36, .25); border-radius: 13px; padding: 13px; margin-bottom: 12px; }
.topic-card b { font-size: 1rem; }
.explain-done p { font-size: .88rem; }
.big-timer { text-align: center; font-size: 2.6rem; font-weight: 900; color: var(--gold); margin: 6px 0; font-variant-numeric: tabular-nums; }
.big-timer.danger { color: var(--red); }

/* ------------------------------ competitions -------------------------- */
.comp-meta { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--ink2); }

/* -------------------------------- admin ------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 14px; }
.scard { background: linear-gradient(180deg, var(--card), var(--card2)); border: 1px solid var(--line); border-radius: 14px; padding: 13px; text-align: center; }
.scard b { display: block; font-size: 1.35rem; color: var(--green); }
.scard small { font-size: .68rem; color: var(--ink3); }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(6, 1fr); } }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .84rem; min-width: 640px; }
.table th, .table td { text-align: left; padding: 9px 7px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--ink3); font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; }
.qlist { list-style: none; padding: 0; margin: 0; }
.qlist li { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .86rem; }
.qt { color: var(--ink2); }
.answer { border: 1px solid var(--line); border-radius: 13px; padding: 13px; margin-bottom: 10px; background: #0a1a13; }
.answer.graded { border-color: rgba(34, 197, 94, .3); }
.answer-head { display: flex; justify-content: space-between; gap: 10px; font-size: .82rem; color: var(--ink3); flex-wrap: wrap; }
.qtopic { margin: 8px 0 4px; font-size: .84rem; }
.atext { background: #07130e; border-left: 3px solid var(--gold); padding: 10px 12px; border-radius: 0 10px 10px 0; font-size: .9rem; }
.ann { border-bottom: 1px solid var(--line); padding: 11px 0; }
.ann-head { display: flex; justify-content: space-between; gap: 10px; font-size: .88rem; }
.ann-head span { color: var(--ink3); font-size: .76rem; }
.temp-pw { font-family: ui-monospace, monospace; font-size: 1.4rem; letter-spacing: 3px; text-align: center; background: #0a1a13; border: 1px dashed var(--gold); border-radius: 12px; padding: 14px; color: var(--gold); }
.danger-zone { border-color: rgba(239, 68, 68, .28); }
.demo-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 13px; margin: 0 0 14px;
  background: rgba(251, 191, 36, .10); border: 1px solid rgba(251, 191, 36, .30);
  font-size: .86rem;
}
.demo-banner.ok { background: rgba(34, 197, 94, .10); border-color: rgba(34, 197, 94, .30); }
.demo-banner span { flex: 1; min-width: 200px; }

/* -------------------------------- modal ------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(2, 8, 5, .72);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
  backdrop-filter: blur(4px); animation: fade .16s ease;
}
.modal {
  position: relative; width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto;
  background: linear-gradient(180deg, #10241a, #0b1a13);
  border: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 22px 18px 26px;
  animation: up .2s ease;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 20px; }
}
.modal-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 10px; background: #0a1a13; border: 1px solid var(--line); cursor: pointer; }
.modal-close svg { width: 16px; height: 16px; fill: var(--ink2); }
.who { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.who h3 { margin: 0; }
.who p { margin: 1px 0 3px; font-size: .84rem; }
.menu { display: flex; flex-direction: column; gap: 7px; }
.menu-item {
  text-align: left; padding: 13px; border-radius: 12px; border: 1px solid var(--line);
  background: #0a1a13; font-weight: 600; cursor: pointer; color: var(--ink);
}
.menu-item.danger { color: #fca5a5; border-color: rgba(239, 68, 68, .3); }

.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 7px; pointer-events: none; padding: 0 14px; }
.toast { background: #12291f; border: 1px solid var(--line); color: var(--ink); padding: 10px 15px; border-radius: 12px; font-size: .86rem; box-shadow: var(--shadow); animation: up .18s ease; max-width: 100%; }
.toast-err { border-color: rgba(239, 68, 68, .45); color: #fecaca; }
.toast-warn { border-color: rgba(251, 191, 36, .45); color: #fde68a; }
.toast.out { opacity: 0; transition: opacity .28s ease; }
.empty { text-align: center; padding: 40px 16px; color: var(--ink2); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes up { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ------------------------- small phones (≤ 430px) ------------------------- */
@media (max-width: 430px) {
  h1 { font-size: 1.3rem; }
  .view { padding: 12px 11px calc(var(--tab-h) + 22px); }
  .card { padding: 13px; border-radius: 14px; }

  /* stack paired form fields instead of squeezing them side by side */
  .two { grid-template-columns: 1fr; gap: 0; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .link-grid { grid-template-columns: 1fr; }
  .badges { grid-template-columns: repeat(3, 1fr); }
  .subject-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
  .subject { min-height: 76px; padding: 10px; }
  .s-name { font-size: .84rem; }

  .bar-row { grid-template-columns: 88px 1fr 46px; gap: 7px; font-size: .78rem; }
  .bar-val { font-size: .7rem; }

  .q-text { font-size: 1.04rem; }
  .option { padding: 12px 11px; gap: 9px; }
  .opt-text { font-size: .9rem; }
  .quiz-nav .btn { padding: 11px 10px; font-size: .88rem; }
  .qdot { width: 31px; height: 31px; font-size: .74rem; }

  .result-head { padding: 18px 12px; }
  .grade { font-size: 2.2rem; }
  .result-head .big { font-size: 1.9rem; }

  .quick { gap: 8px; }
  .qcard { min-height: 96px; padding: 12px; }
  .qcard b { font-size: .9rem; }

  .board .who b { font-size: .86rem; }
  .board .pts { font-size: .94rem; }

  .table { min-width: 560px; }
  .auth-hero h1 { font-size: 1.6rem; }
  .auth-card { padding: 15px; }
  .modal { padding: 20px 15px 24px; }
  .toasts { bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom)); }
}

@media (max-width: 350px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .badges { grid-template-columns: repeat(2, 1fr); }
  .brand-text { font-size: .92rem; }
  .ts-label { display: none; }
}

/* --------------------------- short / landscape --------------------------- */
@media (max-height: 520px) {
  :root { --tab-h: 52px; }
  .hero { padding: 12px; }
  .auth-hero { padding: 10px 8px; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ------------------------------------------------------------------
   ICONS
   The app used to print emoji, which rendered differently on every
   phone. These are line-art SVG drawn in the current text colour, so
   they inherit the theme and stay sharp at any size.
   ------------------------------------------------------------------ */

.ic {
  width: 1.05em;
  height: 1.05em;
  flex: none;
  vertical-align: -0.17em;
  stroke: currentColor;
}

/* Subject tiles carry a larger mark in the subject's own colour. */
.sico {
  width: 1.5rem;
  height: 1.5rem;
  display: block;
}

.s-ico,
.qi,
.wi {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink2, currentColor);
}

.s-ico .sico { width: 1.55rem; height: 1.55rem; }
.qi   .sico,
.qi   .ic   { width: 1.4rem;  height: 1.4rem; }
.wi   .sico { width: 1.15rem; height: 1.15rem; }

.card-head h3 .ic,
.page-head h1 .ic { vertical-align: -0.14em; margin-right: .3rem; }

.menu-item .ic { margin-right: .55rem; }

.badge-tile .ic,
.badges .ic { width: 1.5rem; height: 1.5rem; }

/* ------------------------------------------------------------------
   LEADERBOARD POSITIONS
   Medals were emoji. Rank numbers read better anyway — the top three
   are picked out with a ring instead.
   ------------------------------------------------------------------ */

.board .pos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  font-variant-numeric: tabular-nums;
}

.board li:nth-child(1) .pos { background: #c9a24b; color: #18212f; }
.board li:nth-child(2) .pos { background: #c3cbd6; color: #18212f; }
.board li:nth-child(3) .pos { background: #cd8c5c; color: #18212f; }

/* ------------------------------------------------------------------
   TODAY — the daily loop
   ------------------------------------------------------------------ */

.today-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-bottom: 18px;
}

.today-card {
  background: var(--card, #fff);
  border: 1px solid var(--line, #e6e9ef);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.today-card.go { border-color: var(--gold, #c9a24b); }
.today-card.done { opacity: .82; }
.today-card h3 { margin: 0; }
.today-card .btn { margin-top: auto; }

.tc-ico {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--gold, #c9a24b) 16%, transparent);
  color: var(--gold, #c9a24b);
}

.tc-state {
  margin: auto 0 0;
  font-size: .88rem;
  display: flex; align-items: center; gap: .4rem;
}

.stat-grid.tight { margin-bottom: 10px; }

/* Mastery dots: filled = level reached */
.lvl { letter-spacing: .12em; font-size: .8rem; white-space: nowrap; }
.lvl-0, .lvl-1 { color: #e05260; }
.lvl-2 { color: #e08a2e; }
.lvl-3 { color: #c9a24b; }
.lvl-4 { color: #4b9e5f; }
.lvl-5 { color: #2e8b57; }

.focus-list, .mastery-list { list-style: none; margin: 0; padding: 0; }

.focus-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line, #e6e9ef);
}
.focus-list li:last-child { border-bottom: 0; }
.fl-ico { width: 26px; display: inline-flex; color: var(--ink2, #6b7a8d); }
.fl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fl-main small { color: var(--ink3, #8b97a6); }

.mastery-list li {
  display: grid;
  grid-template-columns: 1fr auto 3.2rem;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line, #e6e9ef);
}
.mastery-list li:last-child { border-bottom: 0; }
.ml-topic { display: flex; flex-direction: column; min-width: 0; }
.ml-topic b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-topic small { color: var(--ink3, #8b97a6); }
.ml-pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink2, #6b7a8d); }

@media (max-width: 520px) {
  .today-grid { grid-template-columns: 1fr; }
  .focus-list li { flex-wrap: wrap; }
  .focus-list li .btn { margin-left: auto; }
}

/* ------------------------------------------------------------------
   SUBJECT COMBINATION PICKER
   A student ticks what they actually register for. CRS and IRS are a
   choice, never both, so ticking one unticks the other.
   ------------------------------------------------------------------ */

.subj-group { margin: 16px 0; }
.subj-group h4 {
  margin: 0 0 8px;
  font-size: .78rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink3, #8b97a6);
}

/* One subject per row on a phone, two or three on wider screens. The name
   is the thing being chosen, so it gets the space; nothing may squeeze it. */
.subj-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

.subj {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--line, #e6e9ef);
  border-radius: 11px;
  cursor: pointer;
  user-select: none;
  transition: border-color .12s, background .12s;
}
.subj:hover { border-color: var(--ink3, #8b97a6); }

.subj input {
  margin: 0;
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--gold, #c9a24b);
}

.subj-ico {
  display: inline-flex;
  align-items: center;
  color: var(--ink3, #8b97a6);
}
.subj-ico .sico { width: 1.25rem; height: 1.25rem; flex: none; }

/* No nowrap, no overflow hidden, no ellipsis. A long name wraps onto a
   second line rather than being clipped to nothing. */
.subj-name {
  font-size: .92rem;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
}

.subj.on {
  border-color: var(--gold, #c9a24b);
  background: color-mix(in srgb, var(--gold, #c9a24b) 10%, transparent);
}
.subj.on .subj-ico { color: var(--gold, #c9a24b); }
.subj.on .subj-name { font-weight: 600; }

.subj.locked { opacity: .78; cursor: not-allowed; }
.subj.locked .subj-name::after {
  content: ' (compulsory)';
  font-weight: 400;
  font-size: .78rem;
  color: var(--ink3, #8b97a6);
}

@media (min-width: 560px) { .subj-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .subj-grid { grid-template-columns: repeat(3, 1fr); } }

.warn-text { color: #f0a868; }


.card.nudge { border-color: var(--gold, #c9a24b); }
.card.nudge .btn { margin-top: 10px; }

/* ------------------------------------------------------------------
   STUDY NOTES — deeper material
   ------------------------------------------------------------------ */

.note-summary {
  margin: 0 0 14px;
  padding-left: 14px;
  border-left: 3px solid var(--gold);
  color: var(--ink2);
  font-size: var(--read);
  line-height: var(--read-lh);
}

.note-block {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 11px;
  background: var(--soft);
  border: 1px solid var(--line);
}
.note-block > b {
  display: block;
  font-size: .72rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 9px;
}

.note-block.defs dl { margin: 0; }
.note-block.defs dt { font-weight: 700; margin-top: 11px; color: var(--ink); }
.note-block.defs dt:first-child { margin-top: 0; }
.note-block.defs dd { margin: 3px 0 0; color: var(--ink2); line-height: var(--read-lh); }

.note-block.worked .we + .we {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.we-q { margin: 0 0 8px; font-weight: 600; color: var(--ink); }
.we-steps { margin: 0 0 8px; padding-left: 1.2rem; color: var(--ink2); }
.we-steps li { margin: 5px 0; line-height: var(--read-lh); }
.we-a { margin: 0; color: var(--ink); }
.we-a b { color: var(--green); }

.note-block.tip {
  background: rgba(251, 191, 36, .09);
  border-color: rgba(251, 191, 36, .28);
}
.note-block.tip > b { color: var(--gold); }
.note-block.tip p { margin: 0; line-height: var(--read-lh); color: var(--ink); }

.note-src { margin: 12px 0 0; font-style: italic; color: var(--ink3); }

/* An option being marked by the server. The clock is paused while this
   shows, so a slow connection costs the student nothing. */
.option.marking {
  position: relative;
  opacity: .75;
  pointer-events: none;
}
.option.marking::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  width: 15px;
  height: 15px;
  margin-top: -8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: a1spin .6s linear infinite;
}
@keyframes a1spin { to { transform: rotate(360deg); } }

/* Shown when the deployed site expects database changes that have not been
   applied. Two silent outages were caused by exactly that drift. */
.db-banner {
  position: sticky;
  top: 0;
  z-index: 999;
  padding: 11px 16px;
  font-size: .9rem;
  line-height: 1.45;
  color: #2a1608;
  background: #f0b429;
  border-bottom: 1px solid #c98f14;
}
.db-banner b { display: block; }

/* ------------------------------------------------------------------
   LITERATURE LIBRARY + READING
   ------------------------------------------------------------------ */
.lib-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 560px) {
  .lib-grid { grid-template-columns: 1fr 1fr; }
}
.lib-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--card), var(--card2));
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}
.lib-card small { color: var(--gold); font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; }
.lib-card b { font-size: 1.02rem; line-height: 1.3; overflow-wrap: anywhere; color: var(--ink); }
.lib-card span { color: var(--ink2); font-size: .88rem; }
.lib-readbadge { color: var(--green); font-size: .76rem; font-style: normal; font-weight: 600; }

.lib-dl { margin: 0; }
.lib-dl dt { font-weight: 700; margin-top: 12px; color: var(--ink); }
.lib-dl dt:first-child { margin-top: 0; }
.lib-dl dd { margin: 3px 0 0; color: var(--ink2); line-height: var(--read-lh); }

.lib-q {
  margin: 0 0 16px;
  padding: 13px 16px;
  background: var(--soft2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0;
}
.lib-q p { margin: 0 0 7px; font-size: var(--read); line-height: 1.5; color: var(--ink); }
.lib-q cite { display: block; font-style: normal; font-weight: 700; font-size: .85rem; color: var(--gold); }
.lib-q small { display: block; margin-top: 5px; color: var(--ink2); }

.lib-verse {
  white-space: pre-wrap;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.06rem;
  line-height: 1.7;
  margin: 0;
  padding: 10px 0;
  color: var(--ink);
}
/* A set poem printed in full. Recessed and serif, so it reads as the text
   itself rather than as more of the app's own commentary. */
.lib-extract {
  background: var(--soft2);
  border-color: rgba(251, 191, 36, .28);
}

/* ------------------------------------------------------------------
   COMPETITION EDITOR
   The three fields that rebuild the paper are grouped and marked, so an
   admin can see at a glance which changes are safe mid-competition and
   which ones invalidate the scores already on the board.
   ------------------------------------------------------------------ */
.paper-fields {
  margin: 14px 0;
  padding: 12px 14px 14px;
  border: 1px solid rgba(251, 191, 36, .32);
  border-radius: 12px;
  background: rgba(251, 191, 36, .06);
}
.paper-fields legend {
  padding: 0 7px;
  font-size: .7rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}
.paper-fields > p { margin: 0 0 10px; }
#editCard { border-color: var(--gold); }

/* A student who has registered but not started yet. Listed, because the
   board doubles as the roster, but visibly dimmer than someone competing. */
.board li.idle { opacity: .62; }
.board li.idle .pts { color: var(--ink3); }
.board .pts small { font-size: .62em; font-weight: 600; opacity: .7; }

/* ------------------------------------------------------------------
   LIVE LEADERBOARD
   The board refreshes itself every 30 seconds. This line says so, and
   says when the figures on screen were actually fetched — a board that
   claims to be live and is quietly four hours old is worse than one
   that admits it.
   ------------------------------------------------------------------ */
.board-live {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
  font-size: .8rem;
  color: var(--ink2);
}
.board-live .btn { margin-left: auto; }
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
  animation: live-pulse 2.4s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, .45); }
  50%      { opacity: .55; box-shadow: 0 0 0 5px rgba(34, 197, 94, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

/* The crawlable fallback in index.html. Only ever seen with JavaScript off,
   but it is a real page for that reader, so it is laid out like one. */
.noscript-nav { max-width: 40rem; margin: 0 auto; padding: 28px 18px 60px; }
.noscript-nav h1 { font-size: 1.4rem; margin-bottom: 12px; }
.noscript-nav ul { padding-left: 20px; }
.noscript-nav li { margin: 8px 0; font-size: 1rem; }
.noscript-nav a { color: var(--green); text-decoration: underline; }
