:root {
  --cream: #fff6e9;
  --ink: #5b4a3f;
  --muted: #8a7a6e;
  --orange: #ff8a3d;
  --orange-dark: #df681b;
  --green: #3e9b68;
  --blue: #4fa8f2;
  --red: #ff5a4e;
  --card: #fff;
  --shadow: 0 6px 0 rgba(91, 74, 63, 0.13), 0 15px 32px rgba(91, 74, 63, 0.12);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, #ffd89b 0 70px, transparent 71px),
    radial-gradient(circle at 92% 86%, #d7eefe 0 90px, transparent 91px),
    var(--cream);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.app { width: 100%; min-height: 100dvh; margin: 0 auto; padding: 12px 20px max(12px, env(safe-area-inset-bottom)); }
.view { min-height: calc(100dvh - 36px); animation: enter 0.28s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } }

.home, .finish { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; }
.sparkles { color: var(--orange); font-size: 28px; letter-spacing: 10px; }
h1 { color: var(--red); font-size: clamp(38px, 10vw, 64px); margin: 0; text-shadow: 0 3px #fff; }
.lead { margin: 0; color: var(--muted); font-size: clamp(18px, 4.5vw, 24px); }
.hero { width: min(330px, 82vw); aspect-ratio: 1.55; overflow: hidden; border: 5px solid white; border-radius: 34px; background: #fff; box-shadow: var(--shadow); }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.primary, .secondary { min-height: 58px; padding: 12px 36px; border-radius: 999px; border: 0; font-size: 22px; font-weight: 800; }
.primary { color: white; background: var(--orange); box-shadow: 0 6px 0 var(--orange-dark); }
.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--orange-dark); }
.secondary { background: white; border: 3px solid #eadfce; }
.tip { color: var(--muted); margin: 0; }

#topics { position: relative; padding-top: 10px; }
#topics h2 { text-align: center; font-size: clamp(28px, 7vw, 38px); margin: 12px 0 24px; }
.back, .sound { width: 50px; height: 50px; border-radius: 50%; border: 0; background: white; box-shadow: 0 3px 0 rgba(91,74,63,.14); font-size: 25px; font-weight: 900; }
#topics > .back { position: absolute; left: 0; top: 8px; }
.topic-grid { width: min(920px, 100%); margin: 0 auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.topic { min-height: 170px; border: 5px solid white; border-radius: 28px; background: var(--topic); box-shadow: var(--shadow); padding: 18px 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.topic .emoji { width: 92px; height: 92px; overflow: hidden; border: 4px solid rgba(255,255,255,.88); border-radius: 22px; background: white; }
.topic .emoji img { width: 100%; height: 100%; object-fit: cover; }
.topic strong { color: white; font-size: clamp(22px, 5.5vw, 30px); text-shadow: 0 2px 3px rgba(0,0,0,.18); }
.topic .count { color: rgba(255,255,255,.92); font-size: 15px; font-weight: 800; }
.topic.mix { grid-column: 1 / -1; min-height: 118px; flex-direction: row; background: linear-gradient(135deg, #ff9d54, #8d7cf4); }
.topic.mix > span:last-child { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }

.game { min-height: calc(100dvh - 24px); display: flex; flex-direction: column; gap: 10px; overflow: visible; }
.game-head { display: grid; grid-template-columns: 52px 1fr 52px; align-items: center; text-align: center; gap: 8px; }
#progress-text { font-weight: 800; font-size: 18px; }
.progress { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.progress span { height: 9px; border-radius: 99px; background: #eadfce; }
.progress .done, .progress .now { background: var(--orange); }
.scene { width: min(1400px, 72vw); height: min(52dvh, 620px); min-height: 360px; flex: none; margin: 0 auto; padding: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 5px solid white; border-radius: 28px; background: linear-gradient(150deg, #eaf6ff, #fff8d8); box-shadow: var(--shadow); text-align: center; }
.scene-emoji { width: 100%; flex: 1 1 auto; min-height: 0; overflow: hidden; border-radius: 20px; background: #fff; }
.scene-emoji img { width: 100%; height: 100%; object-fit: cover; }
.scene h2 { flex: none; margin: 8px 0 2px; font-size: clamp(24px, 3vw, 38px); }
.scene p { margin: 0; color: var(--muted); font-size: 14px; }
.feedback { flex: none; min-height: 26px; color: var(--red); font-weight: 800; text-align: center; }
.answers { flex: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: clamp(260px, 32dvh, 360px); gap: 14px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.answer { min-height: 0; border: 4px solid transparent; border-radius: 23px; background: white; box-shadow: 0 4px 0 rgba(91,74,63,.12); padding: 0; overflow: hidden; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.answer .emoji { width: 100%; min-height: 0; overflow: hidden; background: #f5efe6; }
.answer .emoji img { width: 100%; height: 100%; object-fit: cover; }
.answer .label { padding: 10px 12px 11px; color: #493a31; background: white; font-size: clamp(18px, 2.3vw, 29px); font-weight: 900; line-height: 1.1; text-align: center; }
.answer.wrong { border-color: var(--red); opacity: .48; animation: shake .32s ease; }
.answer.correct { border-color: var(--green); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(91,74,63,.42); }
.learn-card { width: min(470px, 100%); padding: 24px; border-radius: 30px; background: white; box-shadow: 0 22px 60px rgba(70,45,20,.28); text-align: center; }
.celebrate { font-size: 76px; animation: bounce .7s ease; }
@keyframes bounce { 50% { transform: scale(1.18) rotate(8deg); } }
.learn-card h2 { color: var(--green); font-size: 30px; margin: 4px 0 12px; }
.learn-answer { display: inline-flex; align-items: center; gap: 8px; padding: 8px 18px; border-radius: 999px; background: var(--cream); font-size: 22px; font-weight: 900; }
.learn-answer img { width: 58px; height: 58px; object-fit: cover; border-radius: 14px; }
.learn-card p { padding: 14px; border-radius: 18px; background: #eaf6ff; font-size: 18px; line-height: 1.65; text-align: left; }
.trophy { font-size: 110px; }
.finish h2 { color: #7766dd; font-size: clamp(32px, 8vw, 48px); margin: 0; }
.finish-stars { font-size: clamp(34px, 9vw, 54px); letter-spacing: 3px; }
.finish p { color: var(--muted); font-size: 18px; }

button:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }
@media (min-width: 1367px) {
  .topic-grid { grid-template-columns: repeat(4, 1fr); }
  .topic.mix { grid-column: 1 / -1; }
  .answers { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 719px) {
  .app { padding: 10px 10px max(10px, env(safe-area-inset-bottom)); }
  .game { min-height: calc(100dvh - 20px); gap: 7px; }
  .scene { width: 100%; height: 46dvh; min-height: 300px; padding: 8px; }
  .answers { grid-auto-rows: clamp(190px, 28dvh, 260px); gap: 8px; }
  .answer .label { padding: 7px 8px 8px; }
  .answer .label { font-size: clamp(15px, 4.2vw, 20px); }
}
@media (max-height: 720px) {
  .scene h2 { margin-top: 4px; font-size: clamp(21px, 3vw, 31px); }
  .scene p { display: none; }
  .answer .label { padding-top: 7px; padding-bottom: 7px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
