:root {
  --ink: #26354f;
  --muted: #6d7890;
  --panel: rgba(255,255,255,.9);
  --card: #fff;
  --blue: #4fb7ff;
  --blue2: #7dd3fc;
  --pink: #ff83bd;
  --yellow: #ffd166;
  --green: #52d49b;
  --purple: #9b7bff;
  --shadow: 0 16px 40px rgba(47, 78, 120, .16);
}

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

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 209, 102, .45), transparent 24%),
    radial-gradient(circle at 88% 16%, rgba(255, 131, 189, .42), transparent 26%),
    linear-gradient(155deg, #e2f8ff 0%, #fff4cf 48%, #ffe3f0 100%);
  background-attachment: fixed;
  -webkit-user-select: none;
  user-select: none;
}

button, a { font-family: inherit; }

.mul-app {
  width: min(100%, 860px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 14px calc(env(safe-area-inset-bottom) + 18px);
}

.mul-top {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 10px;
  align-items: center;
}

.round-btn {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  color: #2d7fe8;
  text-decoration: none;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 900;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.round-btn:active, .mode-tab:active, .chip:active, .formula-btn:active, .answer-btn:active, .start-btn:active, .pill-btn:active {
  transform: scale(.96);
}

.mul-title {
  text-align: center;
  min-width: 0;
}

.title-kicker {
  color: #71809a;
  font-size: 12px;
  font-weight: 900;
}

.mul-title h1 {
  margin: 2px 0 0;
  font-size: clamp(23px, 6vw, 40px);
  color: #2580e8;
  text-shadow: 0 2px 0 #fff;
  letter-spacing: 0;
}

.hero {
  position: relative;
  overflow: hidden;
  min-height: 150px;
  margin-top: 16px;
  border-radius: 28px;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.95), rgba(255,255,255,.62)),
    linear-gradient(135deg, #e4f7ff, #fff4d4 58%, #ffe1ef);
  border: 3px solid rgba(255,255,255,.72);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 12px;
  align-items: center;
}

.hero > *:not(.hero-orbit) {
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  color: #2d7fe8;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(45,127,232,.14);
}

.hero-badge b { color: #ff6ea8; }

.hero p {
  max-width: 360px;
  margin: 12px 0 0;
  color: #52607a;
  font-size: 19px;
  font-weight: 900;
  line-height: 1.35;
}

.hero-mascot {
  position: relative;
  display: grid;
  justify-items: center;
}

.mascot-face {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border-radius: 32px;
  background: linear-gradient(160deg, #fff, #e8f8ff);
  font-size: 58px;
  box-shadow: 0 14px 30px rgba(44, 103, 161, .2);
  animation: floaty 2.8s ease-in-out infinite;
}

.mascot-shadow {
  width: 68px;
  height: 12px;
  margin-top: 10px;
  border-radius: 50%;
  background: rgba(43, 104, 160, .14);
}

@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

.hero-orbit {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hero-orbit span {
  position: absolute;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.76);
  color: rgba(37,128,232,.72);
  font-weight: 1000;
  box-shadow: 0 8px 22px rgba(47, 78, 120, .12);
}

.hero-orbit span:nth-child(1) { left: 24px; bottom: 18px; transform: rotate(-8deg); }
.hero-orbit span:nth-child(2) { right: 128px; top: 18px; transform: rotate(7deg); }
.hero-orbit span:nth-child(3) { right: 22px; bottom: 20px; transform: rotate(-5deg); }

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.mode-tab {
  min-height: 52px;
  border: 0;
  border-radius: 18px;
  background: rgba(255,255,255,.72);
  color: #5d6a82;
  font-size: 15px;
  font-weight: 1000;
  box-shadow: 0 10px 24px rgba(47, 78, 120, .12);
  cursor: pointer;
}

.mode-tab.active {
  color: #fff;
  background: linear-gradient(135deg, #46a9ff, #9b7bff);
}

.view { display: none; }
.view.active { display: block; }

.group-strip {
  display: grid;
  grid-template-columns: repeat(9, minmax(52px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.chip {
  border: 0;
  min-height: 58px;
  border-radius: 18px;
  background: rgba(255,255,255,.82);
  color: #4b5c78;
  font-weight: 1000;
  box-shadow: 0 10px 22px rgba(47, 78, 120, .12);
  cursor: pointer;
}

.chip span {
  display: block;
  font-size: 17px;
  line-height: 1.1;
}

.chip small {
  display: block;
  margin-top: 2px;
  color: #93a0b6;
  font-size: 11px;
}

.chip .state.done {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin: 4px auto 0;
  border-radius: 999px;
  background: #e8fff2;
  color: #13b76b;
  font-size: 15px;
  box-shadow: inset 0 0 0 2px rgba(19, 183, 107, .18);
}

.chip.active {
  color: #fff;
  background: linear-gradient(145deg, #ff8bbf, #8d7dff);
}

.chip.active small { color: rgba(255,255,255,.82); }
.chip.active .state.done {
  background: #fff;
  color: #13b76b;
  box-shadow: 0 6px 14px rgba(19, 183, 107, .22);
}

.lesson-card, .quiz-setup, .quiz-card, .mistake-card {
  margin-top: 10px;
  border-radius: 28px;
  background: var(--panel);
  border: 3px solid rgba(255,255,255,.75);
  box-shadow: var(--shadow);
  padding: 16px;
}

.lesson-head, .setup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setup-row { align-items: flex-start; }
.setup-row.slim { margin-top: 18px; }

.section-label {
  color: #7c8aa2;
  font-size: 12px;
  font-weight: 1000;
}

h2 {
  margin: 2px 0 0;
  font-size: 24px;
  color: #253b67;
}

.pill-btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  color: #2d7fe8;
  background: #fff;
  font-size: 14px;
  font-weight: 1000;
  box-shadow: 0 9px 18px rgba(47, 78, 120, .12);
  cursor: pointer;
}

.lesson-body {
  display: block;
  margin: 16px 0;
}

.rule-panel {
  min-height: 188px;
  border-radius: 24px;
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(125,211,252,.22);
  padding: 14px;
}

.rule-panel {
  display: grid;
  align-content: center;
  text-align: center;
}

.formula-big {
  color: #1d6fe8;
  font-size: clamp(34px, 8vw, 58px);
  font-weight: 1000;
  line-height: 1.05;
}

.addition-line {
  margin-top: 14px;
  color: #65738c;
  font-size: 18px;
  font-weight: 900;
}

.chant-line {
  display: inline-flex;
  justify-self: center;
  margin-top: 16px;
  padding: 10px 16px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #ff8bbf, #ffb35c);
  font-weight: 1000;
  font-size: 18px;
}

.formula-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.formula-btn {
  border: 0;
  border-radius: 18px;
  background: #fff;
  color: #40516d;
  padding: 12px 8px;
  font-size: 16px;
  font-weight: 1000;
  box-shadow: 0 8px 18px rgba(47, 78, 120, .1);
  cursor: pointer;
}

.formula-btn.active {
  color: #fff;
  background: linear-gradient(135deg, #51b8ff, #52d49b);
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px;
  margin-top: 12px;
}

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.seg-btn {
  border: 0;
  min-height: 44px;
  border-radius: 16px;
  background: #fff;
  color: #5d6a82;
  font-size: 15px;
  font-weight: 1000;
  box-shadow: 0 8px 18px rgba(47, 78, 120, .1);
  cursor: pointer;
}

.seg-btn.active {
  color: #fff;
  background: linear-gradient(135deg, #4fb7ff, #9b7bff);
}

.start-btn, .next-btn, .ghost-btn {
  width: 100%;
  border: 0;
  border-radius: 20px;
  min-height: 56px;
  margin-top: 16px;
  color: #fff;
  background: linear-gradient(135deg, #2f9cff, #9b7bff);
  font-size: 18px;
  font-weight: 1000;
  box-shadow: 0 14px 26px rgba(77, 128, 255, .22);
  cursor: pointer;
}

.ghost-btn {
  color: #2d7fe8;
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(77, 128, 255, .18);
}

.quiz-progress {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #61708a;
  font-size: 14px;
  font-weight: 1000;
}

.quiz-progress b { color: #ff6ea8; }

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(128, 154, 190, .18);
  overflow: hidden;
  margin: 10px 0 16px;
}

.progress-track div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #52d49b, #4fb7ff, #9b7bff);
  border-radius: inherit;
  transition: width .22s ease;
}

.question-box {
  border-radius: 26px;
  background: #fff;
  padding: 16px;
  box-shadow: inset 0 0 0 2px rgba(125,211,252,.2);
  text-align: center;
}

.question-type {
  display: inline-flex;
  padding: 7px 12px;
  border-radius: 999px;
  background: #eef8ff;
  color: #2d7fe8;
  font-size: 13px;
  font-weight: 1000;
}

.question-text {
  margin-top: 10px;
  color: #193764;
  font-size: clamp(38px, 11vw, 72px);
  line-height: 1.05;
  font-weight: 1000;
}

.question-visual {
  margin: 12px auto 0;
  display: grid;
  gap: 6px;
  justify-content: center;
  max-width: 100%;
  min-height: 64px;
}

.mini-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.mini-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(145deg, #7dd3fc, #9b7bff);
  box-shadow: 0 4px 8px rgba(47, 78, 120, .15);
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.answer-btn {
  border: 0;
  min-height: 66px;
  border-radius: 22px;
  background: #fff;
  color: #26354f;
  font-size: clamp(22px, 7vw, 36px);
  font-weight: 1000;
  box-shadow: 0 12px 24px rgba(47, 78, 120, .12);
  cursor: pointer;
}

.answer-btn.correct {
  color: #fff;
  background: linear-gradient(135deg, #32c886, #69dfaa);
}

.answer-btn.wrong {
  color: #fff;
  background: linear-gradient(135deg, #ff7088, #ff9a76);
}

.answer-btn.dim { opacity: .45; }

.feedback {
  margin-top: 12px;
  border-radius: 18px;
  padding: 12px;
  background: rgba(255,255,255,.86);
  color: #51617c;
  font-weight: 900;
  line-height: 1.45;
}

.mistake-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.mistake-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border-radius: 18px;
  background: #fff;
  padding: 12px 14px;
  box-shadow: 0 8px 18px rgba(47, 78, 120, .1);
}

.mistake-item b {
  color: #1d6fe8;
  font-size: 20px;
}

.mistake-item span {
  color: #8793a8;
  font-size: 13px;
  font-weight: 900;
}

.empty {
  border-radius: 22px;
  padding: 24px 16px;
  color: #6b7890;
  background: #fff;
  font-weight: 900;
  text-align: center;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(35, 49, 76, .34);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.overlay[hidden] { display: none; }

.result-card {
  width: min(380px, 100%);
  border-radius: 30px;
  background: rgba(255,255,255,.96);
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(36, 60, 96, .24);
}

.result-medal {
  font-size: 64px;
  line-height: 1;
}

.result-card h2 {
  margin-top: 12px;
  color: #1d6fe8;
}

.result-card p {
  color: #66738b;
  font-weight: 900;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.stat-pill {
  border-radius: 18px;
  background: #eef8ff;
  padding: 10px 8px;
  color: #60708a;
  font-size: 12px;
  font-weight: 1000;
}

.stat-pill b {
  display: block;
  color: #ff6ea8;
  font-size: 22px;
}

@media (max-width: 620px) {
  .mul-app { padding-left: 12px; padding-right: 12px; }
  .hero { grid-template-columns: 1fr 86px; min-height: 134px; padding: 16px; border-radius: 24px; }
  .mascot-face { width: 78px; height: 78px; font-size: 48px; border-radius: 26px; }
  .hero p { font-size: 17px; }
  .rule-panel { min-height: 172px; }
  .formula-grid { grid-template-columns: repeat(2, 1fr); }
  .chip-grid { grid-template-columns: repeat(3, 1fr); }
  .mode-tab { font-size: 14px; min-height: 48px; }
  .hero-orbit { display: none; }
}
