/* Fonts, tokens, buttons, nav, hero, badge shelf, questions, effects, forms. Load order matters: later files refine earlier ones (see docs/STRUCTURE.md). */
@import url('https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@300;400;500;700&family=Open+Sans:wght@400;600;700&family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=Lexend:wght@400;500;600;700;800&family=Nunito:wght@400;600;700;800;900&display=swap');
:root {
  color-scheme: light;
  --page: #edf0fa; --bg: #fbfcff; --card: #ffffff; --ink: #1c2140; --ink-2: #3d4468; --muted: #5b6283; --line: #e3e6f3;
  --y: #ffb62e; --y-soft: #fff2d1; --y-deep: #b36e00; --navy: #1c2f7a; --coral: #e5573b; --purple: #7a4fe6;
  --nav-a: #2a47c4; --nav-b: #1a2c80; --link: #2349c8; --blue: #3f63e6;
  --accent: var(--y);
  --good: #187a42; --bad: #d3304f; --warn: #f5a524;
  --good-bg: #e1f5e8; --bad-bg: #fde7ec; --good-ink: #145c34; --bad-ink: #8c1534;
  --radius: 20px; --shadow: 0 8px 28px rgba(20, 20, 60, .07);
  --head: "Lexend", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--page); font: 16px/1.6 "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif; min-height: 100vh; }
