:root {
  --sky-top: #87d8ff;
  --sky-mid: #b7ecff;
  --sky-low: #ecfbff;
  --ink: #23405b;
  --blue: #2e74da;
  --yellow: #ffd44d;
  --orange: #ffb43b;
  --green: #98e272;
  --cloud: #ffffff;
  --paper: #fffef6;
  --shadow: 0 14px 0 rgba(35, 64, 91, 0.1), 0 24px 34px rgba(35, 64, 91, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", cursive;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-low) 100%);
  color: var(--ink);
  overflow: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  pointer-events: none;
}

body::before {
  left: -10vw;
  right: -10vw;
  bottom: -12vh;
  height: 24vh;
  background: #7fd35f;
  border-radius: 48% 52% 0 0 / 100% 100% 0 0;
  box-shadow: inset 0 10px 0 rgba(255, 255, 255, 0.35);
}

body::after {
  left: 12vw;
  bottom: -13vh;
  width: 48vw;
  height: 22vh;
  background: #69bf4f;
  border-radius: 56% 44% 0 0 / 100% 100% 0 0;
}

.page {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100vw - 18px));
  height: calc(100svh - 12px);
  margin: 6px auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.cloud {
  position: absolute;
  background: var(--cloud);
  height: 52px;
  border-radius: 40px 44px 36px 41px;
  box-shadow: 0 8px 0 rgba(255, 255, 255, 0.55);
  opacity: 0.95;
  animation: drift 14s ease-in-out infinite;
}

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

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

.cloud::after {
  width: 48px;
  height: 48px;
  right: 12px;
  top: -22px;
}

.cloud-a {
  width: 120px;
  top: 7%;
  left: 7%;
}

.cloud-b {
  width: 160px;
  top: 14%;
  right: 10%;
  animation-delay: -5s;
}

.cloud-c {
  width: 108px;
  top: 33%;
  left: 18%;
  animation-delay: -8s;
}

.cloud-d {
  width: 148px;
  top: 42%;
  right: 18%;
  animation-delay: -3s;
}

.hero,
.game,
.scoreboard {
  background: var(--paper);
  border: 4px solid rgba(35, 64, 91, 0.12);
  box-shadow: var(--shadow);
}

.hero {
  padding: 12px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border-radius: 28px 36px 26px 34px;
  min-height: 118px;
}

.hero-copy {
  display: grid;
  gap: 8px;
  align-content: center;
}

.badge {
  width: fit-content;
  padding: 8px 12px;
  border-radius: 18px 22px 16px 24px;
  background: linear-gradient(135deg, #ffe778, #fff6b8);
  border: 3px dashed rgba(35, 64, 91, 0.2);
  font-weight: 900;
  letter-spacing: 0.02em;
  transform: rotate(-2deg);
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 0.95;
  color: var(--blue);
  text-shadow: 0 4px 0 rgba(255, 212, 77, 0.65);
}

.hero p,
.status,
.helper {
  margin: 0;
  font-size: clamp(0.95rem, 1.8vw, 1.08rem);
  line-height: 1.25;
}

.hero p {
  max-width: 520px;
  font-weight: 700;
}

.hero-scene {
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 14px;
  flex-wrap: nowrap;
}

.sun-face,
.buddy {
  position: relative;
  flex: 0 0 auto;
  box-shadow: 0 10px 0 rgba(35, 64, 91, 0.08);
}

.sun-face {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff7b8 0%, var(--yellow) 48%, var(--orange) 100%);
  border: 4px solid rgba(35, 64, 91, 0.08);
  animation: bob 3.4s ease-in-out infinite;
}

.sun-face::before,
.sun-face::after,
.buddy::before,
.buddy::after {
  content: "";
  position: absolute;
  background: var(--ink);
  border-radius: 50%;
}

.sun-face::before {
  width: 7px;
  height: 7px;
  left: 22px;
  top: 27px;
  box-shadow: 23px 2px 0 var(--ink);
}

.sun-face::after {
  width: 26px;
  height: 12px;
  left: 24px;
  top: 40px;
  border-radius: 0 0 18px 18px;
  background: transparent;
  border-bottom: 4px solid var(--ink);
}

.buddy {
  width: 68px;
  height: 64px;
  animation: bob 4.1s ease-in-out infinite;
}

