/* ธีม "อวกาศสดใส" — ท้องฟ้าม่วงคราม ดาวเหลือง ปุ่มชมพู การ์ดสีขาวนวลเหมือนผิวดวงจันทร์ */
:root {
  --space: #1d1550;
  --space-2: #2c1c6e;
  --nebula: #ff6fb5;
  --mint: #3ee0b8;
  --sky: #6ec3ff;
  --star: #ffd23f;
  --star-d: #d9a400;
  --moon: #fffaf2;
  --moon-edge: #e4dcf5;
  --ink: #2a2350;
  --ink-soft: #6b6390;
  --on-space: #f4f0ff;
  --on-space-soft: #c9bff5;
  --primary: #ff5fa8;
  --primary-d: #c93f84;
  --good: #20c08a;
  --good-bg: #dcfff1;
  --bad: #ff5d6c;
  --bad-bg: #ffe3e6;
  --try-bg: #fff6d1;
  --radius: 24px;
  --font-fun: 'Itim', 'Mali', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: 'Mali', 'Leelawadee UI', 'Noto Sans Thai', system-ui, sans-serif;
  color: var(--on-space);
  background: var(--space);
  min-height: 100dvh;
  font-size: 18px;
  line-height: 1.55;
  overflow-x: hidden;
}
#app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 12px 16px 96px; min-height: 100dvh; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; padding: 0; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 3px solid var(--star); outline-offset: 3px; border-radius: 12px; }
h1, h2 { margin: 0; line-height: 1.3; font-family: var(--font-fun); font-weight: 400; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; margin-bottom: 10px; }
.small { font-size: .88rem; }
.muted { color: var(--ink-soft); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.loading { text-align: center; padding-top: 40vh; font-size: 1.3rem; font-family: var(--font-fun); }

/* ---------- ฉากหลังอวกาศ ---------- */
.sky {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(60% 45% at 85% 8%, rgba(255, 111, 181, .38), transparent 70%),
    radial-gradient(55% 40% at 5% 85%, rgba(62, 224, 184, .26), transparent 70%),
    radial-gradient(70% 50% at 50% 110%, rgba(110, 195, 255, .25), transparent 70%),
    linear-gradient(180deg, #1a124a 0%, #2c1c6e 55%, #3b2384 100%);
}
.starfield { position: absolute; inset: -50px; background-repeat: repeat; }
.s1 {
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 90px 140px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 160px 70px, #fff, transparent),
    radial-gradient(1px 1px at 130px 190px, #fff, transparent),
    radial-gradient(1px 1px at 50px 110px, #fff, transparent);
  background-size: 200px 200px;
  animation: twinkle 3.5s ease-in-out infinite alternate;
}
.s2 {
  background-image:
    radial-gradient(2px 2px at 60px 40px, #fff7c2, transparent),
    radial-gradient(1.5px 1.5px at 240px 160px, #ffd6ec, transparent),
    radial-gradient(2px 2px at 180px 260px, #d6f3ff, transparent);
  background-size: 300px 300px;
  animation: twinkle 5s ease-in-out 1.2s infinite alternate;
}
.s3 {
  background-image:
    radial-gradient(3px 3px at 100px 120px, var(--star), transparent),
    radial-gradient(2.5px 2.5px at 330px 60px, #ffb3d9, transparent);
  background-size: 420px 420px;
  animation: twinkle 2.6s ease-in-out .6s infinite alternate;
}
@keyframes twinkle { from { opacity: .35; } to { opacity: 1; } }
.shooting {
  position: absolute; top: 10%; left: -20%; width: 140px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff);
  transform: rotate(18deg); opacity: 0;
  animation: shoot 11s linear 3s infinite;
}
@keyframes shoot {
  0% { transform: translate(0, 0) rotate(18deg); opacity: 0; }
  2% { opacity: 1; }
  9% { transform: translate(135vw, 45vw) rotate(18deg); opacity: 0; }
  100% { transform: translate(135vw, 45vw) rotate(18deg); opacity: 0; }
}
.deco-planet { position: absolute; border-radius: 50%; animation: drift 26s ease-in-out infinite alternate; }
.dp1 {
  width: 150px; height: 150px; right: -60px; top: 22%;
  background: radial-gradient(circle at 32% 30%, #ffd0e8, #ff6fb5 55%, #a83574);
  opacity: .5;
}
.dp2 {
  width: 80px; height: 80px; left: -22px; bottom: 14%;
  background: radial-gradient(circle at 32% 30%, #d4fff3, #3ee0b8 55%, #148a6e);
  opacity: .45; animation-duration: 19s;
}
.dp2::after {
  content: ''; position: absolute; left: -30px; top: 28px; width: 140px; height: 26px; border-radius: 50%;
  border: 4px solid rgba(212, 255, 243, .7); border-top-color: transparent; transform: rotate(-16deg);
}
@keyframes drift { to { transform: translate(-30px, 40px) rotate(20deg); } }

/* เปิดหน้าใหม่: ลอยขึ้นทีละส่วน */
#app.page-in > * { animation: rise .45s cubic-bezier(.2, .9, .3, 1.2) both; }
#app.page-in > :nth-child(2) { animation-delay: .05s; }
#app.page-in > :nth-child(3) { animation-delay: .1s; }
#app.page-in > :nth-child(4) { animation-delay: .15s; }
#app.page-in > :nth-child(n+5) { animation-delay: .2s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 24px; border-radius: 999px; font-family: var(--font-fun); font-size: 1.2rem;
  background: var(--moon); color: var(--ink); box-shadow: 0 5px 0 var(--moon-edge); transition: transform .08s, box-shadow .08s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--moon-edge); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 5px 0 var(--primary-d), 0 0 22px rgba(255, 95, 168, .45); }
.btn-primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--primary-d); }
.btn-danger { background: var(--bad-bg); color: #b4232f; box-shadow: 0 5px 0 #f3b8be; }
.btn-block { width: 100%; margin-top: 14px; }
.icon-btn {
  flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: var(--moon); color: var(--ink); font-size: 1.3rem; font-weight: 700; box-shadow: 0 4px 0 var(--moon-edge);
}
.pill {
  background: rgba(255, 255, 255, .14); border: 2px solid rgba(255, 255, 255, .22); color: var(--on-space);
  border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: .95rem; white-space: nowrap; backdrop-filter: blur(4px);
}
.music-btn {
  position: fixed; right: 16px; bottom: 16px; z-index: 20; width: 56px; height: 56px; border-radius: 50%;
  font-size: 1.6rem; background: var(--star); box-shadow: 0 5px 0 var(--star-d), 0 0 24px rgba(255, 210, 63, .5);
}
.music-btn.playing { animation: wobble 2.4s ease-in-out infinite; }
@keyframes wobble { 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }

/* ---------- ส่วนบน ---------- */
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.spacer { flex: 1; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 30px;
  background: var(--moon); box-shadow: 0 4px 0 var(--moon-edge), 0 0 0 4px rgba(255, 210, 63, .35);
}

.card { background: var(--moon); color: var(--ink); border-radius: var(--radius); padding: 18px; box-shadow: 0 6px 0 var(--moon-edge); margin-bottom: 16px; }

/* มาสคอต: นกฮูกในหมวกนักบินอวกาศ */
.astro {
  flex: none; position: relative; display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .95), rgba(190, 230, 255, .75) 45%, rgba(110, 195, 255, .55));
  border: 4px solid #fff; box-shadow: 0 0 0 4px #c9d3e8, 0 0 26px rgba(110, 195, 255, .6);
  animation: bob 3s ease-in-out infinite;
}
.astro > span { font-size: 42px; line-height: 1; }
.astro::after { content: ''; position: absolute; top: 10px; left: 14px; width: 16px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, .9); transform: rotate(-30deg); }
.astro.xl { width: 128px; height: 128px; }
.astro.xl > span { font-size: 76px; }
.astro.xl::after { top: 18px; left: 26px; width: 28px; height: 15px; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }

.hello { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.bubble {
  position: relative; flex: 1; background: var(--moon); color: var(--ink); border-radius: 22px; padding: 10px 16px;
  box-shadow: 0 5px 0 var(--moon-edge);
}
.bubble b { font-family: var(--font-fun); font-weight: 400; font-size: 1.3rem; }
.bubble .small { color: var(--ink-soft); }
.bubble::before { content: ''; position: absolute; left: -10px; top: 26px; border: 10px solid transparent; border-right-color: var(--moon); border-left: 0; }

/* ยานฝึกอ่าน */
.launch {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(120deg, #ffb347, #ff6fb5); color: #3d0d2b; box-shadow: 0 6px 0 #b8417f, 0 0 30px rgba(255, 111, 181, .35);
}
.launch b { font-family: var(--font-fun); font-weight: 400; font-size: 1.35rem; }
.launch::after {
  content: ''; position: absolute; right: -20px; top: -30px; width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .35), transparent 65%);
}
.rocket { font-size: 52px; line-height: 1; animation: lift 2.2s ease-in-out infinite; }
@keyframes lift { 50% { transform: translate(4px, -8px) rotate(6deg); } }

.section-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-family: var(--font-fun); font-size: 1.3rem; margin: 26px 2px 14px; }
.term-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 4px 14px; border-radius: 999px; background: rgba(255, 255, 255, .12); color: var(--on-space-soft); font-family: var(--font-fun); font-size: 1rem; }
.tab.on { background: var(--star); color: var(--ink); box-shadow: 0 3px 0 var(--star-d); }
.card .tab { background: #efe9fb; color: var(--ink-soft); }
.card .tab.on { background: var(--star); color: var(--ink); }
.empty { text-align: center; padding: 30px 0; color: var(--on-space-soft); }

/* ---------- ระบบดาว (หน้าแรก) ---------- */
.planets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 10px; padding-top: 6px; }
.planet {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  animation: float 5s ease-in-out var(--d, 0s) infinite;
}
@keyframes float { 50% { transform: translateY(-9px); } }
.orb {
  position: relative; display: grid; place-items: center; width: 100px; height: 100px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--c) 30%, #fff) 0%, var(--c) 48%, color-mix(in srgb, var(--c) 55%, #000) 100%);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, .1), 0 0 30px color-mix(in srgb, var(--c) 70%, transparent);
  transition: transform .15s;
}
.orb .ic { font-size: 46px; line-height: 1; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .18)); }
.planet.ringed .orb::after {
  content: ''; position: absolute; width: 150px; height: 40px; border-radius: 50%; pointer-events: none;
  border: 5px solid color-mix(in srgb, var(--c) 35%, #fff); border-top-color: transparent; transform: rotate(-16deg);
}
.planet:active .orb { transform: scale(.92); }
.planet .nm { font-family: var(--font-fun); font-size: 1.15rem; line-height: 1.25; color: #fff; }
.planet-stars { font-size: .82rem; font-weight: 700; color: var(--star); background: rgba(255, 255, 255, .1); border-radius: 99px; padding: 1px 10px; }

/* ---------- หัววิชา + กลุ่มดาวด่าน ---------- */
.subject-head {
  display: flex; align-items: center; gap: 16px; padding: 14px 18px; margin-bottom: 22px; border-radius: var(--radius);
  background: linear-gradient(120deg, color-mix(in srgb, var(--c) 80%, #fff), var(--c));
  color: #fff; box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 60%, #000), 0 0 30px color-mix(in srgb, var(--c) 45%, transparent);
}
.subject-head .orb { width: 72px; height: 72px; flex: none; box-shadow: 0 0 0 4px rgba(255, 255, 255, .35); }
.subject-head .orb .ic { font-size: 38px; }
.subject-head h1 { text-shadow: 0 2px 0 rgba(0, 0, 0, .15); }

.path { position: relative; display: flex; flex-direction: column; gap: 16px; }
.path::before { content: ''; position: absolute; left: 50%; top: 20px; bottom: 20px; border-left: 3px dashed rgba(255, 255, 255, .3); }
.unit {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px;
  background: var(--moon); color: var(--ink); border-radius: var(--radius); box-shadow: 0 5px 0 var(--moon-edge);
}
.unit:nth-child(odd) { margin-right: 28px; }
.unit:nth-child(even) { margin-left: 28px; }
.unit:active { transform: translateY(3px); }
/* เลขด่านอยู่ในดาว (ด่านเป็นลำดับจริง จึงใส่เลข) */
.unit-n {
  flex: none; display: grid; place-items: center; width: 58px; height: 58px; padding-top: 6px;
  font-family: var(--font-fun); font-size: 1.25rem; color: var(--ink);
  background: #ffe9a3;
  clip-path: polygon(50% 0%, 61.5% 34%, 98% 35%, 68.5% 57%, 79.5% 92%, 50% 71%, 20.5% 92%, 31.5% 57%, 2% 35%, 38.5% 34%);
}
.unit.played .unit-n { background: var(--star); }
.unit-body { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.unit-body b { font-family: var(--font-fun); font-weight: 400; font-size: 1.12rem; }
.stars { white-space: nowrap; font-size: 1.1rem; letter-spacing: 1px; }
.stars .on { color: var(--star); text-shadow: 0 2px 0 var(--star-d); }
.stars .off { color: #ddd6ee; }
.boss {
  display: flex; align-items: center; gap: 14px; margin-top: 24px; padding: 16px 18px; border-radius: var(--radius);
  background: linear-gradient(120deg, #7b5cff, #c04dff); color: #fff;
  box-shadow: 0 6px 0 #4f33c4, 0 0 32px rgba(160, 90, 255, .5);
}
.boss b { font-family: var(--font-fun); font-weight: 400; font-size: 1.3rem; }
.ufo { font-size: 52px; line-height: 1; animation: hover 2.6s ease-in-out infinite; }
@keyframes hover { 50% { transform: translateY(-6px) rotate(-6deg); } }

/* ---------- หน้าเล่น ---------- */
.play-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.progress { position: relative; flex: 1; height: 16px; margin: 0 22px 0 6px; background: rgba(255, 255, 255, .14); border-radius: 99px; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--mint), var(--sky)); transition: width .5s ease; box-shadow: 0 0 12px rgba(62, 224, 184, .6); }
.progress-rocket { position: absolute; top: 50%; left: 0; font-size: 26px; line-height: 1; transform: translate(-50%, -55%) rotate(45deg); transition: left .5s ease; }
.progress-goal { position: absolute; right: -24px; top: 50%; transform: translateY(-55%); font-size: 26px; }
.clock { font-variant-numeric: tabular-nums; }
.clock.late { background: var(--bad); border-color: var(--bad); }
.play-title { font-family: var(--font-fun); color: var(--on-space-soft); font-size: 1.05rem; margin: 0 4px 10px; }
.stage.enter { animation: slideIn .35s cubic-bezier(.2, .9, .3, 1.15); }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px) scale(.97); } }

/* การ์ดคำถาม = ผิวดวงจันทร์ มีหลุมจาง ๆ */
.q-card {
  position: relative; text-align: center; padding: 22px 18px 20px; margin-bottom: 18px; border-radius: 28px; color: var(--ink);
  background:
    radial-gradient(circle at 12% 82%, rgba(205, 192, 235, .35) 0 14px, transparent 15px),
    radial-gradient(circle at 90% 18%, rgba(205, 192, 235, .3) 0 9px, transparent 10px),
    radial-gradient(circle at 80% 88%, rgba(205, 192, 235, .25) 0 6px, transparent 7px),
    var(--moon);
  box-shadow: 0 8px 0 var(--moon-edge), 0 0 40px rgba(255, 255, 255, .12);
}
.q-emoji { font-size: 68px; line-height: 1.2; margin-bottom: 6px; animation: bob 3.2s ease-in-out infinite; }
.q-prompt { font-family: var(--font-fun); font-size: 1.5rem; white-space: pre-line; line-height: 1.45; }
.speak-btn {
  position: absolute; top: 12px; right: 12px; width: 48px; height: 48px; border-radius: 50%;
  background: var(--star); font-size: 1.35rem; box-shadow: 0 4px 0 var(--star-d);
}
.speak-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--star-d); }
.q-card:has(.speak-btn) .q-prompt { padding: 0 36px; }

