:root {
  --ink: #2b2150;
  --cream: #fff7ea;
  --card: #fffdf8;
  --gold: #ffc43a;
  --coral: #ff6b6b;
  --mint: #3ddc97;
  --sky: #4cc9f0;
  --lilac: #9b5de5;
  --peach: #ff9f1c;
  --pink: #f72585;
  --shadow: 0 10px 0 rgba(43, 33, 80, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Fredoka, Nunito, "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 0%, #ffe8a3 0%, var(--cream) 42%, #d9f4ff 100%);
  overflow-x: hidden;
}

button, .choice, .topic-card, .num-chip, .key {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.blob {
  position: absolute; border-radius: 50%; filter: blur(8px); opacity: 0.45;
  animation: drift 14s ease-in-out infinite;
}
.b1 { width: 280px; height: 280px; background: #ffd6e8; top: -80px; left: -40px; }
.b2 { width: 220px; height: 220px; background: #c8f4ff; right: -60px; top: 20%; animation-delay: -4s; }
.b3 { width: 180px; height: 180px; background: #e4d5ff; bottom: 8%; left: 30%; animation-delay: -8s; }

.float-shape {
  position: absolute; font-size: 28px; opacity: 0.22; font-weight: 700;
  animation: floaty 8s ease-in-out infinite;
}
.s1 { color: #ff6b6b; top: 12%; left: 8%; }
.s2 { color: #4cc9f0; top: 22%; right: 12%; animation-delay: -2s; font-size: 36px; }
.s3 { color: #9b5de5; bottom: 18%; left: 14%; animation-delay: -3s; }
.s4 { color: #ffc43a; top: 40%; right: 8%; animation-delay: -5s; }
.s5 { color: #3ddc97; bottom: 28%; right: 18%; animation-delay: -1s; }
.s6 { color: #f72585; top: 60%; left: 6%; animation-delay: -6s; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

#app { position: relative; z-index: 1; max-width: 920px; margin: 0 auto; padding: 16px 16px 40px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.icon-btn {
  border: 0; background: #fff; width: 48px; height: 48px; border-radius: 16px;
  font-size: 22px; cursor: pointer; box-shadow: var(--shadow); color: var(--ink);
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 6px 0 rgba(43,33,80,0.12); }
.stars-pill {
  background: #fff; border-radius: 999px; padding: 8px 14px; font-weight: 700;
  box-shadow: var(--shadow); font-size: 18px;
}

.hero { text-align: center; padding: 8px 8px 18px; }
.mascot {
  width: 110px; height: 110px; margin: 0 auto 8px; display: grid; place-items: center;
  animation: bounce 2.2s ease-in-out infinite;
  filter: drop-shadow(0 10px 0 rgba(43,33,80,0.08));
}
.mascot svg { width: 110px; height: 110px; }
.mascot.happy { animation: hop 0.55s ease; }
.mascot.sad { animation: shake 0.45s ease; }
h1 { margin: 0; font-size: clamp(28px, 6vw, 42px); letter-spacing: -0.5px; }
.sub { margin: 6px 0 0; font-size: 18px; opacity: 0.8; }

.grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
}
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.topic-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  border: 0; border-radius: 24px; padding: 16px 14px 14px; min-height: 150px;
  color: #fff; cursor: pointer; text-align: left; box-shadow: 0 8px 0 rgba(0,0,0,0.12);
  transform: translateY(0); transition: transform 0.12s ease;
}
.topic-card:active { transform: translateY(4px); box-shadow: 0 4px 0 rgba(0,0,0,0.12); }
.topic-card .emoji { font-size: 36px; }
.topic-card h2 { margin: 0; font-size: 20px; line-height: 1.15; }
.topic-card p { margin: 0; font-size: 13px; opacity: 0.92; font-weight: 600; }
.topic-card .progress { margin-top: auto; font-size: 13px; background: rgba(255,255,255,0.22); padding: 4px 8px; border-radius: 999px; }

.c1 { background: linear-gradient(160deg, #ff8a5b, #ff5d8f); }
.c2 { background: linear-gradient(160deg, #4cc9f0, #4361ee); }
.c3 { background: linear-gradient(160deg, #9b5de5, #f15bb5); }
.c4 { background: linear-gradient(160deg, #3ddc97, #00bbf9); }
.c5 { background: linear-gradient(160deg, #ffc43a, #ff9f1c); color: #4a3200; }
.c6 { background: linear-gradient(160deg, #f72585, #b5179e); }
.c7 { background: linear-gradient(160deg, #00bbf9, #80ed99); color: #123; }
.c8 { background: linear-gradient(160deg, #f15bb5, #fee440); color: #3b1d4a; }
.c9 { background: linear-gradient(160deg, #2b2150, #7b2cbf); grid-column: 1 / -1; min-height: 92px; flex-direction: row; align-items: center; }

.play-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap;
}
.play-head h2 { margin: 0; font-size: 22px; flex: 1; }
.meter {
  height: 12px; background: #fff; border-radius: 999px; overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(43,33,80,0.08); margin: 8px 0 16px;
}
.meter > span {
  display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffc43a, #3ddc97);
  transition: width 0.3s ease;
}

.card {
  background: var(--card); border-radius: 28px; padding: 18px 16px 20px;
  box-shadow: var(--shadow); min-height: 280px;
}
.q-label { font-size: 15px; font-weight: 700; color: #7a6aa5; text-transform: uppercase; letter-spacing: 0.6px; }
.prompt { font-size: clamp(24px, 5vw, 34px); margin: 8px 0 14px; line-height: 1.25; }
.visual { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 8px 0 16px; }
.obj { font-size: 34px; animation: pop 0.35s ease; }
.big-num {
  font-size: 64px; font-weight: 700; text-align: center; color: #5a3dff;
  text-shadow: 3px 4px 0 #ffe08a;
}
.sequence { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0 16px; }
.seq-box {
  min-width: 58px; min-height: 58px; border-radius: 16px; display: grid; place-items: center;
  background: #fff3d4; font-size: 24px; font-weight: 700; box-shadow: 0 4px 0 #f0c14d;
}
.seq-box.blank { background: #e8f7ff; box-shadow: 0 4px 0 #7ec8e3; color: #4cc9f0; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice {
  border: 0; border-radius: 20px; min-height: 64px; font-size: 22px; font-weight: 700;
  font-family: inherit; cursor: pointer; background: #eef2ff; color: var(--ink);
  box-shadow: 0 6px 0 #c5c9f0; padding: 8px 8px; text-transform: none; word-break: break-word;
}
.choice:active { transform: translateY(3px); box-shadow: 0 3px 0 #c5c9f0; }
.choice.correct { background: #b8f5d2; box-shadow: 0 6px 0 #2fb87a; }
.choice.wrong { background: #ffd0d0; box-shadow: 0 6px 0 #e85d5d; }
.choice:disabled { cursor: default; }

.sign-row { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 12px 0 18px; }
.sign-num {
  font-size: 40px; font-weight: 700; background: #fff; min-width: 110px; padding: 10px;
  border-radius: 20px; text-align: center; box-shadow: 0 6px 0 rgba(43,33,80,0.1);
}
.sign-slot {
  width: 70px; height: 70px; border-radius: 18px; border: 4px dashed #cbbbe8;
  display: grid; place-items: center; font-size: 36px; background: #f7f1ff;
}
.signs { display: flex; justify-content: center; gap: 12px; }
.signs .choice { min-width: 86px; font-size: 36px; }

.order-target {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 70px;
  background: #f3e8ff; border-radius: 18px; padding: 10px; margin-bottom: 14px;
}
.num-chip {
  min-width: 72px; height: 62px; border: 0; border-radius: 16px; font-size: 24px;
  font-weight: 700; font-family: inherit; cursor: pointer; background: #fff;
  box-shadow: 0 5px 0 #d9c7ff; color: var(--ink);
}
.num-chip.used { visibility: hidden; }
.pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.shape-wrap { display: grid; place-items: center; margin: 8px 0 16px; }
.shape-wrap svg { width: 140px; height: 140px; filter: drop-shadow(0 8px 0 rgba(43,33,80,0.08)); }
.card:has(.spell-row) .shape-wrap svg { width: 100px; height: 100px; }

.spell-row {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0 16px;
}
.spell-row.shake { animation: shake 0.45s ease; }
.letter-box {
  width: 36px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  font-size: 22px; font-weight: 800; background: #fff3d4; box-shadow: 0 4px 0 #f0c14d;
}
.letter-box.empty {
  background: #e8f7ff; box-shadow: 0 4px 0 #7ec8e3; color: #4cc9f0;
}
.letter-box.typed { background: #efe7ff; box-shadow: 0 4px 0 #b79cff; }
.letter-box.next { outline: 3px solid #4cc9f0; outline-offset: 1px; }
.letter-box.correct { background: #b8f5d2; box-shadow: 0 4px 0 #2fb87a; }
.keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.key {
  width: 44px; height: 44px; border: 0; border-radius: 12px; font-size: 20px; font-weight: 800;
  font-family: inherit; cursor: pointer; background: #eef2ff; color: var(--ink); box-shadow: 0 4px 0 #c5c9f0;
}
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 #c5c9f0; }
.key.back { width: 56px; background: #ffe0e0; box-shadow: 0 4px 0 #e8a0a0; }
.spell-preview { letter-spacing: 2px; font-size: 14px; opacity: 0.95; }
@media (min-width: 600px) {
  .letter-box { width: 44px; height: 54px; font-size: 26px; }
  .key { width: 50px; height: 50px; font-size: 22px; }
}

.chart {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; max-height: 58vh; overflow: auto;
  padding: 6px;
}
.chart button {
  border: 0; border-radius: 10px; min-height: 36px; font-weight: 700; font-family: inherit;
  background: #fff; cursor: pointer; font-size: 13px; color: var(--ink);
}
.chart button:nth-child(10n) { background: #ffe08a; }
.chart button.found { background: #b8f5d2; }

.learn-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.name-card {
  border: 0; border-radius: 16px; padding: 10px 4px; background: #fff; cursor: pointer;
  box-shadow: 0 4px 0 rgba(43,33,80,0.1); font-family: inherit; color: var(--ink);
}
.name-card .n { font-size: 26px; font-weight: 800; display: block; }
.name-card .w { font-size: 13px; font-weight: 700; }

.actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.btn {
  border: 0; border-radius: 18px; padding: 12px 18px; font-size: 18px; font-weight: 700;
  font-family: inherit; cursor: pointer; color: #fff; background: #5a3dff; box-shadow: 0 6px 0 #3b28b0;
}
.btn.alt { background: #ff8a5b; box-shadow: 0 6px 0 #d45d38; }
.btn.mint { background: #22b07a; box-shadow: 0 6px 0 #19845b; }
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,0.15); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #2b2150; color: #fff; padding: 12px 18px; border-radius: 18px; font-weight: 700;
  opacity: 0; pointer-events: none; z-index: 40; transition: 0.25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.good { background: #19845b; }
.toast.bad { background: #c93a3a; }

.result { text-align: center; padding: 20px 8px; }
.result .big { font-size: 54px; margin: 8px 0; }
.star-row { font-size: 40px; letter-spacing: 6px; }
.ribbon {
  display: inline-block; background: #ffc43a; color: #4a3200; font-weight: 800;
  padding: 6px 14px; border-radius: 999px; letter-spacing: 0.8px; font-size: 14px; margin: 0 0 12px;
}
.sticker-frame {
  width: 160px; height: 160px; margin: 8px auto 8px; border-radius: 28px;
  background: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 0 rgba(43,33,80,0.12); border: 6px dashed #ffc43a;
}
.sticker-frame.gold { border-color: #f4c14e; background: linear-gradient(180deg, #fff6c8, #fff); }
.sticker-big { font-size: 88px; animation: stickerIn 0.7s cubic-bezier(.2,1.5,.3,1); line-height: 1; }
.sticker-name { font-size: 28px; font-weight: 800; margin: 8px 0 0; }
.level-pill {
  background: #fff3d4; border-radius: 999px; padding: 6px 10px; font-weight: 800; font-size: 14px;
  box-shadow: 0 4px 0 rgba(43,33,80,0.08);
}
.album {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
}
.sticker-mini {
  border: 0; background: #fff; border-radius: 16px; padding: 10px 4px; cursor: pointer;
  font-family: inherit; color: var(--ink); box-shadow: 0 4px 0 rgba(43,33,80,0.1);
}
.sticker-mini.gold { background: #fff6c8; }
.sticker-mini .e { font-size: 34px; display: block; }
.sticker-mini .n { font-size: 12px; font-weight: 800; display: block; }
.sticker-mini .lv { font-size: 11px; opacity: 0.7; }
.empty-album { grid-column: 1 / -1; font-size: 72px; text-align: center; padding: 30px; opacity: 0.6; }

.mode-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 12px 0 4px; }
.pill {
  border: 0; background: #fff; border-radius: 999px; padding: 10px 14px; font-weight: 700;
  font-family: inherit; cursor: pointer; box-shadow: var(--shadow); color: var(--ink);
}

.hint { font-size: 16px; color: #6a5a90; margin: 0 0 10px; text-align: center; }

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(18px, 12px) scale(1.08); }
}
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-16px) rotate(8deg); }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes hop {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-18px) scale(1.08); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px) rotate(-6deg); }
  75% { transform: translateX(8px) rotate(6deg); }
}
@keyframes pop {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes stickerIn {
  0% { transform: scale(0) rotate(-24deg); }
  60% { transform: scale(1.18) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}
