:root {
  color-scheme: light;
  --ink: #163340;
  --muted: #4c6570;
  --sky: #84d9f4;
  --sun: #ffd84d;
  --sun-deep: #f7a82b;
  --coral: #ff7b6e;
  --leaf: #58b66d;
  --blue: #5cc6e8;
  --violet: #6c62c7;
  --cream: #fff8dd;
  --white: #ffffff;
  --shadow: rgba(22, 51, 64, 0.18);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: ui-rounded, "Avenir Next", "Segoe UI", system-ui, sans-serif;
  background: var(--sky);
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 10px 24px var(--shadow);
  transform: translateY(-140%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.page-sky {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.65) 0 70px, transparent 71px),
    linear-gradient(180deg, #80daf4 0%, #bdeefb 56%, #b7df89 57%, #8ccf6e 100%);
}

.site-header,
.game-shell,
.site-footer {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 0 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand img {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  filter: drop-shadow(0 10px 14px rgba(133, 92, 18, 0.2));
}

.brand p {
  margin: 0 0 2px;
  color: #275566;
  font-size: 1rem;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  max-width: 13em;
  font-size: 2rem;
  line-height: 1;
}

.age-badge {
  display: grid;
  place-items: center;
  width: 84px;
  min-width: 84px;
  height: 84px;
  border: 4px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  color: var(--ink);
  background: var(--sun);
  box-shadow: 0 12px 26px var(--shadow);
}

.age-badge strong {
  display: block;
  font-size: 2.4rem;
  line-height: 0.85;
}

.age-badge span {
  font-size: 0.9rem;
  font-weight: 800;
}

.game-shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  align-items: start;
  padding: 12px 0 16px;
}

.playground,
.control-panel {
  min-width: 0;
}

.orbit {
  position: relative;
  min-height: 560px;
  height: calc(100svh - 190px);
  max-height: 720px;
  overflow: hidden;
  border: 5px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0) 40%),
    #7bdaf4;
  box-shadow: 0 22px 45px var(--shadow);
}

.orbit::before {
  content: "";
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: -8%;
  height: 28%;
  border-radius: 50% 50% 0 0;
  background: #7fc964;
  box-shadow: inset 0 24px 0 rgba(255, 255, 255, 0.16);
}

.sky-ribbon {
  position: absolute;
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.54);
}

.sky-ribbon-one {
  top: 18%;
  left: 8%;
  width: 32%;
}

.sky-ribbon-two {
  top: 34%;
  right: 10%;
  width: 24%;
}

.scene-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.sun-landing {
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: 360px;
  height: 80px;
  max-width: 68%;
  border-radius: 50%;
  background: rgba(255, 216, 77, 0.34);
  transform: translateX(-50%);
  filter: blur(1px);
}

.sun-wrap {
  position: absolute;
  left: 50%;
  bottom: 11%;
  z-index: 3;
  width: 220px;
  max-width: 38%;
  aspect-ratio: 1;
  transform: translateX(-50%) translateY(36px) scale(0.9);
  transition: transform 420ms cubic-bezier(0.2, 1.4, 0.4, 1), filter 260ms ease;
  filter: saturate(0.72) drop-shadow(0 24px 24px rgba(160, 94, 8, 0.18));
}

.sun-wrap img {
  display: block;
  width: 100%;
  height: 100%;
}

.orbit[data-stage="sunshine"] .sun-wrap,
.orbit[data-stage="julia"] .sun-wrap,
.orbit[data-stage="heyJules"] .sun-wrap {
  transform: translateX(-50%) translateY(-8px) scale(1.08);
  filter: saturate(1.05) drop-shadow(0 26px 28px rgba(160, 94, 8, 0.2));
}

.orbit[data-stage="done"] .sun-wrap {
  transform: translateX(-50%) translateY(-18px) scale(1.18);
  filter: saturate(1.18) drop-shadow(0 30px 32px rgba(160, 94, 8, 0.24));
}

.orbit[data-son-beams="1"] .sun-wrap { transform: translateX(-50%) translateY(28px) scale(0.92); }
.orbit[data-son-beams="2"] .sun-wrap { transform: translateX(-50%) translateY(18px) scale(0.98); }
.orbit[data-son-beams="3"] .sun-wrap { transform: translateX(-50%) translateY(8px) scale(1.03); }
.orbit[data-son-beams="4"] .sun-wrap { transform: translateX(-50%) translateY(-2px) scale(1.08); }
.orbit[data-son-beams="5"] .sun-wrap { transform: translateX(-50%) translateY(-12px) scale(1.12); }
.orbit[data-son-beams="6"] .sun-wrap { transform: translateX(-50%) translateY(-18px) scale(1.16); }

.finish-scene,
.chorus-scene,
.sunshine-scene,
.cloud-field,
.letter-garden {
  position: absolute;
  inset: 0;
}

.finish-scene {
  display: grid;
  place-items: center;
  padding-top: 36%;
  color: #356270;
  font-weight: 900;
  text-transform: uppercase;
}

