:root {
  --sky: #6ec8ff;
  --sun: #ffd54d;
  --berry: #ff6b86;
  --leaf: #6ed28e;
  --orange: #ff9c43;
  --grape: #7f68ff;
  --ink: #24324f;
  --soft-ink: #6b7690;
  --cream: #fff7df;
  --white: #ffffff;
  --line: rgba(36, 50, 79, 0.12);
  --shadow: 0 16px 34px rgba(34, 59, 105, 0.18);
  --pop-shadow: 0 10px 0 rgba(36, 50, 79, 0.08), 0 22px 36px rgba(34, 59, 105, 0.16);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: #9edfff;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100dvh;
}

.screen {
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.home-screen {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, #7ed2ff 0%, #ffe49c 52%, #ffc4d6 100%);
}

.home-screen::before,
.home-screen::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.home-screen::before {
  inset: auto -5vw -14vh -5vw;
  height: 28vh;
  background:
    radial-gradient(65% 110% at 50% 0%, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0) 70%),
    linear-gradient(180deg, #8bdd92, #5fcf7f);
  border-radius: 50% 50% 0 0;
}

.home-screen::after {
  right: clamp(18px, 4vw, 54px);
  top: clamp(16px, 4vh, 34px);
  width: 102px;
  height: 102px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff6bf 0 18%, var(--sun) 20% 68%, #ffbb35 70%);
  box-shadow: 0 0 0 14px rgba(255, 255, 255, 0.22);
}

.home-hero,
.category-grid,
.question-topbar,
.play-layout {
  position: relative;
  z-index: 1;
}

.home-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto 14px;
}

.home-hero h1 {
  width: fit-content;
  margin: 0;
  padding: 4px 18px 8px;
  border-radius: 28px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.64);
  box-shadow: 0 7px 0 rgba(255, 255, 255, 0.38);
  font-size: clamp(42px, 5.2vw, 68px);
  line-height: 1;
  letter-spacing: 0;
}

.home-hero p {
  margin: 10px 0 0 12px;
  color: #375070;
  font-size: clamp(19px, 2vw, 26px);
  font-weight: 900;
}

.parent-dot {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  color: rgba(36, 50, 79, 0.72);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 8px 0 rgba(36, 50, 79, 0.08);
  font-size: 24px;
  font-weight: 1000;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(126px, 1fr));
  gap: clamp(12px, 1.4vw, 18px);
  max-width: 1180px;
  margin: 0 auto;
}

.category-card {
  position: relative;
  min-height: clamp(178px, 24vh, 212px);
  padding: 13px 12px 14px;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  color: var(--ink);
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.88) 0 15%, transparent 16%),
    linear-gradient(180deg, color-mix(in srgb, var(--card-color) 20%, #fff) 0%, #fff 54%, color-mix(in srgb, var(--card-color) 25%, #fff) 100%);
  box-shadow: var(--pop-shadow);
  display: grid;
  grid-template-rows: 1fr auto auto;
  place-items: center;
  gap: 5px;
}

.category-card::after {
  content: "";
  position: absolute;
  right: -22px;
  bottom: -22px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--card-color) 54%, #fff);
  opacity: 0.9;
}

.category-card:active,
.choice-button:active,
.back-button:active,
.sound-button:active {
  transform: translateY(4px) scale(0.98);
}

.category-blob {
  position: relative;
  z-index: 1;
  width: min(142px, 68%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.category-title {
  position: relative;
  z-index: 1;
  width: 100%;
  text-align: center;
  font-size: clamp(18px, 1.8vw, 23px);
  font-weight: 1000;
  line-height: 1.05;
}

.category-progress {
  position: relative;
  z-index: 1;
  min-width: 62px;
  padding: 4px 12px 5px;
  border-radius: 999px;
  color: #fff;
  background: var(--card-color);
  box-shadow: inset 0 -3px 0 rgba(36, 50, 79, 0.12);
  font-size: 17px;
  font-weight: 1000;
}

.visual {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 10px 10px rgba(34, 59, 105, 0.14));
}

.question-screen {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, color-mix(in srgb, var(--category-color) 42%, #ffffff) 0%, #fff2c8 55%, #ffe0ec 100%);
}

.question-screen::before {
  content: "";
  position: absolute;
  inset: auto -5vw -16vh -5vw;
  height: 30vh;
  border-radius: 50% 50% 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(255, 244, 198, 0.98));
}

.question-topbar {
  height: 62px;
  display: grid;
  grid-template-columns: 72px 1fr 118px;
  align-items: center;
  gap: 14px;
  max-width: 1180px;
  margin: 0 auto 12px;
}

.back-button,
.sound-button {
  height: 56px;
  border: 3px solid rgba(255, 255, 255, 0.84);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 0 rgba(36, 50, 79, 0.08);
  font-weight: 1000;
}

.back-button {
  font-size: 43px;
  line-height: 1;
}

.sound-button {
  font-size: 18px;
}

.progress-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.dot {
  width: 15px;
  height: 15px;
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
}

.dot.active {
  background: var(--category-color);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.45);
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(350px, 0.88fr) minmax(430px, 1.12fr);
  gap: clamp(14px, 2vw, 24px);
  max-width: 1180px;
  height: calc(100dvh - 106px);
  margin: 0 auto;
}

.prompt-panel,
.choice-panel {
  border: 4px solid rgba(255, 255, 255, 0.82);
  border-radius: 34px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow);
}

