/* =====================================================================
   STYLES
   A warm "daily paper" look: cream paper, deep ink, an oxblood accent.
   Colours and fonts are defined once at the top, so you can restyle quickly.
   ===================================================================== */

:root {
  /* Paper and ink */
  --paper: #F4EEE3;
  --paper-deep: #EAE1D1;
  --card: #FFFCF7;
  --ink: #1D2134;
  --ink-soft: #3A3F55;
  --muted: #77727E;
  --line: rgba(29, 33, 52, 0.12);
  --line-strong: rgba(29, 33, 52, 0.22);

  /* Accents */
  --accent: #8E2F3C;        /* oxblood */
  --accent-dark: #6F2230;
  --gold: #C29A3A;
  --gold-soft: #F3E6C4;
  --up: #3F7D5C;
  --down: #A8423A;

  /* Rarity colours */
  --textbook: #5E8F6E;        /* sage green */
  --further: #D3A843;         /* ochre */
  --footnote: #CF6A3D;        /* terracotta */
  --archive: #2F6385;         /* archive blue */
  --eureka: #5E4192;          /* plum */
  --miss: #4A4E63;

  /* Shape */
  --radius: 16px;
  --shadow: 0 1px 0 rgba(29, 33, 52, 0.04), 0 10px 30px -12px rgba(29, 33, 52, 0.22);
  --shadow-soft: 0 1px 2px rgba(29, 33, 52, 0.06);

  /* Fonts */
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Faint paper grain */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .1 0 0 0 0 .09 0 0 0 0 .07 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  background: var(--paper) var(--grain);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* the shuffled card swings off the left edge */
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 96;
}

