:root {
  color-scheme: dark;
  --bg: #11111b;
  --card: #1b1a2a;
  --text: #f7f1ed;
  --muted: #b7afc4;
  --accent: #e8b9d0;
  --line: #454054;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, #39304f 0%, transparent 48%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.question-open {
  overflow: hidden;
}

.page {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 16px;
}

.unlock-card,
.birthday-screen,
.question-screen,
.message-screen {
  width: min(100%, 520px);
  flex: 0 0 auto;
  margin: auto 0;
  text-align: center;
  padding: 36px 25px;
  border: 1px solid #ffffff17;
  border-radius: 26px;
  background: #1b1a2add;
  box-shadow: 0 24px 80px #0005;
}

.moon {
  color: var(--accent);
  font-size: 45px;
  line-height: 1;
  margin-bottom: 22px;
}

.moon-large {
  font-size: 60px;
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.17em;
  font-size: 10px;
  line-height: 1.8;
}

h1 {
  margin: 12px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 9vw, 48px);
  font-weight: 400;
  letter-spacing: -0.04em;
}

.period {
  color: var(--accent);
}

.intro,
.hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 30px 0 22px;
  text-align: left;
}

legend {
  width: 100%;
  font-size: 15px;
  line-height: 1.6;
  text-align: center;
}

.hint {
  text-align: center;
  margin: 7px 0 18px;
}

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

.choice {
  position: relative;
  cursor: pointer;
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice span {
  display: grid;
  place-items: center;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  font-size: 14px;
  transition: background 160ms ease, border-color 160ms ease;
}

.choice input:checked + span {
  border-color: var(--accent);
  background: #e8b9d01c;
}

.choice input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 13px;
  padding: 13px 18px;
  background: var(--accent);
  color: #211522;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: opacity 160ms ease, transform 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

button:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.status {
  min-height: 20px;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.6;
}

.footer-note {
  margin: 24px 0 0;
  color: #8e879d;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.birthday-message {
  color: var(--muted);
  line-height: 1.8;
  white-space: pre-line;
  margin: 20px 0 26px;
}

/* Balloon interaction */
.balloon-area {
  width: 100%;
  margin-top: 30px;
}

.balloon-heading {
  margin-bottom: 20px;
}

.balloon-heading h2 {
  margin: 8px 0 14px;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(25px, 6vw, 32px);
  font-weight: 400;
}

.balloon-instruction {
  max-width: 390px;
  margin: 0 auto;
  color: #f5cde1;
  font-size: clamp(23px, 5.5vw, 28px);
  line-height: 1.4;
  font-weight: 700;
  text-align: center;
}

.balloon-subtext {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.balloon-progress {
  min-height: 22px;
  margin: 16px 0 0;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.6;
}

.balloon-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-items: center;
  align-items: center;
  gap: 30px 12px;
  padding: 12px 0 28px;
}

.balloon {
  --balloon-color: #e9b6d3;
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  width: min(100%, 104px);
  height: 120px;
  min-height: 120px;
  padding: 8px;
  margin-bottom: 15px;
  border: 1px solid #ffffff50;
  border-radius: 50% 50% 46% 46%;
  background:
    radial-gradient(ellipse at 30% 23%, #ffffffbd 0%, #ffffff35 15%, transparent 34%),
    linear-gradient(135deg, #ffffff25, transparent 45%),
    var(--balloon-color);
  color: #342039;
  box-shadow:
    inset -8px -10px 16px #35203c22,
    0 10px 24px #0002;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
  animation: float 3.2s ease-in-out infinite;
  transition: background 200ms ease, border-radius 200ms ease;
}

.balloon:nth-child(4n + 1) {
  --balloon-color: #e9b6d3;
}

.balloon:nth-child(4n + 2) {
  --balloon-color: #c8b9f1;
  animation-delay: -0.8s;
}

.balloon:nth-child(4n + 3) {
  --balloon-color: #a9d9e8;
  animation-delay: -1.5s;
}

.balloon:nth-child(4n) {
  --balloon-color: #f0c9a8;
  animation-delay: -2.1s;
}

.balloon::before {
  content: "";
  position: absolute;
  z-index: -1;
  bottom: -5px;
  left: calc(50% - 5px);
  width: 10px;
  height: 10px;
  background: var(--balloon-color);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.balloon::after {
  content: "";
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  width: 1px;
  height: 23px;
  background: #d4c6dc88;
  transform-origin: top;
}

.balloon:hover {
  transform: translateY(-3px) scale(1.03);
}

.balloon:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 5px;
}

.balloon.popping {
  animation: pop 240ms ease-in forwards;
  pointer-events: none;
}

.balloon.revealed {
  width: 100%;
  min-height: 88px;
  height: auto;
  margin-bottom: 0;
  padding: 14px 8px;
  border: 1px solid #e8b9d080;
  border-radius: 16px;
  background: #e8b9d01c;
  color: var(--text);
  box-shadow: none;
  animation: reveal 350ms ease-out both;
  overflow-wrap: anywhere;
}

.balloon.revealed::before,
.balloon.revealed::after {
  display: none;
}

/* Continue popup */
.question-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 22px 16px;
  background: #080710d9;
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  animation: overlay-appear 250ms ease-out both;
}

.question-dialog {
  width: min(100%, 440px);
  margin: auto;
  padding: 34px 26px;
  border: 1px solid #e8b9d055;
  border-radius: 24px;
  background:
    radial-gradient(ellipse at 50% 0%, #39304f 0%, transparent 65%),
    #1b1a2a;
  box-shadow: 0 24px 90px #0008;
  text-align: center;
  animation: reveal 400ms ease-out both;
}

.question-dialog .moon {
  margin-bottom: 18px;
}

.question-dialog .eyebrow {
  margin: 0 0 14px;
}

.question-dialog h2 {
  margin: 0 auto 18px;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(27px, 6.5vw, 34px);
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: -0.025em;
}

.question-description {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

/* Written-answer screen */
.question-screen {
  text-align: left;
}

.question-screen > .moon,
.question-screen > .eyebrow,
.question-screen > h1 {
  text-align: center;
}

.question-intro {
  margin: 18px 0 26px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
  text-align: center;
  white-space: pre-line;
}

.answer-label {
  display: block;
  margin-bottom: 13px;
  color: #f5cde1;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(21px, 5vw, 25px);
  line-height: 1.5;
  text-align: center;
}

#answer-input {
  display: block;
  width: 100%;
  min-height: 140px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px;
  background: #11111b;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.7;
}

#answer-input::placeholder {
  color: #8e879d;
}

#answer-input:focus {
  border-color: var(--accent);
}

#answer-status {
  margin: 12px 0;
  text-align: center;
}

