:root {
  --sun: #ffd24d;
  --melon: #ff7a59;
  --berry: #ff4f8b;
  --sky: #61c7ff;
  --mint: #58d68d;
  --ink: #243047;
  --paper: #fff9e8;
  --cloud: #ffffff;
  --shadow: rgba(36, 48, 71, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: ui-rounded, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 255, 255, 0.75) 0 11%, transparent 12%),
    radial-gradient(circle at 88% 14%, rgba(255, 122, 89, 0.22) 0 10%, transparent 11%),
    linear-gradient(160deg, #78d7ff 0%, #fff0a8 48%, #ffb1cb 100%);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  min-height: 100%;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.game-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(100%, 920px);
  height: calc(100vh - max(28px, env(safe-area-inset-top)) - max(28px, env(safe-area-inset-bottom)));
  min-height: 620px;
  margin: 0 auto;
  padding: 18px;
  border: 5px solid rgba(255, 255, 255, 0.78);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.46)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 16px, transparent 16px 32px);
  box-shadow: 0 22px 60px rgba(36, 48, 71, 0.2);
}

.top-bar,
.settings-head,
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 2px;
  color: #5a6781;
  font-size: 13px;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  line-height: 1;
}

h1 {
  font-size: clamp(31px, 7vw, 56px);
}

h2 {
  font-size: 30px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--ink);
  background: var(--cloud);
  box-shadow: 0 8px 0 rgba(36, 48, 71, 0.12);
  font-size: 30px;
}

.icon-button:active,
.primary-button:active,
.answer-button:active {
  transform: translateY(3px);
}

.stage-wrap {
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto auto auto;
  gap: 14px;
  min-height: 0;
}

.pill,
.streak {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-weight: 900;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 16px 0 0 var(--sun), 32px 0 0 var(--berry);
}

.streak-track {
  width: 86px;
  height: 12px;
  border-radius: 999px;
  background: rgba(36, 48, 71, 0.12);
  overflow: hidden;
}

.streak-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--melon), var(--sun));
  transition: width 220ms ease;
}

.stage {
  position: relative;
  min-height: 0;
  border-radius: 26px;
  background:
    linear-gradient(#fffdf4, #fff5cc),
    radial-gradient(circle at 50% 100%, rgba(88, 214, 141, 0.18), transparent 55%);
  box-shadow: inset 0 -12px 0 rgba(255, 210, 77, 0.22), 0 14px 30px rgba(36, 48, 71, 0.12);
  overflow: hidden;
}

.stage::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 24%;
  background:
    radial-gradient(ellipse at 12% 100%, rgba(88, 214, 141, 0.45), transparent 62%),
    radial-gradient(ellipse at 68% 100%, rgba(97, 199, 255, 0.28), transparent 58%);
}

.object-field {
  position: absolute;
  inset: 18px;
}

.game-object {
  position: absolute;
  display: grid;
  place-items: center;
  width: clamp(48px, 10vw, 76px);
  aspect-ratio: 1;
  border-radius: 50%;
  font-size: clamp(31px, 7vw, 48px);
  filter: drop-shadow(0 9px 5px rgba(36, 48, 71, 0.14));
  transform: translate(-50%, -50%) scale(0);
  animation: popIn 340ms cubic-bezier(0.2, 1.6, 0.34, 1) forwards;
}

.game-object.counting {
  animation: countPulse 700ms ease both;
  z-index: 3;
}

.game-object.correct {
  animation: celebratePulse 500ms ease-in-out 2;
}

.curtain {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(113, 213, 255, 0.42);
  backdrop-filter: blur(7px);
  transition: opacity 260ms ease, transform 260ms ease;
  z-index: 5;
}

.curtain.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.04);
}

.curtain p {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 14px 22px;
  border-radius: 999px;
  background: var(--cloud);
  box-shadow: 0 10px 0 rgba(36, 48, 71, 0.12);
  font-size: clamp(22px, 5vw, 34px);
  font-weight: 1000;
}

.curtain-cloud {
  position: absolute;
  width: 42%;
  aspect-ratio: 2.2;
  border-radius: 999px;
  background: var(--cloud);
  opacity: 0.93;
  box-shadow: 0 12px 0 rgba(255, 255, 255, 0.42);
}

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

.curtain-cloud::before {
  left: 12%;
  width: 36%;
  aspect-ratio: 1;
}

.curtain-cloud::after {
  right: 12%;
  width: 46%;
  aspect-ratio: 1;
}

.cloud-a {
  top: 17%;
  left: 4%;
}

.cloud-b {
  top: 36%;
  right: 5%;
}

.cloud-c {
  bottom: 15%;
  left: 22%;
}

.prompt {
  min-height: 36px;
  margin: 0;
  text-align: center;
  font-size: clamp(20px, 4.8vw, 30px);
  font-weight: 1000;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-height: 92px;
}

