/* ===== Skolefun ===== */
:root {
  --bg: #f6f3ec;
  --bg2: #efeadf;
  --card: #fffdf8;
  --ink: #1c1a17;
  --ink-soft: #6a645a;
  --line: #e4ddcf;
  --brand: #2f5bea;
  --brand-ink: #1d3fb3;
  --accent: #ff6b4a;
  --good: #16935a;
  --good-bg: #e2f5ea;
  --bad: #d9472f;
  --bad-bg: #fde9e4;
  --gold: #f2b000;
  --tip-bg: #fff4cc; --tip-ink: #5e4700;
  --fact-bg: #e3efff; --fact-ink: #123f7a;
  --tog-bg: #ffe9ee; --tog-ink: #7a1734; --tog-line: #f4a9bd;
  --radius: 18px;
  --subject: var(--brand);
  --font-head: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Lexend', 'Segoe UI', system-ui, sans-serif;
  --text-scale: 1;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #141413; --bg2: #1e1d1b; --card: #1f1e1c; --ink: #f2efe8; --ink-soft: #a9a397; --line: #34322e;
  --brand: #7d9bff; --brand-ink: #a9bcff; --good-bg: #16301f; --bad-bg: #3a1d17;
  --tip-bg: #33290d; --tip-ink: #f6dc8b; --fact-bg: #132538; --fact-ink: #b7d4ff; --tog-bg: #351821; --tog-ink: #ffc0d0; --tog-line: #7a3a4c;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --bg2: #1e1d1b; --card: #1f1e1c; --ink: #f2efe8; --ink-soft: #a9a397; --line: #34322e;
    --brand: #7d9bff; --brand-ink: #a9bcff; --good-bg: #16301f; --bad-bg: #3a1d17;
    --tip-bg: #33290d; --tip-ink: #f6dc8b; --fact-bg: #132538; --fact-ink: #b7d4ff; --tog-bg: #351821; --tog-ink: #ffc0d0; --tog-line: #7a3a4c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: calc(16.5px * var(--text-scale)); line-height: 1.6; font-weight: 350;
  padding-bottom: calc(78px + env(safe-area-inset-bottom)); overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.12; margin: 0 0 .45em; font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: clamp(1.9rem, 5.5vw, 2.9rem); font-weight: 800; }