.finish-burst {
  position: absolute;
  left: 50%;
  top: 45%;
  width: 230px;
  max-width: 54%;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    repeating-conic-gradient(from 12deg, rgba(255, 216, 77, 0.72) 0 12deg, transparent 12deg 24deg),
    radial-gradient(circle, rgba(255, 255, 255, 0.5) 0 46%, transparent 47%);
  transform: translate(-50%, -50%);
  opacity: 0.55;
}

.finish-burst {
  animation: spin 7s linear infinite;
  opacity: 0.82;
}

.sunshine-scene {
  pointer-events: none;
}

.sun-ray {
  position: absolute;
  width: 26%;
  height: 26%;
  border-radius: 999px;
  opacity: 0.6;
  transform: scale(0.86);
  transition: transform 180ms ease, opacity 180ms ease, box-shadow 180ms ease;
}

.sun-ray.active {
  opacity: 1;
  transform: scale(1.12);
  box-shadow: 0 0 32px rgba(255, 255, 255, 0.72);
}

.ray-gold {
  top: 12%;
  left: 16%;
  background: var(--sun);
}

.ray-coral {
  top: 16%;
  right: 14%;
  background: var(--coral);
}

.ray-blue {
  left: 12%;
  bottom: 22%;
  background: var(--blue);
}

.ray-green {
  right: 15%;
  bottom: 18%;
  background: var(--leaf);
}

.quest-cloud {
  position: absolute;
  display: grid;
  place-items: center;
  width: 142px;
  height: 72px;
  border: 0;
  border-radius: 999px;
  color: #305060;
  font-weight: 900;
  background: var(--white);
  box-shadow: 0 12px 0 rgba(255, 255, 255, 0.58), 0 16px 26px var(--shadow);
  cursor: pointer;
  animation: drift 2.8s ease-in-out infinite alternate;
  transition: transform 180ms ease, opacity 180ms ease, background 180ms ease;
}

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

.quest-cloud::before {
  left: 24px;
  width: 58px;
  height: 58px;
}

.quest-cloud::after {
  right: 22px;
  width: 70px;
  height: 70px;
}

.quest-cloud span {
  position: relative;
  z-index: 1;
}

.quest-cloud:hover,
.quest-cloud:focus-visible {
  transform: translateY(-7px) rotate(-2deg);
}

.quest-cloud.cleared {
  pointer-events: none;
  color: #714800;
  background: var(--sun);
  opacity: 0.92;
  transform: scale(0.82) rotate(8deg);
}

.letter-garden {
  display: grid;
  grid-template-columns: repeat(3, minmax(70px, 116px));
  gap: 16px;
  align-content: center;
  justify-content: center;
  padding: 8% 5% 18%;
}

.letter-bud {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 5px solid rgba(255, 255, 255, 0.78);
  border-radius: 50% 50% 45% 45%;
  color: var(--ink);
  background: var(--sun);
  box-shadow: 0 12px 20px var(--shadow), inset 0 -10px 0 rgba(160, 94, 8, 0.1);
  cursor: pointer;
  font-size: 2rem;
  font-weight: 900;
  transform: rotate(calc((var(--bud-index) - 4) * 3deg));
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.letter-bud:nth-child(3n + 1) {
  background: #fff18a;
}

.letter-bud:nth-child(3n + 2) {
  background: #ffb7ad;
}

.letter-bud:nth-child(3n) {
  background: #ace3b5;
}

.letter-bud:hover,
.letter-bud:focus-visible {
  transform: translateY(-6px) rotate(calc((var(--bud-index) - 4) * 3deg));
}

.letter-bud.picked {
  color: var(--white);
  background: var(--violet);
  opacity: 0.82;
}

.chorus-scene {
  display: grid;
  place-items: center;
  padding: 12% 7% 20%;
}

.chorus-orbit {
  position: relative;
  width: min(450px, 76%);
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 216, 77, 0.26);
}

.chorus-orbit span {
  position: absolute;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  padding: 8px;
  border: 5px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 14px 22px var(--shadow);
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
}

.chorus-orbit span:nth-child(1) { left: 50%; top: -8%; transform: translateX(-50%); background: var(--sun); }
.chorus-orbit span:nth-child(2) { right: -6%; top: 50%; transform: translateY(-50%); background: var(--coral); }
.chorus-orbit span:nth-child(3) { left: 50%; bottom: -8%; transform: translateX(-50%); background: #ace3b5; }
.chorus-orbit span:nth-child(4) {
  left: -10%;
  top: 50%;
  width: 118px;
  transform: translateY(-50%);
  background: #b9eafe;
}

#chorusPrompt {
  position: absolute;
  left: 50%;
  bottom: 11%;
  width: min(520px, 82%);
  margin: 0;
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 22px var(--shadow);
  font-size: 1.1rem;
  font-weight: 900;
  text-align: center;
  transform: translateX(-50%);
}

.control-panel {
  align-self: start;
  display: flex;
  flex-direction: column;
  min-height: 560px;
  height: auto;
  padding: 24px;
  border: 5px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 248, 221, 0.95);
  box-shadow: 0 22px 45px var(--shadow);
}

.progress-shell {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}

.progress-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #d7d7ca;
}

