:root {
  --sky: #bde8ff;
  --deep: #1d3557;
  --sun: #ffd23f;
  --coral: #ff6b6b;
  --mint: #3ddc97;
  --grape: #8367c7;
  --card: #fff;
  --soft: #f0f6ff;
  --line: #c3d5ee;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  padding: 16px;
  color: var(--deep);
  font-family: 'Fredoka', 'PingFang SC', 'Microsoft YaHei', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
  background: var(--sky);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,.7) 0 40px, transparent 41px),
    radial-gradient(circle at 80% 12%, rgba(255,255,255,.6) 0 55px, transparent 56px),
    radial-gradient(circle at 60% 85%, rgba(255,255,255,.5) 0 45px, transparent 46px);
}
button, select { font: inherit; }
button { color: inherit; }
.app { width: min(100%, 760px); margin: 0 auto; }
.lang-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.portal-link, .lang-btn, .sound-btn {
  min-height: 40px;
  border: 0;
  border-radius: 14px;
  padding: 8px 12px;
  background: rgba(255,255,255,.72);
  color: var(--deep);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.portal-link { display: inline-grid; min-width: 44px; place-items: center; }
.account-panel { flex: 1; justify-content: flex-end; }
.lang-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.lang-btn.active, .sound-btn { background: var(--deep); color: #fff; }
.lang-btn:active, .sound-btn:active, .portal-link:active { transform: scale(.95); }
.card { padding: clamp(20px, 4vw, 34px); border-radius: 28px; background: var(--card); box-shadow: 0 10px 0 rgba(29,53,87,.15); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; text-align: center; font-size: clamp(2rem, 7vw, 2.8rem); }
.subtitle { color: #526c91; text-align: center; font-weight: 600; }
.intro-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.intro-row .subtitle { margin-bottom: 0; }
.section-label { margin: 24px 0 10px; font-size: .92rem; color: #526c91; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.segmented.two { grid-template-columns: repeat(2, 1fr); }
.segment-option, .mode-option { position: relative; min-width: 0; }
.segment {
  width: 100%;
  min-height: 46px;
  border: 2px solid #d8e4f0;
  border-radius: 14px;
  background: #fff;
  font-weight: 750;
  cursor: pointer;
}
.segment-option .segment { min-height: 74px; padding-right: 48px; }
.range-option .segment { min-height: 56px; }
.segment.active { border-color: var(--deep); background: var(--deep); color: #fff; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.mode-card {
  width: 100%;
  min-height: 142px;
  padding: 18px 70px 18px 18px;
  border: 0;
  border-radius: 20px;
  background: #edf7ff;
  box-shadow: 0 5px 0 #bed8ec;
  text-align: left;
  cursor: pointer;
}
.mode-option:nth-child(3n+2) .mode-card { background: #fff1de; box-shadow-color: #ebc89b; }
.mode-option:nth-child(3n) .mode-card { background: #eee8ff; box-shadow-color: #cbbcf1; }
.mode-card:active { transform: translateY(3px); box-shadow: 0 2px 0 #b7c8d8; }
.mode-icon { display: block; margin-bottom: 8px; font-size: 2rem; }
.mode-card strong { display: block; margin-bottom: 5px; font-size: 1.18rem; }
.mode-card small { display: block; color: #526c91; line-height: 1.35; font-weight: 600; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.home-btn, .secondary-btn, .hint-btn, .next-btn, .primary-btn {
  min-height: 46px;
  border: 0;
  border-radius: 15px;
  padding: 10px 17px;
  font-weight: 750;
  cursor: pointer;
}
.home-btn, .secondary-btn, .hint-btn { background: #edf2f7; }
.primary-btn, .next-btn { background: var(--sun); box-shadow: 0 5px 0 #e0b000; }
.progress { font-weight: 800; text-align: right; }
.progress small { display: block; color: #647b9b; font-weight: 650; }
.stars { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: 31px; margin: 12px 0 18px; }
.star { opacity: .22; font-size: 1.3rem; }
.star.first-correct { opacity: 1; }
.star.completed { opacity: .72; filter: grayscale(.5); }
.skill-chip { display: table; margin: 0 auto 12px; border-radius: 999px; padding: 6px 12px; background: #e9f1fb; color: #526c91; font-size: .88rem; font-weight: 750; }
.problem-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 8px 0 18px; }
.problem { text-align: center; font-size: clamp(1.8rem, 7vw, 3.2rem); font-weight: 800; line-height: 1.25; }
.speak-button {
  display: inline-grid;
  flex: 0 0 auto;
  min-width: 48px;
  min-height: 48px;
  place-items: center;
  border: 2px solid #bdd2e8;
  border-radius: 50%;
  background: #edf7ff;
  font-size: 1.2rem;
  cursor: pointer;
}
.speak-button:active { transform: scale(.94); }
.speak-button:focus-visible { outline: 3px solid #a45300; outline-offset: 3px; }
.prompt-speak { min-width: 56px; min-height: 56px; font-size: 1.45rem; }
.compact-speak { position: absolute; top: 10px; right: 10px; min-width: 44px; min-height: 44px; font-size: 1rem; }
.segment-option .compact-speak { top: 50%; right: 5px; transform: translateY(-50%); }
.segment-option .compact-speak:active { transform: translateY(-50%) scale(.94); }
.visual { display: grid; place-items: center; min-height: 74px; margin: 0 0 22px; }
.sequence { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; font-size: clamp(1.6rem, 7vw, 2.6rem); font-weight: 800; }
.ten-frame { display: grid; grid-template-columns: repeat(5, 42px); gap: 7px; padding: 9px; border: 3px solid var(--deep); border-radius: 14px; background: #fff; }
.ten-cell { width: 42px; height: 42px; border: 2px solid #c5d5e6; border-radius: 8px; background: #f7fbff; }
.ten-cell.filled { border-color: #20a46e; background: var(--mint); }
.ten-cell.outside { opacity: .16; }
.object-story { max-width: 100%; text-align: center; font-size: 1.8rem; line-height: 1.55; word-break: break-word; }
.array-grid { display: grid; gap: 7px; justify-content: center; }
.array-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--grape); box-shadow: inset 0 -3px 0 rgba(0,0,0,.14); }
.clock-visual, .clock-pair { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px; }
.clock-card { margin: 0; text-align: center; font-weight: 800; }
.clock-card figcaption { min-height: 24px; }
.clock-face { width: 150px; height: 150px; }
.clock-face circle { fill: #fffdf5; stroke: var(--deep); stroke-width: 4; }
.clock-marks line { stroke: var(--deep); stroke-width: 3; stroke-linecap: round; }
.hour-hand, .minute-hand { stroke: var(--deep); stroke-linecap: round; }
.hour-hand { stroke-width: 7; }
.minute-hand { stroke-width: 5; }
.clock-pin { fill: var(--coral); }
.unit-measure { display: grid; justify-items: center; gap: 8px; }
.measured-object { font-size: 4rem; line-height: 1; transform: rotate(-5deg); }
.measure-units { display: flex; justify-content: center; gap: 3px; }
.measure-units i { display: block; width: 25px; height: 25px; border: 2px solid #8aa7c7; background: #e9f4ff; }
.measure-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; width: min(100%, 500px); }
.measure-compare > div { display: grid; justify-items: center; gap: 8px; padding: 14px 8px; border-radius: 16px; background: #f2f7fc; overflow: hidden; }
.measure-compare strong { font-size: 1.35rem; }
.measure-icon { font-size: 2.5rem; }
.picture-chart { display: grid; gap: 8px; width: min(100%, 480px); }
.picture-chart > div { display: grid; grid-template-columns: 44px 1fr; align-items: center; min-height: 48px; padding: 6px 10px; border-radius: 12px; background: #f2f7fc; }
.picture-chart strong { font-size: 1.6rem; }
.picture-chart span { letter-spacing: .12em; font-size: clamp(1.35rem, 6vw, 2rem); overflow-wrap: anywhere; }
.spatial-row { display: flex; justify-content: center; gap: clamp(14px, 5vw, 36px); padding: 18px; border-radius: 18px; background: #f2f7fc; }
.spatial-row span { font-size: clamp(2.5rem, 10vw, 4.5rem); }
.number-cards, .order-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.number-cards span, .order-cards span { display: grid; min-width: 72px; min-height: 72px; place-items: center; border-radius: 16px; background: #f2f7fc; box-shadow: 0 4px 0 var(--line); font-size: 2rem; font-weight: 850; }
.answers, .shape-answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.answer-btn, .shape-btn {
  min-height: 74px;
  border: 0;
  border-radius: 20px;
  background: var(--soft);
  box-shadow: 0 5px 0 var(--line);
  font-size: 1.7rem;
  font-weight: 800;
  cursor: pointer;
}
.answer-btn.correct, .shape-btn.correct { background: var(--mint); color: #fff; box-shadow-color: #23a470; }
.answer-btn.wrong, .shape-btn.wrong { background: var(--coral); color: #fff; box-shadow-color: #c94a4a; }
.shape-btn { min-height: 128px; }
.shape-btn svg { width: 82px; height: 82px; overflow: visible; }
.keypad-readout { min-height: 65px; margin-bottom: 14px; border: 3px solid #c3d5ee; border-radius: 18px; background: #f8fbff; text-align: center; font-size: 2.3rem; font-weight: 850; line-height: 59px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button { min-height: 58px; border: 0; border-radius: 16px; background: var(--soft); box-shadow: 0 4px 0 var(--line); font-size: 1.5rem; font-weight: 800; cursor: pointer; }
.keypad .confirm { grid-column: span 2; background: var(--sun); box-shadow-color: #e0b000; }
.wallet-total { margin-bottom: 12px; text-align: center; font-size: 1.5rem; font-weight: 800; }
.coin-bank, .coin-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.coin {
  width: 70px;
  height: 70px;
  border: 3px solid #bb7b16;
  border-radius: 50%;
  background: #ffd76d;
  box-shadow: inset 0 0 0 5px #ffe8a8, 0 4px 0 #a86510;
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
}
.coin-tray { min-height: 68px; margin: 15px 0; border: 3px dashed #b8c9db; border-radius: 18px; padding: 10px; text-align: center; background: #f8fbff; }
.coin-token { display: inline-grid; width: 43px; height: 43px; margin: 2px; place-items: center; border-radius: 50%; background: #ffd76d; border: 2px solid #bb7b16; font-weight: 800; }
.feedback { min-height: 36px; margin: 18px 0 0; text-align: center; font-size: 1.17rem; font-weight: 750; }
.feedback.success { color: #137149; }
.feedback.error { color: #a52f36; }
.hint-box, .explanation { margin-top: 12px; border-radius: 15px; padding: 13px 15px; background: #fff7d6; line-height: 1.45; font-weight: 650; }
.readable-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.question-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.summary { text-align: center; }
.summary-emoji { font-size: 4.2rem; }
.summary strong { font-size: 1.2rem; }
.save-state { min-height: 24px; color: #526c91; }
.table-picker { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 5px; margin: 14px 0; }
.table-picker button { aspect-ratio: 1; min-width: 0; border: 0; border-radius: 10px; background: #edf2f7; font-weight: 800; cursor: pointer; }
.table-picker button.active { background: var(--grape); color: #fff; }
.multiplication-preview { min-height: 180px; border-radius: 18px; padding: 16px; background: #f6f2ff; text-align: center; }
.multiplication-preview h2 { margin-bottom: 12px; }
.multiplication-matrix { display: grid; grid-template-columns: repeat(9, minmax(34px, 1fr)); gap: 4px; margin: 10px 0 18px; overflow-x: auto; }
.multiplication-matrix button { min-width: 34px; min-height: 38px; border: 0; border-radius: 8px; background: #edf2f7; font-weight: 750; cursor: pointer; }
.multiplication-matrix button:nth-child(odd) { background: #f3efff; }
.multiplication-matrix small, .multiplication-matrix strong { display: block; }
.multiplication-matrix small { color: #526c91; font-size: .68rem; }
.multiplication-matrix strong { font-size: 1rem; }
.mobile-multiplication-list { display: none; }

@media (max-width: 560px) {
  body { padding: 10px; }
  .lang-actions { width: 100%; justify-content: flex-end; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: 105px; }
  .table-picker { grid-template-columns: repeat(5, 1fr); }
  .multiplication-matrix { display: none; }
  .mobile-multiplication-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
  .mobile-multiplication-list button { min-height: 48px; border: 0; border-radius: 12px; background: #edf2f7; font-weight: 700; cursor: pointer; }
  .card { padding: 20px 16px; border-radius: 22px; }
  .problem-row { align-items: flex-start; }
  .problem { flex: 1; font-size: clamp(1.65rem, 9vw, 2.6rem); }
  .prompt-speak { min-width: 52px; min-height: 52px; }
  .ten-frame { grid-template-columns: repeat(5, 34px); }
  .ten-cell { width: 34px; height: 34px; }
  .clock-face { width: 126px; height: 126px; }
  .measure-units i { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
