:root {
  --bg-deep: #1a1520;
  --bg-mid: #2a2233;
  --bg-soft: #3d3348;
  --fog: rgba(110, 98, 125, 0.72);
  --fog-edge: rgba(75, 65, 90, 0.55);
  --ink: #f4efe8;
  --ink-mute: rgba(244, 239, 232, 0.62);
  --warm: #e8c4a8;
  --warm-strong: #f0d2b4;
  --fear: #4a3f55;
  --fear-core: #2a2434;
  --light: #f7e6d4;
  --light-edge: rgba(255, 230, 200, 0.85);
  --accent: #c9957a;
  --success: #d4b89a;
  --radius: 999px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  font-family: "Outfit", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse 90% 70% at 20% 10%, #3a2f42 0%, transparent 55%),
    radial-gradient(ellipse 80% 60% at 85% 20%, #4a3540 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 50% 100%, #2c2435 0%, transparent 55%),
    linear-gradient(165deg, var(--bg-deep), var(--bg-mid) 45%, #231c28);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(circle at 30% 40%, rgba(232, 196, 168, 0.05), transparent 40%),
    radial-gradient(circle at 70% 60%, rgba(160, 140, 170, 0.08), transparent 45%),
    linear-gradient(180deg, rgba(40, 32, 50, 0.35), transparent 40%, rgba(30, 24, 38, 0.4));
  animation: breathe 14s ease-in-out infinite alternate;
}

@keyframes breathe {
  from { opacity: 0.75; transform: scale(1); }
  to { opacity: 1; transform: scale(1.05); }
}

.haze {
  position: fixed;
  inset: -18%;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(ellipse 80% 60% at 15% 20%, var(--fog), transparent 68%),
    radial-gradient(ellipse 75% 65% at 85% 15%, var(--fog-edge), transparent 62%),
    radial-gradient(ellipse 90% 70% at 50% 55%, rgba(85, 75, 100, 0.55), transparent 72%),
    radial-gradient(ellipse 100% 80% at 40% 90%, rgba(55, 48, 68, 0.5), transparent 70%),
    radial-gradient(ellipse 110% 90% at 50% 40%, rgba(45, 38, 58, 0.38), transparent 78%),
    linear-gradient(160deg, rgba(60, 52, 72, 0.28), rgba(35, 28, 45, 0.18) 50%, rgba(55, 45, 65, 0.32));
  filter: blur(36px);
  opacity: 1;
  transition: opacity 1.2s var(--ease), filter 1.2s var(--ease);
  animation: hazeDrift 22s ease-in-out infinite alternate;
}

@keyframes hazeDrift {
  from { transform: translate(-1.5%, -1%) scale(1); }
  to { transform: translate(1.5%, 1.5%) scale(1.04); }
}

.haze.thin {
  filter: blur(22px);
  opacity: 0.72;
}

.haze.clear {
  opacity: 0;
  filter: blur(10px);
}

.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1.25rem 1.75rem;
  pointer-events: none;
}

.brand {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.25rem, 2.8vw, 1.85rem);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--warm-strong);
  max-width: min(16rem, 55vw);
  line-height: 1.15;
}

.hint {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 300;
  color: var(--ink-mute);
  max-width: 18rem;
  text-align: right;
  transition: opacity 0.5s ease;
}

