:root {
  --ink: #24313f;
  --muted: #657181;
  --paper: #fffaf2;
  --panel: #ffffff;
  --accent: #2f8f83;
  --accent-strong: #176f69;
  --sun: #ffd166;
  --line: #d9e1df;
  --shadow: 0 22px 60px rgba(36, 49, 63, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 209, 102, 0.42), transparent 26rem),
    radial-gradient(circle at 88% 18%, rgba(112, 193, 179, 0.34), transparent 24rem),
    linear-gradient(135deg, #fff8e8 0%, #e7f6f2 56%, #f7ecff 100%);
}

button {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow,
.level-kicker {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.65rem, 4vw, 3.1rem);
}

h2 {
  font-size: clamp(1.35rem, 3vw, 2.4rem);
}

.level-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.level-tab {
  min-height: 48px;
  padding: 0 18px;
  border: 2px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(36, 49, 63, 0.08);
}

.level-tab.active {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.stage {
  min-height: 0;
  padding: clamp(18px, 3vw, 34px);
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto;
  gap: clamp(18px, 4vw, 34px);
}

.prompt-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.score-pill {
  min-width: 104px;
  min-height: 54px;
  padding: 8px 16px;
  border-radius: 18px;
  background: var(--sun);
  color: #674c00;
  display: grid;
  place-items: center;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(151, 111, 0, 0.16);
}

.score-pill span:first-child {
  line-height: 1;
  font-size: 1.35rem;
}

.score-pill span:last-child {
  font-size: 0.8rem;
}

.buddy-button {
  width: min(440px, 100%);
  min-height: 250px;
  margin: 0 auto;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  position: relative;
  touch-action: manipulation;
}

.buddy-button:focus-visible,
.choice:focus-visible,
.level-tab:focus-visible {
  outline: 4px solid #1b84ff;
  outline-offset: 4px;
}

.speech-bubble {
  position: absolute;
  top: 0;
  right: 10%;
  min-width: 120px;
  max-width: 210px;
  padding: 12px 16px;
  border-radius: 22px;
  background: white;
  color: var(--accent-strong);
  font-size: clamp(1rem, 3vw, 1.45rem);
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(36, 49, 63, 0.14);
  z-index: 2;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: 24px;
  bottom: -12px;
  width: 24px;
  height: 24px;
  background: white;
  transform: rotate(45deg);
}

.buddy {
  width: 210px;
  height: 228px;
  position: relative;
  display: block;
  transform-origin: 50% 85%;
}

.buddy.talk {
  animation: bounce 420ms ease;
}

.buddy.happy {
  animation: wiggle 650ms ease;
}

.buddy-face,
.buddy-body,
.buddy-ear {
  position: absolute;
  display: block;
}

.buddy-face {
  width: 180px;
  height: 154px;
  left: 15px;
  top: 22px;
  border: 5px solid #5a4a38;
  border-radius: 48% 48% 44% 44%;
  background: #ffcf7f;
  z-index: 1;
}

.buddy-body {
  width: 128px;
  height: 88px;
  left: 41px;
  bottom: 0;
  border: 5px solid #5a4a38;
  border-radius: 44px 44px 38px 38px;
  background: #70c1b3;
}

.buddy-ear {
  width: 70px;
  height: 72px;
  top: 0;
  border: 5px solid #5a4a38;
  border-radius: 50%;
  background: #ffb45f;
}

.buddy-ear.left {
  left: 4px;
}

.buddy-ear.right {
  right: 4px;
}

.buddy-eye,
.buddy-cheek,
.buddy-mouth {
  position: absolute;
  display: block;
}

.buddy-eye {
  width: 18px;
  height: 24px;
  top: 58px;
  border-radius: 50%;
  background: #263238;
}

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

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

.buddy-cheek {
  width: 24px;
  height: 14px;
  top: 92px;
  border-radius: 50%;
  background: #ff8f86;
  opacity: 0.65;
}

.buddy-cheek.left {
  left: 36px;
}

.buddy-cheek.right {
  right: 36px;
}

.buddy-mouth {
  width: 42px;
  height: 22px;
  left: 69px;
  top: 92px;
  border-bottom: 6px solid #5a4a38;
  border-radius: 0 0 42px 42px;
}

.buddy.sad .buddy-mouth {
  top: 104px;
  border-top: 6px solid #5a4a38;
  border-bottom: 0;
  border-radius: 42px 42px 0 0;
}

.choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(12px, 2.4vw, 22px);
}

.choice {
  min-height: clamp(96px, 16vw, 154px);
  border: 5px solid rgba(36, 49, 63, 0.18);
  border-radius: 24px;
  cursor: pointer;
  box-shadow: 0 16px 32px rgba(36, 49, 63, 0.13);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.choice:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 38px rgba(36, 49, 63, 0.18);
}

.choice.correct {
  border-color: #1f9d55;
}

.choice.wrong {
  border-color: #d93025;
  animation: shake 260ms ease;
}

.picture-choice,
.number-choice {
  display: grid;
  place-items: center;
  line-height: 1;
  font-weight: 900;
}

.picture-choice {
  font-size: clamp(3.5rem, 10vw, 6.4rem);
  text-shadow: 0 6px 14px rgba(36, 49, 63, 0.18);
}

.number-choice {
  color: white;
  font-size: clamp(3rem, 9vw, 6rem);
  text-shadow: 0 5px 0 rgba(36, 49, 63, 0.18);
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  45% {
    transform: translateY(-8px) scale(1.03);
  }
}

@keyframes wiggle {
  0%,
  100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-5deg);
  }
  55% {
    transform: rotate(5deg);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 560px);
    padding: 12px 0;
  }

  .topbar,
  .prompt-row {
    align-items: stretch;
    flex-direction: column;
  }

  .level-tabs {
    justify-content: stretch;
  }

  .level-tab {
    flex: 1 1 30%;
    padding: 0 10px;
  }

  .stage {
    border-radius: 20px;
  }

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

  .speech-bubble {
    right: 0;
  }
}
