:root {
  --bg: #fff8ef;
  --panel: rgba(255, 253, 248, 0.94);
  --line: #edd8bc;
  --ink: #27435a;
  --soft: #6d7e88;
  --orange: #ef955a;
  --orange-deep: #df7946;
  --green: #73cfac;
  --green-deep: #50ba92;
  --yellow: #ffe498;
  --pink: #ffd1de;
  --sky: #cae8ff;
  --shadow: 0 22px 52px rgba(116, 115, 109, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Baloo 2", cursive;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.92), transparent 18%),
    radial-gradient(circle at 88% 12%, rgba(255, 228, 152, 0.52), transparent 16%),
    radial-gradient(circle at 18% 92%, rgba(255, 209, 222, 0.4), transparent 18%),
    linear-gradient(180deg, #fff4de, #fffdf9 58%, #fff7ef);
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(30px);
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 260px;
  height: 260px;
  top: -90px;
  left: -60px;
  background: rgba(255, 228, 152, 0.46);
}

body::after {
  width: 300px;
  height: 300px;
  right: -100px;
  bottom: -120px;
  background: rgba(202, 232, 255, 0.42);
}

.app-shell {
  position: relative;
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 16px 32px;
  z-index: 1;
}

.topbar,
.board,
.answer-card {
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 34px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(255, 248, 236, 0.96)),
    linear-gradient(135deg, #fff3d8, #fffdf8);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 35% 26%, rgba(255, 255, 255, 0.86), transparent 34%),
    linear-gradient(180deg, #ffe4a9, #ffc988);
  font-size: 2.2rem;
  box-shadow: inset 0 -10px 0 rgba(255, 255, 255, 0.2);
}

.mini,
.sub,
.phase,
.progress-pill,
.operator,
.answer-number {
  margin: 0;
}

.mini,
.phase,
.progress-pill {
  font-family: "ZCOOL KuaiLe", cursive;
}

.mini {
  font-size: 1.1rem;
  color: #cc7840;
}

.sub {
  margin-top: 4px;
  color: var(--soft);
  font-size: 1.05rem;
}

.progress-pill {
  padding: 12px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe9b9, #ffd48b);
  font-size: 1.15rem;
  white-space: nowrap;
  color: #8f5d29;
  box-shadow: inset 0 -6px 0 rgba(255, 255, 255, 0.2);
}

.board {
  margin-top: 16px;
  padding: 26px;
  border-radius: 40px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.92), transparent 22%),
    linear-gradient(180deg, rgba(255, 253, 247, 0.98), rgba(255, 248, 237, 0.95));
}

.board::before,
.board::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.board::before {
  width: 160px;
  height: 160px;
  top: -54px;
  right: -38px;
  background: radial-gradient(circle, rgba(255, 228, 152, 0.58), transparent 72%);
}

.board::after {
  width: 180px;
  height: 180px;
  left: -60px;
  bottom: -70px;
  background: radial-gradient(circle, rgba(202, 232, 255, 0.48), transparent 72%);
}

.phase {
  text-align: center;
  font-size: clamp(2rem, 4vw, 3rem);
  position: relative;
  z-index: 1;
}

.scene {
  margin-top: 22px;
  position: relative;
  z-index: 1;
}

.equation {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
}

.pile {
  min-height: 260px;
  padding: 24px 18px;
  border-radius: 36px;
  border: 3px solid #f3d8bc;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 250, 240, 0.98)),
    linear-gradient(180deg, #fffaf0, #fffdf9);
  position: relative;
}

.pile::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 12px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 224, 182, 0.26), rgba(255, 255, 255, 0));
}

.pile.active,
.carry-stage.active,
.total-stage.active {
  box-shadow: 0 0 0 6px rgba(242, 162, 102, 0.16);
  border-color: #efa067;
}

.pile-emoji,
.small-label,
.carry-note {
  text-align: center;
}

.pile-emoji {
  display: none;
}

.small-label {
  display: none;
}