.prompt-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  place-items: center;
  padding: clamp(18px, 2.4vw, 28px);
}

.prompt-panel::before {
  content: "";
  position: absolute;
  inset: 18% 9% 14%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0) 68%);
}

.prompt-bubble {
  position: relative;
  z-index: 1;
  max-width: 100%;
  padding: 14px 24px 16px;
  border-radius: 30px;
  color: #fff;
  background: var(--category-color);
  box-shadow: inset 0 -5px 0 rgba(36, 50, 79, 0.12), 0 10px 0 rgba(36, 50, 79, 0.07);
  font-size: clamp(28px, 3.5vw, 44px);
  font-weight: 1000;
  line-height: 1.08;
  text-align: center;
}

.target-stage {
  position: relative;
  z-index: 1;
  width: min(88%, 380px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.progress-label {
  position: relative;
  z-index: 1;
  min-width: 86px;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--soft-ink);
  background: rgba(255, 255, 255, 0.76);
  text-align: center;
  font-size: 22px;
  font-weight: 1000;
}

.choice-panel {
  padding: clamp(16px, 2.2vw, 24px);
  display: grid;
  grid-template-columns: repeat(2, minmax(154px, 1fr));
  gap: clamp(14px, 1.8vw, 20px);
}

.choice-button {
  position: relative;
  min-height: 172px;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  background:
    radial-gradient(circle at 26% 20%, rgba(255, 255, 255, 0.92) 0 13%, transparent 14%),
    linear-gradient(180deg, #fff 0%, #fff7df 100%);
  box-shadow: var(--pop-shadow);
  display: grid;
  place-items: center;
  padding: clamp(12px, 1.6vw, 18px);
}

.choice-button::after {
  content: "";
  position: absolute;
  inset: auto 18% 12px;
  height: 10px;
  border-radius: 999px;
  background: rgba(36, 50, 79, 0.08);
}

.choice-button .visual {
  position: relative;
  z-index: 1;
}

.choice-button.is-correct {
  animation: correctBounce 0.8s ease both;
  box-shadow: 0 0 0 10px rgba(110, 210, 142, 0.45), var(--pop-shadow);
}

.choice-button.is-wrong {
  animation: gentleShake 0.42s ease both;
}

.complete-screen,
.settings-screen {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--category-color, #8bd7ff), #fff4c8 58%, #ffc4d6);
}

.complete-card,
.settings-card {
  width: min(680px, 92vw);
  padding: 34px;
  border: 4px solid rgba(255, 255, 255, 0.82);
  border-radius: 34px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  text-align: center;
}

.medal {
  width: 118px;
  height: 118px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--sun);
  box-shadow: inset 0 -7px 0 rgba(36, 50, 79, 0.12), 0 12px 0 rgba(255, 255, 255, 0.5);
  font-size: 70px;
}

.complete-card h1,
.settings-card h1 {
  margin: 0 0 12px;
  font-size: 46px;
  line-height: 1.1;
}

.complete-card p {
  margin: 0 0 22px;
  color: var(--soft-ink);
  font-size: 28px;
  font-weight: 900;
}

.complete-actions,
.settings-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.complete-card button,
.settings-actions button {
  min-height: 60px;
  padding: 0 24px;
  border-radius: 999px;
  color: #fff;
  background: var(--berry);
  box-shadow: inset 0 -5px 0 rgba(36, 50, 79, 0.12), 0 8px 0 rgba(36, 50, 79, 0.08);
  font-size: 21px;
  font-weight: 1000;
}

.settings-card {
  display: grid;
  gap: 18px;
  text-align: left;
}

.settings-card label {
  display: grid;
  gap: 8px;
  font-size: 21px;
  font-weight: 900;
}

.settings-card input:not([type]),
.settings-card input[type="text"] {
  height: 56px;
  border: 4px solid #dbe6ff;
  border-radius: 18px;
  padding: 0 16px;
  color: var(--ink);
  background: #fff;
  font-size: 23px;
}

.toggle-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.toggle-row input {
  width: 34px;
  height: 34px;
}

.settings-actions {
  justify-content: flex-start;
}

.settings-actions button {
  background: var(--grape);
  font-size: 20px;
}

@keyframes correctBounce {
  0% { transform: scale(1); }
  38% { transform: scale(1.12) rotate(-2deg); }
  68% { transform: scale(0.98) rotate(1deg); }
  100% { transform: scale(1.04); }
}

@keyframes gentleShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-4px); }
}

@media (max-width: 900px), (orientation: portrait) {
  body {
    overflow: auto;
  }

  .screen {
    min-height: 100svh;
  }

  .home-hero {
    align-items: start;
  }

  .category-grid {
    grid-template-columns: repeat(2, minmax(132px, 1fr));
  }

  .play-layout {
    height: auto;
    grid-template-columns: 1fr;
  }

  .choice-panel {
    grid-template-columns: repeat(2, minmax(132px, 1fr));
  }
}

@media (max-height: 690px) and (orientation: landscape) {
  .home-hero {
    margin-bottom: 10px;
  }

  .home-hero h1 {
    font-size: 42px;
  }

  .home-hero p {
    font-size: 18px;
  }

  .category-card {
    min-height: 154px;
  }

  .question-topbar {
    height: 54px;
  }

  .back-button,
  .sound-button {
    height: 50px;
  }

  .play-layout {
    height: calc(100dvh - 92px);
  }
}

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