em { font-style: italic; }

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- Home background: library shelves ---------- */
.app { position: relative; z-index: 1; }
/* The room: a warm brown floor glow fading up to near-black */
.library {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(to top, #2B1D14 0%, #1E1510 40%, #120E0C 75%, #0D0B0A 100%);
  opacity: 0;
  transition: opacity 0.5s ease;
}
/* The shelves: strongest at the bottom, melting into the dark above */
.library::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--shelves);
  background-repeat: repeat;
  background-position: center bottom;
  opacity: 0.9;
  -webkit-mask-image: linear-gradient(to top, #000 0%, #000 22%, rgba(0, 0, 0, 0.55) 50%, rgba(0, 0, 0, 0.15) 78%, transparent 100%);
  mask-image: linear-gradient(to top, #000 0%, #000 22%, rgba(0, 0, 0, 0.55) 50%, rgba(0, 0, 0, 0.15) 78%, transparent 100%);
}
/* A warm lamp glow behind the main card */
.library::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 55% 42% at 50% 26%, rgba(255, 186, 104, 0.17) 0%, rgba(255, 186, 104, 0.05) 50%, rgba(255, 186, 104, 0) 75%);
}
body.home-bg .library { opacity: 1; }
body.home-bg { background-color: #0D0B0A; }
/* the copy on the first flip page keeps its shelves while it turns */
.flip-page .library { position: absolute; opacity: 1; transition: none; }

/* Switching between the dark home screen and the light pages: text and
   background colours fade together (0.5s, like the shelves) instead of snapping. */
body, .alpha-banner, .topbar, .logo, .nav-btn, .icon-btn, .account-chip,
.section-title, .footer, .footer .link-btn {
  transition: color 0.5s ease, background-color 0.5s ease, border-color 0.5s ease;
}

/* Light text on the dark home screen
   (".home-bg" is on the body, or on the first flip page while it turns) */
.home-bg .alpha-banner { background: rgba(0, 0, 0, 0.45); }
.home-bg .topbar { border-bottom-color: rgba(255, 240, 220, 0.1); }
.home-bg .logo { color: #E7C77F; }
.home-bg .nav-btn, .home-bg .icon-btn { color: rgba(255, 240, 220, 0.75); }
.home-bg .nav-btn:hover, .home-bg .icon-btn:hover { background: rgba(255, 240, 220, 0.08); }
.home-bg .nav-btn.active { color: #FFF3E0; background: rgba(255, 240, 220, 0.12); }
.home-bg .account-chip { background: rgba(255, 240, 220, 0.08); border-color: rgba(255, 240, 220, 0.2); color: rgba(255, 240, 220, 0.8); }
.home-bg .account-chip.verified { color: #9CCBAA; border-color: rgba(156, 203, 170, 0.4); }
.home-bg .section-title { color: #F2E6D2; }
.home-bg .section-title::after { background: rgba(255, 240, 220, 0.14); }
.home-bg .card { border-color: rgba(0, 0, 0, 0.4); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.7); }
.home-bg .ad-slot { border-color: rgba(255, 240, 220, 0.18); color: rgba(255, 240, 220, 0.45); }
.home-bg .footer { color: rgba(255, 240, 220, 0.5); }
.home-bg .footer .link-btn { color: rgba(255, 240, 220, 0.5); }
.home-bg .footer .link-btn:hover { color: #E7C77F; }

/* ---------- Home: notes and cards ---------- */
.notices { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 4px 4px 0; }
.sticky-note {
  position: relative;
  padding: 22px 18px 18px;
  border-radius: 2px 2px 14px 2px;
  color: #2B2418;
  box-shadow: 0 14px 24px -12px rgba(0, 0, 0, 0.75), inset 0 -18px 30px -24px rgba(0, 0, 0, 0.35);
  transform: rotate(-1.8deg);
}
.sticky-note:nth-child(2n) { transform: rotate(1.6deg) translateY(6px); }
.sticky-note:nth-child(3n) { transform: rotate(-0.8deg); }
.sticky-note::before {
  /* a strip of tape */
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 72px;
  height: 20px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(255, 250, 235, 0.45);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.sticky-note.yellow { background: #F1DE8E; }
.sticky-note.pink { background: #EDBCB8; }
.sticky-note.green { background: #C3D9B4; }
.sticky-note.blue { background: #BCD0E2; }
.note-title { font-family: "Caveat", cursive; font-weight: 700; font-size: 1.55rem; line-height: 1; margin: 0 0 6px; }
.note-text { margin: 0; font-size: 0.88rem; line-height: 1.45; }

/* ---------- Yesterday's verdict ---------- */

/* Top of the class: a degree certificate */
.certificate {
  position: relative;
  padding: 22px 22px 26px;
  text-align: center;
  color: var(--ink);
  border-radius: 4px;
  background:
    radial-gradient(ellipse at 50% 40%, #FFFBF0 0%, #F7EEDA 70%, #EEDFC0 100%);
  box-shadow:
    inset 0 0 0 5px #F7EEDA,
    inset 0 0 0 6px rgba(176, 140, 60, 0.85),
    inset 0 0 0 9px #F7EEDA,
    inset 0 0 0 10px rgba(176, 140, 60, 0.5),
    0 16px 30px -14px rgba(0, 0, 0, 0.8);
}
.cert-label {
  margin: 4px 0 12px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: #8A6A2A;
  letter-spacing: 0.02em;
}
.cert-label::before, .cert-label::after { content: " ❦ "; font-style: normal; font-size: 0.8rem; opacity: 0.7; }
.certificate::before {
  /* fine engraved rings, like the background of a real certificate */
  content: "";
  position: absolute;
  inset: 12px;
  pointer-events: none;
  background:
    repeating-radial-gradient(circle at 50% 115%, rgba(176, 140, 60, 0.09) 0 1px, transparent 1px 6px),
    repeating-radial-gradient(circle at 50% -15%, rgba(176, 140, 60, 0.06) 0 1px, transparent 1px 6px);
}
.certificate > p, .certificate > div:not(.cert-particles) { position: relative; z-index: 1; } /* text sits in front of the gold dust */
.certificate .verdict-name { font-size: 1.3rem; margin-bottom: 2px; }
.certificate .verdict-score { color: #7A6A50; }
.cert-small { margin: 2px 0 6px; font-family: var(--serif); font-style: italic; font-size: 0.74rem; color: #8A7A5C; }
.cert-signature { display: flex; flex-direction: column; align-items: flex-start; width: 52%; margin-top: 14px; }
.cert-sign { font-family: "Caveat", cursive; font-size: 1.35rem; line-height: 1; color: #2E3A5C; padding: 0 6px; transform: rotate(-4deg); }
.cert-role {
  width: 100%;
  margin-top: 2px;
  padding-top: 2px;
  border-top: 1px solid rgba(138, 106, 42, 0.55);
  text-align: left;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #8A7A5C;
}
/* Gold dust slowly floating up and away */
.cert-particles { position: absolute; inset: 0; pointer-events: none; z-index: 0; } /* drifts behind the text */
.cert-particles span {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, #FFF6D0 0%, #E6BC52 55%, rgba(230, 188, 82, 0) 100%);
  box-shadow: 0 0 6px rgba(245, 205, 110, 0.85);
  opacity: 0;
  animation-name: gold-float;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes gold-float {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: 0.95; }
  70% { opacity: 0.55; }
  100% { transform: translate(var(--drift), -160px); opacity: 0; }
}
.cert-seal {
  /* gold wax seal with ribbon tails */
  position: absolute;
  right: 16px;
  bottom: -12px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.3rem;
  color: #6E4F12;
  background: radial-gradient(circle at 35% 30%, #F2D58A, #C99B3B 55%, #9C7424);
  box-shadow: 0 0 0 3px rgba(156, 116, 36, 0.35), 0 4px 8px rgba(0, 0, 0, 0.35);
}
/* the two ribbon tails, drawn before the seal so they sit behind it */
.cert-ribbon { position: absolute; right: 16px; bottom: -12px; width: 46px; height: 46px; }
.cert-ribbon::before, .cert-ribbon::after {
  content: "";
  position: absolute;
  top: 30px;
  width: 12px;
  height: 26px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
}
.cert-ribbon::before { left: 9px; transform: rotate(14deg); }
.cert-ribbon::after { right: 9px; transform: rotate(-14deg); }

/* Wooden spoon: a cracked wooden plank */
.cracked-wood {
  position: relative;
  padding: 22px 22px 26px;
  text-align: center;
  border-radius: 4px;
  color: #F1E2CC;
  overflow: hidden;
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.3)),
    repeating-linear-gradient(178deg, #5C3C25 0 3px, #50331F 3px 7px, #644229 7px 9px, #563721 9px 15px, #5F3F27 15px 18px),
    #563721;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.5),
    inset 0 2px 0 rgba(255, 220, 170, 0.12),
    inset 0 0 24px rgba(0, 0, 0, 0.55), /* scorched edges */
    0 16px 30px -14px rgba(0, 0, 0, 0.8);
}
.cracked-wood::before {
  /* four nail heads in the corners, and two knots in the grain */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12px 12px, #D4CCBE 0 1.5px, #6E665A 2.5px, rgba(0, 0, 0, 0.55) 3.5px, transparent 4.5px),
    radial-gradient(circle at calc(100% - 12px) 12px, #D4CCBE 0 1.5px, #6E665A 2.5px, rgba(0, 0, 0, 0.55) 3.5px, transparent 4.5px),
    radial-gradient(circle at 12px calc(100% - 12px), #D4CCBE 0 1.5px, #6E665A 2.5px, rgba(0, 0, 0, 0.55) 3.5px, transparent 4.5px),
    radial-gradient(circle at calc(100% - 12px) calc(100% - 12px), #D4CCBE 0 1.5px, #6E665A 2.5px, rgba(0, 0, 0, 0.55) 3.5px, transparent 4.5px),
    radial-gradient(ellipse 24px 9px at 76% 28%, rgba(30, 15, 5, 0.6) 0 3px, rgba(70, 42, 22, 0.45) 4px 6px, rgba(30, 15, 5, 0.3) 7px 9px, transparent 12px),
    radial-gradient(ellipse 16px 6px at 22% 80%, rgba(30, 15, 5, 0.55) 0 2px, rgba(70, 42, 22, 0.4) 3px 5px, transparent 8px);
}
.cracked-wood > .wood-spoon {
  position: absolute;
  top: 10px;
  right: 22px;
  width: 16px;
  transform: rotate(22deg);
  filter: drop-shadow(1px 2px 1px rgba(0, 0, 0, 0.5));
  z-index: 1;
}
.wood-quip { margin: 10px 0 0; font-family: "Caveat", cursive; font-size: 1.2rem; color: #E8D2AE; opacity: 0.85; transform: rotate(-2deg); }
.cracked-wood::after {
  /* the cracks: a dark split with a faint light edge */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 160' preserveAspectRatio='none'%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg stroke='%23C9A27A' stroke-opacity='.22' stroke-width='1' transform='translate(0 1.8)'%3E%3Cpath d='M0 46 L34 52 L58 44 L92 58 L118 51 L146 66 L172 60 L204 74 L222 70'/%3E%3Cpath d='M146 66 L152 86 L144 104 L150 122'/%3E%3Cpath d='M300 118 L270 112 L248 124 L218 116 L196 128'/%3E%3C/g%3E%3Cg stroke='%23000' stroke-opacity='.7' stroke-width='2.2'%3E%3Cpath d='M0 46 L34 52 L58 44 L92 58 L118 51 L146 66 L172 60 L204 74 L222 70'/%3E%3Cpath d='M146 66 L152 86 L144 104 L150 122' stroke-width='1.4'/%3E%3Cpath d='M300 118 L270 112 L248 124 L218 116 L196 128'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.cracked-wood > * { position: relative; z-index: 1; }
.wood-label {
  margin: 4px 0 12px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: #D9B98C;
}
.cracked-wood .verdict-name { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.cracked-wood .verdict-score { color: #CDB394; }
.cracked-wood .cc { color: #D9C2A2; border-color: rgba(241, 226, 204, 0.4); }

/* ---------- Hall of Fame: a framed photo with a brass plaque ---------- */
.hall-of-fame { display: flex; flex-direction: column; align-items: center; gap: 0; margin-bottom: 8px; }
.hof-frame {
  width: min(280px, 80%);
  aspect-ratio: 4 / 5;
  padding: 14px;
  border-radius: 3px;
  background:
    linear-gradient(135deg, #B58D3D, #E6C77C 25%, #9C7428 50%, #D9B868 75%, #A8822F);
  box-shadow: 0 22px 40px -18px rgba(0, 0, 0, 0.9), inset 0 0 0 2px rgba(0, 0, 0, 0.25);
}
.hof-frame img, .hof-frame .hof-placeholder {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #2A211B;
  box-shadow: inset 0 0 0 3px #3A2C1E, 0 0 0 2px rgba(0, 0, 0, 0.3);
}
.hof-placeholder { color: #E7C77F; padding: 18%; }
.hof-plaque {
  margin-top: -6px;
  width: min(250px, 72%);
  padding: 10px 14px 12px;
  text-align: center;
  border-radius: 3px;
  background: linear-gradient(#E9D197, #C7A456);
  color: #3A2A0E;
  box-shadow: 0 8px 16px -8px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  position: relative;
  z-index: 1;
}
.hof-week { margin: 0; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; opacity: 0.75; }
.hof-name { margin: 2px 0; font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.hof-meta { margin: 0; font-size: 0.8rem; opacity: 0.85; }
.hof-meta .link-btn { color: #3A2A0E; font-size: 0.8rem; }

.hof-cta { text-align: center; }
.hof-cta p { margin: 0 0 12px; color: var(--ink-soft); }
.hof-cta .hof-cta-title { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; color: var(--ink); margin-bottom: 6px; }

/* ---------- Top 10 universities snapshot ---------- */
.snapshot { padding: 10px 20px 20px; }
.snapshot-list { list-style: none; margin: 0; padding: 0; }
.snapshot-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.snapshot-row:last-child { border-bottom: none; }
.snapshot-row.me { background: #FFF4E6; margin: 0 -10px; padding: 9px 10px; border-radius: 8px; }
.snapshot-rank { width: 24px; text-align: center; font-family: var(--serif); font-weight: 600; color: var(--muted); flex-shrink: 0; }
.snapshot-row:nth-child(1) .snapshot-rank { color: var(--gold); }
.snapshot-name { flex: 1; min-width: 0; font-weight: 600; font-size: 0.92rem; overflow-wrap: anywhere; }
.snapshot-score { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; }

/* ---------- Guest mode / account bits ---------- */
.unlocks { margin: 0 0 18px; padding-left: 0; list-style: none; color: var(--ink-soft); }
.unlocks li { padding-left: 24px; position: relative; margin-bottom: 4px; }
.unlocks li::before { content: "✓"; position: absolute; left: 4px; color: var(--up); font-weight: 700; }
.unlocks.compact { margin: 8px 0 0; font-size: 0.86rem; }
.status-pill.founding { background: var(--gold-soft); color: #7A5A12; }
.founding-pill { display: inline-block; margin: -6px 0 14px; background: var(--gold-soft); border-radius: 999px; padding: 4px 12px; font-size: 0.85rem; font-weight: 600; }
.you-tag { display: inline-block; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 7px; margin-left: 6px; vertical-align: 2px; }
.username-form { margin: 0 0 16px; }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; min-width: 0; }
.field-row .btn { flex-shrink: 0; }
.field-help { margin: 6px 0 0; font-size: 0.78rem; color: var(--muted); }
.form-success { color: var(--up) !important; }

/* ---------- Photo pop-up ---------- */
.rules { margin: 0 0 18px; padding-left: 20px; font-size: 0.88rem; color: var(--ink-soft); }
.rules li { margin-bottom: 4px; }
.upload-btn {
  display: block;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  padding: 14px;
  font-weight: 700;
  cursor: pointer;
}
.upload-btn:hover { background: rgba(29, 33, 52, 0.04); }
.upload-btn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.photo-preview { display: block; max-width: 100%; max-height: 240px; margin: 14px auto 0; border-radius: 8px; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 0.9rem; }
.photo-demo { margin: 12px 0 0 !important; text-align: center; }

/* Lined flashcard: ruled lines and a red margin */
.lined-card {
  position: relative;
  margin: 44px 2px 20px;
  padding: 18px 20px 20px 54px;
  border-radius: 4px;
  line-height: 28px;
  background:
    linear-gradient(90deg, transparent 38px, rgba(142, 47, 60, 0.4) 38px, rgba(142, 47, 60, 0.4) 39.5px, transparent 39.5px),
    repeating-linear-gradient(to bottom, transparent 0 27px, rgba(62, 107, 168, 0.17) 27px 28px) 0 18px / 100% calc(100% - 18px) no-repeat,
    #FFFCF4;
  box-shadow: 0 16px 30px -16px rgba(0, 0, 0, 0.75);
  transform: rotate(0.6deg);
}
.lined-card h3 { font-family: "Caveat", cursive; font-weight: 700; font-size: 1.8rem; line-height: 28px; margin: 0 0 0; }
.lined-card ol { margin: 0; padding-left: 20px; color: var(--ink-soft); }
.lined-card li { margin: 0; }

/* ---------- Alpha banner ---------- */
.alpha-banner {
  background: var(--ink);
  color: rgba(255, 255, 255, 0.82);
  text-align: center;
  font-size: 0.8rem;
  padding: 7px 16px;
  letter-spacing: 0.01em;
}
.alpha-tag {
  display: inline-block;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.68rem;
  color: var(--ink);
  background: var(--gold);
  border-radius: 4px;
  padding: 1px 6px;
  vertical-align: 1px;
}
.alpha-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; }
.alpha-text strong { color: #F2C66D; letter-spacing: 0.02em; }

/* Flip-board countdown: one split-flap tile per digit */
.flipboard { display: inline-flex; align-items: center; gap: 2px; }
.flap {
  position: relative;
  width: 17px;
  height: 24px;
  border-radius: 3px;
  color: #F6E7C1;
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  perspective: 120px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.7), 0 2px 4px rgba(0, 0, 0, 0.3);
}
.flap::after {
  /* the hinge line across the middle */
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: rgba(0, 0, 0, 0.7);
  z-index: 5;
}
.flap > span { position: absolute; left: 0; right: 0; height: 50%; overflow: hidden; background: #262938; }
.flap > span > span { display: block; height: 24px; line-height: 24px; text-align: center; }
.flap-upper, .flap-fold-top { top: 0; border-radius: 3px 3px 0 0; background: #2F3346 !important; }
.flap-lower, .flap-fold-bottom { bottom: 0; border-radius: 0 0 3px 3px; }
.flap-lower > span, .flap-fold-bottom > span { transform: translateY(-50%); }
.flap-fold-top { z-index: 3; transform-origin: bottom; animation: flap-top 0.2s ease-in forwards; }
.flap-fold-bottom { z-index: 4; transform-origin: top; transform: rotateX(90deg); animation: flap-bottom 0.2s ease-out 0.2s forwards; }
@keyframes flap-top { to { transform: rotateX(-90deg); } }
@keyframes flap-bottom { to { transform: rotateX(0deg); } }
.flap-unit { font-size: 0.68rem; color: rgba(255, 255, 255, 0.6); margin: 0 1px; align-self: flex-end; }
.flap-gap { width: 3px; }

/* The fuse: burns down towards the bomb as launch day approaches */
.fuse {
  position: relative;
  max-width: 340px;
  height: 14px;
  margin: 6px auto 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.fuse::before {
  /* the burnt part: a faint line of ash */
  content: "";
  position: absolute;
  left: 0; right: 18px; top: 50%;
  border-top: 1px dashed rgba(255, 255, 255, 0.14);
}
.fuse-rope {
  position: relative;
  height: 3px;
  border-radius: 2px;
  background: repeating-linear-gradient(110deg, #D2AE72 0 3px, #8C6A3C 3px 5px);
}
.fuse-spark {
  position: absolute;
  left: -4px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, #FFF6C8 0%, #FFC14D 45%, rgba(255, 120, 30, 0) 75%);
  box-shadow: 0 0 8px 3px rgba(255, 170, 60, 0.7);
  animation: spark 0.35s infinite alternate;
}
@keyframes spark {
  from { transform: scale(0.8); box-shadow: 0 0 6px 2px rgba(255, 170, 60, 0.6), -3px -3px 0 -2px #FFD27A, 4px -2px 0 -2px #FFB347; }
  to { transform: scale(1.25); box-shadow: 0 0 10px 4px rgba(255, 170, 60, 0.85), -5px 2px 0 -2px #FFE1A0, 3px -5px 0 -2px #FF9B3D; }
}
.fuse-bomb { font-size: 0.85rem; line-height: 1; margin-left: 2px; filter: saturate(0.8); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 20px 10px;
  border-bottom: 1px solid var(--line);
}
.logo {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 2.7rem;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
  font-variation-settings: "opsz" 144;
}
.founding-mark { font-size: 1.1rem; font-style: normal; }

/* Wordmark: the first letter wears a mortarboard with a swinging tassel */
.logo { --cap: #2E3242; --cap-top: #4A5068; --tuft: #E2BC5C; padding-top: 10px; }
.wordmark { display: inline-flex; align-items: baseline; }
.wm-first { position: relative; display: inline-block; }
/* The cap sits ON the A: its skull overlaps the top of the letter.
   To nudge it: "left" moves it sideways, "top" up/down, "width" resizes it. */
.cap {
  position: absolute;
  left: 0.1em;
  top: -0.04em;
  width: 0.72em;
  height: auto;
  overflow: visible;
  transform: rotate(-10deg);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}
/* A charcoal cap with a lighter top and a gold trim, so it stands out on
   both the light pages and the dark home screen */
.cap-board { fill: var(--cap-top); stroke: var(--tuft); stroke-width: 1; stroke-linejoin: round; }
.cap-skull { fill: var(--cap); stroke: var(--tuft); stroke-width: 0.7; stroke-opacity: 0.6; }
.cap-skull-shade { fill: #000; opacity: 0.12; }
.cap-button { fill: var(--tuft); }
.cap-cord { fill: none; stroke: var(--tuft); stroke-width: 1.3; stroke-linecap: round; }
.cap-tuft { fill: var(--tuft); }
.cap-tassel { transform-box: view-box; transform-origin: 33px 9.5px; }
.wordmark.swing .cap-tassel { animation: tassel-swing 1.6s cubic-bezier(0.25, 0.6, 0.3, 1); }
@keyframes tassel-swing {
  0% { transform: rotate(0deg); }
  12% { transform: rotate(28deg); }
  30% { transform: rotate(-18deg); }
  48% { transform: rotate(11deg); }
  66% { transform: rotate(-6deg); }
  82% { transform: rotate(3deg); }
  100% { transform: rotate(0deg); }
}

/* Word of the day: a small paper slip taped askew to the corner of the main card */
.hero-wrap { position: relative; }
.wotd {
  position: absolute;
  top: -16px;
  right: 14px;
  z-index: 5;
  width: 160px;
  padding: 0;
  border: none;
  background: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  perspective: 700px;
  transform: rotate(4deg);
  transition: transform 0.2s ease;
}
@media (hover: hover) { .wotd:hover { transform: rotate(2.5deg) translateY(-2px); } }
.wotd::before {
  /* a strip of tape (it doesn't flip with the slip) */
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  width: 56px;
  height: 16px;
  transform: translateX(-50%) rotate(-5deg);
  background: rgba(255, 250, 235, 0.55);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  z-index: 2;
}
.wotd-inner { display: grid; transform-style: preserve-3d; transition: transform 0.5s cubic-bezier(0.4, 0.1, 0.3, 1); } /* a firm paper flip, no bounce */
.wotd.flipped .wotd-inner { transform: rotateY(180deg); }
.wotd-face {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 13px 12px 11px;
  border-radius: 3px;
  background:
    repeating-linear-gradient(to bottom, transparent 0 17px, rgba(62, 107, 168, 0.1) 17px 18px),
    #FFFDF5;
  box-shadow: 0 12px 20px -9px rgba(0, 0, 0, 0.6);
  backface-visibility: hidden;
}
.wotd-back { transform: rotateY(180deg); justify-content: center; }
.wotd-label { font-family: "Caveat", cursive; font-weight: 700; font-size: 1.02rem; line-height: 1; color: var(--accent); }
.wotd-word { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 1.12rem; line-height: 1.1; overflow-wrap: anywhere; }
.wotd-say { font-size: 0.6rem; color: var(--muted); letter-spacing: 0.02em; }
.wotd-meaning { margin-top: 3px; font-size: 0.73rem; line-height: 1.3; color: var(--ink-soft); }
.wotd-example { font-family: var(--serif); font-style: italic; font-size: 0.8rem; line-height: 1.35; color: var(--ink-soft); }
/* keep the top of the main card clear of the slip on wider screens */
.hero-wrap .hero .eyebrow, .hero-wrap .hero h1, .hero-wrap .hero .tagline { max-width: calc(100% - 160px); }
@media (max-width: 560px) {
  /* on phones the slip sits just above the card instead of over it */
  .wotd { position: relative; top: auto; right: auto; display: block; width: 150px; margin: 0 6px -12px auto; }
  .hero-wrap .hero .eyebrow, .hero-wrap .hero h1, .hero-wrap .hero .tagline { max-width: none; }
}

/* Today's live counters (small flip-boards) */
.hero-stats { display: flex; justify-content: center; gap: 28px; margin: 0 0 20px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.stat-label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.74rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.flipboard.small .flap { width: 20px; height: 28px; font-size: 17px; }
.flipboard.small .flap > span > span { height: 28px; line-height: 28px; }
.flipboard.small .flap-unit { color: var(--muted); font-size: 1rem; align-self: flex-end; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #3FA866; box-shadow: 0 0 0 0 rgba(63, 168, 102, 0.6); animation: live-pulse 2s infinite; }
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(63, 168, 102, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(63, 168, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(63, 168, 102, 0); }
}
.nav { display: flex; align-items: center; gap: 4px; }
.nav-btn {
  background: none;
  border: none;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.nav-btn:hover { background: rgba(29, 33, 52, 0.05); }
.nav-btn.active { color: var(--ink); background: rgba(29, 33, 52, 0.07); }
.icon-btn {
  background: none;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
}
.icon-btn:hover { background: rgba(29, 33, 52, 0.06); }
.account-chip {
  border: 1px solid var(--line-strong);
  background: var(--card);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}
.account-chip.verified { color: var(--up); border-color: rgba(63, 125, 92, 0.4); }

/* ---------- Layout ---------- */
.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.section-title {
  font-size: 1.35rem;
  margin: 36px 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.muted-title { font-family: var(--sans); font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.page-title { font-size: 2.4rem; margin: 8px 0 18px; }
.eyebrow {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

/* ---------- Buttons ---------- */
/* 3D buttons: each sits on a solid "edge" (--edge, --depth deep) and
   presses down into it when clicked. */
.btn {
  --depth: 4px;
  --edge: rgba(0, 0, 0, 0.35);
  position: relative;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 0.98rem;
  box-shadow: 0 var(--depth) 0 var(--edge), 0 calc(var(--depth) + 5px) 12px -6px rgba(0, 0, 0, 0.35);
  transition: background 0.15s, transform 0.06s ease-out, box-shadow 0.06s ease-out;
}
/* Lift on hover only where there's a real mouse (phones keep "hover" after a tap) */
@media (hover: hover) {
  .btn:hover { transform: translateY(-1px); box-shadow: 0 calc(var(--depth) + 1px) 0 var(--edge), 0 calc(var(--depth) + 7px) 14px -6px rgba(0, 0, 0, 0.35); }
}
.btn:active {
  transform: translateY(calc(var(--depth) - 1px));
  box-shadow: 0 1px 0 var(--edge), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  transition-duration: 0.03s;
}
.btn-primary {
  --edge: #07080F;
  background: linear-gradient(to bottom, #2A2F47, var(--ink));
  color: var(--paper);
}
.btn-primary:hover { --edge: #4A1720; background: linear-gradient(to bottom, #A23A48, var(--accent)); }
.btn-ghost {
  --depth: 3px;
  --edge: rgba(29, 33, 52, 0.28);
  background: var(--card);
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn-ghost:hover { background: #FFFFFF; }
.btn-wide { display: block; width: 100%; margin-top: 16px; }
.btn-big { padding: 16px 20px; font-size: 1.05rem; margin-top: 22px; }
.link-btn {
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--muted);
  font-size: 0.85rem;
}
.link-btn:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Chips and pills ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 4px 12px 4px 10px;
  font-size: 0.82rem;
  font-weight: 600;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cat, var(--ink));
  flex-shrink: 0;
}
.status-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 999px;
  padding: 2px 9px;
  vertical-align: 1px;
}
.status-pill.guest { background: rgba(29, 33, 52, 0.07); color: var(--ink-soft); }
.status-pill.verified { background: rgba(63, 125, 92, 0.13); color: var(--up); }
.cc {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 0 5px;
  margin-left: 6px;
  vertical-align: 2px;
}

/* ---------- Home ---------- */
.hero { padding: 30px 28px 26px; position: relative; overflow: hidden; }
.hero::before {
  /* a thin gold rule along the top, like a masthead */
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}
.hero h1 { font-size: 3.4rem; margin: 0 0 10px; font-weight: 500; }
.hero h1 em { color: var(--accent); font-weight: 500; }
.tagline { margin: 0 0 20px; color: var(--muted); font-size: 1.02rem; }
.hero-note { margin: 12px 0 0; text-align: center; font-size: 0.82rem; color: var(--muted); }

.account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  box-shadow: var(--shadow-soft);
}
.account-main { min-width: 0; }
.account-title { margin: 6px 0 2px; font-weight: 700; }
.account-text { margin: 0; color: var(--muted); font-size: 0.88rem; overflow-wrap: anywhere; }
.account-card .btn { flex-shrink: 0; padding: 10px 16px; font-size: 0.9rem; }

.verdict-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 12px; }
.verdict-name { font-family: var(--serif); font-size: 1.2rem; font-weight: 500; line-height: 1.2; margin: 0 0 6px; }
.verdict-score { margin: 0; color: var(--muted); font-size: 0.85rem; }

.how li { padding-left: 4px; }
.how li::marker { font-family: var(--serif); color: var(--accent); font-weight: 600; }

/* ---------- Ad slots (placeholders) ---------- */
.ad-slot {
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  opacity: 0.7;
  text-align: center;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  padding: 22px 10px;
  margin: 28px 0;
}

/* ---------- Play ---------- */
/* Progress: six tall slats that fill with your tier colour */
.progress { display: flex; gap: 6px; margin-bottom: 18px; }
.slat {
  position: relative;
  flex: 1;
  height: 46px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slat-num { font-family: var(--serif); font-size: 0.9rem; color: var(--muted); opacity: 0.6; }
.slat.current { border: 2px solid var(--accent); animation: slat-glow 1.6s ease-in-out infinite; }
.slat.current .slat-num { color: var(--accent); opacity: 1; font-weight: 600; }
@keyframes slat-glow {
  0%, 100% { box-shadow: 0 0 0 3px rgba(142, 47, 60, 0.14); }
  50% { box-shadow: 0 0 0 6px rgba(142, 47, 60, 0.04); }
}
.slat.filled { border-color: transparent; }
.slat-fill { position: absolute; inset: 0; background: var(--tier, var(--miss)); transform-origin: bottom; }
.slat-pts { position: relative; color: #fff; font-family: var(--serif); font-weight: 600; font-size: 1.05rem; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25); }
.slat.further .slat-pts { color: var(--ink); text-shadow: none; }
.slat.rising .slat-fill { animation: slat-rise 0.7s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
.slat.rising .slat-pts { animation: rise 0.4s 0.45s both; }
@keyframes slat-rise { from { transform: scaleY(0); } }

/* Grade reveal: the whole book flips through full-size pages, one per tier,
   then stops on the page for your tier, where your answer appears. */
/* The pages get their own 3D view, so they genuinely swing up and over the spine */
.book-pages {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  perspective: 2600px;
  perspective-origin: 30% 50%;
}
.book-page {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  will-change: transform;
}
/* Each page has a front and a back. Kept simple (no lined paper) so many
   pages can turn at once smoothly, even on older phones. */
.page-face {
  position: absolute;
  inset: 0;
  border-radius: 3px 8px 8px 3px;
  backface-visibility: hidden;
}
.page-front {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(90deg, rgba(60, 40, 20, 0.18), rgba(60, 40, 20, 0) 30px), #FBF6EA;
  box-shadow: inset 0 0 0 1px rgba(60, 40, 20, 0.08);
}
.page-back {
  transform: rotateY(180deg);
  border-radius: 8px 3px 3px 8px;
  background: linear-gradient(270deg, rgba(60, 40, 20, 0.2), rgba(60, 40, 20, 0) 30px), #F3EBD9;
}
.book-page-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 2.6rem;
  font-weight: 500;
  color: color-mix(in srgb, var(--tier, var(--miss)) 80%, #000);
}
.book-page-note { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
/* Turning: up and over the spine, landing open to the left (showing its back),
   then fading into the pile there so the left side doesn't fill up. */
.book-page.turned {
  animation:
    page-turn 0.45s cubic-bezier(0.4, 0.1, 0.45, 1) forwards,
    page-settle 0.35s ease-out 0.45s forwards;
}
@keyframes page-turn { to { transform: rotateY(-180deg); } }
@keyframes page-settle { to { opacity: 0; } }

/* The points, counting up in the corner while the pages turn */
.book-score {
  position: absolute;
  top: 18px;
  right: 86px; /* clear of the bookmark */
  z-index: 3;
  font-family: var(--serif);
  font-size: 2.2rem;
  font-weight: 600;
  line-height: 1;
  color: var(--accent);
}

.book:not(.open) .book-score { display: none; } /* hidden whenever the cover is shut */
.book-score { color: color-mix(in srgb, var(--tier, var(--accent)) 82%, #000); transition: color 0.2s; }
/* Reaching a new tier: the score pops */
.book-score.tier-up { animation: tier-pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes tier-pop { 0% { transform: scale(1); } 35% { transform: scale(1.35) rotate(-3deg); } 100% { transform: scale(1); } }

/* Before opening: the book lifts slightly first, in anticipation */
.book.lifting { animation: book-breath 0.7s ease-out; }
@keyframes book-breath {
  0% { transform: none; }
  20% { transform: translateY(-5px) scale(1.012); }
  100% { transform: none; }
}

/* Page headings while riffling: chapter number and page number */
.book-page-chapter { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.book-page-folio { position: absolute; bottom: 14px; right: 22px; font-family: var(--serif); font-size: 0.85rem; color: var(--muted); }

/* The final tier heading lands like an ink stamp */
.final-tier.stamped { animation: tier-stamp 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
@keyframes tier-stamp {
  0% { transform: scale(1.7) rotate(-6deg); opacity: 0; filter: blur(2px); }
  60% { transform: scale(0.96) rotate(1deg); opacity: 1; filter: none; }
  100% { transform: none; }
}

/* Bursts of colour */
.burst-layer { position: fixed; inset: 0; pointer-events: none; z-index: 2000; }
.spark {
  position: fixed;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  animation: spark-fly 1.1s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}
.spark.strip { width: 5px; height: 12px; border-radius: 2px; }
@keyframes spark-fly {
  0% { transform: translate(0, 0) scale(0.6) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 60px)) scale(1) rotate(var(--spin)); opacity: 0; }
}

/* Text only screen readers hear */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
abbr.cc { text-decoration: none; cursor: help; }

/* Streak line: a button that opens a plain explanation */
.streak-line {
  display: block;
  margin: 10px auto 0;
  padding: 4px 10px;
  border: none;
  border-radius: 999px;
  background: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.streak-line:hover { background: rgba(29, 33, 52, 0.05); }
.info-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 2px;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 0.65rem;
  font-weight: 700;
  opacity: 0.7;
  vertical-align: 1px;
}
.streak-help {
  margin: 8px auto 0;
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--paper);
  font-size: 0.85rem;
  text-align: left;
  color: var(--ink-soft);
}

/* "Add my university" */
.request-link { margin: 14px 0 0; font-size: 0.85rem; color: var(--muted); text-align: center; }
.request-back { margin-top: 14px; }
.error-action { display: inline; margin-left: 2px; color: var(--accent); font-weight: 700; font-size: inherit; }
.dialog select.field { appearance: auto; }
#request-form .field { margin-bottom: 4px; }
#request-form .field-label { margin-top: 12px; }

/* The page it stops on: your tier as a heading, then your answer */
.final-tier {
  margin: 0 0 6px;
  max-width: calc(100% - 150px);
  font-family: var(--serif);
  font-style: italic;
  font-size: 2.3rem;
  font-weight: 500;
  line-height: 1.05;
  color: color-mix(in srgb, var(--tier, var(--miss)) 80%, #000);
}
/* While waiting, the answer page is blank AND nothing on it animates yet, so
   animations like the "See Me" stamp play when you can actually see them. */
.reveal.waiting { visibility: hidden; animation: none; }
.reveal.waiting * { animation: none !important; }
/* Arriving: the lines come in one after another */
.reveal.arrive { animation: none; }
.reveal.arrive > * { animation: rise 0.4s ease-out both; }
.reveal.arrive > :nth-child(1), .reveal.arrive > :nth-child(2) { animation-delay: 0s; }
.reveal.arrive > :nth-child(3) { animation-delay: 0.2s; }
.reveal.arrive > :nth-child(4) { animation-delay: 0.3s; }
.reveal.arrive > :nth-child(n+5) { animation-delay: 0.4s; }
.reveal.arrive > .final-tier.stamped { animation: tier-stamp 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
/* The question reminder at the top of the answer page */
.reveal-question {
  margin: 0 0 10px;
  max-width: calc(100% - 150px);
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted);
}
@keyframes grade-final { 40% { transform: scale(1.08); } }

/* ---------- The question book (seen from above) ---------- */
.book {
  --leather: #6E2430;
  position: relative;
  display: grid;
  perspective: 3000px; /* viewed from further away, so the cover doesn't loom */
  border-radius: 3px 8px 8px 3px;
  background: #FBF6EA; /* the block of pages under the cover */
  box-shadow:          /* page edges peeking out on the right and bottom, then the book's shadow */
    1px 1px 0 #EFE6D2, 2px 2px 0 #E0D4BA, 3px 3px 0 #F1E9D6,
    4px 4px 0 #DCCFB3, 5px 5px 0 #EEE5D0, 6px 6px 0 #D6C8AA,
    12px 18px 28px -10px rgba(0, 0, 0, 0.38);
}
/* A different leather for each book */
.cover-0 { --leather: #6E2430; } /* oxblood */
.cover-1 { --leather: #23345A; } /* navy */
.cover-2 { --leather: #24493A; } /* bottle green */
.cover-3 { --leather: #8A5A32; } /* tan */
.cover-4 { --leather: #4A2B55; } /* plum */
.cover-5 { --leather: #3B4652; } /* slate */

.book-inside, .book-cover { grid-area: 1 / 1; }

/* The inside page: cream paper with faint lines and a shadow at the binding */
.book-inside {
  padding: 26px 24px 26px 40px;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(60, 40, 20, 0.2), rgba(60, 40, 20, 0) 30px),
    repeating-linear-gradient(to bottom, transparent 0 27px, rgba(62, 107, 168, 0.08) 27px 28px),
    #FBF6EA;
}

/* The front cover: leather, a ribbed spine, a gold tooled border, and a cream label */
.book-cover {
  position: relative;
  z-index: 2;
  padding: 18px 18px 18px 36px;
  border-radius: inherit;
  background:
    radial-gradient(ellipse at 30% 15%, rgba(255, 255, 255, 0.12), transparent 60%),
    var(--grain),
    var(--leather);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 0 22px rgba(0, 0, 0, 0.4);
  transform-origin: left center;
  backface-visibility: hidden;
  /* Closing: waits for the lining to rise first, then drops back down */
  transition: transform 0.33s cubic-bezier(0.1, 0.4, 0.5, 1) 0.33s;
}
.book-cover::before {
  /* the spine, with raised gold bands */
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 24px;
  border-radius: 3px 0 0 3px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.05) 70%, rgba(255, 255, 255, 0.1)),
    repeating-linear-gradient(to bottom, transparent 0 34px, rgba(210, 174, 98, 0.6) 34px 36px, transparent 36px 41px, rgba(210, 174, 98, 0.6) 41px 43px, transparent 43px 96px);
}
.book-cover::after {
  /* gold tooled border */
  content: "";
  position: absolute;
  inset: 8px 8px 8px 30px;
  border: 1.5px solid rgba(210, 174, 98, 0.55);
  border-radius: 2px;
  pointer-events: none;
}
.cover-label {
  position: relative;
  z-index: 1;
  padding: 22px 22px 24px;
  border-radius: 3px;
  background: #FBF5E6;
  box-shadow: inset 0 0 0 1px rgba(176, 140, 60, 0.45), 0 2px 6px rgba(0, 0, 0, 0.35);
}
/* Opening happens in two halves, hinged on the spine:
   1. the cover swings up until it stands upright (edge-on), then
   2. its cream lining carries on down and settles flat to the left of the book.
   Closing plays the same two halves in reverse. */
.book.open .book-cover {
  transform: rotateY(-90deg);
  pointer-events: none;
  transition: transform 0.33s cubic-bezier(0.5, 0, 0.9, 0.6) 0s;
}
.cover-lining {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 100%;
  width: 100%;
  z-index: 0;
  pointer-events: none;
  border-radius: 8px 3px 3px 8px;
  /* marbled endpaper, slightly dimmed because it's lying in shadow */
  background:
    linear-gradient(270deg, rgba(40, 25, 10, 0.28), rgba(40, 25, 10, 0) 26px),
    radial-gradient(ellipse 60% 40% at 30% 30%, rgba(142, 47, 60, 0.12), transparent 70%),
    radial-gradient(ellipse 50% 35% at 70% 70%, rgba(47, 99, 133, 0.12), transparent 70%),
    #EFE6D2;
  box-shadow: inset 0 0 0 10px var(--leather), inset 0 0 0 11px rgba(0, 0, 0, 0.25), -6px 10px 18px -8px rgba(0, 0, 0, 0.3);
  filter: brightness(0.94);
  transform-origin: right center;
  transform: rotateY(90deg);
  opacity: 0;
  backface-visibility: hidden;
  /* Closing: rises first (no delay) */
  transition: transform 0.33s cubic-bezier(0.5, 0, 0.9, 0.6) 0s, opacity 0s linear 0.33s;
}
.book.open .cover-lining {
  transform: rotateY(0deg);
  opacity: 1;
  transition: transform 0.33s cubic-bezier(0.1, 0.4, 0.5, 1) 0.33s, opacity 0s linear 0.33s;
}

/* The bookmark: a ribbon in your tier's colour, slotted in at the top.
   The outer part reveals it from the top edge downward, so the ribbon looks
   like it's being slid in between the pages; the inner part is the ribbon. */
.bookmark {
  position: absolute;
  top: -14px;
  right: 30px;
  z-index: 6;
  width: 40px;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.35));
  animation: bookmark-in 0.45s cubic-bezier(0.3, 0.7, 0.4, 1) both;
}
.bookmark-ribbon {
  display: flex;
  justify-content: center;
  padding: 12px 0 24px;
  background: var(--tier, var(--miss));
  color: var(--tier-ink, #fff);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%);
}
.bookmark-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--serif);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
@keyframes bookmark-in {
  from { clip-path: inset(0 -10px 100% -10px); transform: translateY(-10px); }
  to { clip-path: inset(0 -10px -10px -10px); transform: none; }
}

/* Timer: a number plus a bar that drains */
.timer { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.timer-num {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
  width: 2ch;
  text-align: center;
  line-height: 1;
  transition: color 0.2s;
}
.timer-track { flex: 1; height: 6px; border-radius: 999px; background: var(--paper-deep); overflow: hidden; }
.timer-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--ink);
  transition: width 0.1s linear, background 0.2s;
}
.timer.urgent .timer-num { color: var(--accent); animation: pulse 1s infinite; }
.timer.urgent .timer-fill { background: var(--accent); }
.timer.stopped .timer-num { animation: none; }
.timer.stopped { opacity: 0.45; }
@keyframes pulse { 50% { transform: scale(1.12); } }

.q-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hard-badge {
  background: var(--eureka);
  color: #fff;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.q-text { font-size: 2rem; font-weight: 500; margin: 18px 0 8px; }
.q-hint { margin: 0 0 22px; color: var(--muted); font-size: 0.92rem; }

#answer-input {
  width: 100%;
  font: inherit;
  font-size: 1.15rem;
  padding: 15px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
#answer-input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px rgba(194, 154, 58, 0.25); }
#answer-input:disabled { background: var(--paper); }
.form-buttons { display: flex; gap: 10px; margin-top: 12px; }
/* "One more try" note under the answer box */
.retry-msg {
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: #FBEDE4;
  border-left: 3px solid var(--footnote);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.retry-msg strong { color: var(--accent); }
.retry-msg.pop { animation: rise 0.25s ease-out; }
.form-buttons .btn-primary { flex: 1; }
.shake { animation: shake 0.3s; }
@keyframes shake {
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.reveal { margin-top: 2px; animation: rise 0.3s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.reveal-result { font-family: var(--serif); font-size: 1.6rem; font-weight: 500; margin: 0 0 12px; line-height: 1.2; }
.reveal-result.good::before { content: "✓ "; color: var(--up); }
.reveal-result.bad { color: var(--ink-soft); }
.reveal-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; font-size: 0.92rem; }
.points { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; color: var(--accent); margin-left: auto; }
.reveal-facts { border-top: 1px solid var(--line); padding-top: 12px; }
.reveal-sub { margin: 0 0 6px; font-size: 0.88rem; color: var(--muted); }
.reveal-sub strong { color: var(--ink-soft); margin-right: 4px; }
.tip { text-align: center; color: var(--muted); font-size: 0.85rem; font-style: italic; font-family: var(--serif); }

/* Rarity labels */
.rarity {
  display: inline-block;
  color: #fff;
  border-radius: 999px;
  padding: 3px 11px;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--miss);
}
.rarity { background: var(--tier, var(--miss)); color: var(--tier-ink, #fff); }

/* One class per tier sets its colour; every badge, tile, slat and card reads it.
   (Add a new tier here and in config.js.) */
.textbook { --tier: var(--textbook); --tier-ink: #fff; }
.further  { --tier: var(--further);  --tier-ink: var(--ink); }
.footnote { --tier: var(--footnote); --tier-ink: #fff; }
.archive  { --tier: var(--archive);  --tier-ink: #fff; }
.eureka   { --tier: var(--eureka);   --tier-ink: #fff; }
.miss     { --tier: var(--miss);     --tier-ink: #fff; }
/* Eureka answers get a little golden glow */
.rarity.eureka, .tile.eureka { box-shadow: 0 0 0 2px rgba(226, 184, 79, 0.55), 0 0 14px rgba(226, 184, 79, 0.45); }
.bookmark.eureka { filter: drop-shadow(0 0 6px rgba(226, 184, 79, 0.85)) drop-shadow(0 3px 3px rgba(0, 0, 0, 0.35)); }
/* "See Me": a teacher's red-pen note for wrong answers */
.see-me {
  display: inline-block;
  font-family: "Caveat", cursive;
  font-weight: 700;
  font-size: 1.7rem;
  line-height: 1;
  color: #B3261E;
  border: 2px solid #B3261E;
  border-radius: 40% 55% 45% 60% / 60% 45% 55% 40%;
  padding: 2px 14px 4px;
  transform: rotate(-6deg);
  margin: 0 0 10px;
  animation: stamp 0.35s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
@keyframes stamp { from { transform: rotate(-6deg) scale(1.8); opacity: 0; } }

/* ---------- Results ---------- */
.score-card { text-align: center; padding: 32px 24px; }
.big-score {
  font-family: var(--serif);
  font-size: 5rem;
  font-weight: 500;
  line-height: 1;
  margin: 6px 0 8px;
  color: var(--ink);
  font-variation-settings: "opsz" 144;
}
.out-of { font-size: 1.5rem; color: var(--muted); }
.score-verdict { font-family: var(--serif); font-style: italic; font-size: 1.15rem; margin: 0 0 14px; }
.count-status { margin: 0; font-size: 0.88rem; color: var(--muted); }
.count-status .link-btn { margin-left: 4px; }
.founding-earned {
  margin: 16px 0 0;
  background: var(--gold-soft);
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 0.88rem;
}

.share-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 270px;
  margin: 0 auto;
}
.tile {
  aspect-ratio: 1;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  background: var(--miss);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}
.tile { background: var(--tier, var(--miss)); color: var(--tier-ink, #fff); }
.legend { text-align: center; font-size: 0.78rem; color: var(--muted); margin: 16px 0 12px; }
.share-text {
  background: var(--paper);
  border-radius: 10px;
  padding: 14px;
  margin: 0;
  font-family: inherit;
  font-size: 0.92rem;
  white-space: pre-wrap;
  text-align: center;
}
.copy-msg { text-align: center; font-weight: 600; color: var(--up); margin: 10px 0 0; }

.breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 8px;
}
.breakdown-cat {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.breakdown-time { font-weight: 500; letter-spacing: 0; text-transform: none; margin-left: 4px; opacity: 0.8; }
.breakdown-answer { font-family: var(--serif); font-size: 1.1rem; margin-top: 2px; overflow-wrap: anywhere; }
.breakdown-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.breakdown-pts { font-family: var(--serif); font-weight: 600; font-size: 1.2rem; min-width: 2.2ch; text-align: right; }

/* ---------- Leaderboards ---------- */
.tabs {
  display: flex;
  background: var(--paper-deep);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  border-radius: 9px;
  padding: 9px 4px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.tab.active { background: var(--card); color: var(--ink); box-shadow: 0 2px 0 rgba(29, 33, 52, 0.18), var(--shadow-soft); }
.tab:active { transform: translateY(1px); }
.board-note { color: var(--muted); font-size: 0.85rem; margin: 14px 0; }
.board-list { list-style: none; padding: 0; margin: 0; }
.board-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
}
.board-row:nth-child(1) .board-rank { color: var(--gold); }
.board-row.me { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: #FFF8F0; }
.board-rank { font-family: var(--serif); font-weight: 600; font-size: 1.3rem; width: 28px; text-align: center; flex-shrink: 0; color: var(--muted); }
.board-main { flex: 1; min-width: 0; }
.board-name { font-weight: 600; overflow-wrap: anywhere; }
.board-meta { font-size: 0.78rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.up { color: var(--up); font-weight: 600; }
.down { color: var(--down); font-weight: 600; }
.board-score { font-family: var(--serif); font-weight: 600; font-size: 1.35rem; flex-shrink: 0; }
.board-unranked { font-size: 0.82rem; color: var(--muted); }
.board-empty { text-align: center; padding: 28px 24px; }
.board-empty p { margin: 0 0 16px; color: var(--ink-soft); }

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0 16px 36px;
}
.footer p { margin: 0 0 6px; }
.footer .site-name { font-family: var(--serif); font-style: italic; }

/* ---------- Account pop-up ---------- */
.dialog {
  width: calc(100% - 32px);
  max-width: 440px;
  border: none;
  border-radius: 20px;
  padding: 30px 28px 26px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 30px 80px -20px rgba(29, 33, 52, 0.5);
}
.dialog::backdrop { background: rgba(29, 33, 52, 0.45); backdrop-filter: blur(3px); }
.dialog[open] { animation: rise 0.25s ease-out; }
.dialog h2 { font-size: 1.8rem; margin: 0 0 10px; font-weight: 500; }
.dialog-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 999px;
}
.dialog-close:hover { background: rgba(29, 33, 52, 0.06); }
.dialog-text { margin: 0 0 18px; color: var(--ink-soft); }
.dialog-small { margin: -10px 0 14px; color: var(--muted); font-size: 0.88rem; }
.dialog-note { margin: 0; font-size: 0.88rem; background: var(--paper); border-radius: 10px; padding: 10px 12px; }
.field-label { display: block; font-size: 0.8rem; font-weight: 700; margin-bottom: 6px; }
.field {
  width: 100%;
  font: inherit;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
.field:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px rgba(194, 154, 58, 0.25); }
.code-field { font-size: 1.5rem; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; }
.form-error { color: var(--down); font-size: 0.85rem; margin: 8px 0 0; }
.demo-code { background: var(--gold-soft); border-radius: 10px; padding: 10px 12px; font-size: 0.88rem; margin: 0 0 18px; }
.demo-code strong { font-size: 1.05rem; letter-spacing: 0.1em; }
#change-email { margin-top: 14px; }
.demo-note { margin-top: 18px; font-size: 0.82rem; color: var(--muted); }
.demo-note summary { cursor: pointer; font-weight: 600; }
.demo-note ul { max-height: 160px; overflow-y: auto; padding-left: 18px; margin: 6px 0 0; }
.demo-note code { font-size: 0.8rem; color: var(--ink); }

/* ---------- Page-flip transition ---------- */
.flipbook {
  position: fixed;
  inset: 0;
  z-index: 1000;
  perspective: 3200px;   /* further away = gentler, less looming turn */
  perspective-origin: 30% 50%;
  overflow: hidden;
}
/* The spine every page hinges from: a shadowed gutter down the left edge */
.flip-spine {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 26px;
  z-index: 100;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(20, 14, 8, 0.45) 0%, rgba(20, 14, 8, 0.18) 35%, rgba(20, 14, 8, 0) 100%);
  box-shadow: inset 2px 0 0 rgba(0, 0, 0, 0.25);
}
/* Shadow cast onto the page (or screen) beneath a turning page */
.flip-cast {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 4;
  transform-origin: left center;
  background: linear-gradient(90deg, rgba(15, 10, 5, 0.42) 0%, rgba(15, 10, 5, 0.14) 30%, rgba(15, 10, 5, 0) 65%);
}
.flip-page {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--paper) var(--grain);
  transform-origin: left center;
  backface-visibility: hidden;
  will-change: transform;
  box-shadow: 0 0 40px rgba(29, 33, 52, 0.18);
}
.flip-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  /* a band of light and shadow that sweeps across as the paper curves */
  background: linear-gradient(90deg,
    rgba(29, 33, 52, 0) 0%,
    rgba(29, 33, 52, 0.16) 32%,
    rgba(255, 250, 240, 0.12) 48%,
    rgba(29, 33, 52, 0.32) 72%,
    rgba(29, 33, 52, 0.5) 100%);
  background-size: 260% 100%;
  background-position: 100% 0;
}
/* Darker edges so each page reads as a separate sheet of paper:
   a soft spine shadow on the left, a deeper fade at the outer (right) edge,
   a faint fade top and bottom, and a thin edge line. */
.flip-page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    linear-gradient(to left, rgba(29, 33, 52, 0.16), rgba(29, 33, 52, 0.05) 2.5%, rgba(29, 33, 52, 0) 9%),
    linear-gradient(to right, rgba(29, 33, 52, 0.10), rgba(29, 33, 52, 0) 5%),
    linear-gradient(to bottom, rgba(29, 33, 52, 0.05), rgba(29, 33, 52, 0) 4%, rgba(29, 33, 52, 0) 96%, rgba(29, 33, 52, 0.06));
  box-shadow: inset -1px 0 0 rgba(29, 33, 52, 0.22), inset 0 0 0 1px rgba(29, 33, 52, 0.05);
}
.flip-shade { z-index: 3; }
/* Every other page is a touch warmer, so the stack doesn't blur together */
.flip-page.alt { background-color: #EFE7D8; }
.sheet-inner { height: 100%; position: relative; }
.sheet-head {
  position: absolute;
  top: 26px;
  left: 0; right: 0;
  margin: 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--muted);
}
.sheet-folio {
  position: absolute;
  bottom: 24px;
  right: 30px;
  margin: 0;
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--muted);
}

/* ---------- Home: face-down cards ---------- */
.mystery { display: flex; justify-content: center; gap: 10px; }
.mystery-slot { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 52px; }
.mystery-meter { width: 100%; height: 4px; border-radius: 2px; background: var(--paper-deep); overflow: hidden; }
.mystery-meter i { display: block; height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--gold), var(--accent)); }
.mystery-avg { font-size: 0.7rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.mystery-note { text-align: center; font-size: 0.72rem; color: var(--muted); margin: 8px 0 0; }
.mystery-card {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.06) 0 6px, transparent 6px 12px),
    var(--ink);
  box-shadow: inset 0 0 0 3px var(--ink), inset 0 0 0 4px rgba(194, 154, 58, 0.6);
}
.mystery-card.done { color: #fff; font-size: 1.1rem; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.mystery-card.done { background: var(--tier, var(--miss)); color: var(--tier-ink, #fff); }

/* ---------- Play: the pile of books ---------- */
.deck { position: relative; isolation: isolate; margin: 22px 0 30px; }
.deck .question-card { position: relative; z-index: 3; margin-bottom: 0; }
/* The books underneath, slightly out of line, in other leathers */
.deck-back {
  position: absolute;
  inset: 0;
  border-radius: 3px 8px 8px 3px;
  background: radial-gradient(ellipse at 30% 15%, rgba(255, 255, 255, 0.1), transparent 60%), var(--grain), var(--leather);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.35),
    1px 1px 0 #EFE6D2, 2px 2px 0 #E0D4BA, 3px 3px 0 #F1E9D6, 4px 4px 0 #DCCFB3,
    10px 14px 22px -10px rgba(0, 0, 0, 0.35);
}
.deck-back::before {
  /* spine */
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 24px;
  border-radius: 3px 0 0 3px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.05) 70%, rgba(255, 255, 255, 0.1));
}
.deck-back.back-1 { --leather: #3B4652; z-index: 2; transform: translate(7px, 9px) rotate(1.5deg); }
.deck-back.back-2 { --leather: #8A5A32; z-index: 1; transform: translate(-5px, 15px) rotate(-2.2deg); }
.card-clone {
  position: absolute !important;
  top: 0;
  left: 0;
  z-index: 4 !important;
  margin: 0 !important;
  overflow: hidden;
  pointer-events: none;
}
.card-clone:not(.book) { box-shadow: 0 24px 50px -18px rgba(29, 33, 52, 0.45); }
.card-clone.book { overflow: visible; animation: none !important; } /* keep the bookmark showing as it flies */
.card-clone .book-page.turned { display: none; } /* pages already turned stay gone */
.card-clone.behind { z-index: 0 !important; }

.ready-panel { text-align: center; padding: 26px 4px 6px; }
.ready-howto { display: inline-block; margin-top: 14px; }

/* How to play cards */
.howto-panel { text-align: center; padding: 18px 4px 4px; }
.howto-title { font-size: 2.1rem; font-weight: 500; margin: 0 0 12px; }
.howto-title em { color: var(--accent); }
.howto-text { margin: 0 auto 6px; max-width: 380px; color: var(--ink-soft); }
.howto-ladder { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 16px 0 4px; }
.howto-ladder .rarity { text-transform: none; letter-spacing: 0; font-size: 0.8rem; }
.howto-ladder small { opacity: 0.8; font-weight: 600; margin-left: 2px; }
.howto-skip { display: inline-block; margin-top: 12px; }

/* Streaks */
.streak-line { margin: 10px 0 0; text-align: center; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); cursor: help; }
.streak-status { margin: 10px auto 0; max-width: 420px; font-size: 0.88rem; color: var(--ink-soft); }
.ready-title { font-size: 3rem; font-weight: 500; font-style: italic; margin: 0 0 10px; color: var(--accent); }
.ready-text { margin: 0 auto; max-width: 340px; color: var(--muted); }
.q-count {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

/* Points settle with a little pop */
.settled { display: inline-block; animation: settle 0.35s ease-out; }
@keyframes settle { 40% { transform: scale(1.18); } }

/* Screens fade in gently */
.screen:not([hidden]) { animation: rise 0.35s ease-out; }
/* ...but the copies used in the page flip and card shuffle must not replay animations */
.flip-page *, .card-clone * { animation: none !important; }

/* ---------- Small phones ---------- */
@media (max-width: 480px) {
  .alpha-extra { display: none; }
  .topbar { padding: 14px 14px 8px; }
  .logo { font-size: 2.2rem; }
  .nav-btn { padding: 6px 8px; font-size: 0.82rem; }
  .wrap { padding: 16px 14px 32px; }
  .card { padding: 20px; }
  .hero { padding: 26px 20px 22px; }
  .hero h1 { font-size: 2.7rem; }
  .q-text { font-size: 1.6rem; }
  .verdict-grid { grid-template-columns: 1fr; gap: 18px; }
  .notices { grid-template-columns: 1fr; }
  .account-card { flex-direction: column; align-items: stretch; }
  .big-score { font-size: 4rem; }
  .ready-title { font-size: 2.5rem; }
  .book-cover { padding: 12px 12px 12px 30px; }
  .book-cover::after { inset: 6px 6px 6px 26px; }
  .cover-label { padding: 16px 14px 18px; }
  .book-inside { padding: 20px 16px 20px 30px; }
  .book-page-label { font-size: 2.1rem; }
  .final-tier { font-size: 1.9rem; }
}
@media (max-width: 380px) {
  .nav-btn[data-go="home"] { display: none; }
}
@media (max-width: 480px) {
  .nav-btn[data-go="home"] { display: none; } /* the logo goes home on small screens */
  .honours-list { grid-template-columns: 1fr 1fr; gap: 14px 10px; }
}

/* ---------- Honours board: gold lettering on dark wood ---------- */
.honours-board {
  position: relative;
  padding: 26px 22px 22px;
  border-radius: 6px;
  color: #EBD49A;
  background:
    linear-gradient(rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.35)),
    repeating-linear-gradient(178deg, #3E2716 0 4px, #35210F 4px 9px, #452C19 9px 11px, #3A2413 11px 17px),
    #3A2413;
  box-shadow:
    inset 0 0 0 8px #2A190C,
    inset 0 0 0 10px #8A6A35,
    inset 0 0 30px rgba(0, 0, 0, 0.6),
    0 20px 40px -18px rgba(0, 0, 0, 0.7);
  margin-bottom: 20px;
}
.honours-title {
  margin: 4px 0 14px;
  text-align: center;
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #F0D58C;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6), 0 0 12px rgba(240, 200, 110, 0.25);
}
.honours-title .site-name { font-style: italic; text-transform: none; }
.honours-tally {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  margin: 0 0 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(235, 212, 154, 0.25);
  font-size: 0.85rem;
}
.tally-label { width: 100%; margin: 0; text-align: center; font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.7; }
.tally-item strong { color: #FFE3A0; }
/* A grid of little framed certificates, one per day */
.honours-list {
  list-style: none;
  margin: 0;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px 14px;
}
.mini-cert {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 12px 18px;
  text-align: center;
  color: var(--ink);
  border-radius: 3px;
  background: radial-gradient(ellipse at 50% 40%, #FFFBF0 0%, #F5EBD3 75%, #EBDBB8 100%);
  box-shadow:
    inset 0 0 0 3px #F5EBD3,
    inset 0 0 0 4px rgba(176, 140, 60, 0.8),
    inset 0 0 0 6px #F5EBD3,
    inset 0 0 0 7px rgba(176, 140, 60, 0.45),
    0 0 0 3px #6B4A22,                       /* thin wooden frame */
    0 0 0 4px #A07C3E,
    0 10px 18px -8px rgba(0, 0, 0, 0.8);
  transition: transform 0.2s ease;
}
.mini-cert:nth-child(odd) { transform: rotate(-0.6deg); }
.mini-cert:nth-child(even) { transform: rotate(0.5deg); }
@media (hover: hover) { .mini-cert:hover { transform: translateY(-3px) rotate(0deg); } }
.mini-cert.me { box-shadow:
    inset 0 0 0 3px #F5EBD3, inset 0 0 0 4px rgba(176, 140, 60, 0.8),
    inset 0 0 0 6px #F5EBD3, inset 0 0 0 7px rgba(176, 140, 60, 0.45),
    0 0 0 3px #6B4A22, 0 0 0 4px #E7C77F, 0 0 22px rgba(240, 200, 110, 0.55); }
.mc-date { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #8A7A5C; }
.mc-name { font-family: var(--serif); font-size: 0.98rem; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.mc-score { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; color: #8A6A2A; }
.mc-score small { font-family: var(--sans); font-size: 0.65rem; font-weight: 600; color: #8A7A5C; }
.mc-seal {
  position: absolute;
  right: 8px;
  bottom: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 0.75rem;
  color: #6E4F12;
  background: radial-gradient(circle at 35% 30%, #F2D58A, #C99B3B 55%, #9C7424);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
.honours-empty { grid-column: 1 / -1; text-align: center; padding: 12px; font-style: italic; }
.verdict-more { text-align: center; margin: 22px 0 0; }
.home-bg .verdict-more .link-btn { color: rgba(255, 240, 220, 0.7); }
.home-bg .verdict-more .link-btn:hover { color: #E7C77F; }

/* ---------- Enrolled: the slim account bar ---------- */
.account-card.compact { display: block; padding: 12px 18px; }
.enrolled-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
.enrolled-text { flex: 1; min-width: 0; font-size: 0.9rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.enrolled-text strong { color: var(--ink); }
.enrolled-bar .link-btn { font-weight: 600; }
.status-pill.enrolled { background: rgba(63, 125, 92, 0.13); color: var(--up); }
.enrolled-hint { margin: 6px 0 0; font-size: 0.78rem; color: var(--muted); }

/* People who prefer less motion get no pulsing either */
@media (prefers-reduced-motion: reduce) {
  .timer.urgent .timer-num, .reveal, .dialog[open], .settled, .screen:not([hidden]),
  .slat, .slat-fill, .slat-pts, .fuse-spark, .book-page, .cap-tassel, .live-dot, .bookmark,
  .book.lifting, .book-score, .final-tier, .reveal.arrive > * { animation: none !important; }
  .cover-lining { transition: none; }
  .book-page.turned { display: none; }
  .book-cover { transition: none; }
  .cert-particles { display: none; }
  .wotd-inner { transition: none; }
}
