:root {
  --ink: #1d2758;
  --paper: #fff;
  --cream: #fff9e9;
  --yellow: #ffd84d;
  --mint: #75dfc6;
  --blue: #80c8ff;
  --pink: #ff8fbd;
  --purple: #b9a2ff;
  --orange: #ffb65c;
  --green: #16836c;
  --red: #b94763;
  font-family: "Trebuchet MS", "Avenir Next", system-ui, sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}

* { box-sizing: border-box; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
body { min-height: 100vh; margin: 0; background: radial-gradient(circle at 8% 7%, #fff 0 4rem, transparent 4.1rem), linear-gradient(180deg, #b9eee2 0 23rem, var(--cream) 23rem); }
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.topbar, .shell, footer { width: min(1160px, calc(100% - 2rem)); margin-inline: auto; }
.topbar { min-height: 6.2rem; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; }
.back-link { font-weight: 900; text-decoration: none; }
.brand { display: flex; align-items: center; gap: .7rem; }
.brand-mark { display: grid; place-items: center; width: 3.2rem; aspect-ratio: 1; border: 3px solid var(--ink); border-radius: 1rem; background: var(--yellow); box-shadow: 4px 4px 0 var(--ink); font-weight: 1000; }
.brand strong, .brand small { display: block; line-height: 1.05; }
.brand small { margin-top: .18rem; font-size: .68rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.offline-pill { justify-self: end; padding: .62rem .9rem; border: 2px solid rgba(29,39,88,.45); border-radius: 999px; background: rgba(255,255,255,.55); font-size: .76rem; font-weight: 900; }

.shell { padding-bottom: 3rem; }
.view { animation: enter .28s ease; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
.hero { display: grid; grid-template-columns: 1.2fr .8fr; align-items: center; gap: clamp(2rem, 5vw, 5rem); min-height: 29rem; padding: 2.5rem clamp(.5rem, 4vw, 3rem) 4rem; }
.eyebrow { display: inline-flex; padding: .42rem .7rem; border: 2px solid var(--ink); border-radius: .55rem; background: var(--paper); box-shadow: 3px 3px 0 var(--ink); font-size: .7rem; font-weight: 1000; letter-spacing: .12em; }
.eyebrow.soft { background: #e9e4ff; box-shadow: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 1.2rem 0 1rem; font-size: clamp(2.75rem, 7vw, 5.5rem); line-height: .92; letter-spacing: -.065em; }
h1 mark { color: inherit; background: linear-gradient(transparent 60%, var(--yellow) 60%); }
.hero p { max-width: 37rem; font-size: clamp(1rem, 2vw, 1.24rem); line-height: 1.5; font-weight: 700; }
.hero-actions, .result-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.5rem; }
.primary-button, .secondary-button { min-height: 3.5rem; padding: .9rem 1.15rem; border: 3px solid var(--ink); border-radius: .9rem; font-weight: 1000; cursor: pointer; }
.primary-button { display: inline-flex; align-items: center; justify-content: space-between; gap: 2rem; background: var(--yellow); box-shadow: 5px 5px 0 var(--ink); }
.secondary-button { background: var(--paper); }
.primary-button:hover, .primary-button:focus-visible, .secondary-button:hover, .secondary-button:focus-visible { transform: translateY(-2px); outline: none; }

.place-visual { padding: 1.6rem; border: 3px solid var(--ink); border-radius: 1.7rem; background: var(--paper); box-shadow: 9px 9px 0 var(--ink); transform: rotate(1.5deg); }
.place-head, .place-number { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.place-head span { padding: .5rem; border-radius: .6rem .6rem 0 0; background: #e9e4ff; font-size: .72rem; font-weight: 1000; }
.place-number { position: relative; font-size: clamp(2.7rem, 6vw, 4.3rem); font-weight: 1000; line-height: 1.1; }
.place-number span { padding: .35rem; border-right: 2px dashed #c6cbea; }
.place-number span:last-child { border-right: 0; }
.place-number.second { grid-template-columns: repeat(3, 1fr); }
.place-number.second b { position: absolute; left: -.75rem; bottom: .55rem; color: var(--green); font-size: .72em; }
.place-line { height: 3px; background: var(--ink); }
.place-visual small { display: block; margin-top: .8rem; color: var(--green); text-align: center; font-weight: 900; }

.home-stats { display: flex; justify-content: center; gap: 1rem; margin: -1rem 0 2.4rem; }
.home-stats > div { min-width: 11rem; display: grid; grid-template-columns: auto auto; align-items: center; justify-content: center; gap: .1rem .5rem; padding: .8rem 1rem; border: 2px solid var(--ink); border-radius: 1rem; background: rgba(255,255,255,.85); }
.home-stats > div > span { grid-row: 1 / 3; color: #f0a700; font-size: 1.6rem; }
.home-stats strong { font-size: 1.25rem; }.home-stats small { font-weight: 800; }

.quick-missions { padding: clamp(1.2rem, 4vw, 2.5rem); border: 3px solid var(--ink); border-radius: 2rem; background: rgba(255,255,255,.93); box-shadow: 8px 8px 0 var(--ink); }
.section-title h2, .menu-view h2, .theory-hero h2 { margin: .7rem 0 1.3rem; font-size: clamp(2rem, 5vw, 3.4rem); letter-spacing: -.05em; }
.mission-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.mission-card { min-height: 14rem; display: grid; grid-template-columns: auto 1fr; align-content: end; gap: .35rem 1rem; padding: 1.35rem; border: 3px solid var(--ink); border-radius: 1.35rem; text-align: left; cursor: pointer; transition: .18s; }
.mission-card:hover, .mission-card:focus-visible { transform: translateY(-4px); box-shadow: 0 7px 0 var(--ink); outline: none; }
.sign-card { background: #ffd36e; }.decomp-card { background: #8fdccb; }.jumps-card { background: #9dccff; }.mix-card { background: #d0bfff; }
.mission-icon { grid-row: 1 / 5; display: grid; place-items: center; align-self: end; width: 4.2rem; aspect-ratio: 1; border: 3px solid var(--ink); border-radius: 1.1rem; background: var(--paper); font-size: 1.25rem; font-weight: 1000; }
.mission-card small { font-size: .66rem; font-weight: 1000; letter-spacing: .1em; }.mission-card strong { font-size: 1.5rem; }.mission-card > span:not(.mission-icon) { font-weight: 700; line-height: 1.3; }.mission-card b { margin-top: .35rem; }

.bonus-zone { margin-top: 1.5rem; padding: clamp(1.2rem, 4vw, 2.5rem); border: 3px solid var(--ink); border-radius: 2rem; background: #fff3bd; box-shadow: 8px 8px 0 var(--ink); }
.bonus-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.bonus-heading h2 { margin: .7rem 0 .25rem; font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -.05em; }
.bonus-heading p { margin: 0; font-weight: 750; }
.bonus-total { min-width: 9rem; padding: .8rem 1rem; border: 2px solid var(--ink); border-radius: 1rem; background: var(--paper); text-align: center; }
.bonus-total strong, .bonus-total span { display: block; }.bonus-total strong { font-size: 1.35rem; }.bonus-total span { font-size: .72rem; font-weight: 850; }
.bonus-track { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .65rem; }
.bonus-track button { min-height: 10.5rem; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: .2rem; padding: .8rem .45rem; border: 2px solid var(--ink); border-radius: 1rem; background: var(--paper); cursor: pointer; }
.bonus-track button:not(:disabled):hover, .bonus-track button:not(:disabled):focus-visible { transform: translateY(-3px); box-shadow: 0 5px 0 var(--ink); outline: none; }
.bonus-track button:disabled { cursor: not-allowed; opacity: .52; filter: grayscale(.45); }
.bonus-track button.completed { background: #dff8ef; }
.bonus-medal { display: grid; place-items: center; width: 3.2rem; aspect-ratio: 1; margin-bottom: auto; border: 2px solid var(--ink); border-radius: 50%; background: var(--yellow); font-size: 1.2rem; font-weight: 1000; }
.bonus-track strong, .bonus-track small, .bonus-track b { display: block; text-align: center; }.bonus-track small { font-weight: 750; }.bonus-track b { margin-top: .35rem; font-size: .73rem; }

.view-toolbar, .game-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0 2rem; }
.back-button, .step-pill { min-height: 2.8rem; padding: .65rem .9rem; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); font-weight: 900; }
.back-button { cursor: pointer; }.step-pill { background: var(--yellow); }
.theory-view, .menu-view { max-width: 970px; margin-inline: auto; }
.theory-hero { text-align: center; }.theory-hero p, .menu-intro { font-size: 1.05rem; font-weight: 700; }
.rule-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.rule-card, .method-card { position: relative; padding: 1.6rem; border: 3px solid var(--ink); border-radius: 1.5rem; background: var(--paper); }
.addition-rule { box-shadow: 7px 7px 0 var(--mint); }.subtraction-rule { box-shadow: 7px 7px 0 var(--blue); }
.rule-symbol { position: absolute; right: 1.2rem; top: 1rem; font-size: 2.5rem; font-weight: 1000; }.rule-card h3 { font-size: 1.55rem; }.rule-card p { min-height: 3.2rem; line-height: 1.45; font-weight: 700; }
.mini-operation { width: 9rem; display: grid; margin: 1.1rem auto; text-align: right; font-size: 1.85rem; font-weight: 1000; }.mini-operation b { padding-top: .2rem; border-top: 3px solid var(--ink); }
.rule-card ul { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; padding: 0; list-style: none; }.rule-card li { padding: .5rem .2rem; border-radius: .5rem; background: #f2f4ff; text-align: center; font-weight: 900; }.rule-ok { color: var(--green); }
.method-card { margin-top: 1.5rem; }.method-card h3 { margin: .6rem 0 1.2rem; font-size: 1.6rem; }.method-row { display: flex; gap: 1rem; align-items: flex-start; padding: 1rem 0; border-top: 2px dashed #d5d8e9; }.method-row p { margin: .25rem 0 0; line-height: 1.45; }.number-badge { display: grid; flex: 0 0 2.5rem; place-items: center; aspect-ratio: 1; border: 2px solid var(--ink); border-radius: .8rem; background: var(--yellow); font-weight: 1000; }.wide-button { margin: 1.8rem auto 0; }

.menu-view { text-align: center; }.menu-list { display: grid; gap: .8rem; text-align: left; }.menu-list button { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem; padding: 1.2rem; border: 3px solid var(--ink); border-radius: 1.1rem; background: var(--paper); cursor: pointer; }.menu-list button:hover, .menu-list button:focus-visible { background: #fff1b5; transform: translateX(4px); outline: none; }.menu-list strong, .menu-list small { display: block; }.menu-list strong { font-size: 1.2rem; }.menu-list small { margin-top: .25rem; font-weight: 700; }.menu-number { display: grid; place-items: center; width: 3.2rem; aspect-ratio: 1; border-radius: .85rem; background: #e9e4ff; font-weight: 1000; }.menu-list b { font-size: 1.5rem; }

.game-view { max-width: 970px; margin-inline: auto; }.game-toolbar { padding-bottom: 1rem; }.game-progress { min-width: min(55%, 30rem); display: flex; align-items: center; gap: .7rem; }.game-progress > div { flex: 1; height: .85rem; overflow: hidden; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); }.game-progress span { display: block; width: 0; height: 100%; background: var(--pink); transition: width .3s; }.star-counter { padding: .6rem .8rem; border: 2px solid var(--ink); border-radius: .8rem; background: var(--yellow); font-weight: 1000; }
.question-card { min-height: 36rem; display: flex; flex-direction: column; align-items: center; padding: clamp(1.4rem, 4vw, 3rem); border: 3px solid var(--ink); border-radius: 2rem; background: var(--paper); box-shadow: 9px 9px 0 var(--ink); text-align: center; }.question-card h2 { margin: 1rem 0 .4rem; font-size: clamp(2rem, 5vw, 3.2rem); }.question-help { min-height: 1.6rem; font-weight: 700; }.question-area { width: 100%; display: grid; place-items: center; margin: 1rem 0; }
.sign-guide { width: min(100%, 46rem); display: grid; gap: .35rem; margin: 0 auto 1.4rem; padding: 1rem 1.15rem; border: 2px solid var(--ink); border-radius: 1rem; background: #fff7d2; text-align: left; }
.sign-guide strong { font-size: 1.1rem; }.sign-guide span { font-weight: 800; line-height: 1.4; }.sign-guide small { color: #4f5680; font-weight: 750; line-height: 1.4; }
.sign-equation { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .8rem; font-size: clamp(2.2rem, 7vw, 4.8rem); font-weight: 1000; }.equals-sign { color: #69709a; }.sign-choices { display: flex; gap: .6rem; }.sign-choices button { width: clamp(3.7rem, 10vw, 5.5rem); aspect-ratio: 1; border: 3px solid var(--ink); border-radius: 1rem; background: #f3f0ff; font-size: 2rem; font-weight: 1000; cursor: pointer; }.sign-choices button.selected { background: var(--yellow); box-shadow: 4px 4px 0 var(--ink); }.sign-choices button.correct { background: var(--mint); }.sign-choices button.incorrect { background: #ffd5df; }
.operation-title { margin-bottom: 1.2rem; font-size: clamp(2.4rem, 6vw, 4rem); font-weight: 1000; }.steps-grid { width: min(100%, 760px); display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }.step-box { padding: .9rem .6rem; border: 2px solid var(--ink); border-radius: 1rem; background: #f4f5ff; }.step-box small, .step-box strong { display: block; }.step-box small { margin-bottom: .35rem; font-size: .68rem; font-weight: 1000; letter-spacing: .08em; }.step-box strong { min-height: 1.7rem; font-size: 1.15rem; }.math-input { width: 100%; min-height: 3.4rem; margin-top: .7rem; border: 3px solid var(--ink); border-radius: .75rem; background: var(--paper); text-align: center; font-size: 1.5rem; font-weight: 1000; }.math-input:focus { outline: 4px solid rgba(128,200,255,.45); }.math-input.correct { border-color: var(--green); background: #dcf8ef; }.math-input.incorrect { border-color: var(--red); background: #fff0f3; }.total-box { width: min(100%, 280px); margin: 1rem auto 0; padding: .9rem; border: 3px solid var(--ink); border-radius: 1rem; background: #fff3b6; }.total-box label { display: block; font-weight: 1000; }
.jump-path { width: min(100%, 820px); display: grid; grid-template-columns: repeat(4, 1fr); align-items: end; gap: .55rem; }.jump-node { position: relative; padding-top: 2.8rem; }.jump-node:not(:first-child)::before { content: attr(data-delta); position: absolute; top: 0; left: -50%; right: 50%; padding-top: .15rem; border-top: 3px solid var(--ink); border-radius: 50% 50% 0 0; font-size: .9rem; font-weight: 1000; }.jump-start, .jump-node .math-input { min-height: 4.2rem; display: grid; place-items: center; margin: 0; border: 3px solid var(--ink); border-radius: 1rem; background: var(--paper); font-size: 1.5rem; font-weight: 1000; }.jump-start { background: #e9e4ff; }
.feedback { min-height: 2.8rem; display: grid; place-items: center; margin: .7rem 0; padding: .65rem 1rem; border-radius: .8rem; font-weight: 900; }.feedback.success { color: var(--green); background: #dcf8ef; }.feedback.gentle { color: #8b3850; background: #fff0f3; }.check-button, .next-button { min-width: min(100%, 18rem); margin-top: auto; }

.result-view { max-width: 800px; margin-inline: auto; padding-top: 2rem; }.result-card { display: flex; flex-direction: column; align-items: center; padding: clamp(1.5rem, 5vw, 3.5rem); border: 3px solid var(--ink); border-radius: 2rem; background: var(--paper); box-shadow: 9px 9px 0 var(--ink); text-align: center; }.result-star { color: #f2ad00; font-size: 4.5rem; line-height: 1; }.result-card h2 { margin: 1rem 0 .5rem; font-size: clamp(2rem, 5vw, 3.4rem); }.big-score { margin: 1rem 0; }.big-score strong, .big-score span { display: block; }.big-score strong { font-size: 4rem; line-height: 1; }.big-score span { font-weight: 900; }.result-details { width: min(100%, 34rem); display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }.result-details div { padding: 1rem; border: 2px solid var(--ink); border-radius: 1rem; background: #f4f5ff; }.result-details strong, .result-details span { display: block; }.result-details strong { font-size: 1.5rem; }.result-details span { font-size: .78rem; font-weight: 800; }
footer { padding: 2rem 1rem; text-align: center; font-size: .78rem; font-weight: 800; opacity: .7; }

@media (max-width: 720px) {
  body { background: linear-gradient(180deg, #b9eee2 0 28rem, var(--cream) 28rem); }
  .topbar { min-height: 5.3rem; grid-template-columns: 1fr auto; }.brand { justify-self: end; }.offline-pill { display: none; }.back-link span { display: none; }
  .hero { grid-template-columns: 1fr; padding-top: 1.5rem; }.place-visual { width: min(100%, 25rem); margin-inline: auto; }.hero-actions { align-items: stretch; flex-direction: column; }
  .home-stats { margin-top: 0; flex-wrap: wrap; }.home-stats > div { min-width: 9.3rem; }
  .mission-grid, .rule-grid { grid-template-columns: 1fr; }.mission-card { min-height: 12rem; }.rule-card p { min-height: 0; }
  .bonus-heading { align-items: flex-start; flex-direction: column; }.bonus-track { grid-template-columns: repeat(2, 1fr); }.bonus-track button:last-child { grid-column: 1 / -1; }
  .game-toolbar { flex-wrap: wrap; }.game-progress { order: 3; width: 100%; min-width: 100%; }.question-card { min-height: 34rem; border-radius: 1.3rem; box-shadow: 5px 5px 0 var(--ink); }
  .steps-grid { grid-template-columns: 1fr; }.step-box { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: .5rem; }.step-box small { grid-column: 1 / -1; }.step-box .math-input { margin-top: 0; }
  .jump-path { grid-template-columns: repeat(2, 1fr); row-gap: 1rem; }.jump-node:nth-child(3)::before { display: none; }
  .sign-guide { text-align: center; }.sign-equation { gap: .45rem; font-size: clamp(1.75rem, 9vw, 3.2rem); }.sign-choices { gap: .35rem; }.sign-choices button { width: clamp(3.2rem, 15vw, 4.2rem); }
  .result-details { grid-template-columns: 1fr; }.result-actions { flex-direction: column; width: 100%; }.result-actions button { width: 100%; }
}

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