/*
 * site.css — Easypeasy Cambridge times-tables site.
 * Night-sky hero bands over a soft lavender paper page; gold is the one
 * call-to-action colour, coral/mint/sky are accents.
 */

:root {
  --space-1: #0e0b33;
  --space-2: #231a63;
  --space-3: #3b2a8f;
  --paper: #f7f5ff;
  --card: #ffffff;
  --ink: #1b1747;
  --muted: #5d5a85;
  --line: #e3def7;
  --gold: #ffc83d;
  --gold-dark: #d99a00;
  --coral: #ff6b6b;
  --mint: #2fd39a;
  --sky: #5fd0ff;
  --violet: #7b61ff;
  --radius: 22px;
  --head: "Baloo 2", ui-rounded, "Nunito", "Segoe UI", system-ui, sans-serif;
  --body: "Nunito", ui-rounded, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
img, svg { max-width: 100%; }
a { color: var(--violet); }
h1, h2, h3 { font-family: var(--head); line-height: 1.12; margin: 0 0 .4em; }
h1 { font-size: clamp(36px, 6vw, 60px); font-weight: 800; }
h2 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; }
h3 { font-size: 22px; font-weight: 700; }
p { margin: 0 0 1em; }

.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.section { padding: 64px 0; }
.section-head { max-width: 720px; margin-bottom: 32px; }
.section-head p { color: var(--muted); font-size: 18px; }
.eyebrow {
  display: inline-block;
  font: 800 13px/1 var(--body);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--violet);
  margin-bottom: 12px;
}

/* ---- header ---------------------------------------------------------- */