#answer-submit {
  margin-top: 8px;
}

/* Final birthday message */
.message-screen {
  text-align: center;
  overflow-wrap: anywhere;
}

.final-message {
  margin-top: 30px;
  padding: 24px 10px;
  border-top: 1px solid #ffffff20;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  line-height: 1.7;
  color: var(--accent);
  white-space: pre-line;
  overflow-wrap: anywhere;
  animation: reveal 700ms ease-out both;
}

/* Balloon sections */
.balloon-section {
  margin-top: 26px;
}

.balloon-section-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.balloon-section:not([hidden]) {
  animation: reveal 600ms ease-out both;
}

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

.balloon-grid-magic {
  grid-template-columns: minmax(0, 1fr);
}

.balloon-face {
  font-size: 22px;
  line-height: 1;
  opacity: 0.8;
}

.balloon-text {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.balloon.revealed {
  cursor: default;
}

.balloon.revealed:hover {
  transform: none;
}

.balloon.balloon-magic {
  --balloon-color: #f6e7a8;
  width: 128px;
  height: 148px;
  min-height: 148px;
  box-shadow:
    inset -8px -10px 16px #35203c22,
    0 0 36px #f6e7a888;
}

.balloon-magic .balloon-face {
  font-size: 40px;
  opacity: 0.9;
}

/* Moon scene */
.moon-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  overflow-y: auto;
  padding: 28px 20px;
  background: #020208;
  animation: overlay-appear 1400ms ease-out both;
}

.moon-content {
  width: min(100%, 460px);
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  text-align: center;
}

.full-moon {
  position: relative;
  flex: 0 0 auto;
  width: min(54vw, 190px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 62% 36%, #c9c2a8 0 7%, transparent 8%),
    radial-gradient(circle at 34% 62%, #cfc8ae 0 10%, transparent 11%),
    radial-gradient(circle at 58% 70%, #d3ccb3 0 5%, transparent 6%),
    radial-gradient(circle at 36% 30%, #fffdf2 0%, #f4efdc 40%, #dcd5bd 72%, #bdb59c 100%);
  box-shadow:
    0 0 40px 8px #fff6d640,
    0 0 120px 40px #f4e9bd2e;
  animation:
    moon-rise 1800ms ease-out 700ms both,
    moon-glow 5s ease-in-out 2500ms infinite;
}

.moon-message {
  margin: 0;
  color: #f3ecd9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 4.6vw, 22px);
  line-height: 1.8;
  animation: reveal 1400ms ease-out 1800ms both;
}

.moon-content button {
  width: min(100%, 320px);
  animation: reveal 900ms ease-out 3200ms both;
}

@keyframes moon-rise {
  from {
    opacity: 0;
    scale: 0.88;
  }

  to {
    opacity: 1;
    scale: 1;
  }
}

@keyframes moon-glow {
  0%, 100% {
    box-shadow:
      0 0 40px 8px #fff6d640,
      0 0 120px 40px #f4e9bd2e;
  }

  50% {
    box-shadow:
      0 0 56px 14px #fff6d65c,
      0 0 160px 60px #f4e9bd40;
  }
}

@keyframes float {
  0%, 100% {
    translate: 0 0;
  }

  50% {
    translate: 0 -10px;
  }
}

@keyframes pop {
  to {
    opacity: 0;
    scale: 1.35;
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

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

@keyframes overlay-appear {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@media (max-width: 380px) {
  .page {
    padding: 18px 12px;
  }

  .unlock-card,
  .birthday-screen,
  .question-screen,
  .message-screen {
    padding: 28px 17px;
    border-radius: 22px;
  }

  .balloon-grid {
    gap: 24px 8px;
  }

  .balloon {
    height: 102px;
    min-height: 102px;
  }

  .balloon.revealed {
    min-height: 82px;
  }

  .question-dialog {
    padding: 28px 19px;
    border-radius: 21px;
  }

  .final-message {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}