/* Learning Land — big, bright, touch-friendly. */

/* Nunito variable font, self-hosted (SIL Open Font License). */
@font-face {
  font-family: "Nunito";
  src: url("../fonts/nunito.woff2") format("woff2");
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --line: #e7e3da;
  --edge: #d9d4c8;
  --ink: #1d2030;
  --muted: #6b6f80;
  --brand: #5b54e8;
  --brand-soft: #edecfd;
  --brand-edge: #d4d1fa;
  --good: #1fa971;
  --good-ink: #0f7a50;
  --good-soft: #e2f6ec;
  --bad: #e5484d;
  --bad-ink: #b4262b;
  --bad-soft: #fdeceb;
  --gold: #f5b301;
  --star-off: #e6e1d6;
  --accent: var(--brand);
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 28px;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }

main { max-width: 1120px; margin: 0 auto; padding: 28px 20px 56px; }

.icon { display: block; width: 24px; height: 24px; flex: none; }

/* Pressable surfaces share one look: a hairline border and a solid bottom edge that collapses on press. */
.icon-btn, .say-btn, .subject-tab, .skill-link, .big-btn, .choice, .grade-card {
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; height: 72px; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 900; letter-spacing: -0.01em; }
.logo { width: 36px; height: 36px; display: block; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--line); box-shadow: 0 3px 0 var(--edge);
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge); }
.icon-btn[aria-pressed="false"] { color: var(--muted); }
.icon-btn.placeholder { visibility: hidden; }

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

.say-btn {
  border: 0; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
  box-shadow: 0 3px 0 var(--brand-edge);
}
.say-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--brand-edge); }
.say-btn.big { width: 60px; height: 60px; }
.say-btn.big .icon { width: 30px; height: 30px; }
.say-btn.small { width: 38px; height: 38px; }
.say-btn.small .icon { width: 19px; height: 19px; }

/* ---------- home ---------- */

.hero {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  margin: 24px 0 40px; text-align: center;
}
.hero h1 { font-size: clamp(36px, 5.5vw, 56px); font-weight: 900; letter-spacing: -0.02em; line-height: 1.05; }
.hero p { font-size: 19px; color: var(--muted); font-weight: 600; }