.site-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(14, 11, 51, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.site-header .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font: 800 21px/1 var(--head); }
.logo img { width: 30px; height: 40px; }
.logo small { display: block; font: 700 11px/1.2 var(--body); color: var(--gold); letter-spacing: .04em; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.site-nav a { color: #dcd6ff; text-decoration: none; font-weight: 700; font-size: 15px; padding: 8px 12px; border-radius: 999px; }
.site-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.site-nav a.btn { color: var(--ink); margin-left: 6px; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; color: #fff; font-size: 26px; cursor: pointer; }

@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .site-nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; padding: 12px 16px 20px;
    background: var(--space-1); border-bottom: 1px solid rgba(255,255,255,.1);
  }
  .site-nav.open { display: flex; }
  .site-nav a.btn { margin: 8px 0 0; text-align: center; }
}

/* ---- buttons --------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 800 18px/1 var(--head);
  padding: 15px 28px 13px;
  border-radius: 999px; border: 0; cursor: pointer; text-decoration: none;
  transition: transform .12s, box-shadow .12s;
}
.btn-gold { background: var(--gold); color: var(--ink); box-shadow: 0 5px 0 var(--gold-dark); }
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--gold-dark); }
.btn-gold:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--gold-dark); }
.btn-ghost { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.btn-ghost:hover { background: rgba(255,255,255,.18); }
.btn-small { font-size: 15px; padding: 10px 18px 9px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---- space bands ----------------------------------------------------- */

.space {
  position: relative; overflow: hidden; color: #fff;
  background:
    radial-gradient(1.5px 1.5px at 20px 30px, #fff 60%, transparent),
    radial-gradient(1px 1px at 90px 120px, #fff 60%, transparent),
    radial-gradient(2px 2px at 160px 60px, #fff8d0 60%, transparent),
    radial-gradient(1px 1px at 230px 170px, #fff 60%, transparent),
    radial-gradient(1.5px 1.5px at 300px 20px, #d8f4ff 60%, transparent),
    radial-gradient(600px 400px at 85% 10%, rgba(123,97,255,.45), transparent 70%),
    radial-gradient(500px 360px at 5% 90%, rgba(255,107,107,.22), transparent 70%),
    linear-gradient(160deg, var(--space-1), var(--space-2) 60%, var(--space-3));
  background-size: 320px 200px, 320px 200px, 320px 200px, 320px 200px, 320px 200px, auto, auto, auto;
}
.space p { color: #dcd6ff; }
.space .eyebrow { color: var(--gold); }

.hero { padding: 64px 0 72px; }
.hero .wrap { display: grid; grid-template-columns: 1.15fr .85fr; gap: 32px; align-items: center; }
.hero h1 b { color: var(--gold); }
.hero .lead { font-size: 20px; max-width: 560px; }
.hero-badge {
  display: inline-block; padding: 7px 14px; border-radius: 999px;
  background: rgba(255,200,61,.15); color: var(--gold);
  font: 800 13px/1 var(--body); letter-spacing: .08em; margin-bottom: 16px;
}
.hero-note { font-size: 14px; margin-top: 14px; opacity: .8; }
.hero-art { position: relative; height: 380px; }
.hero-art img { position: absolute; }
.hero-art .a-rocket { width: 130px; left: 38%; top: 40px; animation: float 4s ease-in-out infinite; }
.hero-art .a-planet1 { width: 170px; right: 0; top: 0; animation: float 6s ease-in-out infinite reverse; }
.hero-art .a-planet2 { width: 110px; left: 0; bottom: 30px; animation: float 5s ease-in-out infinite; }
.hero-art .a-astro { width: 70px; right: 22%; bottom: 10px; animation: drift 7s ease-in-out infinite; }
.hero-art .a-meteor { width: 70px; left: 8%; top: 20px; animation: float 3.5s ease-in-out infinite; }

@keyframes float { 50% { transform: translateY(-14px); } }
@keyframes drift { 50% { transform: translate(-10px, -18px) rotate(-8deg); } }

@media (max-width: 820px) {
  .hero .wrap { grid-template-columns: 1fr; }
  .hero-art { height: 240px; order: -1; }
  .hero-art .a-rocket { width: 90px; }
  .hero-art .a-planet1 { width: 120px; }
  .hero-art .a-planet2 { width: 80px; }
}

.crumbs { font-size: 14px; margin-bottom: 18px; }
.crumbs a { color: #bfb6ff; text-decoration: none; }
.crumbs span { opacity: .6; margin: 0 6px; }

/* ---- cards & grids --------------------------------------------------- */

.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border-radius: var(--radius); padding: 24px;
  box-shadow: 0 1px 0 var(--line), 0 10px 30px rgba(27,23,71,.06);
}
.card p:last-child { margin-bottom: 0; }

.mission { padding: 0; overflow: hidden; }
.mission .scene {
  height: 170px; position: relative;
  background: linear-gradient(170deg, var(--space-1), var(--space-3));
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.mission .scene img { height: 90px; }
.mission .scene .q {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: #fffaf0; color: var(--ink); font: 800 20px/1 var(--head);
  padding: 8px 14px 6px; border-radius: 12px;
}
.mission .body { padding: 20px 22px 24px; }
.mission .tag { font: 800 12px/1 var(--body); letter-spacing: .1em; color: var(--coral); text-transform: uppercase; }

.steps { counter-reset: step; }
.step { position: relative; padding-top: 58px; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; top: 18px; left: 24px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--violet); color: #fff; font: 800 17px/32px var(--head); text-align: center;
}

.order { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.order .stage { display: flex; gap: 6px; padding: 10px; border-radius: 18px; background: #efeaff; }
.order .arrow { color: var(--muted); font-weight: 800; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 52px; height: 44px; padding: 0 12px; border-radius: 14px;
  background: var(--card); color: var(--ink); text-decoration: none;
  font: 800 19px/1 var(--head); box-shadow: 0 3px 0 var(--line);
}
.chip:hover { background: var(--gold); }

.tables { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
@media (max-width: 820px) { .tables { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 480px) { .tables { grid-template-columns: repeat(3, 1fr); } }
.table-card {
  display: block; text-align: center; text-decoration: none; color: var(--ink);
  background: var(--card); border-radius: 18px; padding: 18px 8px 14px;
  box-shadow: 0 4px 0 var(--line); transition: transform .15s;
}
.table-card:hover { transform: translateY(-4px); }
.table-card b { display: block; font: 800 34px/1 var(--head); color: var(--violet); }
.table-card span { font-size: 13px; color: var(--muted); font-weight: 700; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .split { grid-template-columns: 1fr; } }
.callout { display: flex; flex-direction: column; align-items: flex-start; }
.callout .btn { margin-top: auto; }
.callout.dark { background: linear-gradient(160deg, var(--space-2), var(--space-3)); color: #fff; }
.callout.dark p { color: #dcd6ff; }

/* ---- times-table page ------------------------------------------------ */

.chart { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .chart { grid-template-columns: repeat(2, 1fr); } }
.fact {
  display: flex; align-items: baseline; justify-content: space-between;
  background: var(--card); border-radius: 16px; padding: 14px 18px;
  font: 700 24px/1 var(--head); box-shadow: 0 3px 0 var(--line);
}
.fact b { color: var(--violet); font-weight: 800; }
.fact.square { background: #fff6d9; }

.skip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.skip span {
  min-width: 48px; text-align: center; padding: 8px 10px; border-radius: 12px;
  background: var(--space-2); color: #fff; font: 800 18px/1 var(--head);
}

.aloud { columns: 2; column-gap: 32px; padding: 0; margin: 0; list-style: none; }
@media (max-width: 560px) { .aloud { columns: 1; } }
.aloud li { padding: 6px 0; border-bottom: 1px dashed var(--line); break-inside: avoid; }
.aloud li b { color: var(--violet); }

.tip { border-top: 5px solid var(--sky); }
.tip:nth-child(2) { border-color: var(--coral); }
.tip:nth-child(3) { border-color: var(--mint); }
.tip:nth-child(4) { border-color: var(--gold); }
.pattern { margin-top: 20px; font-weight: 700; }
.pattern code { font: 800 18px var(--head); background: #efeaff; padding: 3px 8px; border-radius: 8px; }

.game-poster {
  position: relative; display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
  border-radius: 28px; padding: 32px;
}
.game-poster .poster-art { display: flex; gap: 8px; align-items: flex-end; }
.game-poster .poster-art img { height: 110px; }
@media (max-width: 720px) {
  .game-poster { grid-template-columns: 1fr; }
  .game-poster .poster-art { order: -1; justify-content: center; }
  .game-poster .poster-art img { height: 80px; }
}
.small-link { display: inline-block; margin-top: 14px; color: #bfb6ff; font-weight: 700; font-size: 15px; }

.quiz { background: var(--card); border-radius: var(--radius); padding: 28px; max-width: 560px; box-shadow: 0 10px 30px rgba(27,23,71,.08); }
.quiz-q { font: 800 46px/1.1 var(--head); text-align: center; margin-bottom: 18px; }
.quiz-opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 420px) { .quiz-opts { grid-template-columns: repeat(2, 1fr); } }
.quiz-opts button {
  font: 800 26px/1 var(--head); padding: 16px 0 12px; border-radius: 16px; cursor: pointer;
  border: 0; background: #efeaff; color: var(--ink); box-shadow: 0 4px 0 #d5ccff;
}
.quiz-opts button:hover { background: #e2dbff; }
.quiz-opts button.ok { background: var(--mint); color: #fff; box-shadow: 0 4px 0 #1f9c70; }
.quiz-opts button.no { background: var(--coral); color: #fff; box-shadow: 0 4px 0 #c94a4a; }
.quiz-foot { display: flex; justify-content: space-between; margin-top: 16px; color: var(--muted); font-weight: 700; }

.pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }

.faq details { background: var(--card); border-radius: 16px; padding: 4px 20px; margin-bottom: 10px; box-shadow: 0 2px 0 var(--line); }
.faq summary { cursor: pointer; font: 700 19px/1.3 var(--head); padding: 14px 0; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; float: right; color: var(--violet); font-size: 24px; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq details p { color: var(--muted); }

/* ---- worksheets ------------------------------------------------------ */

.ws-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 24px; }
.ws-controls label { display: flex; flex-direction: column; font-weight: 700; font-size: 14px; gap: 6px; }
.ws-controls select {
  font: 700 16px var(--body); padding: 10px 12px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
}
.sheet { background: #fff; color: #111; border-radius: 12px; padding: 36px 40px; box-shadow: 0 10px 30px rgba(27,23,71,.1); max-width: 820px; }
.sheet-top { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #111; padding-bottom: 10px; margin-bottom: 20px; font-weight: 700; }
.sheet h2 { font-size: 28px; margin-bottom: 4px; }
.sheet-qs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 40px; list-style: none; padding: 0; margin: 0; counter-reset: q; }
.sheet-qs li { font: 600 22px/1.4 var(--head); counter-increment: q; }
.sheet-qs li::before { content: counter(q) ".  "; color: #888; font-size: 15px; }
.sheet-qs .blank { display: inline-block; min-width: 64px; border-bottom: 2px solid #333; text-align: center; color: #c33; }
.sheet:not(.show-answers) .blank em { visibility: hidden; }
.sheet-foot { margin-top: 24px; font-size: 13px; color: #666; display: flex; justify-content: space-between; }
@media (max-width: 560px) { .sheet { padding: 24px 18px; } .sheet-qs { grid-template-columns: 1fr; } }

@media print {
  .site-header, .site-footer, .no-print, .space { display: none !important; }
  body { background: #fff; }
  .section { padding: 0; }
  .sheet { box-shadow: none; padding: 0; max-width: none; }
}

/* ---- embed ----------------------------------------------------------- */

.code {
  position: relative; background: var(--space-1); color: #d8f4ff; border-radius: 16px;
  padding: 20px; font: 14px/1.6 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all;
}
.code button { position: absolute; top: 10px; right: 10px; }
.embed-demo { display: flex; justify-content: center; }
.embed-demo iframe { width: 390px; max-width: 100%; height: 720px; border: 0; border-radius: 18px; box-shadow: 0 20px 50px rgba(27,23,71,.25); }

/* ---- game overlay ---------------------------------------------------- */

.game-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(7,6,26,.94);
  display: flex; align-items: center; justify-content: center;
  animation: fade-in .25s ease;
}
.game-overlay iframe { width: min(100vw, calc(100vh * .56)); height: 100vh; height: 100dvh; border: 0; }
.game-close {
  position: absolute; top: 14px; right: 14px; width: 46px; height: 46px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 22px; cursor: pointer;
}
.game-close:hover { background: rgba(255,255,255,.28); }
@keyframes fade-in { from { opacity: 0; } }

/* ---- create (teacher) page ------------------------------------------- */

.create { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 28px; align-items: start; }
@media (max-width: 960px) { .create { grid-template-columns: 1fr; } }
.create-form { display: flex; flex-direction: column; gap: 18px; }
.create-form h2 { font-size: 24px; }
.create-form label { display: block; font-weight: 700; font-size: 15px; margin-bottom: 12px; }
.field {
  display: block; width: 100%; margin-top: 6px; font: 600 16px var(--body); color: var(--ink);
  padding: 11px 14px; border: 2px solid var(--line); border-radius: 12px; background: #fff;
}
.field:focus { outline: none; border-color: var(--violet); }
textarea.field { font: 15px/1.5 ui-monospace, Consolas, monospace; resize: vertical; }
.muted { color: var(--muted); font-size: 14px; }
.step-head, .samples-head, .preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.btn-soft { background: #efeaff; color: var(--ink); }
.btn-soft:hover { background: #e2dbff; }
.seg { display: inline-flex; background: #efeaff; border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.seg button { border: 0; background: none; font: 800 15px var(--body); color: var(--muted); padding: 9px 16px; border-radius: 999px; cursor: pointer; }
.seg button.on { background: var(--violet); color: #fff; }
.topic-options fieldset { border: 0; padding: 0; margin: 0 0 12px; }
.topic-options legend { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check input { position: absolute; opacity: 0; }
.check span {
  display: inline-block; min-width: 44px; text-align: center; padding: 7px 12px; border-radius: 10px; cursor: pointer;
  background: #efeaff; font-weight: 800; font-size: 15px;
}
.check input:checked + span { background: var(--violet); color: #fff; }
.check input:focus-visible + span { outline: 2px solid var(--violet); outline-offset: 2px; }
.status { font-weight: 700; font-size: 14px; }
.status.ok { color: #1f9c70; }
.status.bad, .samples .bad { color: #c94a4a; }
.samples { list-style: none; padding: 0; margin: 10px 0 0; }
.samples li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.samples span { color: #1f9c70; font-weight: 800; }
.samples em { color: var(--muted); font-size: 13px; }
.mission-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.mission-pick { position: relative; display: flex !important; flex-direction: column; gap: 4px; margin: 0 !important; padding: 12px; border-radius: 16px; border: 2px solid var(--line); cursor: pointer; }
.mission-pick input { position: absolute; top: 10px; right: 10px; width: 18px; height: 18px; accent-color: var(--violet); }
.mission-pick img { height: 44px; width: 44px; object-fit: contain; }
.mission-pick b { font-family: var(--head); font-size: 17px; }
.mission-pick span { font-weight: 400; font-size: 13px; color: var(--muted); line-height: 1.35; }
.mission-pick:has(input:checked) { border-color: var(--violet); background: #f6f3ff; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .row-2 { grid-template-columns: 1fr; } }
.link-out { margin-top: 18px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row .field { margin-top: 6px; }
.copy-row .btn { flex: none; margin-top: 6px; }
.link-out a { display: inline-block; margin: 0 0 14px; font-weight: 700; }
.create-preview { position: sticky; top: 84px; }
.create-preview iframe { display: block; width: 100%; height: 720px; margin: 10px 0; border: 0; border-radius: 22px; background: #0b0930; box-shadow: 0 20px 50px rgba(27,23,71,.25); }
@media (max-width: 960px) { .create-preview { position: static; } .create-preview iframe { max-width: 400px; margin: 10px auto; } }
.my-game h3 { overflow-wrap: anywhere; }

/* ---- footer ---------------------------------------------------------- */

.site-footer { background: var(--space-1); color: #bfb6ff; padding: 40px 0; font-size: 15px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; }
.site-footer a { color: #fff; text-decoration: none; margin-right: 16px; }
.site-footer .tagline { color: var(--gold); font-weight: 800; }

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

/* ---- student log in, my page, teacher dashboard ------------------------ */

.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
.narrow-wrap { max-width: 560px; }
.btn-danger { background: #ffe4e4; color: #b03030; }
.btn-danger:hover { background: #ffd2d2; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.demo-note { background: #fff6d6; border: 2px dashed var(--gold); border-radius: 16px; padding: 12px 16px; font-size: 15px; }
.demo-note code, .muted code { background: #fff; padding: 1px 6px; border-radius: 6px; }
.login-form label { display: block; font-weight: 800; margin-bottom: 14px; }
.login-form .btn { width: 100%; margin: 6px 0 10px; }
.code-field { text-transform: uppercase; letter-spacing: .2em; font-weight: 800; }

.board { list-style: none; padding: 0; margin: 8px 0 14px; }
.board li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto 64px; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; }
.board li:nth-child(odd):not(.muted) { background: #f6f3ff; }
.board li.me { background: #fff1c2 !important; box-shadow: inset 0 0 0 2px var(--gold); }
.board li.muted { display: block; }
.board .rank { font: 800 20px var(--head); text-align: center; }
.board .who { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .games { color: var(--muted); font-size: 14px; }
.board .pts { font: 800 20px var(--head); text-align: right; color: var(--violet); }
.board.history li { grid-template-columns: 56px minmax(0, 1fr) auto 56px; }
.board .when { color: var(--muted); font-size: 14px; }

.t-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.class-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.class-tabs button { border: 2px solid var(--line); background: #fff; font: 800 15px var(--body); color: var(--ink); padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.class-tabs button.on { border-color: var(--violet); background: var(--violet); color: #fff; }
.t-user { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.class-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.class-head > div:first-child { flex: 1 1 340px; }
.class-code { font: 800 26px var(--head); letter-spacing: .14em; color: var(--violet); }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 700px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat { background: #fff; border-radius: 16px; padding: 14px 16px; box-shadow: 0 1px 0 var(--line); }
.stat b { display: block; font: 800 28px var(--head); }
.stat span { color: var(--muted); font-size: 14px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th { text-align: left; font-size: 13px; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data .mono { font-family: ui-monospace, Consolas, monospace; }
table.data .actions { white-space: nowrap; }
table.data .actions .btn { padding: 6px 10px; font-size: 13px; margin: 2px; }
.idle-tag { display: block; color: #b46a00; font-size: 12px; font-weight: 700; }
.field.narrow { max-width: 280px; margin-bottom: 14px; }
.spaced { margin: 14px 0; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 14px; }
.login-card { border: 2px dashed #9b8cff; border-radius: 16px; padding: 14px 16px; background: #fff; break-inside: avoid; }
.lc-brand { font: 800 14px var(--head); color: var(--violet); }
.lc-name { font: 800 24px var(--head); margin: 2px 0 8px; }
.lc-row { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding: 5px 0; font-size: 14px; }
.lc-row b { font-family: ui-monospace, Consolas, monospace; font-size: 16px; letter-spacing: .05em; }
.lc-tag { margin-top: 6px; font-size: 11px; color: var(--muted); }
@media print {
  .cards-section { padding: 0; }
  .cards-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}
.class-head .btn-row { align-self: flex-start; align-items: flex-start; }
.card .step-head { flex-wrap: wrap; }
.grid-2 .card h2 { font-size: 30px; }

/* ---- worksheet hub and category pages ---------------------------------- */
.ws-card { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); transition: transform .15s; }
.ws-card:hover { transform: translateY(-4px); }
.ws-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--violet); color: #fff; display: grid; place-items: center; font: 800 30px var(--head); margin-bottom: 14px; }
.ws-card p { color: var(--muted); flex: 1; }
.ws-go { font-weight: 800; color: var(--violet); }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 24px; }
.chip { background: #efeaff; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 15px; padding: 7px 14px; border-radius: 999px; }
.chip:hover { background: #e2dbff; }
.narrow-faq { max-width: 820px; }
.sheet-qs.families { grid-template-columns: 1fr; gap: 18px; }
.sheet-qs.families li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 26px; font-size: 19px; padding-bottom: 12px; border-bottom: 1px dashed #ccc; }
.family-nums { display: inline-block; min-width: 120px; font-weight: 800; background: #f1edff; border-radius: 10px; padding: 2px 12px; }
.sheet-qs .blank.short { min-width: 40px; }
@media print { .family-nums { background: none; border: 2px solid #111; } }
@media (max-width: 480px) {
  .board li, .board.history li { grid-template-columns: 36px minmax(0, 1fr) 56px; }
  .board .games { display: none; }
}

/* ---- typing answers on the worksheet ------------------------------------ */
.sheet-qs .blank { border-bottom: 0; min-width: 0; vertical-align: baseline; }
.sheet-qs .blank em { display: none; }
.sheet.show-answers .blank em { display: inline-block; visibility: visible; min-width: 64px; border-bottom: 2px solid #333; font-style: normal; }
.sheet.show-answers .blank.short em { min-width: 40px; }
.sheet.show-answers .blank .ans { display: none; }
.ans {
  width: 72px; font: 700 22px/1.2 var(--head); color: var(--violet); text-align: center;
  border: 0; border-bottom: 2px solid #333; border-radius: 8px 8px 0 0; background: #f4f1ff; padding: 2px 4px;
}
.blank.short .ans { width: 48px; font-size: 19px; }
.ans:focus { outline: none; background: #fff6d6; border-bottom-color: var(--violet); }
.ans.ok { background: #dcf7ec; border-bottom-color: #1f9c70; color: #157a56; }
.ans.no { background: #ffe1e1; border-bottom-color: #c94a4a; color: #b03030; }
.ws-check { max-width: 820px; margin-top: 18px; }
.ws-result { font: 800 20px var(--head); margin: 12px 0 4px; min-height: 1.2em; }
.ws-result.ok { color: #1f9c70; }
.ws-save { font: 700 15px var(--body); color: var(--muted); }
@media print {
  .ans { background: none !important; color: #111 !important; border-radius: 0; }
  .ans:placeholder-shown { color: transparent; }
}

/* fact families: numbers on the left, × facts on top, ÷ facts lined up beneath */
.sheet-qs.families li {
  display: grid; grid-template-columns: 150px repeat(2, max-content); grid-template-rows: auto auto;
  align-items: center; gap: 12px 40px;
}
.sheet-qs.families .family-nums { grid-row: 1 / span 2; align-self: center; justify-self: start; }
.sheet-qs.families .fact {
  display: inline-flex; align-items: baseline; justify-content: flex-start; gap: 8px;
  background: none; box-shadow: none; border-radius: 0; padding: 0; font: 600 21px/1.4 var(--head);
}
@media (max-width: 640px) {
  .sheet-qs.families li { grid-template-columns: repeat(2, max-content); gap: 10px 20px; }
  .sheet-qs.families .family-nums { grid-row: auto; grid-column: 1 / -1; }
}
/* fixed places: number | family | × × on row 1, ÷ ÷ right under them on row 2 */
.sheet-qs.families li { grid-template-columns: 28px 140px max-content max-content; }
.sheet-qs.families li::before { grid-column: 1; grid-row: 1 / span 2; align-self: center; }
.sheet-qs.families .family-nums { grid-column: 2; grid-row: 1 / span 2; }
.sheet-qs.families .fact:nth-child(2) { grid-column: 3; grid-row: 1; }
.sheet-qs.families .fact:nth-child(3) { grid-column: 4; grid-row: 1; }
.sheet-qs.families .fact:nth-child(4) { grid-column: 3; grid-row: 2; }
.sheet-qs.families .fact:nth-child(5) { grid-column: 4; grid-row: 2; }
@media (max-width: 640px) {
  .sheet-qs.families li { grid-template-columns: 24px max-content max-content; }
  .sheet-qs.families li::before { grid-row: 1; }
  .sheet-qs.families .family-nums { grid-column: 2 / -1; grid-row: 1; }
  .sheet-qs.families .fact:nth-child(2) { grid-column: 2; grid-row: 2; }
  .sheet-qs.families .fact:nth-child(3) { grid-column: 3; grid-row: 2; }
  .sheet-qs.families .fact:nth-child(4) { grid-column: 2; grid-row: 3; }
  .sheet-qs.families .fact:nth-child(5) { grid-column: 3; grid-row: 3; }
}
@media (max-width: 640px) {
  .sheet-qs.families li { grid-template-columns: 24px max-content; }
  .sheet-qs.families .family-nums { grid-column: 2; }
  .sheet-qs.families .fact:nth-child(n) { grid-column: 2; }
  .sheet-qs.families .fact:nth-child(2) { grid-row: 2; }
  .sheet-qs.families .fact:nth-child(3) { grid-row: 3; }
  .sheet-qs.families .fact:nth-child(4) { grid-row: 4; }
  .sheet-qs.families .fact:nth-child(5) { grid-row: 5; }
}

/* ---- diamonds, ranks and stickers --------------------------------------- */
.rewards, .stickers-card { margin-bottom: 20px; }
.rank-box { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 20px; align-items: center; }
.rank-gem .gem { filter: drop-shadow(0 6px 10px rgba(27,23,71,.18)); }
.rank-text h2 { margin: 0 0 8px; }
.rank-text .eyebrow { margin-bottom: 4px; }
.rank-bar { height: 14px; border-radius: 999px; background: #efeaff; overflow: hidden; }
.rank-bar i { display: block; height: 100%; border-radius: 999px; transition: width .6s ease; }
.rank-text .muted { margin: 6px 0 0; }
.wallet { text-align: center; background: #f6f3ff; border-radius: 18px; padding: 12px 18px; }
.wallet b { display: block; font: 800 34px/1 var(--head); color: var(--violet); }
.wallet span { font-size: 13px; font-weight: 700; color: var(--muted); }
.rank-ladder { list-style: none; padding: 0; margin: 20px 0 12px; display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.rank-ladder li { text-align: center; padding: 8px 2px; border-radius: 12px; opacity: .55; }
.rank-ladder li.done { opacity: .85; }
.rank-ladder li.here { opacity: 1; background: #fff1c2; box-shadow: inset 0 0 0 2px var(--gold); }
.rank-ladder span { display: block; font: 800 13px var(--head); }
.rank-ladder small { display: block; font-size: 11px; color: var(--muted); }
@media (max-width: 700px) {
  .rank-box { grid-template-columns: auto minmax(0, 1fr); }
  .wallet { grid-column: 1 / -1; }
  .rank-ladder { grid-template-columns: repeat(5, 1fr); }
}
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.sticker { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 14px 10px; border-radius: 18px; background: #f6f3ff; }
.sticker img { width: 86px; height: 86px; object-fit: contain; filter: grayscale(1) opacity(.45); }
.sticker.owned { background: #fff; box-shadow: 0 0 0 2px var(--gold), 0 8px 18px rgba(27,23,71,.08); }
.sticker.owned img { filter: drop-shadow(0 0 0 #fff) drop-shadow(3px 3px 0 #fff) drop-shadow(-3px -3px 0 #fff) drop-shadow(0 6px 8px rgba(27,23,71,.25)); }
.sticker b { font: 800 15px var(--head); }
.sticker .got { font-weight: 800; color: #1f9c70; font-size: 14px; }
.ws-reward { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; background: #fff6d6; border: 2px solid var(--gold); border-radius: 18px; padding: 12px 18px; margin: 8px 0 14px; }
.ws-reward .gain { font: 800 30px var(--head); color: var(--violet); animation: gem-pop .5s cubic-bezier(.34,1.56,.64,1); }
.ws-reward > div:nth-child(2) { display: flex; align-items: center; gap: 8px; font-weight: 700; flex: 1 1 260px; }
.ws-reward a { font-weight: 800; }
.ws-reward.rank-up { background: #e6fff4; border-color: var(--mint); }
@keyframes gem-pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.rank-cell { white-space: nowrap; }
.rank-cell .gem { vertical-align: middle; margin-right: 4px; }
.sticker-cell { cursor: help; }
.site-footer .disclaimer { margin-top: 8px; font-size: 13px; color: #9a91d6; max-width: 560px; }

/* home: rewards promo */
.promo-stickers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; max-width: 380px; margin: 0 auto; }
.promo-stickers img {
  width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 24px; padding: 14px;
  box-shadow: 0 0 0 2px var(--gold), 0 10px 20px rgba(27,23,71,.1);
}
.promo-stickers img:nth-child(odd) { transform: rotate(-6deg); }
.promo-stickers img:nth-child(even) { transform: rotate(5deg); }
.rewards-promo .btn-soft { background: #fff; box-shadow: 0 0 0 2px var(--line); }