.buddy-apple {
  background: #ff5b57;
  border-radius: 47% 53% 50% 50% / 42% 42% 58% 58%;
  border: 4px solid rgba(35, 64, 91, 0.08);
  transform: rotate(-6deg);
}

.buddy-apple .stem,
.buddy-apple .leaf {
  position: absolute;
  top: -10px;
  left: 30px;
  width: 6px;
  height: 16px;
  background: #6d4b2d;
  border-radius: 8px;
  transform: rotate(8deg);
}

.buddy-apple .leaf {
  width: 18px;
  height: 11px;
  left: 36px;
  top: -6px;
  background: #43a848;
  border-radius: 80% 20% 70% 30%;
  transform: rotate(24deg);
}

.buddy-star {
  width: 72px;
  height: 72px;
  background: var(--yellow);
  clip-path: polygon(50% 0%, 62% 34%, 98% 36%, 70% 57%, 80% 92%, 50% 72%, 20% 92%, 30% 57%, 2% 36%, 38% 34%);
  border: none;
  filter: drop-shadow(0 10px 0 rgba(35, 64, 91, 0.08));
  transform: rotate(8deg);
  box-shadow: none;
}

.buddy-eye {
  position: absolute;
  width: 7px;
  height: 7px;
  background: var(--ink);
  border-radius: 50%;
  top: 24px;
}

.buddy-eye.left {
  left: 21px;
}

.buddy-eye.right {
  right: 21px;
}

.buddy-smile {
  position: absolute;
  left: 22px;
  top: 35px;
  width: 22px;
  height: 12px;
  border-bottom: 4px solid var(--ink);
  border-radius: 0 0 18px 18px;
}

.panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 12px;
  min-height: 0;
}

.game {
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto auto auto auto auto;
  gap: 12px;
  border-radius: 34px 24px 28px 38px;
  min-height: 0;
  overflow: hidden;
}