.stage {
  position: relative;
  z-index: 5;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

.fears,
.lights {
  position: absolute;
  inset: 0;
}

.cloud {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.1rem 1.4rem;
  border: 0;
  cursor: grab;
  touch-action: none;
  transition:
    transform 0.35s var(--ease),
    opacity 0.55s var(--ease),
    box-shadow 0.35s ease,
    filter 0.45s ease;
  will-change: transform, left, top;
}

.cloud:active {
  cursor: grabbing;
}

.cloud.fear {
  color: rgba(236, 228, 240, 0.92);
  background:
    radial-gradient(ellipse at 28% 22%, rgba(95, 82, 115, 0.95), transparent 52%),
    radial-gradient(ellipse at 72% 35%, rgba(55, 45, 70, 0.9), transparent 50%),
    radial-gradient(ellipse at 48% 78%, rgba(28, 22, 38, 0.95), rgba(18, 14, 28, 0.92));
  box-shadow:
    0 18px 48px rgba(8, 4, 16, 0.65),
    0 0 60px rgba(40, 30, 55, 0.45),
    inset 0 2px 8px rgba(0, 0, 0, 0.35),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04);
  filter: saturate(0.85) contrast(1.08);
  border-radius: 62% 38% 58% 42% / 48% 62% 38% 52%;
  min-width: min(48vw, 280px);
  max-width: 320px;
  min-height: 128px;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.05rem, 2.5vw, 1.35rem);
  font-style: italic;
  line-height: 1.25;
  z-index: 3;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.cloud.fear:nth-child(2) {
  border-radius: 40% 60% 45% 55% / 55% 40% 60% 45%;
  min-width: min(50vw, 300px);
  max-width: 340px;
  min-height: 140px;
}

.cloud.fear:nth-child(3) {
  border-radius: 58% 42% 35% 65% / 42% 58% 48% 52%;
  min-width: min(46vw, 270px);
  max-width: 310px;
  min-height: 132px;
}

.cloud.fear:nth-child(4) {
  border-radius: 45% 55% 60% 40% / 60% 45% 55% 40%;
  min-width: min(52vw, 310px);
  max-width: 350px;
  min-height: 148px;
}

.cloud.fear::before,
.cloud.fear::after {
  content: "";
  position: absolute;
  border-radius: inherit;
  z-index: -1;
  pointer-events: none;
}

.cloud.fear::before {
  inset: -28% -22% -20% -26%;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(50, 42, 65, 0.75), transparent 60%),
    radial-gradient(ellipse at 70% 55%, rgba(35, 28, 48, 0.7), transparent 55%);
  opacity: 0.85;
  filter: blur(18px);
}

.cloud.fear::after {
  inset: -18% -32% -30% -16%;
  background:
    radial-gradient(ellipse at 55% 30%, rgba(70, 55, 90, 0.55), transparent 55%),
    radial-gradient(ellipse at 40% 80%, rgba(20, 16, 30, 0.65), transparent 50%);
  opacity: 0.7;
  filter: blur(22px);
}

.cloud.fear .hits {
  position: absolute;
  bottom: 0.45rem;
  right: 0.75rem;
  font-family: "Outfit", sans-serif;
  font-size: 0.65rem;
  font-style: normal;
  letter-spacing: 0.08em;
  color: rgba(244, 239, 232, 0.45);
  text-transform: uppercase;
}

.cloud.fear.is-hit {
  animation: fearPulse 0.55s var(--ease);
}

.cloud.fear.is-clearing {
  opacity: 0;
  transform: scale(1.15) translateY(-12px);
  filter: blur(12px);
  pointer-events: none;
}

@keyframes fearPulse {
  0% { transform: scale(1); filter: brightness(1); }
  40% { transform: scale(0.96); filter: brightness(1.25); }
  100% { transform: scale(1); filter: brightness(1); }
}

.cloud.light {
  color: #3a2e28;
  background:
    radial-gradient(ellipse at 40% 20%, #fffdf8, transparent 50%),
    radial-gradient(ellipse at 55% 65%, var(--warm-strong), var(--light));
  box-shadow:
    0 10px 28px rgba(40, 24, 30, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.35) inset,
    0 0 28px rgba(255, 236, 210, 0.75),
    0 0 56px rgba(255, 210, 170, 0.55),
    0 0 90px rgba(232, 180, 140, 0.35);
  border-radius: 60% 40% 55% 45% / 45% 55% 45% 55%;
  min-width: min(38vw, 180px);
  max-width: 210px;
  min-height: 78px;
  font-size: clamp(0.78rem, 1.8vw, 0.92rem);
  font-weight: 400;
  line-height: 1.3;
  z-index: 6;
  animation: floatY 7s ease-in-out infinite;
}

.cloud.light::before {
  content: "";
  position: absolute;
  inset: -35% -40%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 236, 210, 0.55) 0%, rgba(255, 210, 170, 0.22) 40%, transparent 70%);
  z-index: -1;
  pointer-events: none;
  filter: blur(8px);
  animation: glowPulse 5.5s ease-in-out infinite alternate;
}