.grade-picker {
  display: grid; gap: 24px;
  grid-template-columns: repeat(3, 1fr);
}
.grade-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center;
  padding: 32px 20px 28px; border-radius: var(--radius-lg);
  color: #fff;
  background: linear-gradient(165deg, color-mix(in srgb, var(--c) 82%, #fff), var(--c) 60%);
  box-shadow: 0 8px 0 color-mix(in srgb, var(--c) 72%, #000), 0 18px 30px -12px color-mix(in srgb, var(--c) 60%, transparent);
}
.grade-card::after {
  content: ""; position: absolute; right: -60px; top: -60px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12); pointer-events: none;
}
.grade-card:active { transform: translateY(6px); box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 72%, #000); }
.grade-icon {
  width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center; font-size: 56px;
  background: rgba(255, 255, 255, 0.22);
}
.grade-label { margin-top: 8px; font-size: 96px; font-weight: 900; line-height: 1; letter-spacing: -0.03em; }
.grade-name { margin-top: 4px; font-size: 22px; font-weight: 800; }
.grade-go {
  margin-top: 20px; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.22); font-size: 17px; font-weight: 800;
}
.grade-go .icon { width: 20px; height: 20px; }

/* ---------- grade page ---------- */

.page-head { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; }
.grade-badge {
  width: 76px; height: 76px; border-radius: 22px; flex: none;
  display: grid; place-items: center; font-size: 44px;
  background: color-mix(in srgb, var(--c) 14%, #fff);
  border: 2px solid color-mix(in srgb, var(--c) 24%, #fff);
}
.page-head-text { flex: 1; min-width: 0; }
.eyebrow { font-size: 14px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.page-head h1 { margin-top: 2px; font-size: clamp(30px, 4vw, 40px); font-weight: 900; letter-spacing: -0.02em; line-height: 1.1; }
.summary { width: 240px; flex: none; }
.summary p { font-size: 15px; font-weight: 700; color: var(--muted); margin-bottom: 8px; text-align: right; }
.summary strong { color: var(--ink); font-size: 18px; }
.meter { height: 12px; border-radius: 6px; background: #ebe7de; overflow: hidden; }
.meter span { display: block; height: 100%; min-width: 0; border-radius: 6px; background: var(--gold); }

.subject-nav {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px;
  margin-bottom: 28px;
}
.subject-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 14px 8px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--line);
  box-shadow: 0 4px 0 var(--edge);
}
.subject-tab:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.subject-tab.active {
  background: var(--c); border-color: var(--c); color: #fff;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 72%, #000);
}
.subject-icon { font-size: 30px; line-height: 1; }
.subject-name { font-size: 16px; font-weight: 800; text-align: center; line-height: 1.15; }

.skill-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
}
.skill-list .skill-grid + .unit-title { margin-top: 36px; }
.unit-title {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 14px; font-size: 22px; font-weight: 900; letter-spacing: -0.01em;
}
.unit-title span { font-size: 14px; font-weight: 700; color: var(--muted); }
.skill-card { position: relative; }
.skill-link {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 10px;
  height: 100%; min-height: 204px; padding: 26px 12px 18px;
  background: var(--surface); border-radius: var(--radius);
  border: 2px solid var(--line); box-shadow: 0 5px 0 var(--edge);
  text-align: center;
}
.skill-link:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge); }
.skill-num {
  position: absolute; top: 12px; left: 12px;
  min-width: 28px; height: 28px; padding: 0 6px; border-radius: 14px;
  display: grid; place-items: center;
  background: #f2efe8; color: var(--muted); font-weight: 800; font-size: 14px;
}
.skill-icon {
  width: 84px; height: 84px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 46px; line-height: 1;
  background: color-mix(in srgb, var(--accent) 10%, #fff);
}
.skill-title { flex: 1; display: flex; align-items: center; font-size: 17px; font-weight: 800; line-height: 1.2; }
.skill-card .say-btn { position: absolute; top: 10px; right: 10px; }
.skill-card.mastered .skill-link { background: #fffbeb; border-color: #f6dc8c; box-shadow: 0 5px 0 #ecc85c; }
.skill-card.mastered .skill-num { background: var(--gold); color: #fff; }

.skill-stars, .panel-stars, .done-stars { display: flex; justify-content: center; gap: 3px; }
.star { color: var(--star-off); }
.star.on { color: var(--gold); }
.skill-stars .icon { width: 22px; height: 22px; }

.empty { text-align: center; font-size: 22px; font-weight: 700; color: var(--muted); margin: 60px 0; }

@media (hover: hover) {
  .grade-card:hover { transform: translateY(-3px); }
  .grade-card:active { transform: translateY(6px); }
  .skill-link:hover, .subject-tab:not(.active):hover, .choice:not(:disabled):hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  }
}

/* ---------- quiz ---------- */

.quiz { max-width: 920px; margin: 0 auto; }
.screen { display: flex; flex-direction: column; align-items: center; gap: 24px; text-align: center; }

.panel {
  width: min(620px, 100%); margin-top: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  padding: 44px 32px 36px; border-radius: 32px;
  background: var(--surface); border: 2px solid var(--line); box-shadow: 0 6px 0 var(--edge);
}
.start-icon, .done-icon {
  width: 160px; height: 160px; border-radius: 50%;
  display: grid; place-items: center; font-size: 92px; line-height: 1;
  background: color-mix(in srgb, var(--accent) 10%, #fff);
}
.title-row { display: flex; align-items: center; justify-content: center; gap: 14px; }
.screen h1 { font-size: clamp(30px, 4.5vw, 44px); font-weight: 900; letter-spacing: -0.02em; line-height: 1.1; }
.panel-stars .icon { width: 34px; height: 34px; }

.big-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-width: 180px; padding: 16px 30px; border-radius: 18px;
  font-size: 22px; font-weight: 900;
  background: var(--surface); border: 2px solid var(--line); box-shadow: 0 5px 0 var(--edge);
}
.big-btn .icon { width: 26px; height: 26px; }
.big-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge); }
.big-btn.go {
  background: var(--good); border-color: var(--good); color: #fff;
  box-shadow: 0 5px 0 var(--good-ink);
}
.big-btn.go:active { box-shadow: 0 1px 0 var(--good-ink); }
.start .big-btn.go { width: 100%; max-width: 320px; font-size: 26px; padding: 18px 30px; }