.big-number {
  margin: 10px 0 16px;
  text-align: center;
  font-family: "ZCOOL KuaiLe", cursive;
  font-size: 3.9rem;
  letter-spacing: 0.02em;
}

.split {
  display: grid;
  gap: 18px;
}

.split-row {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.split-tag {
  display: none;
}

.counters,
.plates {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.counter {
  width: 50px;
  height: 50px;
  border-radius: 20px;
  box-shadow: inset 0 -8px 0 rgba(255, 255, 255, 0.18);
}

.counter.orange {
  background: linear-gradient(180deg, var(--orange), var(--orange-deep));
}

.counter.green {
  background: linear-gradient(180deg, var(--green), var(--green-deep));
}

.operator {
  font-family: "ZCOOL KuaiLe", cursive;
  font-size: clamp(3rem, 8vw, 5rem);
  color: #e48951;
  text-shadow: 0 6px 16px rgba(228, 137, 81, 0.18);
}

.carry-stage,
.total-stage {
  padding: 26px 22px;
  border-radius: 34px;
  border: 3px solid #f3d8bc;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 250, 240, 0.98)),
    linear-gradient(180deg, #fffaf0, #fffdf9);
}

.carry-note {
  margin-top: 16px;
  font-family: "ZCOOL KuaiLe", cursive;
  font-size: 1.9rem;
  color: #a86a32;
  letter-spacing: 0.03em;
}

.carry-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
}

.plate {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ffe490, var(--yellow));
  color: #9f6d1b;
  font-family: "ZCOOL KuaiLe", cursive;
  font-size: 1.3rem;
  box-shadow: inset 0 -10px 0 rgba(255, 255, 255, 0.2);
}

.plate::after {
  content: "10";
}

.answers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.answer-card {
  min-height: 144px;
  border-radius: 32px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 16px;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  position: relative;
  overflow: hidden;
}

.answer-card:hover {
  transform: translateY(-2px);
}

.answer-card:nth-child(3n + 1) {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 246, 234, 0.98)),
    linear-gradient(180deg, #fff7ea, #fffdf9);
}

.answer-card:nth-child(3n + 2) {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(237, 255, 246, 0.96)),
    linear-gradient(180deg, #eefcf6, #fffdf9);
}

.answer-card:nth-child(3n) {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(242, 247, 255, 0.96)),
    linear-gradient(180deg, #f2f8ff, #fffdf9);
}

.answer-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 18px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.55), transparent 44%);
}

.answer-card.correct {
  animation: pop-good 420ms ease-out;
  border-color: #f0b45d;
  box-shadow: 0 0 0 7px rgba(255, 228, 152, 0.28);
}

.answer-card.wrong {
  border-color: #e9aaaa;
  animation: shake-bad 240ms ease-in-out;
}

.answer-number {
  font-family: "Baloo 2", cursive;
  font-weight: 700;
  font-size: clamp(4.6rem, 10vw, 6.8rem);
  line-height: 1;
  color: #214057;
  text-shadow: 0 4px 0 rgba(255, 255, 255, 0.28);
}

.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.sparkle {
  position: fixed;
  left: 50%;
  top: 60%;
  font-size: 2rem;
  pointer-events: none;
  animation: sparkle-up 1s ease-out forwards;
}

.topbar,
.board,
.answers {
  animation: lift-in 420ms ease-out;
}

@keyframes pop-good {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake-bad {
  0%,
  100% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(-6px);
  }
  70% {
    transform: translateX(6px);
  }
}

@keyframes sparkle-up {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.6);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-140px + var(--y))) scale(1.2) rotate(18deg);
  }
}

@keyframes lift-in {
  0% {
    opacity: 0;
    transform: translateY(14px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 760px) {
  .equation {
    grid-template-columns: 1fr;
  }

  .carry-grid {
    grid-template-columns: 1fr;
  }

  .operator {
    text-align: center;
  }

  .answers {
    grid-template-columns: 1fr;
  }
}