#app { width: calc(100% - 40px); max-width: 1640px; margin: 20px auto; padding: 4px clamp(28px, 4vw, 72px) 56px; background: var(--bg); border-radius: 28px; box-shadow: 0 20px 60px rgba(40, 40, 120, .12); overflow: hidden; position: relative; }
#app > * { animation: rise .4s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
h1, h2, h3 { font-family: var(--head); line-height: 1.2; margin: 0 0 .4em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 2rem; } h2 { font-size: 1.55rem; } h3 { font-size: 1.1rem; }
h2 { margin-top: 8px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card.click { cursor: pointer; transition: transform .18s, box-shadow .18s; border-top: 6px solid var(--y); }
.card.click:hover, .card.click:focus-visible { transform: translateY(-5px); outline: none; box-shadow: 0 16px 36px rgba(20, 20, 60, .14); }
.big-emoji { font-size: 3rem; line-height: 1.1; display: inline-block; }
.card.click:hover .big-emoji { animation: wiggle .6s; }
@keyframes wiggle { 25% { transform: rotate(-12deg) scale(1.1); } 75% { transform: rotate(12deg) scale(1.1); } }

/* buttons */
button { font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 11px 22px; cursor: pointer; color: var(--ink); background: var(--y);
  box-shadow: 0 6px 14px rgba(255, 184, 0, .35); transition: transform .12s, box-shadow .12s, filter .15s; }
button:hover { filter: brightness(1.05); transform: translateY(-1px); }
button:active { transform: translateY(1px); box-shadow: 0 2px 6px rgba(255, 184, 0, .35); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
button.ghost { background: #fff; border: 1.5px solid var(--y); box-shadow: none; }
button.ghost:hover { background: var(--y-soft); }
button.small { padding: 7px 14px; font-size: .88rem; border-radius: 10px; }
button.big { font-size: 1.05rem; padding: 15px 30px; }
button:disabled { opacity: .45; cursor: default; box-shadow: none; transform: none; }
.play { display: inline-flex; align-items: center; gap: 12px; background: transparent; box-shadow: none; color: var(--muted); padding: 6px; font-weight: 500; }
.play span { width: 48px; height: 48px; border-radius: 50%; background: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(20, 20, 60, .14); color: var(--muted); font-size: .9rem; }
.play:hover { background: transparent; }

/* nav */
.nav { display: flex; justify-content: space-between; align-items: center; padding: 22px 0 10px; gap: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--head); font-weight: 700; font-size: 1.2rem; }
.stripes { display: inline-flex; gap: 3px; } .stripes i { width: 6px; height: 18px; border-radius: 3px; transform: skewX(-24deg); background: #22c55e; }
.stripes i:nth-child(2) { background: #f97316; } .stripes i:nth-child(3) { background: var(--y); }
.links { display: flex; gap: 6px; flex-wrap: wrap; }
.links a { color: var(--muted); font-weight: 500; padding: 6px 14px; cursor: pointer; position: relative; text-decoration: none; }
.links a:hover { color: var(--ink); }
.links a.active { color: var(--ink); font-weight: 600; }
.links a.active::after { content: ""; position: absolute; left: 50%; bottom: -2px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--y); }
.nav .row { gap: 8px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 16px; gap: 10px; flex-wrap: wrap; }

/* sparkles + home hero */
.spark { position: absolute; background: var(--y); opacity: .55; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); animation: twinkle 3.2s ease-in-out infinite; pointer-events: none; }
@keyframes twinkle { 50% { transform: scale(.7) rotate(20deg); opacity: .9; } }
.display { font-size: clamp(2.1rem, 5.4vw, 4rem); font-weight: 800; line-height: 1.28; text-transform: uppercase; letter-spacing: .01em; margin: 0 0 18px; }
.dash-word { display: inline-block; border: 3px dashed var(--y); border-radius: 44px; padding: 0 .3em; margin-right: .1em; }
.yl { color: var(--y); }
.lead { color: var(--muted); max-width: 30em; margin: 0 0 26px; }
.faces { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.faces .fs { display: flex; } .faces .fs i { width: 44px; height: 44px; border-radius: 50%; background: var(--y-soft); border: 3px solid #fff; display: grid; place-items: center; font-style: normal; font-size: 1.4rem; margin-left: -10px; box-shadow: 0 4px 10px rgba(20,20,60,.14); }
.faces .fs i:first-child { margin-left: 0; }
.art { position: relative; display: grid; place-items: center; }
.art .mascot { width: min(100%, 340px); height: auto; filter: drop-shadow(0 22px 24px rgba(180, 120, 0, .28)); animation: bob 4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(1.5deg); } }
.feats { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 40px 0 36px; padding-top: 40px; }
.feat { position: relative; min-height: 190px; display: flex; align-items: flex-end; }
.feat .blob { position: absolute; inset: 40px 0 0; background: var(--navy); clip-path: polygon(0 20%, 100% 0, 100% 100%, 0 100%); border-radius: 0 0 22px 22px; border-bottom: 5px solid var(--y); }
.feat .toy { position: absolute; top: -14px; left: 16px; font-size: 5.2rem; line-height: 1; filter: drop-shadow(0 14px 12px rgba(0,0,0,.28)); transform: rotate(-8deg); transition: transform .25s; }
.feat:hover .toy { transform: rotate(6deg) scale(1.08); }
.feat .cap { position: relative; color: #fff; padding: 16px 20px; max-width: 100%; margin-left: auto; text-align: right; }
.feat .cap b { display: block; font-family: var(--head); font-size: 1.25rem; color: var(--y); }
.feat .cap span { font-size: .9rem; opacity: .9; }
#who h2, #subjects, #badges { font-size: 1.7rem; }

/* dashboard hero */
.hero { display: grid; grid-template-columns: auto 1fr auto; gap: 22px; align-items: center; margin-bottom: 20px; overflow: hidden; position: relative;
  background: linear-gradient(135deg, var(--y), #ffd45a); color: var(--ink); border: 0; padding: 26px 28px; box-shadow: 0 14px 34px rgba(255, 184, 0, .35); }
.hero .avatar { font-size: 3.6rem; background: rgba(255,255,255,.55); border-radius: 50%; width: 92px; height: 92px; display: grid; place-items: center; animation: bob 3s ease-in-out infinite; }
.hero h1 { margin: 0; font-size: 2.2rem; font-weight: 800; } .hero .sub { font-weight: 600; opacity: .85; }
.hero .bar { background: rgba(255,255,255,.55); height: 12px; margin-top: 8px; } .hero .bar > i { background: var(--navy); }
.hero .hero-art { width: 130px; margin: -16px -4px -30px 0; }
.hero .hero-art svg { width: 100%; height: auto; filter: drop-shadow(0 10px 10px rgba(120,80,0,.25)); }
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip { background: #fff; border-radius: 99px; padding: 3px 13px; font-weight: 600; font-size: .9rem; }
.bubble { background: #fff; color: var(--ink); border-radius: 14px; padding: 9px 14px; margin-top: 10px; font-weight: 500; font-size: .95rem; display: inline-block; }
.goal { display: flex; gap: 16px; align-items: center; }
.ring { --p: 0; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; flex: none; font-family: var(--head); font-weight: 700; font-size: 1.05rem;
  background: conic-gradient(var(--y) calc(var(--p) * 1%), var(--line) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 9px; background: var(--card); border-radius: 50%; }
.ring span { position: relative; }
.badges { display: flex; gap: 10px; flex-wrap: wrap; }
.badge { width: 88px; text-align: center; font-size: .76rem; font-weight: 600; line-height: 1.25; }
.badge .ic { font-size: 2rem; width: 62px; height: 62px; margin: 0 auto 4px; display: grid; place-items: center; border-radius: 50%; background: var(--y-soft); border: 3px solid var(--y); }
.badge.locked { opacity: .45; filter: grayscale(1); } .badge.locked .ic { border-color: var(--line); background: var(--bg); }
/* badge shelf: one compact card, a row of medals per category */
.bdash { padding: 16px 18px 8px; }
.bd-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.bd-top h2 { margin: 0; font-size: 1.4rem; } .bd-sum { font-size: .82rem; color: var(--muted, var(--muted)); } .bd-sum b { color: var(--navy, #14142b); font-size: 1.05rem; }
.bdash .bar { height: 7px; }
.bd-cap { display: flex; align-items: center; gap: 10px; margin: 12px 0 6px; padding: 8px 12px; min-height: 46px; border-radius: 14px; background: var(--bg, #f6f7fb); border: 1px solid var(--line); font-size: .86rem; line-height: 1.3; transition: background .2s; }
.bd-cap.got { background: var(--y-soft); border-color: transparent; }
.bd-cap .bd-ci { font-size: 1.5rem; flex: none; } .bd-cap span:nth-child(2) { flex: 1; min-width: 0; } .bd-cap b { font-weight: 700; }
.bd-cap em { font-style: normal; font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted, var(--muted)); white-space: nowrap; }
.bd-cap.got em { color: #15803d; }
.bd-rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); column-gap: 30px; }
.bd-row { display: flex; flex-direction: column; gap: 8px; padding: 12px 0 13px; border-bottom: 1px solid var(--line); }
.bd-lab { display: flex; align-items: baseline; gap: 6px; font-size: .86rem; white-space: nowrap; } .bd-lab b { font-weight: 600; } .bd-gi { font-size: 1rem; }
.bd-lab small { margin-left: auto; font-size: .72rem; font-weight: 700; color: var(--muted, var(--muted)); }
.bd-chips { display: flex; flex-wrap: wrap; gap: 7px; flex: 1; min-width: 0; }
.bd-chip { width: 38px; height: 38px; padding: 0; border-radius: 50%; display: grid; place-items: center; font-size: 1.15rem; line-height: 1; cursor: pointer; background: var(--y-soft); border: 2px solid var(--y); box-shadow: 0 2px 6px rgba(150, 100, 20, .16); transition: transform .15s, box-shadow .15s; }
.bd-chip:hover, .bd-chip:focus-visible { transform: translateY(-2px) scale(1.1); box-shadow: 0 6px 12px rgba(150, 100, 20, .25); outline: 0; }
.bd-chip.lock { background: transparent; border: 2px dashed var(--line); box-shadow: none; filter: grayscale(1); opacity: .42; }
.bd-chip.lock:hover, .bd-chip.lock:focus-visible { opacity: .75; box-shadow: none; }
@media (max-width: 560px) { .bd-rows { grid-template-columns: 1fr; } .bd-chip { width: 42px; height: 42px; } }
.bar { height: 11px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--y), #ffd45a); border-radius: 99px; transition: width .5s cubic-bezier(.3,1.4,.5,1); }
.pill { display: inline-block; font-size: .76rem; padding: 2px 11px; border-radius: 99px; background: var(--line); font-weight: 600; vertical-align: middle; }
.pill.mastered { background: #dcfce7; color: #166534; } .pill.getting { background: var(--y-soft); color: #92400e; } .pill.needs { background: #ffe4e6; color: #9f1239; }
.pill.now { background: #e0e4ff; color: var(--navy); }
.stars { letter-spacing: 2px; font-size: 1.1rem; } .stars .off { filter: grayscale(1); opacity: .3; }
.unit { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; margin-bottom: 14px; border-left: 7px solid var(--y); }
.unit .acts { display: flex; gap: 8px; flex-wrap: wrap; }

/* questions */
.q { font-family: var(--head); font-size: 1.4rem; font-weight: 600; white-space: pre-line; margin: 6px 0 20px; line-height: 1.4; }
.choices { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 680px) { .choices { grid-template-columns: 1fr; } }
.choice { text-align: left; background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: none; padding: 15px 18px; font-weight: 500; display: flex; gap: 12px; align-items: center; border-radius: 14px; }
.choice .k { flex: none; width: 28px; height: 28px; border-radius: 9px; background: var(--y-soft); display: grid; place-items: center; font-size: .82rem; font-weight: 700; }
.choice:hover:not(:disabled) { border-color: var(--y); background: #fffbea; box-shadow: none; }
.choice.sel { border-color: var(--y); background: var(--y-soft); }
.choice.right { border-color: var(--good); background: var(--good-bg); color: var(--good-ink); animation: pop .4s; opacity: 1; }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); color: var(--bad-ink); animation: shake .4s; opacity: 1; }
@keyframes pop { 40% { transform: scale(1.04); } }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.feedback { margin-top: 18px; padding: 16px; border-radius: 16px; background: var(--bad-bg); color: var(--bad-ink); animation: rise .3s both; }
.feedback.ok { background: var(--good-bg); color: var(--good-ink); }
.feedback b { font-family: var(--head); font-size: 1.15rem; }
.lesson { font-size: 1.05rem; } .lesson p { margin: .7em 0; }
.ex { background: var(--y-soft); padding: 12px 16px; border-radius: 14px; border-left: 6px solid var(--y); }
.score { font-family: var(--head); font-size: 3.4rem; font-weight: 800; line-height: 1; }
.review { border-left: 6px solid var(--bad); padding-left: 14px; margin: 14px 0; } .review.ok { border-color: var(--good); }
table { width: 100%; border-collapse: collapse; } td, th { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.streak { font-weight: 700; color: var(--y-deep); }

/* effects */
.xpfloat { position: fixed; pointer-events: none; font-family: var(--head); font-weight: 800; font-size: 1.5rem; color: var(--y-deep); animation: floatup 1s ease-out forwards; z-index: 60; text-shadow: 0 2px 0 #fff; }
@keyframes floatup { to { transform: translateY(-70px); opacity: 0; } }
.conf { position: fixed; top: -12px; width: 10px; height: 14px; z-index: 70; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .9; } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 16px; font-weight: 600; z-index: 80; animation: toast 3.2s both; box-shadow: var(--shadow); }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 20px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.celebrate { text-align: center; } .celebrate .big-emoji { font-size: 5rem; animation: bob 1.6s ease-in-out infinite; }

/* forms */
.form { display: grid; gap: 12px; } .form.row { display: flex; align-items: center; margin-bottom: 8px; }
.form label { display: grid; gap: 4px; font-weight: 600; }
input { font: inherit; padding: 11px 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink); }
input:focus { border-color: var(--y); }
.err { color: var(--bad); min-height: 1.2em; font-weight: 600; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 860px) {
  #app { margin: 0; border-radius: 0; padding: 4px 18px 40px; }
  .art { order: -1; } .art .mascot { width: 220px; }
  .hero { grid-template-columns: auto 1fr; } .hero .hero-art { display: none; }
  .links { display: none; }
}
@media (max-width: 560px) { .unit { grid-template-columns: 1fr; } .hero { grid-template-columns: 1fr; text-align: center; } .hero .avatar { margin: 0 auto; } .stats { justify-content: center; } .statline { gap: 22px; } }