@keyframes glowPulse {
  from { opacity: 0.7; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1.08); }
}

.cloud.light:nth-child(2n) {
  animation-duration: 8.5s;
  animation-delay: -1.5s;
}

.cloud.light:nth-child(3n) {
  animation-duration: 6.2s;
  animation-delay: -3s;
  border-radius: 45% 55% 40% 60% / 55% 40% 60% 45%;
}

.cloud.light.dragging {
  z-index: 20;
  animation: none;
  transform: scale(1.06);
  box-shadow:
    0 18px 40px rgba(40, 24, 30, 0.35),
    0 0 40px rgba(255, 236, 210, 0.9),
    0 0 80px rgba(255, 210, 170, 0.65),
    0 0 120px rgba(232, 180, 140, 0.45);
  cursor: grabbing;
}

.cloud.light.dragging::before {
  animation: none;
  opacity: 1;
  transform: scale(1.15);
}

.cloud.light.spent {
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
}

.cloud.light.over-target {
  box-shadow:
    0 14px 36px rgba(40, 24, 30, 0.3),
    0 0 42px rgba(232, 196, 168, 0.75);
}

@keyframes floatY {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -10px; }
}

.slide {
  position: fixed;
  left: 1.5rem;
  right: auto;
  bottom: 1.75rem;
  z-index: 12;
  max-width: min(28rem, calc(100vw - 3rem));
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.45s var(--ease);
  padding: 1rem 1.15rem;
  background: linear-gradient(
    135deg,
    rgba(26, 21, 32, 0.55),
    rgba(42, 34, 51, 0.35)
  );
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 1.1rem;
  backdrop-filter: blur(10px);
}

.slide.pulse {
  animation: slideIn 0.7s var(--ease);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}

.slide-title {
  margin: 0 0 0.45rem;
  font-family: "Cormorant Garamond", serif;
  font-weight: 500;
  font-size: clamp(1.55rem, 4vw, 2.1rem);
  line-height: 1.15;
  color: var(--ink);
}

.slide-text {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 300;
  line-height: 1.55;
  color: var(--ink-mute);
  max-width: 26rem;
}

.progress {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  z-index: 15;
  background: rgba(255, 255, 255, 0.06);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--warm-strong));
  transition: width 0.7s var(--ease);
}

.finale {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(18, 14, 22, 0.35);
  backdrop-filter: blur(8px);
  opacity: 1;
  transition: opacity 0.6s ease;
}

.finale.hidden {
  opacity: 0;
  pointer-events: none;
}