.story {
  padding: 12px 14px;
  border-radius: 24px 18px 28px 16px;
  background: linear-gradient(135deg, #ffeeb2, #ffd3a6);
  border: 3px dashed rgba(35, 64, 91, 0.14);
  font-size: clamp(1rem, 2vw, 1.18rem);
  font-weight: 800;
  text-align: center;
}

.mode-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-chip {
  border: 3px solid rgba(35, 64, 91, 0.08);
  border-radius: 999px;
  padding: 8px 12px;
  background: white;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(35, 64, 91, 0.08);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.mode-chip.active {
  background: #fff0a8;
  transform: translateY(-2px);
}

.count-stage {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(230, 246, 255, 0.85));
  border: 3px solid rgba(35, 64, 91, 0.07);
}

.count-row {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.count-label {
  font-size: 0.92rem;
  font-weight: 900;
  color: var(--blue);
}

.count-icons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 34px;
}

.count-icon {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  line-height: 1;
  filter: drop-shadow(0 3px 0 rgba(35, 64, 91, 0.08));
  animation: popIn 220ms ease both;
}

.sum-cloud {
  display: flex;
  justify-content: center;
}

.sum-bubble {
  min-width: 150px;
  padding: 10px 16px;
  border-radius: 999px;
  background: white;
  border: 3px dashed rgba(35, 64, 91, 0.16);
  text-align: center;
  font-size: 1rem;
  font-weight: 900;
}

.question {
  font-size: clamp(1.9rem, 5.4vw, 3.2rem);
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.02em;
  color: #ff7a00;
  text-shadow: 0 5px 0 rgba(255, 212, 77, 0.55);
  line-height: 1.05;
}

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

.answer-btn,
.action-btn {
  border: 3px solid rgba(35, 64, 91, 0.08);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
  font-family: inherit;
}

.answer-btn {
  padding: 16px 12px;
  border-radius: 26px 18px 28px 20px;
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 900;
  color: var(--ink);
  box-shadow: 0 10px 0 rgba(35, 64, 91, 0.1);
}

.answer-btn.correct-hit {
  animation: correctPulse 520ms ease;
  background: #baf5a7;
}

.answer-btn.wrong-hit {
  animation: wrongShake 460ms ease;
  background: #ffd0d8;
}

.answer-btn:nth-child(4n + 1) {
  background: #fff2b8;
}

.answer-btn:nth-child(4n + 2) {
  background: #c7ffe1;
}

.answer-btn:nth-child(4n + 3) {
  background: #ffd2d8;
}

.answer-btn:nth-child(4n + 4) {
  background: #d8e8ff;
}

.answer-btn:hover,
.answer-btn:focus-visible,
.action-btn:hover,
.action-btn:focus-visible,
.mode-chip:hover,
.mode-chip:focus-visible {
  transform: translateY(-3px) rotate(-1deg) scale(1.01);
  box-shadow: 0 14px 0 rgba(35, 64, 91, 0.12), 0 18px 24px rgba(35, 64, 91, 0.12);
  outline: none;
  filter: saturate(1.08);
}

.status {
  min-height: 1.5em;
  text-align: center;
  font-weight: 900;
  color: var(--blue);
}

.status.correct-text {
  color: #228a45;
  animation: correctPulse 520ms ease;
}

.status.wrong-text {
  color: #d44b68;
  animation: wrongShake 460ms ease;
}

.action-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.action-btn {
  padding: 12px 18px;
  border-radius: 18px 22px 18px 24px;
  background: linear-gradient(135deg, var(--blue), #67a2ff);
  color: white;
  font-size: 0.98rem;
  font-weight: 900;
  box-shadow: 0 10px 0 rgba(35, 64, 91, 0.12);
}

.action-btn.secondary {
  background: linear-gradient(135deg, #ff9db0, #ffcb7d);
  color: var(--ink);
}

.scoreboard {
  padding: 14px;
  display: grid;
  gap: 10px;
  align-content: start;
  border-radius: 30px 38px 24px 34px;
  min-height: 0;
  overflow: hidden;
}

.score-title {
  margin: 0;
  font-size: 1.25rem;
  color: #ff7a00;
  text-align: center;
}

.score-box {
  padding: 12px;
  border-radius: 20px 28px 18px 24px;
  background: white;
  text-align: center;
  box-shadow: inset 0 0 0 3px rgba(46, 116, 218, 0.08);
}

.score-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 800;
  opacity: 0.86;
}

.score-value {
  display: block;
  font-size: 2rem;
  font-weight: 900;
  margin-top: 4px;
}

.stars {
  font-size: 1.7rem;
  letter-spacing: 0.12em;
  text-align: center;
  min-height: 1.4em;
}

.helper {
  padding: 10px 12px;
  border-radius: 18px 24px 18px 22px;
  background: linear-gradient(135deg, rgba(152, 226, 114, 0.36), rgba(255, 244, 169, 0.6));
  text-align: center;
  font-weight: 800;
}

.progress-track {
  display: grid;
  gap: 8px;
}

.progress-bar {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: rgba(35, 64, 91, 0.12);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #73d86d, #ffd44d, #ff9b70);
  transition: width 220ms ease;
}

.buddy-says {
  padding: 10px 12px;
  border-radius: 22px 18px 24px 18px;
  background: white;
  border: 3px solid rgba(35, 64, 91, 0.08);
  text-align: center;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.3;
}

.buddy-says.buddy-happy {
  background: #efffdc;
  animation: correctPulse 520ms ease;
}

.buddy-says.buddy-oops {
  background: #fff0f3;
  animation: wrongShake 460ms ease;
}

.question.question-correct,
.sum-bubble.sum-correct,
.count-stage.stage-correct {
  animation: correctPulse 520ms ease;
}

.question.question-wrong,
.sum-bubble.sum-wrong,
.count-stage.stage-wrong {
  animation: wrongShake 460ms ease;
}

.tiny-links {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tiny-link {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 900;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 2px solid rgba(35, 64, 91, 0.08);
}

.mini-buddies {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.mini-buddy {
  width: 42px;
  height: 42px;
  border-radius: 20px 16px 18px 22px;
  position: relative;
  box-shadow: 0 8px 0 rgba(35, 64, 91, 0.08);
}

.mini-buddy.sun {
  background: #ffe36c;
  border-radius: 50%;
}

.mini-buddy.apple {
  background: #ff7474;
  border-radius: 45% 55% 48% 52% / 40% 40% 60% 60%;
}

.mini-buddy.cloud {
  background: white;
  width: 54px;
  height: 30px;
  margin-top: 6px;
  border-radius: 24px;
}

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

.mini-buddy.cloud::before {
  width: 22px;
  height: 22px;
  left: 8px;
  top: -10px;
}

.mini-buddy.cloud::after {
  width: 26px;
  height: 26px;
  right: 10px;
  top: -12px;
}

@keyframes drift {
  0%, 100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(14px);
  }
}

@keyframes bob {
  0%, 100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.7) translateY(6px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes correctPulse {
  0% {
    transform: scale(1);
  }

  35% {
    transform: scale(1.05) translateY(-4px);
  }

  70% {
    transform: scale(0.98) translateY(0);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes wrongShake {
  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-8px);
  }

  40% {
    transform: translateX(8px);
  }

  60% {
    transform: translateX(-6px);
  }

  80% {
    transform: translateX(6px);
  }
}

@media (max-width: 860px) {
  .page {
    width: min(100vw - 10px, 1100px);
    height: calc(100svh - 8px);
    margin: 4px auto;
    gap: 8px;
  }

  .hero {
    padding: 10px 12px;
    gap: 10px;
  }

  .hero p {
    font-size: 0.88rem;
  }

  .hero-scene {
    gap: 8px;
  }

  .sun-face {
    width: 58px;
    height: 58px;
  }

  .buddy {
    width: 54px;
    height: 50px;
  }

  .buddy-star {
    width: 58px;
    height: 58px;
  }

  .panels {
    grid-template-columns: minmax(0, 1fr) 200px;
    gap: 8px;
  }

  .game,
  .scoreboard {
    padding: 10px;
    gap: 8px;
  }

  .answers {
    gap: 8px;
  }

  .answer-btn {
    padding: 12px 10px;
    font-size: 1.55rem;
  }
}

@media (max-height: 860px) {
  .page {
    gap: 8px;
  }

  .hero,
  .game,
  .scoreboard {
    padding: 10px;
    gap: 8px;
  }

  .question {
    font-size: clamp(1.6rem, 4.8vw, 2.6rem);
  }

  .count-stage {
    padding: 10px;
    gap: 8px;
  }

  .answer-btn {
    padding: 10px 8px;
    font-size: 1.35rem;
  }
}

@media (max-height: 940px) {
  .page {
    gap: 8px;
  }

  .hero {
    min-height: 86px;
    padding: 8px 12px;
  }

  .hero p {
    font-size: 0.84rem;
    line-height: 1.15;
  }

  .badge {
    padding: 6px 10px;
    font-size: 0.82rem;
  }

  h1 {
    font-size: clamp(1.4rem, 3vw, 2.2rem);
  }

  .sun-face {
    width: 56px;
    height: 56px;
  }

  .buddy {
    width: 50px;
    height: 46px;
  }

  .buddy-star {
    width: 52px;
    height: 52px;
  }

  .panels {
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) 210px;
  }

  .game,
  .scoreboard {
    padding: 8px;
    gap: 6px;
  }

  .story {
    padding: 8px 10px;
    font-size: 0.94rem;
  }

  .mode-chip {
    padding: 6px 9px;
    font-size: 0.85rem;
  }

  .count-stage {
    padding: 8px;
    gap: 6px;
  }

  .count-label {
    font-size: 0.84rem;
  }

  .count-icons {
    min-height: 26px;
    gap: 4px;
  }

  .count-icon {
    font-size: clamp(1.05rem, 2.4vw, 1.45rem);
  }

  .sum-bubble {
    min-width: 128px;
    padding: 6px 12px;
    font-size: 0.92rem;
  }

  .question {
    font-size: clamp(1.45rem, 4.1vw, 2.2rem);
    line-height: 1;
  }

  .answers {
    gap: 8px;
  }

  .answer-btn {
    padding: 10px 8px;
    font-size: clamp(1.25rem, 2.8vw, 1.7rem);
  }

  .status,
  .helper,
  .buddy-says {
    font-size: 0.86rem;
    line-height: 1.15;
  }

  .action-btn {
    padding: 8px 12px;
    font-size: 0.84rem;
  }

  .score-title {
    font-size: 1.02rem;
  }

  .score-box {
    padding: 8px;
  }

  .score-label {
    font-size: 0.78rem;
  }

  .score-value {
    font-size: 1.48rem;
    margin-top: 2px;
  }

  .progress-track .score-label {
    font-size: 0.76rem;
  }

  .progress-bar {
    height: 10px;
  }

  .mini-buddies,
  .tiny-links,
  .buddy-says {
    display: none;
  }

  .stars {
    font-size: 1.25rem;
    letter-spacing: 0.08em;
    min-height: 1.15em;
  }
}
