* {
  box-sizing: border-box;
}

:root {
  --sky-top: #8bdfff;
  --sky-bottom: #fff3d2;
  --panel: rgba(255, 255, 255, 0.86);
  --text: #214064;
  --text-soft: rgba(33, 64, 100, 0.74);
  --accent: #ff9a3c;
  --accent-dark: #ea7521;
  --green: #7cd862;
  --green-dark: #4eb033;
  --pink: #ff78ac;
  --yellow: #ffe26f;
  --shadow: 0 24px 54px rgba(71, 117, 158, 0.18);
  --equation-bg: #fffdf6;
  --success: #52c979;
  --error: #ff7f74;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Nunito", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.84), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.64), transparent 24%),
    linear-gradient(180deg, var(--sky-top) 0%, #ddf7ff 48%, var(--sky-bottom) 100%);
  overflow-x: hidden;
}

body.scene-meadow {
  --sky-top: #8bdfff;
  --sky-bottom: #fff3d2;
}

body.scene-forest {
  --sky-top: #83dfc0;
  --sky-bottom: #fff2c4;
}

body.scene-sunset {
  --sky-top: #ffbf8d;
  --sky-bottom: #ffe6c8;
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1220px;
  margin: 0 auto;
  padding: 24px 18px 40px;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  border: 2px solid rgba(255, 255, 255, 0.88);
  background: var(--panel);
  border-radius: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 360px);
  gap: 24px;
  align-items: center;
  padding: 28px;
}

.hero-copy h1,
.control-card h2,
.question-head h2,
.mascot-name {
  font-family: "Baloo 2", cursive;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 24px rgba(71, 117, 158, 0.14);
  font-weight: 900;
}

.eyebrow::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 20px 0 0 var(--green), 40px 0 0 var(--pink);
}

.hero-copy h1 {
  margin: 12px 0 0;
  font-size: clamp(3.1rem, 6vw, 5rem);
  line-height: 0.92;
}

.hero-copy p {
  margin: 16px 0 0;
  max-width: 700px;
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.6;
  font-weight: 800;
}

.speech-bubble {
  position: relative;
  margin-top: 18px;
  padding: 18px 22px;
  border-radius: 24px;
  background: #fffef4;
  border: 2px solid rgba(255, 225, 135, 0.74);
  font-weight: 800;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: 24px;
  bottom: -12px;
  width: 22px;
  height: 22px;
  background: #fffef4;
  border-right: 2px solid rgba(255, 225, 135, 0.74);
  border-bottom: 2px solid rgba(255, 225, 135, 0.74);
  transform: rotate(45deg);
}

.mascot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.76), transparent 46%),
    linear-gradient(180deg, #fff7d9 0%, #f7ffe2 100%);
}

.mascot {
  position: relative;
  width: 228px;
  height: 214px;
}

.head {
  position: absolute;
  left: 28px;
  right: 28px;
  top: 30px;
  bottom: 24px;
  border-radius: 54% 54% 48% 48%;
  background: linear-gradient(180deg, #ff9f43 0%, #f07c20 100%);
}

.ear {
  position: absolute;
  top: 8px;
  width: 78px;
  height: 88px;
  border-radius: 16px 62px 16px 62px;
  background: #ef7a21;
}

.ear::after {
  content: "";
  position: absolute;
  inset: 12px 16px;
  border-radius: 12px 42px 12px 42px;
  background: #ffe4cf;
}

.ear-left {
  left: 24px;
  transform: rotate(-14deg);
}

.ear-right {
  right: 24px;
  transform: scaleX(-1) rotate(-14deg);
}

.eye {
  position: absolute;
  top: 56px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff9f0;
}

.eye-left {
  left: 34px;
}

.eye-right {
  right: 34px;
}

.pupil {
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  background: #223952;
}

.pupil::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
}

.snout {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 88px;
  height: 72px;
  border-radius: 46px 46px 34px 34px;
  background: #fff0e0;
  transform: translateX(-50%);
}