h2 { font-size: clamp(1.35rem, 3.6vw, 1.75rem); }
h3 { font-size: 1.15rem; letter-spacing: -.01em; }
h4 { font-size: 1rem; letter-spacing: 0; }
p { margin: 0 0 .8em; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 10px; }
.small { font-size: .9rem; }
.eyebrow { font-family: var(--font-head); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--subject); margin: 0 0 .4em; }
.link { color: var(--brand); text-decoration: none; font-weight: 700; }

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 9px; text-decoration: none; font-family: var(--font-head); font-size: 1.3rem; font-weight: 800; letter-spacing: -.03em; }
.logo img { border-radius: 9px; display: block; }
.topbar-right { display: flex; align-items: center; gap: 6px; margin-left: auto; order: 3; }
.gradebar { display: flex; align-items: center; gap: 8px; order: 2; }
.gradebar[hidden] { display: none; }
.gb-label { font-family: var(--font-head); font-weight: 600; font-size: .85rem; color: var(--ink-soft); }
.gb-seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.gb-seg button { border: 0; background: transparent; width: 36px; height: 34px; border-radius: 9px; font-family: var(--font-head); font-weight: 700; font-size: 1rem; color: var(--ink-soft); }
.gb-seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
@media (max-width: 640px) {
  .gradebar { order: 4; width: 100%; justify-content: space-between; }
  .gb-seg { flex: 1; } .gb-seg button { flex: 1; width: auto; }
}
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  font-family: var(--font-head); font-weight: 600; font-size: .95rem; text-decoration: none; white-space: nowrap;
}
.chip.points { color: #9a6b00; }
:root[data-theme="dark"] .chip.points { color: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.points { color: var(--gold); } }
.chip.bump { animation: bump .5s; }
.avatar-chip { font-size: 1.25rem; padding: 3px 9px; }

/* layout */
main { max-width: 1040px; margin: 0 auto; padding: 18px 16px 40px; outline: none; }
main:focus, main:focus-visible { outline: none; }
.view { animation: rise .3s ease both; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.stack > * + * { margin-top: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 30px 0 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px;
  padding: 12px 20px; font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; text-decoration: none; letter-spacing: -.01em;
  background: var(--ink); color: var(--bg); box-shadow: 0 3px 0 color-mix(in srgb, var(--ink) 55%, #000);
  transition: transform .08s, box-shadow .08s; min-height: 50px; touch-action: manipulation;
}
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 transparent; }
.btn.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 3px 0 var(--line); }
.btn.good { background: var(--good); color: #fff; box-shadow: 0 3px 0 #0d6a3f; }
.btn.subject { background: var(--subject); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--subject) 55%, #000); }
.btn.small { padding: 7px 13px; min-height: 40px; font-size: .95rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn { border: 1px solid var(--line); background: var(--card); width: 40px; height: 40px; border-radius: 50%; font-size: 1.05rem; display: inline-grid; place-items: center; flex: none; }
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-family: var(--font-head); font-weight: 600; color: var(--ink-soft); margin: 0 0 12px; padding: 4px 0; }
.back:hover { color: var(--ink); }

/* hero */
.hero { display: grid; gap: 18px; grid-template-columns: 1fr; align-items: stretch; }
.hero-text { padding: 8px 0; }
.hero h1 { margin-bottom: .2em; }
.hero .lead { font-size: 1.2rem; color: var(--ink-soft); }
.hero-level { display: flex; align-items: center; gap: 14px; text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; align-self: center; }
.hero-level small { display: block; color: var(--ink-soft); font-size: .85rem; }
.hero-level b { display: block; font-family: var(--font-head); font-size: 1.2rem; }
@media (min-width: 760px) { .hero { grid-template-columns: 1.7fr 1fr; } }
.welcome { display: grid; gap: 22px; align-items: center; }
.welcome-mascot { display: flex; justify-content: center; }
@media (min-width: 760px) { .welcome { grid-template-columns: 1.5fr 1fr; } }
.mascot { flex: none; line-height: 0; }
.mascot-svg { display: block; height: auto; overflow: visible; }
.mascot-wave .mascot-svg, .mascot-happy .mascot-svg { animation: sway 4s ease-in-out infinite; transform-origin: 50% 100%; }
.mascot-cheer .mascot-svg { animation: hop .6s ease-out 2; transform-origin: 50% 100%; }
.mascot-think .mascot-svg { animation: tilt 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
.center-mascot, .result-mascot { display: flex; justify-content: center; margin-bottom: 6px; }
.feedback .mascot-svg { width: 52px; }
.speech { display: inline-block; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 12px; font-weight: 700; margin-bottom: 12px; }

/* subject tiles */
.tile {
  --c: var(--brand);
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-decoration: none; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-height: 150px;
  transition: transform .15s, border-color .15s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--c); }
.tile:active { transform: scale(.98); }
.tile .tile-emoji { font-size: 1.9rem; line-height: 1; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; background: color-mix(in srgb, var(--c) 15%, var(--card)); margin-bottom: 6px; }
.tile h3 { margin: 0; font-size: 1.1rem; }
.tile small { color: var(--ink-soft); font-size: .86rem; line-height: 1.35; }
.tile .stars { position: absolute; top: 14px; right: 14px; font-size: .85rem; font-family: var(--font-head); font-weight: 700; color: #9a6b00; }

.progress { height: 8px; background: var(--bg2); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--c, var(--brand)); border-radius: 99px; transition: width .6s; }

/* poster tiles */
.poster-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.poster-tile { --c: var(--brand); display: flex; flex-direction: column; gap: 2px; text-decoration: none; padding: 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); transition: transform .15s, border-color .15s; }
.poster-tile:hover { transform: translateY(-2px); border-color: var(--c); }
.pt-icon { font-family: var(--font-head); font-weight: 800; font-size: 1.5rem; color: #fff; background: var(--c); width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 8px; letter-spacing: -.03em; }
.poster-tile b { font-family: var(--font-head); font-size: 1.05rem; }
.poster-tile small { color: var(--ink-soft); font-size: .85rem; line-height: 1.3; }
.poster-icon { font-family: var(--font-head); font-weight: 800; color: #fff; background: var(--subject) !important; }

.subject-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.subject-head .big-emoji { font-size: 2.2rem; width: 64px; height: 64px; flex: none; border-radius: 18px; display: grid; place-items: center; background: color-mix(in srgb, var(--subject) 16%, var(--card)); }
.subject-head h1 { margin: 0; }
.subject-head p { margin: 0; color: var(--ink-soft); }

/* tabs */
.tabs { display: flex; gap: 4px; background: var(--bg2); padding: 4px; border-radius: 14px; margin-bottom: 16px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 11px; padding: 11px; font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; color: var(--ink-soft); }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* learn blocks */
.learn > * + * { margin-top: 12px; }
.learn .block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; position: relative; }
.block.text p:last-child { margin: 0; }
.block p:last-child { margin-bottom: 0; }
.block .label { font-family: var(--font-head); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; display: block; margin-bottom: 6px; }
.block.tip { background: var(--tip-bg); border-color: transparent; color: var(--tip-ink); }
.block.fact { background: var(--fact-bg); border-color: transparent; color: var(--fact-ink); }
.block.together { background: var(--tog-bg); border: 2px dashed var(--tog-line); color: var(--tog-ink); }
.block.example { border-left: 5px solid var(--subject); }
.reveal { margin-top: 10px; }
.reveal .answer { margin-top: 10px; padding: 12px 14px; background: var(--good-bg); border-radius: 12px; animation: rise .3s; }
.speak-btn { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; font-size: 1rem; }
.block.has-speak { padding-right: 58px; }
.words { display: grid; gap: 6px; }
.words div { display: flex; gap: 10px; padding: 8px 12px; background: var(--bg2); border-radius: 10px; flex-wrap: wrap; }
.words b { font-family: var(--font-head); color: var(--subject); }

/* visuals */
.visual { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 4px 0; }
.visual .caption, .caption { font-size: .95rem; color: var(--ink-soft); text-align: center; }
.v-emoji { text-align: center; line-height: 1.3; word-break: break-word; }
.v-emoji.md { font-size: 2rem; } .v-emoji.lg { font-size: 3rem; } .v-emoji.xl { font-size: 4.2rem; }
.v-count { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; font-size: 2.1rem; }
.v-count span { animation: pop .4s both; }
.v-tenframe { display: grid; grid-template-columns: repeat(5, 44px); gap: 3px; padding: 5px; background: var(--ink); border-radius: 10px; }
.v-tenframe i { width: 44px; height: 44px; background: var(--card); border-radius: 6px; display: grid; place-items: center; }
.v-tenframe i.on::after { content: ''; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); }
.v-svg { width: 100%; max-width: 520px; }
.v-svg svg { width: 100%; height: auto; display: block; }
.v-table { border-collapse: collapse; width: 100%; max-width: 560px; background: var(--card); border-radius: 12px; overflow: hidden; }
.v-table th, .v-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.v-table th { background: color-mix(in srgb, var(--subject) 14%, var(--card)); font-family: var(--font-head); }
.v-steps { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; }
.v-steps .step { background: var(--bg2); padding: 10px 14px; border-radius: 12px; font-weight: 700; text-align: center; }
.v-steps .arrow { color: var(--subject); font-size: 1.3rem; font-weight: 700; }
.v-array { display: grid; gap: 4px; font-size: 1.7rem; line-height: 1; }
.v-letters { font-family: var(--font-body); font-size: clamp(3.5rem, 14vw, 6rem); font-weight: 700; color: var(--subject); letter-spacing: .05em; line-height: 1.1; text-align: center; }
.v-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; width: 100%; }
.v-cards div { background: var(--bg2); border-radius: 14px; padding: 10px 6px; text-align: center; font-weight: 700; }
.v-cards div span { display: block; font-size: 2.2rem; line-height: 1.2; }
.v-coins { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.coin { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; background: radial-gradient(circle at 35% 30%, #fff3b0, #e0b03c 60%, #b68512); color: #5a3d00; box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); font-size: 1rem; }
.coin.silver { background: radial-gradient(circle at 35% 30%, #fff, #c8ccd4 60%, #8d939e); color: #333; }
.coin.c1 { width: 46px; height: 46px; } .coin.c5 { width: 54px; height: 54px; position: relative; } .coin.c5::before { content: ''; position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--card); }
.note { width: 96px; height: 52px; border-radius: 8px; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; color: #fff; }
.note.n50 { background: #4e9a62; } .note.n100 { background: #c94c4c; } .note.n200 { background: #3a72b8; } .note.n500 { background: #a8742d; } .note.n1000 { background: #7b5ab0; }
.v-bars svg, .v-clock svg, .v-numberline svg, .v-fraction svg, .v-shape svg { display: block; max-width: 100%; height: auto; }

/* tasks / quiz */
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.quiz-top .progress { flex: 1; height: 12px; }
.quiz-top .progress > i { background: var(--subject); }
.combo { font-family: var(--font-head); font-weight: 800; color: var(--accent); min-width: 48px; text-align: right; }
.combo.hot { animation: bump .5s; }
.task { animation: slidein .3s ease both; }
.task .q { font-family: var(--font-head); font-size: clamp(1.25rem, 4.2vw, 1.6rem); font-weight: 700; letter-spacing: -.015em; margin: 4px 0 16px; display: flex; gap: 10px; align-items: flex-start; }
.task .q .speak-btn { position: static; }
.options { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .options.two { grid-template-columns: 1fr 1fr; } }
.opt {
  border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 14px 16px; font-size: 1.15rem; font-weight: 700;
  text-align: left; box-shadow: 0 3px 0 var(--line); transition: transform .08s; min-height: 58px; display: flex; align-items: center; gap: 12px;
  touch-action: manipulation; word-break: break-word;
}
.opt:hover { border-color: color-mix(in srgb, var(--subject) 45%, var(--line)); }
.opt .key { flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--bg2); display: grid; place-items: center; font-family: var(--font-head); font-size: .9rem; color: var(--ink-soft); }
.opt:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.opt.selected { border-color: var(--subject); background: color-mix(in srgb, var(--subject) 9%, var(--card)); }
.opt.correct { border-color: var(--good); background: var(--good-bg); box-shadow: 0 3px 0 var(--good); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: 0 3px 0 var(--bad); animation: shake .4s; }
.opt.dim { opacity: .45; }
.opt.big { justify-content: center; font-size: 1.45rem; font-family: var(--font-head); }
.answer-input { width: 100%; font: inherit; font-size: 1.5rem; font-weight: 700; padding: 13px 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--ink); text-align: center; }
.answer-input:focus { border-color: var(--subject); outline: none; }
.answer-input.correct { border-color: var(--good); background: var(--good-bg); }
.answer-input.wrong { border-color: var(--bad); background: var(--bad-bg); animation: shake .4s; }
.numpad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.numpad button { border: 1px solid var(--line); background: var(--card); box-shadow: 0 3px 0 var(--line); border-radius: 12px; font-family: var(--font-head); font-size: 1.45rem; font-weight: 700; padding: 11px 0; touch-action: manipulation; }
.numpad button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.order-slots { display: flex; flex-direction: column; gap: 8px; min-height: 60px; padding: 10px; border-radius: 14px; border: 2px dashed var(--line); margin-bottom: 12px; }
.order-slots .opt { min-height: 48px; padding: 9px 13px; }
.order-slots .ph { color: var(--ink-soft); text-align: center; padding: 8px; }
.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-cols .opt { min-height: 52px; padding: 9px 11px; font-size: 1.02rem; justify-content: center; text-align: center; }
.match-cols .opt.p0 { border-color: #ff6b4a; } .match-cols .opt.p1 { border-color: #16935a; } .match-cols .opt.p2 { border-color: #2f5bea; } .match-cols .opt.p3 { border-color: #d6409f; } .match-cols .opt.p4 { border-color: #e0a100; }
.feedback { margin-top: 16px; border-radius: 16px; padding: 14px 16px; animation: rise .3s both; display: flex; gap: 12px; align-items: flex-start; }
.feedback.good { background: var(--good-bg); }
.feedback.bad { background: var(--bad-bg); }
.feedback h3 { margin: 0 0 4px; }
.feedback p { margin: 0; }
.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.actions .btn { flex: 1; min-width: 140px; }
.float-points { position: fixed; z-index: 60; font-family: var(--font-head); font-weight: 800; font-size: 1.7rem; color: var(--gold); text-shadow: 0 2px 0 #8a6200; pointer-events: none; animation: floatup 1.1s ease-out forwards; }

/* results */
.result { text-align: center; }
.result .big-stars { font-size: 3.2rem; letter-spacing: .1em; margin: 8px 0; }
.result .big-stars span { display: inline-block; animation: pop .5s both; }
.result .big-stars span.off { filter: grayscale(1); opacity: .25; }
.stat-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.stat { background: var(--bg2); border-radius: 14px; padding: 12px 18px; min-width: 110px; }
.stat b { display: block; font-family: var(--font-head); font-size: 1.7rem; color: var(--ink); }
.stat span { font-size: .85rem; color: var(--ink-soft); }

/* level */
.level-card { display: flex; gap: 16px; align-items: center; }
.level-badge { width: 64px; height: 64px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; background: conic-gradient(var(--gold) var(--p, 0%), var(--bg2) 0); position: relative; }
.level-badge::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--card); }
.level-badge span { position: relative; }

/* badges */
.badges { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.badge { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 10px; text-align: center; }
.badge .b-emoji { font-size: 2.3rem; display: block; }
.badge b { font-family: var(--font-head); display: block; font-size: .98rem; line-height: 1.2; margin-top: 4px; }
.badge small { color: var(--ink-soft); font-size: .8rem; line-height: 1.25; display: block; margin-top: 4px; }
.badge.locked .b-emoji { filter: grayscale(1); opacity: .3; }
.badge.locked b { color: var(--ink-soft); }

/* profiles */
.profiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.profile-btn { border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 18px 10px; text-align: center; position: relative; }
.profile-btn:hover { border-color: var(--ink); }
.profile-btn .av { font-size: 3.2rem; display: block; }
.profile-btn b { font-family: var(--font-head); font-size: 1.15rem; display: block; }
.profile-btn small { color: var(--ink-soft); }
.profile-btn.add { border: 2px dashed var(--line); background: transparent; }
.avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; }
.avatars button { font-size: 1.9rem; border: 2px solid transparent; background: var(--bg2); border-radius: 14px; padding: 5px 0; }
.avatars button[aria-pressed="true"] { border-color: var(--ink); background: var(--card); }
.field { display: block; margin-bottom: 16px; }
.signup { max-width: 560px; margin: 0 auto; }
.signup-hello { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 6px; }
.signup-hello .speech { margin: 0 0 18px; font-size: 1.05rem; line-height: 1.4; }
.name-row { display: flex; gap: 8px; }
.name-row input { flex: 1; min-width: 0; font-size: 1.2rem; }
.name-row .btn { flex: none; }
.signup details { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.signup summary { cursor: pointer; font-family: var(--font-head); font-weight: 700; color: var(--ink-soft); list-style: none; }
.signup summary::-webkit-details-marker { display: none; }
.signup summary::before { content: '▸ '; } .signup details[open] summary::before { content: '▾ '; }
.signup details[open] > .field:first-of-type { margin-top: 14px; }
.field > span { display: block; font-family: var(--font-head); font-weight: 700; margin-bottom: 6px; }
.field input, .field select { width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1; min-width: 44px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 9px 6px; font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; }
.seg button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.seg.small button { font-size: .9rem; padding: 6px 8px; flex: 0 1 auto; }

/* parent + curriculum */
.parent-table { width: 100%; border-collapse: collapse; }
.parent-table td, .parent-table th { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.parent-table .progress { min-width: 80px; }
.tips-list { padding-left: 1.2em; margin: 0; } .tips-list li { margin-bottom: 8px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.switch:last-child { border: 0; }
.goals { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.goals li { position: relative; padding: 10px 12px 10px 40px; background: var(--bg2); border-radius: 12px; }
.goals li::before { content: '✓'; position: absolute; left: 12px; top: 9px; width: 20px; height: 20px; border-radius: 6px; background: var(--subject); color: #fff; font-size: .8rem; font-weight: 700; display: grid; place-items: center; }
.source { font-size: .9rem; color: var(--ink-soft); }
.source a { color: var(--brand); }
details.card summary { cursor: pointer; list-style: none; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary::before { content: '▸ '; color: var(--ink-soft); }
details[open].card summary::before { content: '▾ '; }
details.card[open] > *:not(summary) { margin-top: 14px; }
.core h4 { margin-bottom: 4px; }
.core p { color: var(--ink-soft); font-size: .95rem; }
.links { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.links li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.links li:last-child { border: 0; }
.links a { font-weight: 700; color: var(--brand); text-decoration: none; }
.links a:hover { text-decoration: underline; }
.links small { color: var(--ink-soft); width: 100%; }
.tag { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: var(--accent); color: #fff; padding: 2px 7px; border-radius: 6px; }
.adult-card { display: flex; gap: 14px; align-items: center; margin-top: 18px; text-decoration: none; border-style: dashed; }
.adult-card:hover { border-color: var(--ink); }
.adult-card .ac-icon { font-size: 1.8rem; }
.adult-card b { font-family: var(--font-head); font-size: 1.1rem; display: block; }
.adult-card small { color: var(--ink-soft); }
.adult-card .ac-arrow { margin-left: auto; font-size: 1.4rem; color: var(--ink-soft); }
.principle .num { font-family: var(--font-head); font-weight: 800; font-size: .85rem; background: var(--ink); color: var(--bg); width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center; margin-bottom: 8px; }
.principle p { margin: 0; color: var(--ink-soft); }

/* posters */
.poster { overflow: hidden; }
.alpha-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.alpha { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; touch-action: manipulation; }
.alpha:active { transform: scale(.96); }
.alpha.vowel { background: var(--fact-bg); border-color: transparent; }
.al-letter { font-family: var(--font-body); font-size: 2.1rem; font-weight: 700; line-height: 1; color: var(--subject); }
.alpha.vowel .al-letter { color: var(--fact-ink); }
.al-letter small { font-size: 1.4rem; margin-left: 3px; }
.al-emoji { font-size: 1.7rem; line-height: 1.2; }
.al-word { font-size: .9rem; color: var(--ink-soft); }
.legend { display: inline-block; padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line); font-size: .85rem; }
.legend.vowel { background: var(--fact-bg); border-color: transparent; color: var(--fact-ink); }
.hundred { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin-top: 12px; }
.hundred button { border: 0; background: var(--bg2); border-radius: 6px; aspect-ratio: 1; font-family: var(--font-head); font-weight: 600; font-size: clamp(.7rem, 2.6vw, 1rem); padding: 0; }
.hundred button.on { background: var(--subject); color: #fff; }
.hundred button:nth-child(10n) { font-weight: 800; }
.mtable-wrap { overflow-x: auto; margin-top: 10px; }
.mtable { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 2px; }
.mtable > * { aspect-ratio: 1; display: grid; place-items: center; font-family: var(--font-head); font-size: clamp(.72rem, 2.4vw, 1rem); border-radius: 6px; }
.mtable .hd { background: var(--ink); color: var(--bg); font-weight: 800; }
.mtable .hd.hl { background: var(--accent); }
.mtable button { border: 0; background: var(--bg2); padding: 0; font-weight: 600; }
.mtable button.sq { background: color-mix(in srgb, var(--subject) 14%, var(--bg2)); }
.mtable button.line { background: color-mix(in srgb, var(--accent) 22%, var(--card)); }
.mtable button.pick { background: var(--accent); color: #fff; font-weight: 800; }
.mt-info { font-family: var(--font-head); font-size: 1.2rem; min-height: 1.6em; }
.clock-label { display: flex; flex-direction: column; align-items: center; margin: 6px 0 12px; }
.clock-label b { font-family: var(--font-head); font-size: 2rem; }
.clock-label span { color: var(--ink-soft); font-size: 1.1rem; }
.wl-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.wl { background: var(--bg2); border-radius: 14px; padding: 14px 16px; }
.wl ol { margin: 0; padding-left: 1.4em; } .wl li { padding: 2px 0; cursor: default; }
.wl .v-table { background: transparent; }
.plain { list-style: none; padding: 0; margin: 0; } .plain li { padding: 4px 0; }
.seasons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seasons div { background: var(--card); border-radius: 10px; padding: 8px; text-align: center; }
.seasons span { font-size: 1.6rem; display: block; } .seasons small { display: block; color: var(--ink-soft); font-size: .78rem; }
.shape-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.shape-card { background: var(--bg2); border-radius: 14px; padding: 10px; text-align: center; }
.shape-card svg { width: 80px; height: 80px; }
.shape-card b { display: block; font-family: var(--font-head); } .shape-card small { color: var(--ink-soft); }
.fwall { display: grid; gap: 4px; }
.frow { display: flex; gap: 3px; }
.frow span { flex: 1; text-align: center; padding: 8px 0; border-radius: 5px; font-family: var(--font-head); font-weight: 700; font-size: clamp(.6rem, 2.2vw, .95rem); color: #1c1a17; overflow: hidden; }
.en-nums { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
.en-nums button, .en-cols button { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 6px 8px; display: flex; gap: 8px; align-items: center; }
.en-nums b { font-family: var(--font-head); color: var(--subject); min-width: 1.6em; }
.en-cols { display: flex; flex-wrap: wrap; gap: 6px; }
.en-cols i { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); }

/* bottom nav */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.bottomnav { justify-content: center; gap: 4px; }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; text-decoration: none; font-family: var(--font-head); font-weight: 600; font-size: .78rem; color: var(--ink-soft); padding: 5px 0; border-radius: 12px; max-width: 110px; }
.bottomnav a span { font-size: 1.4rem; line-height: 1.25; filter: grayscale(.6); opacity: .8; transition: transform .2s; }
.bottomnav a.active { color: var(--ink); }
.bottomnav a.active span { filter: none; opacity: 1; transform: translateY(-1px) scale(1.1); }

/* toast */
#toast-root { position: fixed; top: calc(76px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.2); animation: toastin .4s both; font-weight: 700; }
.toast .t-emoji { font-size: 1.8rem; }
.toast small { display: block; font-weight: 400; opacity: .85; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 80; }

.modal-back { position: fixed; inset: 0; background: rgba(20, 18, 14, .5); z-index: 90; display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.modal { background: var(--card); border-radius: 22px; padding: 22px; width: min(100%, 460px); max-height: 90vh; overflow: auto; animation: rise .3s; }

.empty { text-align: center; padding: 30px 10px; }
.empty .e-emoji { font-size: 3.5rem; }
.mascot-tip { display: flex; gap: 12px; align-items: center; padding: 14px 16px; }
.mascot-tip .mascot-svg { width: 64px; }

.area-list { display: grid; gap: 10px; }
.area-row { display: flex; gap: 14px; align-items: center; text-decoration: none; background: var(--card); border: 1px solid var(--line); padding: 13px 16px; border-radius: var(--radius); transition: transform .12s, border-color .12s; }
.area-row:hover { transform: translateX(3px); border-color: var(--subject); }
.area-row .ae { font-size: 1.9rem; width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 14px; background: color-mix(in srgb, var(--subject) 14%, var(--card)); }
.area-row h3 { margin: 0; font-size: 1.1rem; }
.area-row p { margin: 0; color: var(--ink-soft); font-size: .9rem; line-height: 1.35; }
.area-row .st { margin-left: auto; font-size: .95rem; white-space: nowrap; flex: none; }

/* animations */
@keyframes sway { 50% { transform: rotate(-2.5deg); } }
@keyframes hop { 40% { transform: translateY(-10px) scale(1.04); } }
@keyframes tilt { 50% { transform: rotate(3deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes slidein { from { opacity: 0; transform: translateX(24px); } }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes bump { 40% { transform: scale(1.25); } }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@keyframes floatup { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-80px) scale(1.4); } }
@keyframes toastin { from { opacity: 0; transform: translateY(-20px) scale(.95); } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 420px) {
  .card { padding: 16px; }
  .card.poster { padding: 10px; }
  .chip { padding: 4px 8px; font-size: .88rem; }
  .v-tenframe { grid-template-columns: repeat(5, 38px); } .v-tenframe i { width: 38px; height: 38px; }
}

@media print {
  .topbar, .bottomnav, .back, .row .btn, #toast-root { display: none !important; }
  body { background: #fff; padding: 0; }
  .card { border: 0; }
}