.finale-card {
  text-align: center;
  padding: 2.5rem 2rem;
  max-width: 24rem;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 236, 220, 0.18), transparent 55%),
    linear-gradient(180deg, rgba(58, 46, 58, 0.9), rgba(36, 28, 40, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1.5rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  animation: slideIn 0.8s var(--ease);
}

.finale-kicker {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.finale-title {
  margin: 0 0 0.75rem;
  font-family: "Cormorant Garamond", serif;
  font-weight: 500;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  color: var(--warm-strong);
}

.finale-text {
  margin: 0 0 1.5rem;
  font-weight: 300;
  color: var(--ink-mute);
  line-height: 1.55;
}

.finale-card--poem {
  text-align: left;
  max-width: min(34rem, calc(100vw - 1.5rem));
  max-height: min(92dvh, 92vh);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.5rem 1.35rem 1.35rem;
  overscroll-behavior: contain;
}

.finale-card--poem .finale-title {
  text-align: center;
}

.finale-card--poem .finale-kicker {
  text-align: center;
}

.finale-poem {
  margin: 0 0 1.35rem;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(0.98rem, 3.6vw, 1.2rem);
  font-style: italic;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-line;
}

.finale-card--poem .finale-btn {
  display: block;
  margin: 0 auto;
  min-height: 44px;
  min-width: 44px;
}

.finale-btn {
  appearance: none;
  border: 1px solid rgba(232, 196, 168, 0.45);
  background: transparent;
  color: var(--warm-strong);
  font-family: "Outfit", sans-serif;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
}

.finale-btn:hover {
  background: rgba(232, 196, 168, 0.15);
}

.finale-btn:focus-visible {
  outline: 2px solid var(--warm);
  outline-offset: 3px;
}

@media (max-width: 700px) {
  html,
  body {
    overflow: hidden;
    width: 100%;
    max-width: 100vw;
  }

  .top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding:
      max(0.65rem, env(safe-area-inset-top))
      max(0.85rem, env(safe-area-inset-right))
      0.35rem
      max(0.85rem, env(safe-area-inset-left));
  }

  .brand {
    font-size: 1.35rem;
  }

  .hint {
    text-align: left;
    max-width: none;
    font-size: 0.72rem;
    line-height: 1.35;
  }

  .slide {
    left: max(0.65rem, env(safe-area-inset-left));
    right: max(0.65rem, env(safe-area-inset-right));
    bottom: max(0.55rem, env(safe-area-inset-bottom));
    max-width: none;
    max-height: 22vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.65rem 0.75rem;
    z-index: 12;
  }

  .slide-kicker {
    font-size: 0.62rem;
    margin-bottom: 0.2rem;
  }

  .slide-title {
    font-size: clamp(1.05rem, 5vw, 1.35rem);
    margin-bottom: 0.25rem;
  }

  .slide-text {
    font-size: 0.78rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .cloud {
    min-height: 44px;
  }

  .cloud.fear,
  .cloud.light {
    min-width: 0;
    width: 46vw;
    max-width: 46vw;
    padding: 0.65rem 0.7rem;
    font-size: 0.78rem;
    line-height: 1.25;
  }

  .cloud.fear,
  .cloud.fear:nth-child(n) {
    min-width: 0;
    width: 48vw;
    max-width: 48vw;
    min-height: 88px;
    font-size: 0.95rem;
  }

  .cloud.fear::before {
    inset: -22% -18% -16% -20%;
  }

  .cloud.fear::after {
    inset: -14% -24% -22% -12%;
  }

  .cloud.light {
    min-height: 58px;
  }

  .cloud.light::before {
    inset: -28% -32%;
  }

  .haze {
    inset: -22%;
    filter: blur(30px);
  }

  .cloud.fear .hits {
    font-size: 0.58rem;
    bottom: 0.3rem;
    right: 0.5rem;
  }

  .finale {
    align-items: stretch;
    padding:
      max(0.5rem, env(safe-area-inset-top))
      max(0.5rem, env(safe-area-inset-right))
      max(0.5rem, env(safe-area-inset-bottom))
      max(0.5rem, env(safe-area-inset-left));
  }

  .finale-card--poem {
    width: 100%;
    max-width: none;
    max-height: none;
    height: 100%;
    border-radius: 1rem;
    padding: 1.1rem 1rem 1.25rem;
  }

  .finale-poem {
    font-size: clamp(0.92rem, 3.8vw, 1.05rem);
    line-height: 1.5;
  }

  .progress {
    height: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .atmosphere,
  .haze,
  .cloud.light,
  .cloud.light::before,
  .slide.pulse,
  .finale-card {
    animation: none;
  }

  .haze,
  .cloud,
  .progress-bar,
  .finale {
    transition: none;
  }
}