.nose {
  position: absolute;
  left: 50%;
  top: 110px;
  width: 24px;
  height: 18px;
  border-radius: 50% 50% 58% 58%;
  background: #223952;
  transform: translateX(-50%);
  z-index: 2;
}

.cheek {
  position: absolute;
  top: 116px;
  width: 18px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 193, 190, 0.72);
}

.cheek-left {
  left: 42px;
}

.cheek-right {
  right: 42px;
}

.tail {
  position: absolute;
  right: -12px;
  bottom: 22px;
  width: 82px;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffb55f 0%, #f07c20 100%);
  transform: rotate(-18deg);
}

.tail::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  width: 26px;
  height: 42px;
  border-radius: 999px;
  background: #fff3e6;
}

.mascot-name {
  margin: 0;
  text-align: center;
  font-size: 1.35rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.control-card {
  padding: 22px;
}

.control-card-wide {
  grid-column: 1 / -1;
}

.control-card h2 {
  margin: 0 0 14px;
  font-size: 1.8rem;
}

.toggle-row,
.toggle-grid,
.mini-language-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.toggle-chip {
  min-height: 58px;
  padding: 14px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  box-shadow: 0 12px 22px rgba(71, 117, 158, 0.12);
  font-weight: 900;
  text-align: center;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.toggle-chip.small {
  min-height: 46px;
  min-width: 72px;
  padding: 10px 16px;
  font-size: 0.95rem;
}

.toggle-chip.active {
  background: linear-gradient(180deg, #b8ff96 0%, #78dd52 100%);
  box-shadow: 0 12px 0 #52b438, 0 20px 28px rgba(82, 180, 56, 0.26);
  transform: translateY(-2px);
}

.start-actions {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 24px;
}

.primary-button,
.secondary-button,
.answer-button {
  width: 100%;
  border-radius: 999px;
  font-weight: 900;
}

.menu-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.start-link-button {
  max-width: 420px;
  min-height: 74px;
  padding: 18px 28px;
  font-size: 1.25rem;
}

.primary-button {
  color: #143624;
  background: linear-gradient(180deg, #b8ff98 0%, #78dd52 100%);
  box-shadow: 0 16px 0 #4eb133, 0 24px 34px rgba(78, 177, 51, 0.26);
}

.secondary-button {
  color: #7a611f;
  background: linear-gradient(180deg, #fff8ea 0%, #ffe1a4 100%);
  box-shadow: 0 10px 0 #e9c463;
}

.primary-button {
  max-width: 420px;
  min-height: 74px;
  padding: 18px 28px;
  font-size: 1.4rem;
}

.small-button {
  max-width: 220px;
  min-height: 60px;
  padding: 14px 20px;
  font-size: 1.08rem;
}

.helper-text {
  margin: 0;
  text-align: center;
  max-width: 740px;
  font-weight: 800;
  color: var(--text-soft);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
}

.score-row,
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.score-pill {
  min-width: 104px;
  padding: 12px 16px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 18px rgba(71, 117, 158, 0.12);
  text-align: center;
}

.score-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--text-soft);
}

.score-pill strong {
  font-size: 1.2rem;
}

.round-button {
  min-width: 52px;
  min-height: 52px;
  padding: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 12px 18px rgba(71, 117, 158, 0.14);
  font-size: 1.2rem;
}

.game-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.side-panel,
.question-panel {
  padding: 22px;
}

.mascot-mini {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mini-avatar {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fff0bf 0%, #ffd470 100%);
  font-size: 2rem;
}

.side-title,
.side-subtitle {
  margin: 0;
  font-weight: 900;
}

.side-subtitle {
  margin-top: 6px;
  color: var(--text-soft);
}

.speech-bubble-small {
  margin-top: 18px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.status-strip span {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  font-weight: 900;
}

.question-head {
  text-align: center;
}

.question-kicker {
  margin: 0;
  font-weight: 900;
  color: var(--text-soft);
}

.question-head h2 {
  margin: 8px 0 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.question-head > p:last-child {
  margin: 10px auto 0;
  max-width: 680px;
  font-weight: 800;
  color: var(--text-soft);
}

.equation-stage {
  display: grid;
  place-items: center;
  margin-top: 20px;
}

.equation-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: min(100%, 560px);
  min-height: 150px;
  padding: 24px 34px;
  border-radius: 34px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.82), transparent 40%),
    linear-gradient(180deg, #fffef7 0%, #fff4d7 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.74), 0 18px 34px rgba(71, 117, 158, 0.12);
  font-family: "Baloo 2", cursive;
  font-size: clamp(3rem, 10vw, 5.2rem);
  line-height: 1;
  letter-spacing: 0.04em;
}

.notebook-equation {
  position: relative;
  overflow: hidden;
  min-width: min(100%, 340px);
  padding: 24px 30px 20px;
  border-radius: 34px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.82), transparent 40%),
    linear-gradient(180deg, #fffef7 0%, #fff4d7 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.74), 0 18px 34px rgba(71, 117, 158, 0.12);
  font-family: "Baloo 2", cursive;
  font-size: clamp(2.6rem, 8vw, 4.2rem);
  line-height: 1.05;
}

.notebook-equation-line {
  position: relative;
  z-index: 1;
  pointer-events: none;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 54px;
  letter-spacing: 0.05em;
}

.notebook-equation-line-operation {
  gap: 16px;
}

.notebook-operator {
  color: var(--accent-dark);
}

.notebook-equation-rule {
  position: relative;
  z-index: 1;
  pointer-events: none;
  height: 8px;
  margin-top: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2a4462 0%, #3d5d84 100%);
}

.notebook-draw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  border-radius: 34px;
  touch-action: none;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.notebook-panel {
  margin-top: 22px;
  padding: 18px;
  border-radius: 30px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.84), transparent 40%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 249, 228, 0.96));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.72);
}