.answer-button,
.primary-button {
  border-radius: 22px;
  color: var(--ink);
  font-weight: 1000;
  box-shadow: 0 9px 0 rgba(36, 48, 71, 0.15);
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 160ms ease;
}

.answer-button {
  min-height: 86px;
  background: var(--cloud);
  font-size: clamp(34px, 10vw, 58px);
}

.answer-button:nth-child(1) {
  border-bottom: 8px solid var(--sky);
}

.answer-button:nth-child(2) {
  border-bottom: 8px solid var(--sun);
}

.answer-button:nth-child(3) {
  border-bottom: 8px solid var(--berry);
}

.answer-button:disabled {
  cursor: default;
  opacity: 0.62;
}

.answer-button.wrong {
  animation: nope 340ms ease;
  background: #ffe1e7;
}

.answer-button.right {
  background: #dbffdf;
}

.primary-button {
  min-height: 58px;
  padding: 0 26px;
  background: linear-gradient(180deg, #fff176, var(--sun));
  font-size: 24px;
}

.primary-button.hidden {
  display: none;
}

.settings-panel,
.reward-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(36, 48, 71, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 20;
}

.settings-panel.open,
.reward-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.settings-card,
.reward-card {
  width: min(100%, 520px);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 22px 70px rgba(36, 48, 71, 0.34);
}

.settings-card {
  display: grid;
  gap: 24px;
  padding: 22px;
}

.control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  font-size: 20px;
  font-weight: 900;
}

.control strong {
  color: #d94870;
}

.control input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--melon);
}

.control small {
  grid-column: 1 / -1;
  color: #667088;
  font-size: 15px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 20px;
  font-weight: 900;
}

.toggle input {
  position: absolute;
  opacity: 0;
}

.toggle-ui {
  position: relative;
  width: 64px;
  height: 36px;
  border-radius: 999px;
  background: #ccd4e2;
  transition: background 180ms ease;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 5px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--cloud);
  transition: transform 180ms ease;
}

.toggle input:checked + .toggle-ui {
  background: var(--mint);
}

.toggle input:checked + .toggle-ui::after {
  transform: translateX(28px);
}

.reward-card {
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 28px;
  text-align: center;
  animation: rewardIn 440ms cubic-bezier(0.2, 1.45, 0.3, 1) both;
}

.reward-card p {
  margin: 0 0 8px;
  color: #5a6781;
  font-size: 20px;
  font-weight: 800;
}

.sticker-burst {
  display: grid;
  place-items: center;
  width: 132px;
  aspect-ratio: 1;
  border-radius: 34px;
  background:
    radial-gradient(circle at 30% 24%, #fff 0 10%, transparent 11%),
    linear-gradient(135deg, #ffef75, #ff8fb3);
  box-shadow: 0 14px 0 rgba(36, 48, 71, 0.13);
  font-size: 72px;
  animation: stickerDance 860ms ease-in-out infinite alternate;
}

.confetti-piece {
  position: absolute;
  top: 42%;
  left: 50%;
  width: 11px;
  height: 18px;
  border-radius: 4px;
  background: var(--sun);
  z-index: 8;
  animation: confettiFly 820ms ease-out forwards;
}

@keyframes popIn {
  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes countPulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }

  45% {
    transform: translate(-50%, -50%) scale(1.34);
  }
}

@keyframes celebratePulse {
  50% {
    transform: translate(-50%, -50%) scale(1.22) rotate(6deg);
  }
}

@keyframes nope {
  25% {
    transform: translateX(-8px);
  }

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

@keyframes confettiFly {
  to {
    transform: translate(var(--x), var(--y)) rotate(420deg);
    opacity: 0;
  }
}

@keyframes rewardIn {
  from {
    transform: translateY(24px) scale(0.86);
    opacity: 0;
  }
}

@keyframes stickerDance {
  to {
    transform: rotate(-4deg) scale(1.04);
  }
}

@media (max-width: 620px) {
  .app {
    padding: 10px;
  }

  .game-shell {
    height: calc(100vh - 20px);
    min-height: 0;
    padding: 12px;
    border-width: 3px;
    border-radius: 22px;
  }

  .top-bar {
    align-items: flex-start;
  }

  .icon-button {
    width: 46px;
    height: 46px;
  }

  .stage-wrap {
    grid-template-rows: auto minmax(220px, 1fr) auto auto auto;
    gap: 10px;
  }

  .status-row {
    align-items: stretch;
  }

  .pill,
  .streak {
    flex: 1;
    justify-content: center;
  }

  .answer-grid {
    gap: 9px;
    min-height: 78px;
  }

  .answer-button {
    min-height: 74px;
    border-radius: 18px;
  }
}

@media (max-height: 680px) and (orientation: landscape) {
  .game-shell {
    min-height: 0;
    height: calc(100vh - 20px);
  }

  h1 {
    font-size: 32px;
  }

  .stage-wrap {
    grid-template-rows: auto minmax(190px, 1fr) auto auto;
  }

  .primary-button {
    min-height: 48px;
  }

  .answer-button {
    min-height: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