.progress-dot.active {
  background: var(--coral);
  box-shadow: 0 0 0 5px rgba(255, 123, 110, 0.16);
}

.control-panel h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.05;
}

.control-panel p {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.5;
}

.quest-meter {
  width: 100%;
  height: 18px;
  margin-top: 24px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(22, 51, 64, 0.13);
}

.quest-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sun), var(--coral));
  transition: width 260ms ease;
}

.status-line {
  min-height: 58px;
  font-weight: 800;
}

.stage-controls {
  margin-top: 16px;
  padding-top: 18px;
  border-top: 2px dashed rgba(22, 51, 64, 0.18);
}

.panel-label {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 900;
  text-transform: uppercase;
}

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

.choice-button,
.primary-action,
.secondary-action {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 900;
  background: var(--white);
  box-shadow: 0 5px 0 rgba(22, 51, 64, 0.14);
  cursor: pointer;
}

.choice-button:hover,
.primary-action:hover,
.secondary-action:hover {
  transform: translateY(-2px);
}

.choice-button:active,
.primary-action:active,
.secondary-action:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(22, 51, 64, 0.16);
}

.choice-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.primary-action {
  color: var(--white);
  background: var(--violet);
}

.primary-action {
  width: 100%;
  margin-bottom: 10px;
}

.ray-choice.gold { background: var(--sun); }
.ray-choice.coral { background: var(--coral); color: var(--white); }
.ray-choice.blue { background: var(--blue); }
.ray-choice.green { background: var(--leaf); color: var(--white); }

.token-choice.na { background: var(--sun); }
.token-choice.hey-jules { background: var(--coral); color: var(--white); }

.actions {
  margin-top: auto;
  padding-top: 20px;
}

.secondary-action {
  width: 100%;
}

.quest-cloud:focus-visible,
.letter-bud:focus-visible,
.choice-button:focus-visible,
.primary-action:focus-visible,
.secondary-action:focus-visible {
  outline: 4px solid rgba(108, 98, 199, 0.45);
  outline-offset: 3px;
}

.shake {
  animation: shake 280ms linear;
}

.site-footer {
  position: relative;
  z-index: 2;
  padding: 4px 0 18px;
  color: rgba(22, 51, 64, 0.72);
  font-size: 0.95rem;
  font-weight: 800;
  text-align: center;
}

@keyframes drift {
  from { margin-left: -10px; margin-top: 0; }
  to { margin-left: 12px; margin-top: -10px; }
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(1turn); }
}

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

@media (min-width: 900px) {
  .brand h1 {
    font-size: 2.8rem;
  }
}

@media (max-width: 900px) {
  .site-header {
    align-items: flex-start;
  }

  .brand h1 {
    font-size: 1.75rem;
  }

  .age-badge {
    width: 70px;
    min-width: 70px;
    height: 70px;
  }

  .age-badge strong {
    font-size: 2rem;
  }

  .game-shell {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .orbit,
  .control-panel {
    min-height: auto;
    height: auto;
    max-height: none;
  }

  .orbit {
    aspect-ratio: 1 / 1;
  }

  .control-panel {
    padding: 20px;
  }

  .quest-cloud {
    width: 118px;
    height: 62px;
  }

  .quest-cloud::before {
    left: 20px;
    width: 48px;
    height: 48px;
  }

  .quest-cloud::after {
    right: 18px;
    width: 58px;
    height: 58px;
  }
}

@media (max-width: 520px) {
  .site-header,
  .game-shell,
  .site-footer {
    width: min(100% - 20px, 1160px);
  }

  .brand {
    gap: 10px;
  }

  .brand img {
    width: 52px;
    height: 52px;
  }

  .brand h1 {
    font-size: 1.35rem;
    line-height: 1.08;
  }

  .brand p {
    font-size: 0.92rem;
  }

  .age-badge {
    width: 58px;
    min-width: 58px;
    height: 58px;
    border-width: 3px;
  }

  .age-badge strong {
    font-size: 1.65rem;
  }

  .age-badge span {
    font-size: 0.78rem;
  }

  .orbit {
    border-width: 4px;
  }

  .sun-wrap {
    max-width: 42%;
  }

  .finish-scene {
    padding-top: 42%;
  }

  .quest-cloud {
    width: 90px;
    height: 48px;
    font-size: 0.86rem;
  }

  .quest-cloud::before {
    bottom: 20px;
    left: 16px;
    width: 38px;
    height: 38px;
  }

  .quest-cloud::after {
    bottom: 20px;
    right: 14px;
    width: 44px;
    height: 44px;
  }

  .letter-garden {
    grid-template-columns: repeat(3, minmax(62px, 88px));
    gap: 10px;
    padding-top: 6%;
  }

  .letter-bud {
    font-size: 1.55rem;
  }

  .chorus-orbit span {
    width: 70px;
    height: 70px;
    font-size: 0.86rem;
  }

  #chorusPrompt {
    bottom: 8%;
    font-size: 0.9rem;
  }

  .control-panel h2 {
    font-size: 1.55rem;
  }

  .control-panel p {
    font-size: 1rem;
  }
}

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