.notebook-title,
.notebook-help,
.notebook-preview {
  margin: 0;
  text-align: center;
  font-weight: 900;
}

.notebook-title {
  font-size: 1.2rem;
}

.notebook-help,
.notebook-preview {
  margin-top: 10px;
  color: var(--text-soft);
}

.notebook-sheet {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.digit-wheel {
  position: relative;
  height: 260px;
  overflow-y: auto;
  scrollbar-width: none;
  scroll-snap-type: y mandatory;
  border-radius: 22px;
  padding: 102px 0;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(100, 160, 214, 0.16) 0,
      rgba(100, 160, 214, 0.16) 2px,
      transparent 2px,
      transparent 30px
    ),
    linear-gradient(180deg, #fffef8 0%, #fff7dc 100%);
  box-shadow: 0 12px 20px rgba(71, 117, 158, 0.1);
  -webkit-overflow-scrolling: touch;
}

.digit-wheel::-webkit-scrollbar {
  display: none;
}

.digit-wheel::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 56px;
  transform: translateY(-50%);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 243, 201, 0.92));
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.88),
    inset 0 0 0 4px rgba(255, 157, 60, 0.28),
    0 8px 16px rgba(71, 117, 158, 0.12);
  pointer-events: none;
}

.digit-wheel::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 50%;
  height: 56px;
  transform: translateY(-50%);
  border-top: 3px solid rgba(255, 157, 60, 0.92);
  border-bottom: 3px solid rgba(255, 157, 60, 0.92);
  border-radius: 14px;
  pointer-events: none;
}

.digit-wheel-track {
  display: flex;
  flex-direction: column;
}

.digit-wheel-item {
  min-height: 56px;
  border: 0;
  margin: 0 8px;
  border-radius: 14px;
  background: transparent;
  color: rgba(33, 64, 100, 0.6);
  font-family: "Baloo 2", cursive;
  font-size: 2rem;
  font-weight: 800;
  scroll-snap-align: center;
  transition: color 0.15s ease, transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  opacity: 0.62;
}