.burst { position: absolute; inset: 0; pointer-events: none; }
.burst i { position: absolute; left: 50%; top: 45%; font-style: normal; font-size: 24px; animation: burst .85s ease-out forwards; }
@keyframes burst {
  from { transform: translate(-50%, -50%) scale(.3); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1) rotate(160deg); opacity: 0; }
}

/* ตัวเลือก: สีลูกกวาดวนสี่สี */
.choices { display: grid; gap: 12px; }
.choices.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice {
  --k: var(--nebula);
  min-height: 64px; padding: 12px 14px; border-radius: 20px; background: var(--moon); color: var(--ink);
  border: 3px solid color-mix(in srgb, var(--k) 45%, #fff); box-shadow: 0 5px 0 var(--k);
  font-family: var(--font-fun); font-size: 1.3rem; transition: transform .08s, box-shadow .08s;
}
.choice:nth-child(4n+2) { --k: var(--sky); }
.choice:nth-child(4n+3) { --k: var(--mint); }
.choice:nth-child(4n+4) { --k: #ffb347; }
.choice:active:not(:disabled) { transform: translateY(4px) scale(.98); box-shadow: 0 1px 0 var(--k); }
.choice-emoji { font-size: 2.6rem; }
.choice.picked { background: #fff0f7; border-color: var(--primary); }
.good { border-color: var(--good) !important; background: var(--good-bg) !important; box-shadow: 0 5px 0 var(--good) !important; animation: pop .4s; }
.bad { border-color: var(--bad) !important; background: var(--bad-bg) !important; box-shadow: 0 5px 0 var(--bad) !important; animation: shake .4s; }
.choice.bad:disabled { opacity: .55; }
@keyframes pop { 40% { transform: scale(1.08); } }
@keyframes shake { 20% { transform: translateX(-7px) rotate(-2deg); } 60% { transform: translateX(7px) rotate(2deg); } }
.shake { animation: shake .4s; }

.feedback:empty { display: none; }
.feedback { margin-top: 18px; }
.fb { position: relative; border-radius: 20px; padding: 14px 16px; color: var(--ink); animation: pop .35s; }
.fb b { font-family: var(--font-fun); font-weight: 400; font-size: 1.45rem; }
.fb p { margin: 4px 0 0; }
.fb-good { background: var(--good-bg); border: 3px solid var(--good); padding-right: 70px; }
.fb-try { background: var(--try-bg); border: 3px solid var(--star); }
.fb-bad { background: #ecf1ff; border: 3px solid #9fb6ff; }
.cheer { position: absolute; right: 12px; top: 50%; margin-top: -26px; font-size: 48px; line-height: 1; animation: cheer .6s ease-in-out 2; }
@keyframes cheer { 30% { transform: translateY(-16px) rotate(-12deg); } 60% { transform: translateY(0) rotate(10deg); } }

/* จับคู่ */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.m-col { display: flex; flex-direction: column; gap: 10px; }
.m-item {
  position: relative; min-height: 60px; padding: 10px 12px; border-radius: 18px; background: var(--moon); color: var(--ink);
  border: 3px solid var(--moon-edge); box-shadow: 0 4px 0 var(--moon-edge); font-family: var(--font-fun); font-size: 1.15rem;
}
.m-item.sel { border-color: var(--primary) !important; transform: translateY(-4px); }
.m-item[data-tag]:not([data-tag=""])::after {
  content: attr(data-tag); position: absolute; top: -10px; right: -8px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: .8rem; display: grid; place-items: center;
}

/* เรียงลำดับ / จัดกลุ่ม */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 15px; border-radius: 16px; background: var(--moon); color: var(--ink);
  border: 3px solid var(--moon-edge); box-shadow: 0 4px 0 var(--moon-edge); font-family: var(--font-fun); font-size: 1.25rem;
}
.chip.sel { border-color: var(--primary); transform: translateY(-4px); }
.chip-n { background: var(--ink); color: #fff; border-radius: 50%; width: 22px; height: 22px; font-size: .75rem; display: grid; place-items: center; font-family: 'Mali', sans-serif; }
.o-slots, .s-tray {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 74px; padding: 12px;
  border: 3px dashed rgba(255, 255, 255, .4); border-radius: 20px; background: rgba(255, 255, 255, .08);
}
.o-bank { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
.hint-text { color: var(--on-space-soft); font-size: .92rem; width: 100%; }
.s-buckets { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.s-buckets.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.s-bucket { min-height: 124px; padding: 10px; border-radius: 20px; background: var(--moon); color: var(--ink); border: 3px solid var(--moon-edge); box-shadow: 0 5px 0 var(--moon-edge); cursor: pointer; }
.s-bucket.target { border-color: var(--sky); }
.s-title { font-family: var(--font-fun); font-size: 1.05rem; margin-bottom: 6px; }
.s-items { display: flex; flex-wrap: wrap; gap: 6px; }
.s-items .chip { font-size: 1rem; padding: 5px 10px; }

.flash-word {
  font-family: var(--font-fun); font-size: 3.8rem; text-align: center; color: var(--ink); background: var(--moon);
  border-radius: var(--radius); padding: 22px 10px; box-shadow: 0 6px 0 var(--moon-edge), 0 0 30px rgba(255, 210, 63, .3);
}

/* ---------- สนามต่อสู้ ---------- */
.arena {
  position: relative; margin-bottom: 14px; padding: 10px 12px 4px; border-radius: 24px; overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .03));
  border: 2px solid rgba(255, 255, 255, .16);
}
.boss-arena { border-color: rgba(255, 93, 108, .6); box-shadow: inset 0 0 50px rgba(255, 93, 108, .28), 0 0 24px rgba(255, 93, 108, .25); }
.arena-top { display: flex; justify-content: space-between; gap: 12px; }
.side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.side.right { align-items: flex-end; }
.who { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-fun); font-size: 1rem; color: var(--on-space-soft); }
.hearts { display: flex; flex-wrap: wrap; gap: 1px; font-size: 1rem; line-height: 1.2; }
.heart.lost { opacity: .55; }
.hp { width: 100%; max-width: 180px; height: 13px; border-radius: 99px; overflow: hidden; background: rgba(255, 255, 255, .15); }
.hp i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #ff5d6c, #ffb347); transition: width .45s ease; }
.hp.low i { animation: blink .45s ease-in-out infinite alternate; }
@keyframes blink { to { opacity: .45; } }
.stage-row { display: flex; justify-content: space-between; align-items: flex-end; height: 104px; padding: 0 8px; }
.fighter { position: relative; }
.hero .astro { width: 66px; height: 66px; }
.hero .astro > span { font-size: 40px; }
.mon-emoji {
  display: inline-block; font-size: 72px; line-height: 1;
  filter: drop-shadow(0 0 10px var(--glow)) drop-shadow(0 0 3px var(--glow));
  animation: menace 1.5s ease-in-out infinite;
}
.monster.is-boss .mon-emoji { font-size: 96px; animation-duration: 1.1s; }
.crown { position: absolute; top: -18px; left: 50%; transform: translateX(-50%) rotate(-10deg); font-size: 30px; z-index: 1; }
@keyframes menace { 50% { transform: translateY(-6px) scale(1.05); } }
.vs { align-self: center; font-family: var(--font-fun); font-size: 1.6rem; color: rgba(255, 255, 255, .3); }

.lunge-r { animation: lungeR .35s ease; }
@keyframes lungeR { 50% { transform: translateX(30px) scale(1.08); } }
.lunge-l { animation: lungeL .4s ease; }
@keyframes lungeL { 50% { transform: translateX(-36px) scale(1.12); } }
.monster.hit .mon-emoji { animation: hitFlash .45s ease; }
@keyframes hitFlash {
  20% { transform: translateX(10px) rotate(10deg); filter: brightness(2.6) drop-shadow(0 0 14px #fff); }
  55% { transform: translateX(-6px) rotate(-6deg); }
}
.hurt { animation: hurt .5s ease; }
@keyframes hurt { 20% { transform: translateX(-12px) rotate(-10deg); filter: drop-shadow(0 0 14px #ff5d6c); } 60% { transform: translateX(6px); } }
.arena.quake { animation: quake .4s; }
.arena.quake::after { content: ''; position: absolute; inset: 0; background: rgba(255, 60, 80, .32); animation: flashOut .45s forwards; pointer-events: none; }
@keyframes quake { 25% { transform: translate(-5px, 2px); } 50% { transform: translate(5px, -2px); } 75% { transform: translate(-3px, 1px); } }
@keyframes flashOut { to { opacity: 0; } }
.monster.ko .mon-emoji { animation: ko 1s ease forwards; }
@keyframes ko { to { transform: rotate(-80deg) translate(-6px, 14px) scale(.9); filter: grayscale(.7) brightness(.8); } }
.monster.ko::after { content: '💫'; position: absolute; top: -14px; left: 50%; font-size: 28px; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: translateX(-50%) rotate(360deg); } }

.fx { position: absolute; inset: 0; pointer-events: none; }
.shot { position: absolute; bottom: 34px; font-size: 30px; line-height: 1; }
.shot.to-mon { animation: toMon .4s ease-in forwards; }
.shot.to-hero { animation: toHero .4s ease-in forwards; }
.shot.big { font-size: 44px; bottom: 50px; }
@keyframes toMon { from { left: 16%; transform: rotate(0); } to { left: 76%; transform: rotate(540deg); } }
@keyframes toHero { from { left: 74%; transform: scale(1); } to { left: 12%; transform: scale(1.3); } }
.dmg {
  position: absolute; top: 44px; font-family: var(--font-fun); font-size: 1.8rem; color: #fff;
  text-shadow: 0 3px 0 #c93f84, 0 0 10px rgba(255, 95, 168, .8); animation: dmg 1s ease-out forwards;
}
.dmg.on-mon { right: 14%; }
.dmg.on-hero { left: 12%; }
.dmg.crit { font-size: 2.4rem; color: var(--star); text-shadow: 0 3px 0 #8a3b00, 0 0 14px rgba(255, 210, 63, .9); }
.dmg.bonus { font-size: 1.4rem; }
@keyframes dmg { from { opacity: 0; transform: translateY(0) scale(.5); } 20% { opacity: 1; transform: translateY(-8px) scale(1.25); } to { opacity: 0; transform: translateY(-40px); } }
.banner {
  position: absolute; left: 50%; top: 52%; white-space: nowrap; font-family: var(--font-fun); font-size: 1.6rem; color: var(--star);
  text-shadow: 0 3px 0 #8a3b00, 0 0 18px rgba(255, 210, 63, .8); animation: bannerIn 1.5s ease forwards;
}
@keyframes bannerIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -80%); }
}
/* ระหว่างต่อสู้ ย่อรูปในการ์ดคำถามลงหน่อย ให้คำตอบอยู่ในจอ */
.arena ~ .stage .q-emoji { font-size: 50px; }
.arena ~ .stage .q-card { padding-top: 16px; }

/* แพ้ / ได้เพื่อนใหม่ */
.mon-big { display: inline-block; font-size: 110px; line-height: 1.1; filter: drop-shadow(0 0 18px var(--glow)); animation: laugh .9s ease-in-out infinite; }
.mon-big.is-boss { font-size: 140px; }
@keyframes laugh { 50% { transform: translateY(-8px) rotate(6deg) scale(1.05); } }
.lose h1 { margin-top: 8px; color: #ffb3bb; }
.friend-win { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mon-big.friendly { position: relative; animation: bob 2.4s ease-in-out infinite; }
.heart-pop { position: absolute; right: -10px; top: -6px; font-size: 40px; animation: pop 1s ease-in-out infinite; }
.friend-text { display: flex; flex-direction: column; font-family: var(--font-fun); font-size: 1.2rem; color: var(--mint); }
.friend-text b { font-weight: 400; font-size: 1.5rem; color: #fff; }

/* สมุดเพื่อนมอนสเตอร์ */
.friends-link {
  display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 16px; border-radius: var(--radius);
  background: rgba(255, 255, 255, .1); border: 2px solid rgba(255, 255, 255, .18);
}
.friends-link b { flex: 1; font-family: var(--font-fun); font-weight: 400; font-size: 1.2rem; }
.fl-icons { display: flex; font-size: 1.5rem; }
.fl-icons span { margin-right: -4px; }
.fl-icons .unknown { filter: brightness(0) opacity(.45); }
.friends { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.friend {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px; text-align: center;
  background: var(--moon); color: var(--ink); border-radius: var(--radius); box-shadow: 0 5px 0 var(--moon-edge), 0 0 22px color-mix(in srgb, var(--glow) 35%, transparent);
}
.friend .fe { font-size: 58px; line-height: 1.15; filter: drop-shadow(0 0 8px var(--glow)); }
.friend b { font-family: var(--font-fun); font-weight: 400; font-size: 1.1rem; }
.friend .small { color: var(--ink-soft); }
.friend.unknown { background: rgba(255, 255, 255, .08); color: var(--on-space-soft); box-shadow: none; border: 2px dashed rgba(255, 255, 255, .2); }
.friend.unknown .fe { filter: brightness(0) opacity(.5); }
.friend.unknown .small { color: var(--on-space-soft); }
.friend-crown { position: absolute; top: 6px; right: 10px; font-size: 24px; }
@media (min-width: 520px) { .friends { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- ผลลัพธ์ ---------- */
.result { text-align: center; padding-top: 10px; }
.result h1 { margin-top: 12px; font-size: 2rem; }
.trophy { font-size: 110px; line-height: 1; animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 0 26px rgba(255, 210, 63, .7)); }
.stars.big { display: block; margin: 8px 0; font-size: 3.4rem; letter-spacing: 8px; }
.stars.big span { display: inline-block; animation: starIn .5s cubic-bezier(.2, .9, .3, 1.5) both; }
.stars.big span:nth-child(2) { animation-delay: .25s; }
.stars.big span:nth-child(3) { animation-delay: .5s; }
@keyframes starIn { from { transform: scale(0) rotate(-120deg); opacity: 0; } }
.score { font-size: 1.2rem; margin: 6px 0; }
.result > .small { color: var(--on-space-soft); }
.coin-gain { display: inline-block; margin: 10px 0 18px; font-size: 1.15rem; color: var(--star); }
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.breakdown, .review { text-align: left; }
.bd-row { display: grid; grid-template-columns: 1fr 80px auto; gap: 10px; align-items: center; font-size: .92rem; padding: 4px 0; }
.bd-bar { height: 10px; background: #ece6f7; border-radius: 99px; overflow: hidden; }
.bd-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--sky)); }
.review summary { font-family: var(--font-fun); font-size: 1.15rem; cursor: pointer; }
.review-item { border-top: 2px dashed var(--moon-edge); padding: 10px 0; }
.review-q { font-weight: 600; white-space: pre-line; }
.review-a { color: #0f8a61; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.confetti i { position: absolute; top: -40px; font-style: normal; animation: fall 3s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

/* ---------- ฟอร์ม / ต้อนรับ ---------- */
.welcome { text-align: center; padding: 30px 0 18px; }
.welcome p { color: var(--on-space-soft); margin: 4px 0 0; }
.brand { font-size: 3.6rem; line-height: 1.25; margin-top: 14px; }
.brand span {
  display: inline-block; color: var(--star); text-shadow: 0 4px 0 var(--primary-d), 0 0 24px rgba(255, 210, 63, .5);
  animation: hop 2.8s ease-in-out calc(var(--i) * .12s) infinite;
}
.brand span:nth-child(even) { color: #ff9fd0; text-shadow: 0 4px 0 #8f2f63, 0 0 24px rgba(255, 111, 181, .5); }
@keyframes hop { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-12px); } }
.label { display: block; font-weight: 700; margin: 14px 0 6px; }
.input { width: 100%; font: inherit; font-size: 1.15rem; padding: 12px 16px; border-radius: 16px; border: 3px solid var(--moon-edge); outline: none; background: #fff; color: var(--ink); }
.input:focus { border-color: var(--primary); }
.avatar-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.avatar-pick { font-size: 2rem; aspect-ratio: 1; border-radius: 50%; background: #f1ecfb; border: 3px solid transparent; transition: transform .1s; }
.avatar-pick.on { border-color: var(--primary); background: #fff0f7; transform: scale(1.08); }
.toggle { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-weight: 600; }
.toggle input { width: 22px; height: 22px; accent-color: var(--primary); }

/* ---------- ฝึกอ่าน ---------- */
.goal { font-weight: 600; }
.games { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.game-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px; text-align: center;
  background: var(--moon); color: var(--ink); border-radius: var(--radius); box-shadow: 0 5px 0 #f3b0d2;
}
.game-btn b { font-family: var(--font-fun); font-weight: 400; font-size: 1.15rem; }
.game-btn .ic { font-size: 38px; line-height: 1.2; }
.game-btn:active { transform: translateY(3px); }
.word-wall { display: flex; flex-wrap: wrap; gap: 8px; }
.word {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 16px; background: var(--moon); color: var(--ink);
  font-family: var(--font-fun); font-size: 1.4rem; box-shadow: 0 4px 0 var(--moon-edge);
}
.word:active { transform: translateY(3px); }
.word-emoji { font-size: 1.1rem; }
.story { text-align: center; }
.story h1 { margin-bottom: 12px; }
.story .q-emoji { animation: none; }
.sentence { display: block; width: 100%; text-align: left; font-family: var(--font-fun); font-size: 1.5rem; padding: 10px 14px; border-radius: 16px; margin: 8px 0; background: #f3eefc; color: var(--ink); }
.sentence-speak { font-size: 1rem; opacity: .6; }
.error { text-align: center; }

/* ---------- เลือกห้องเรียน ---------- */
.level-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.level-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; border-radius: 20px;
  background: #f1ecfb; border: 3px solid transparent; color: var(--ink);
}
.level-btn.on { border-color: var(--primary); background: #fff0f7; }
.level-btn .lv-ic { font-size: 2.2rem; line-height: 1.2; }
.level-btn b { font-family: var(--font-fun); font-weight: 400; font-size: 1.2rem; }
.level-btn .small { color: var(--ink-soft); }

/* =========================================================
   ห้องเรียนหนูน้อย (2–4 ขวบ): ธีมกลางวันสีพาสเทล ปุ่มใหญ่ ภาพใหญ่
   ========================================================= */
body.kids { color: #3a2e5c; }
body.kids .sky {
  background:
    radial-gradient(40% 30% at 85% 10%, rgba(255, 236, 150, .9), transparent 70%),
    radial-gradient(50% 35% at 10% 90%, rgba(190, 240, 210, .8), transparent 70%),
    linear-gradient(180deg, #ffe3f1 0%, #e3f3ff 50%, #fff6d8 100%);
}
body.kids .starfield, body.kids .shooting { display: none; }
body.kids .dp1 { background: radial-gradient(circle at 32% 30%, #fff, #ffd6ea 60%, #ffb3d6); opacity: .7; border-radius: 50% 50% 48% 52%; }
body.kids .dp2 { background: radial-gradient(circle at 32% 30%, #fff, #c9f2ff 60%, #9fdcf5); opacity: .7; }
body.kids .dp2::after { display: none; }
body.kids .pill { background: #fff; color: #3a2e5c; border-color: #f3d4e6; }
body.kids .icon-btn, body.kids .avatar { box-shadow: 0 4px 0 #f3d4e6; }
body.kids .music-btn { background: #ffd54f; }

.kimg { width: 190px; height: 190px; object-fit: contain; filter: drop-shadow(0 10px 10px rgba(80, 40, 120, .18)); user-select: none; -webkit-user-drag: none; }
.kimg.mid { width: 130px; height: 130px; }
.kimg.small { width: 84px; height: 84px; filter: drop-shadow(0 5px 5px rgba(80, 40, 120, .15)); }
.kimg.tiny { width: 40px; height: 40px; filter: none; }
.kimg.count { width: 58px; height: 58px; transition: transform .2s; }
.kimg.count.lit { transform: scale(1.25); filter: drop-shadow(0 0 12px #ffd23f); }

.k-hello { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.k-mascot { width: 92px; height: 92px; animation: bob 2.8s ease-in-out infinite; }
.k-bubble { position: relative; flex: 1; display: flex; flex-direction: column; padding: 12px 18px; border-radius: 26px; background: #fff; box-shadow: 0 6px 0 #f3d4e6; }
.k-bubble b { font-family: var(--font-fun); font-weight: 400; font-size: 1.45rem; }
.k-bubble span { color: #8b80a8; }
.k-bubble::before { content: ''; position: absolute; left: -11px; top: 30px; border: 11px solid transparent; border-right-color: #fff; border-left: 0; }

.k-rooms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.k-room {
  display: flex; flex-direction: column; align-items: center; gap: 0; padding: 14px 8px 12px; text-align: center; border-radius: 30px;
  background: #fff; border-bottom: 8px solid var(--c); box-shadow: 0 6px 18px color-mix(in srgb, var(--c) 25%, transparent);
  transition: transform .1s;
}
.k-room:active { transform: scale(.95); }
.k-room-img { width: 96px; height: 96px; animation: float 4s ease-in-out var(--d) infinite; filter: drop-shadow(0 8px 6px rgba(80, 40, 120, .18)); }
.k-room b { font-family: var(--font-fun); font-weight: 400; font-size: 1.35rem; color: #3a2e5c; }
.k-room span { font-size: .9rem; color: var(--c); font-weight: 700; }
.k-sticker-link { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 16px; border-radius: 26px; background: #fff; box-shadow: 0 6px 0 #f3d4e6; }
.k-sticker-link b { flex: 1; font-family: var(--font-fun); font-weight: 400; font-size: 1.25rem; }
.k-sl-img { width: 48px; height: 48px; }

.k-room-head {
  display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding: 12px 18px; border-radius: 30px;
  background: var(--c); color: #fff; box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 70%, #000);
}
.k-room-head h1 { font-size: 1.8rem; text-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.k-head-img { width: 70px; height: 70px; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .15)); }

.k-topics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.k-topic { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; border-radius: 26px; background: #fff; border-bottom: 6px solid var(--c); }
.k-topic b { font-family: var(--font-fun); font-weight: 400; font-size: 1.3rem; }
.k-topic-pics { display: flex; gap: 2px; }
.k-topic-pics .kimg.tiny { width: 46px; height: 46px; }
.k-progress { font-size: .9rem; color: #8b80a8; font-weight: 700; }

.k-games { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.k-game {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 150px; padding: 18px 8px; border-radius: 30px;
  background: #fff; box-shadow: 0 7px 0 var(--c); transition: transform .1s;
}
.k-game:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--c); }
.k-game-ic { font-size: 3.8rem; line-height: 1.1; }
.k-game b { font-family: var(--font-fun); font-weight: 400; font-size: 1.5rem; }
/* ถ้าจำนวนเกมเป็นเลขคี่ ให้เกมสุดท้ายกว้างเต็มแถว */
.k-game:last-child:nth-child(odd) { grid-column: 1 / -1; flex-direction: row; min-height: 96px; gap: 14px; }

.k-section { margin: 24px 4px 12px; font-family: var(--font-fun); font-size: 1.4rem; }
.k-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.k-gitem {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 140px; padding: 12px 4px 10px;
  background: #fff; border-radius: 26px; box-shadow: 0 6px 0 #f3d4e6; transition: transform .1s;
}
.k-gitem:active { transform: translateY(4px); box-shadow: 0 2px 0 #f3d4e6; }
.k-gitem.k-tapped { animation: pop .4s; }
.k-gitem .kimg.small { width: 76px; height: 76px; }
.k-gitem .kletter-wrap.small { gap: 4px; }
.k-gitem .kletter-wrap.small .kletter { font-size: 3rem; }
.k-gitem .kletter-wrap.small .kimg.tiny { width: 44px; height: 44px; }
.k-gitem .kshape.small, .k-gitem .kswatch.small { width: 76px; height: 76px; }
.k-glabel { font-family: var(--font-fun); font-size: 1.4rem; line-height: 1.25; text-align: center; color: #3a2e5c; }
.k-gitem.got .k-glabel::after { content: ' 🌟'; font-size: .85rem; }

/* เวทีเล่น */
.k-dots { flex: 1; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.k-dots i { width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 2px #f3d4e6; }
.k-dots i.on { background: #ffd23f; box-shadow: 0 0 8px rgba(255, 210, 63, .8); }
.k-stage { position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; padding-bottom: 20px; }
.k-card {
  width: 100%; display: flex; flex-direction: column; align-items: center; padding: 22px 16px 18px; border-radius: 38px; text-align: center;
  background: #fff; box-shadow: 0 8px 0 #f3d4e6, 0 12px 30px rgba(255, 143, 199, .25); animation: cardIn .45s cubic-bezier(.2, .9, .3, 1.4);
}
@keyframes cardIn { from { opacity: 0; transform: scale(.7) rotate(-4deg); } }
.k-card.k-pop { animation: pop .5s; }
.k-visual { animation: wiggle 2.6s ease-in-out infinite; }
@keyframes wiggle { 25% { transform: rotate(-4deg) scale(1.03); } 75% { transform: rotate(4deg) scale(1.03); } }
.k-word { font-family: var(--font-fun); font-size: 3rem; line-height: 1.3; margin-top: 6px; }
.k-sub { font-family: var(--font-fun); font-size: 1.5rem; color: #8b80a8; }
.k-tip { margin-top: 8px; padding: 8px 14px; border-radius: 16px; background: #fff6d8; font-size: 1.05rem; }
.kletter-wrap { display: inline-flex; align-items: center; gap: 10px; }
.kletter { font-family: var(--font-fun); font-size: 7rem; line-height: 1; color: #ff6f91; text-shadow: 0 6px 0 #f3d4e6; }
.kletter-wrap.small .kletter { font-size: 3.4rem; text-shadow: 0 3px 0 #f3d4e6; }
.kshape { display: inline-block; width: 190px; height: 190px; filter: drop-shadow(0 10px 8px rgba(80, 40, 120, .18)); }
.kshape.small { width: 90px; height: 90px; }
.kshape svg { width: 100%; height: 100%; }
.kswatch { position: relative; display: inline-block; width: 180px; height: 180px; border-radius: 46% 54% 52% 48%; background: var(--sw); border: 5px solid #fff; box-shadow: 0 8px 0 rgba(0, 0, 0, .08), inset 0 -10px 0 rgba(0, 0, 0, .08); }
.kswatch.small { width: 92px; height: 92px; border-width: 4px; }
.kswatch-img { position: absolute; right: -16px; bottom: -14px; width: 46%; height: 46%; object-fit: contain; }

.k-status { min-height: 34px; display: flex; align-items: center; gap: 8px; font-family: var(--font-fun); font-size: 1.4rem; }
.k-status b { font-weight: 400; color: #e8a400; }
.k-rec { width: 18px; height: 18px; border-radius: 50%; background: #ff4d6d; animation: rec 1s ease-in-out infinite; }
@keyframes rec { 50% { transform: scale(1.5); opacity: .5; } }
.k-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.k-btn {
  min-width: 140px; padding: 16px 26px; border-radius: 999px; font-family: var(--font-fun); font-size: 1.45rem; color: #fff; text-align: center;
  transition: transform .08s;
}
.k-btn:active:not(:disabled) { transform: translateY(4px); }
.k-listen { background: #ffb300; box-shadow: 0 6px 0 #c98a00; }
.k-mic { background: #ff5fa8; box-shadow: 0 6px 0 #c93f84; }
.k-next { min-width: 220px; margin-top: 4px; background: #43c46b; box-shadow: 0 6px 0 #2a8c4a; }
.k-ask { display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px; border-radius: 999px; background: #fff; font-family: var(--font-fun); font-size: 1.4rem; box-shadow: 0 5px 0 #f3d4e6; }
.k-tiles { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.k-tiles.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.k-tile {
  display: grid; place-items: center; aspect-ratio: 1; border-radius: 30px; background: #fff;
  box-shadow: 0 7px 0 #f3d4e6; transition: transform .12s; animation: cardIn .4s cubic-bezier(.2, .9, .3, 1.4) both;
}
.k-tile:nth-child(2) { animation-delay: .08s; }
.k-tile:nth-child(3) { animation-delay: .16s; }
.k-tile:nth-child(4) { animation-delay: .24s; }
.k-tile:active { transform: scale(.94); }
.k-right { background: #dcfff1 !important; box-shadow: 0 7px 0 #20c08a !important; animation: pop .5s !important; }
.k-wrong { animation: shake .4s; opacity: .45; }
.k-memory { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.k-mcard {
  display: grid; place-items: center; aspect-ratio: 3 / 4; border-radius: 24px;
  background: linear-gradient(135deg, #ff8fc7, #9b8cff); box-shadow: 0 6px 0 #c06bb0; transition: transform .25s;
}
.k-mcard.open { background: #fff; box-shadow: 0 6px 0 #f3d4e6; transform: rotateY(360deg); }
.k-mcard.done { background: #dcfff1; box-shadow: 0 6px 0 #20c08a; }
.k-mback { font-size: 2.4rem; }
.k-count-box { width: 100%; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 16px; border-radius: 30px; background: #fff; box-shadow: 0 6px 0 #f3d4e6; }
.k-numbers { display: flex; gap: 14px; justify-content: center; }
.k-num { width: 92px; height: 92px; border-radius: 50%; background: #fff; font-family: var(--font-fun); font-size: 3rem; color: #4aa8ff; box-shadow: 0 7px 0 #cfe6ff; }
.k-toast {
  position: fixed; left: 50%; top: 16px; z-index: 30; display: flex; align-items: center; gap: 8px; padding: 8px 18px 8px 10px; border-radius: 999px;
  background: #fff; font-family: var(--font-fun); font-size: 1.2rem; color: #3a2e5c; box-shadow: 0 6px 20px rgba(80, 40, 120, .2);
  animation: toast 1.6s ease forwards;
}
@keyframes toast { 0% { transform: translate(-50%, -80px); } 15%, 80% { transform: translate(-50%, 0); } 100% { transform: translate(-50%, -80px); } }
.k-stickers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.k-sticker { display: grid; place-items: center; aspect-ratio: 1; border-radius: 22px; background: #fff; box-shadow: 0 5px 0 #f3d4e6; }
.k-sticker .kimg.small { width: 70%; height: 70%; }
.k-sticker.locked { background: rgba(255, 255, 255, .5); box-shadow: none; }
.k-sticker.locked img { filter: brightness(0) opacity(.18); }
.k-done { text-align: center; padding-top: 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.k-done h1 { font-size: 2.6rem; color: #ff5fa8; }
.k-done p { font-size: 1.3rem; margin: 0; }
.k-done-img { width: 150px; height: 150px; animation: bob 2s ease-in-out infinite; }
.k-earned { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.k-earned img { animation: cardIn .5s cubic-bezier(.2, .9, .3, 1.4) both; }

/* =========================================================
   ไอคอนเคลื่อนไหว (Lottie) / ภาพ 3D และท่าขยับของภาพ
   ========================================================= */
.icon { display: inline-block; flex: none; vertical-align: middle; object-fit: contain; }
.lottie svg { display: block; }
.astro .astro-ic { width: 76%; height: 76%; }
.pill-ic { width: 22px; height: 22px; margin-right: 4px; }
.orb .icon.ic { width: 64%; height: 64%; filter: drop-shadow(0 4px 2px rgba(0, 0, 0, .18)); }
.launch .rocket { width: 60px; height: 60px; }
.boss .ufo { width: 60px; height: 60px; }
.icon.mon-emoji { width: 84px; height: 84px; }
.monster.is-boss .icon.mon-emoji { width: 110px; height: 110px; }
.icon.crown { width: 34px; height: 34px; }
.icon.heart { width: 18px; height: 18px; }
.icon.trophy { width: 130px; height: 130px; }
.icon.mon-big-ic { width: 120px; height: 120px; }
.mon-big.is-boss .icon.mon-big-ic { width: 150px; height: 150px; }
.icon.heart-pop { width: 46px; height: 46px; }
.icon.fe { width: 66px; height: 66px; filter: drop-shadow(0 0 8px var(--glow)); }
.friend.unknown .icon.fe { filter: brightness(0) opacity(.5); }
.icon.fl-ic { width: 32px; height: 32px; margin-right: -6px; }
.icon.fl-ic.unknown { filter: brightness(0) opacity(.45); }
.icon.cheer { width: 58px; height: 58px; font-size: 0; }
.music-btn { display: grid; place-items: center; }
.music-ic { width: 34px; height: 34px; }
.icon.k-game-ic { width: 74px; height: 74px; }
.k-game:last-child:nth-child(odd) .icon.k-game-ic { width: 60px; height: 60px; }
.btn-ic { width: 34px; height: 34px; margin-right: 6px; }
.k-btn { display: inline-flex; align-items: center; justify-content: center; }
.sec-ic { width: 32px; height: 32px; margin-right: 6px; }
.k-section { display: flex; align-items: center; }
.st-ic { width: 36px; height: 36px; }
.ask-ic { width: 38px; height: 38px; }
.icon.k-done-img { width: 160px; height: 160px; }

/* ท่าขยับของภาพ 3D (แต่ละคำได้ท่าประจำตัว) */
.m-jelly { animation: mJelly 1.8s ease-in-out infinite; transform-origin: 50% 100%; }
.m-hop { animation: mHop 1.4s cubic-bezier(.3, .7, .4, 1) infinite; transform-origin: 50% 100%; }
.m-wobble { animation: mWobble 2.2s ease-in-out infinite; }
.m-swing { animation: mSwing 2.6s ease-in-out infinite; transform-origin: 50% 12%; }
.m-breathe { animation: mBreathe 2.4s ease-in-out infinite; }
.m-idle { animation: mIdle 3.2s ease-in-out infinite; }
@keyframes mJelly { 0%, 100% { transform: scale(1, 1); } 30% { transform: scale(1.12, .88); } 50% { transform: scale(.92, 1.1) translateY(-12px); } 70% { transform: scale(1.04, .96); } }
@keyframes mHop { 0%, 100% { transform: translateY(0) scale(1.08, .92); } 40% { transform: translateY(-28px) scale(.95, 1.06); } 60% { transform: translateY(-28px) scale(.95, 1.06) rotate(6deg); } }
@keyframes mWobble { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-12deg) scale(1.05); } 40% { transform: rotate(10deg); } 60% { transform: rotate(-6deg); } }
@keyframes mSwing { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(10deg); } }
@keyframes mBreathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); filter: drop-shadow(0 0 16px rgba(255, 210, 63, .9)); } }
@keyframes mIdle { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-5px) rotate(-3deg); } }
.k-visual { animation: none; }

@media (min-width: 520px) {
  .planets { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .k-rooms { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .k-stickers { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .k-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .shooting { display: none; }
}