.progress { display: flex; gap: 6px; width: 100%; max-width: 720px; }
.dot { flex: 1; height: 12px; border-radius: 6px; background: #e9e5dc; transition: background-color 0.2s; }
.dot.now { background: color-mix(in srgb, var(--accent) 55%, #fff); }
.dot.good { background: var(--good); }
.dot.miss { background: var(--bad); }

.prompt { display: flex; align-items: center; gap: 16px; max-width: 860px; }
.q-text { font-size: clamp(24px, 3.6vw, 34px); font-weight: 800; text-align: left; line-height: 1.3; }

.show {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 2px solid var(--line); box-shadow: 0 4px 0 var(--edge);
  padding: 18px 28px; white-space: pre-line; line-height: 1.25; max-width: 100%;
  font-weight: 800; overflow-wrap: anywhere;
}
.show.xl { font-size: 104px; }
.show.lg { font-size: 60px; }
.show.md { font-size: 40px; }
.show.sm { font-size: 26px; font-weight: 700; text-align: left; }

.choices { display: grid; gap: 16px; width: 100%; max-width: 860px; grid-template-columns: repeat(2, 1fr); }
.choices.n3 { grid-template-columns: repeat(3, 1fr); }
.choices:has(.choice.long) { grid-template-columns: 1fr; }
.choices:has(.choice.long) .choice {
  min-height: 72px; padding: 16px 64px 16px 22px;
  font-size: 20px; font-weight: 700; line-height: 1.3; text-align: left;
}
.choice-wrap { position: relative; display: flex; }
.choice {
  flex: 1; min-height: 124px; padding: 16px 20px;
  border: 2px solid var(--line); border-radius: 22px;
  background: var(--surface); box-shadow: 0 5px 0 var(--edge);
  font-size: 30px; font-weight: 800; line-height: 1.2;
  overflow-wrap: anywhere;
}
.choice.short { font-size: 56px; }
.choice.emoji-only { font-size: 48px; }
.choice.medium { font-size: 23px; }
.choice:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge); }
.choice:disabled { cursor: default; }
.choice:disabled:not(.right):not(.wrong) { opacity: 0.55; }
.choice.right { background: var(--good-soft); border-color: var(--good); color: var(--good-ink); box-shadow: 0 5px 0 var(--good); }
.choice.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad-ink); box-shadow: 0 5px 0 var(--bad); animation: shake 0.4s; }
.choice-say { position: absolute; top: 10px; right: 10px; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* Feedback slides up from the bottom so it never pushes the choices around. */
.screen.question { padding-bottom: 150px; }
.feedback:empty { display: none; }
.feedback {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  border-top: 2px solid;
  animation: slide-up 0.22s ease-out;
}
.feedback.good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 35%, #fff); color: var(--good-ink); }
.feedback.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, #fff); color: var(--bad-ink); }
.fb-inner { max-width: 860px; margin: 0 auto; display: flex; align-items: center; gap: 16px; text-align: left; }
.fb-icon {
  width: 56px; height: 56px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff;
}
.fb-icon .icon { width: 30px; height: 30px; stroke-width: 3.5; }
.good .fb-icon { background: var(--good); animation: pop 0.3s; }
.bad .fb-icon { background: var(--bad); }
.fb-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.fb-text strong { font-size: 26px; font-weight: 900; }
.fb-text span { font-size: 19px; font-weight: 700; overflow-wrap: anywhere; }
.feedback .big-btn.next {
  min-width: 150px; background: var(--bad); border-color: var(--bad); color: #fff;
  box-shadow: 0 5px 0 var(--bad-ink);
}
.feedback .big-btn.next:active { box-shadow: 0 1px 0 var(--bad-ink); }

@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pop { from { transform: scale(0.4); } to { transform: scale(1); } }

.done-icon { width: 140px; height: 140px; font-size: 80px; background: #fff6d6; }
.done-stars { gap: 8px; }
.done-stars .icon { width: 60px; height: 60px; }
.done-stars .star.on { animation: pop 0.4s both; }
.done-stars .star:nth-child(2) { animation-delay: 0.15s; }
.done-stars .star:nth-child(3) { animation-delay: 0.3s; }
.score { font-size: 20px; font-weight: 700; color: var(--muted); }
.done-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 8px; }
.done-actions .big-btn { min-width: 0; padding: 14px 24px; }

.confetti {
  position: fixed; top: -20px; z-index: 50; pointer-events: none;
  height: 14px; border-radius: 3px;
  animation: fall 3s ease-in forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- math visuals ---------- */

.clock { width: 260px; height: 260px; display: block; }
.clock-face { fill: #fff; stroke: var(--ink); stroke-width: 6; }
.tick { stroke: #a3a3ad; stroke-width: 1.5; }
.tick.big { stroke: var(--ink); stroke-width: 3; }
.clock-num { font-size: 18px; font-weight: 800; text-anchor: middle; fill: var(--ink); font-family: var(--font); }
.hand { stroke-linecap: round; }
.hand.hour { stroke: var(--bad); stroke-width: 9; }
.hand.minute { stroke: var(--brand); stroke-width: 5; }
.hub { fill: var(--ink); }

.coins { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px; max-width: 700px; }
.coin {
  border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; color: #3b3b3b; font-size: 22px;
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.15), 0 4px 0 rgba(0, 0, 0, 0.15);
}
.coin-p { width: 76px; height: 76px; background: radial-gradient(circle at 35% 35%, #f0a36b, #b86b35); color: #4a2410; }
.coin-n { width: 84px; height: 84px; background: radial-gradient(circle at 35% 35%, #eee, #a7a7a7); }
.coin-d { width: 68px; height: 68px; background: radial-gradient(circle at 35% 35%, #f5f5f5, #b5b5b5); font-size: 20px; }
.coin-q { width: 96px; height: 96px; background: radial-gradient(circle at 35% 35%, #f5f5f5, #9e9e9e); font-size: 26px; }

.blocks { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 760px; }
.flat, .rod, .unit {
  background-color: #8fb4ff; border: 2px solid #2f63d6;
  background-image: linear-gradient(#2f63d6 1px, transparent 1px), linear-gradient(90deg, #2f63d6 1px, transparent 1px);
}
.flat { width: 150px; height: 150px; background-size: 15px 15px; }
.rod { width: 17px; height: 150px; background-size: 15px 15px; background-image: linear-gradient(#2f63d6 1px, transparent 1px); }
.ones { display: flex; flex-wrap: wrap-reverse; width: 55px; gap: 4px; }
.unit { width: 15px; height: 15px; background-image: none; background-color: #ffc14d; border-color: #c98a00; }

.shape { width: 200px; height: 200px; display: block; }
.shape-fill { fill: #a59cf7; stroke: var(--brand); stroke-width: 3; stroke-linejoin: round; }

.fraction { width: 260px; height: auto; display: block; }
.part { fill: #fff; stroke: var(--ink); stroke-width: 2; }
.part.on { fill: #f58bb0; }

.viz-label { font-family: var(--font); font-size: 20px; font-weight: 800; fill: var(--ink); text-anchor: middle; }
.viz-label.end { text-anchor: end; font-size: 16px; fill: var(--muted); }
.viz-label.end-strong { text-anchor: end; }

.numberline { width: 560px; max-width: 100%; height: auto; display: block; }
.nl-line { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.nl-tick { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.nl-point { fill: var(--bad); stroke: #fff; stroke-width: 3; }

.grid-viz { max-width: 100%; height: auto; display: block; }
.cell { fill: #fff; stroke: #9aa3b8; stroke-width: 1.5; }
.cell.on { fill: #b9ccff; stroke: #2f63d6; }

.bars-viz { max-width: 100%; height: auto; display: block; }
.bar-gridline { stroke: #e7e3da; stroke-width: 1.5; }
.bar-0 { fill: #3b7cf5; } .bar-1 { fill: #e5508a; } .bar-2 { fill: #1fa971; } .bar-3 { fill: #ef8a17; } .bar-4 { fill: #7c5cf0; }

.angle-viz { width: 260px; height: auto; display: block; }
.ray { stroke: var(--ink); stroke-width: 5; stroke-linecap: round; }
.angle-mark { fill: none; stroke: var(--bad); stroke-width: 4; }

/* ---------- smaller screens ---------- */

@media (max-width: 900px) {
  .grade-picker { grid-template-columns: repeat(2, 1fr); }
  .subject-nav { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 800px) {
  .page-head { flex-wrap: wrap; }
  .summary { width: 100%; }
  .summary p { text-align: left; }
  .subject-tab { flex-direction: column; gap: 4px; padding: 12px 6px; }
  .subject-name { font-size: 14px; text-align: center; }
}

@media (max-width: 640px) {
  main { padding: 20px 14px 44px; }
  .topbar-inner { height: 64px; padding: 0 14px; }
  .brand { font-size: 19px; }
  .logo { width: 32px; height: 32px; }
  .icon-btn { width: 44px; height: 44px; }
  .hero { margin: 8px 0 28px; }
  .hero p { font-size: 16px; }
  .grade-picker { grid-template-columns: 1fr; gap: 16px; }
  .grade-card {
    display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto;
    column-gap: 16px; align-items: center; padding: 18px 20px; text-align: left;
  }
  .grade-icon { grid-row: 1 / 3; width: 76px; height: 76px; font-size: 44px; }
  .grade-label { grid-column: 2; margin: 0; font-size: 44px; }
  .grade-name { grid-column: 2; margin: 0; font-size: 18px; }
  .grade-go { grid-column: 3; grid-row: 1 / 3; margin: 0; padding: 12px; }
  .grade-go span, .grade-go { font-size: 0; }
  .skill-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .skill-link { min-height: 180px; padding-top: 22px; }
  .skill-icon { width: 72px; height: 72px; font-size: 40px; }
  .panel { padding: 32px 20px 28px; }
  .start-icon { width: 128px; height: 128px; font-size: 72px; }
  .choices, .choices.n3 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .choices.n3:not(:has(.choice:not(.short))) { grid-template-columns: repeat(3, 1fr); }
  .choice { font-size: 22px; min-height: 92px; }
  .choice.short { font-size: 42px; }
  .choice.medium { font-size: 18px; }
  .choices:has(.choice.long) .choice { font-size: 16px; padding: 14px 54px 14px 16px; min-height: 60px; }
  .show.xl { font-size: 76px; }
  .show.lg { font-size: 42px; }
  .show.md { font-size: 28px; }
  .fb-icon { width: 44px; height: 44px; }
  .fb-text strong { font-size: 21px; }
  .fb-text span { font-size: 16px; }
  .feedback .big-btn.next { min-width: 0; padding: 14px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .confetti { display: none; }
}