.digit-wheel-item.active {
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 245, 215, 0.96), rgba(255, 255, 255, 0.98));
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  transform: scale(1.14);
  opacity: 1;
}

.digit-wheel-item.empty {
  color: rgba(33, 64, 100, 0.38);
}

.notebook-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.answer-button {
  min-height: 92px;
  padding: 18px 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 22px rgba(71, 117, 158, 0.12);
  color: var(--text);
  font-size: clamp(1.4rem, 4vw, 2rem);
}

.answer-button.correct {
  background: linear-gradient(180deg, #d7ffd5 0%, #b5f2aa 100%);
}

.answer-button.wrong {
  background: linear-gradient(180deg, #ffd9d2 0%, #ffbfb6 100%);
}

.feedback-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(27, 50, 76, 0.26);
  backdrop-filter: blur(10px);
}

.feedback-card {
  width: min(100%, 520px);
  padding: 26px 24px;
  text-align: center;
}

.feedback-badge {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin: 0 auto;
  border-radius: 50%;
  font-size: 2.2rem;
  background: linear-gradient(180deg, #fff0bf 0%, #ffd766 100%);
}

.feedback-card h2 {
  margin: 14px 0 0;
  font-family: "Baloo 2", cursive;
  font-size: 2.3rem;
}

.feedback-card p {
  margin: 12px 0 0;
  font-weight: 800;
}

.feedback-answer {
  color: var(--text-soft);
}

.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

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

.spark {
  position: absolute;
  top: -24px;
  width: 18px;
  height: 18px;
  opacity: 0;
  animation: drop 1.35s ease forwards;
}

.spark.star {
  clip-path: polygon(50% 0%, 62% 35%, 100% 35%, 70% 57%, 82% 100%, 50% 74%, 18% 100%, 30% 57%, 0% 35%, 38% 35%);
}

.spark.leaf {
  border-radius: 10px 60px;
}

@keyframes drop {
  0% {
    transform: translateY(-10px) scale(0.7) rotate(0deg);
    opacity: 0;
  }

  16% {
    opacity: 1;
  }

  100% {
    transform: translateY(100vh) scale(1.05) rotate(240deg);
    opacity: 0;
  }
}

.bg-shape,
.cloud {
  position: fixed;
  pointer-events: none;
}

.bg-shape {
  width: 230px;
  height: 230px;
  border-radius: 34% 66% 40% 60%;
  filter: blur(10px);
}

.bg-shape-left {
  left: -56px;
  bottom: 62px;
  background: rgba(118, 216, 110, 0.22);
}

.bg-shape-right {
  right: -44px;
  top: 170px;
  background: rgba(255, 157, 60, 0.22);
}

.cloud {
  background: rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  filter: drop-shadow(0 12px 18px rgba(71, 117, 158, 0.12));
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud-left {
  top: 86px;
  left: 8%;
  width: 138px;
  height: 48px;
}

.cloud-left::before {
  width: 56px;
  height: 56px;
  top: -18px;
  left: 18px;
}

.cloud-left::after {
  width: 66px;
  height: 66px;
  top: -24px;
  right: 16px;
}

.cloud-right {
  top: 116px;
  right: 10%;
  width: 160px;
  height: 54px;
}

.cloud-right::before {
  width: 68px;
  height: 68px;
  top: -22px;
  left: 18px;
}

.cloud-right::after {
  width: 72px;
  height: 72px;
  top: -28px;
  right: 18px;
}

@media (max-width: 980px) {
  .hero-card,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .settings-grid,
  .options-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    justify-content: center;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px 14px 34px;
  }

  .hero-card,
  .control-card,
  .start-actions,
  .side-panel,
  .question-panel,
  .feedback-card {
    padding: 18px;
    border-radius: 26px;
  }

  .mascot {
    width: 190px;
    height: 188px;
  }

  .equation-card {
    min-height: 126px;
    font-size: clamp(2.6rem, 14vw, 4.4rem);
  }

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

  .notebook-sheet {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .score-pill {
    min-width: 92px;
    flex: 1 1 92px;
  }
}
