:root {
  --bg: #fffdf0;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.88);
  --surface-soft: #fff4c2;
  --pink-soft: #ffe4ec;
  --text: #2c2416;
  --muted: #6e624d;
  --accent: #eab308;
  --accent-dark: #a16207;
  --pink: #ec4899;
  --pink-dark: #be185d;
  --border: rgba(245, 215, 120, 0.78);
  --radius: 22px;
  --shadow: 0 18px 46px rgba(44, 36, 22, 0.08);
  --ease-silk: cubic-bezier(0.22, 1, 0.36, 1);
  --font-display: Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: #0d080d;
  min-height: 100%;
  touch-action: manipulation;
  overscroll-behavior-y: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100dvh;
  touch-action: manipulation;
  overscroll-behavior-y: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
  transition: background-color 0.8s var(--ease-silk);
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
  display: none;
}

body.intro-active {
  background: #0d080d;
  overflow: hidden;
}

body.intro-dawn {
  background: #fff9d6;
}

body.intro-crash {
  background: #0b0509;
}

.hidden {
  display: none !important;
}

/* Living Aurora Background */
.aurora-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background: linear-gradient(145deg, #fffdf0 0%, #fff6d6 48%, #ffe8f0 100%);
}

.aurora-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(76px);
  opacity: 0.65;
  animation: orbDrift 18s ease-in-out infinite alternate;
}

.orb-yellow {
  width: 430px;
  height: 430px;
  background: #fde047;
  top: -120px;
  left: -90px;
}

.orb-pink {
  width: 400px;
  height: 400px;
  background: #f9a8d4;
  bottom: -110px;
  right: -80px;
  animation-delay: -6s;
}

.orb-gold {
  width: 310px;
  height: 310px;
  background: #fed7aa;
  top: 40%;
  left: 55%;
  animation-delay: -12s;
}

#ambient-canvas,
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#ambient-canvas {
  z-index: 45;
}

#confetti-canvas {
  z-index: 95;
}

/* Smooth 60fps Keyframes (Zero Abrupt Flips) */
@keyframes orbDrift {
  0% {
    transform: translate(0, 0) scale(1);
  }

  50% {
    transform: translate(35px, -28px) scale(1.07);
  }

  100% {
    transform: translate(-25px, 24px) scale(0.96);
  }
}

@keyframes smoothRiseIn {
  0% {
    opacity: 0;
    transform: translateY(72vh);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardEnter {
  0% {
    opacity: 0;
    transform: translateY(16px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideFromRight {
  0% {
    opacity: 0;
    transform: translateX(46px) scale(0.982);
  }

  70% {
    opacity: 1;
    transform: translateX(-4px) scale(1.004);
  }

  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes slideFromLeft {
  0% {
    opacity: 0;
    transform: translateX(-46px) scale(0.982);
  }

  70% {
    opacity: 1;
    transform: translateX(4px) scale(1.004);
  }

  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes neonBreath {

  0%,
  100% {
    text-shadow: 0 0 14px rgba(244, 114, 182, 0.85), 0 0 36px rgba(250, 204, 21, 0.45);
  }

  50% {
    text-shadow: 0 0 24px rgba(244, 114, 182, 1), 0 0 56px rgba(250, 204, 21, 0.72);
  }
}

@keyframes twilightPulse {
  0%, 100% {
    opacity: 0.82;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

@keyframes realGlitchJerk {

  0%,
  100% {
    transform: translate(0, 0);
  }

  18% {
    transform: translate(-7px, 2px);
  }

  36% {
    transform: translate(6px, -2px);
  }

  54% {
    transform: translate(-5px, -1px);
  }

  72% {
    transform: translate(5px, 2px);
  }

  88% {
    transform: translate(-2px, 1px);
  }
}

@keyframes rgbSplit {

  0%,
  100% {
    text-shadow: -2px 0 rgba(236, 72, 153, 0.9), 2px 0 rgba(56, 189, 248, 0.9);
  }

  50% {
    text-shadow: 3px 0 rgba(236, 72, 153, 0.9), -3px 0 rgba(250, 204, 21, 0.95);
  }
}

@keyframes scanlineScroll {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 0 120px;
  }
}

@keyframes blurPulse {

  0%,
  100% {
    opacity: 0.45;
    transform: translateX(0);
  }

  50% {
    opacity: 0.82;
    transform: translateX(6px);
  }
}

@keyframes eqBar {

  0%,
  100% {
    transform: scaleY(0.3);
  }

  50% {
    transform: scaleY(1);
  }
}

@keyframes liquidDrift {
  0% { background-position: 0% 50%; }
  25% { background-position: 50% 0%; }
  50% { background-position: 100% 50%; }
  75% { background-position: 50% 100%; }
  100% { background-position: 0% 50%; }
}

@keyframes ribbonSweep {
  0% {
    transform: translateX(-140%) skewX(-20deg);
    opacity: 0;
  }

  20% {
    opacity: 0.75;
  }

  55% {
    transform: translateX(240%) skewX(-20deg);
    opacity: 0;
  }

  100% {
    transform: translateX(240%) skewX(-20deg);
    opacity: 0;
  }
}

@keyframes liquidBlob {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    opacity: 0.35;
  }
  33% {
    transform: translate(-40%, -60%) scale(1.15) rotate(120deg);
    opacity: 0.45;
  }
  66% {
    transform: translate(-60%, -40%) scale(0.9) rotate(240deg);
    opacity: 0.3;
  }
}

/* Flowy Liquid-Glass Buttons */
.water-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 13px 20px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: linear-gradient(120deg,
    rgba(255, 250, 235, 0.95),
    rgba(255, 237, 200, 0.92),
    rgba(255, 224, 236, 0.92),
    rgba(254, 240, 180, 0.95));
  background-size: 300% 300%;
  animation: liquidDrift 6s ease-in-out infinite;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1.5px solid rgba(236, 72, 153, 0.38);
  border-radius: 999px;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    0 4px 18px rgba(236, 72, 153, 0.1),
    0 2px 6px rgba(234, 179, 8, 0.08),
    inset 0 1px 2px rgba(255, 255, 255, 0.6);
  transition:
    transform 0.5s var(--ease-silk),
    border-color 0.4s var(--ease-silk),
    box-shadow 0.45s var(--ease-silk),
    opacity 0.35s ease;
}

.water-btn-accent {
  background: linear-gradient(120deg,
    rgba(254, 236, 120, 0.95),
    rgba(251, 200, 220, 0.93),
    rgba(253, 224, 71, 0.93),
    rgba(252, 185, 210, 0.95));
  background-size: 320% 320%;
  animation: liquidDrift 5s ease-in-out infinite;
  border-color: rgba(236, 72, 153, 0.55);
  box-shadow:
    0 4px 20px rgba(236, 72, 153, 0.14),
    0 2px 8px rgba(234, 179, 8, 0.1),
    inset 0 1px 2px rgba(255, 255, 255, 0.5);
}

.water-btn-accent::before,
.water-btn-light::before {
  left: 0;
  width: 55%;
  animation: ribbonSweep 5.2s ease-in-out infinite;
}

.water-btn-sm {
  width: auto;
  min-width: 88px;
  padding: 8px 14px;
  font-size: 0.84rem;
  border-color: var(--border);
}

.water-btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border-color: var(--border);
  animation: liquidDrift 6s ease-in-out infinite;
}

.water-btn-icon::after {
  display: none; /* no blob on small icon buttons */
}

.water-btn-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.water-btn-light {
  color: #fff6fb;
  background: linear-gradient(120deg,
    rgba(255, 255, 255, 0.2),
    rgba(253, 224, 71, 0.22),
    rgba(244, 114, 182, 0.18),
    rgba(255, 255, 255, 0.2));
  background-size: 300% 300%;
  animation: liquidDrift 6s ease-in-out infinite;
  border-color: rgba(250, 204, 21, 0.7);
  box-shadow:
    0 8px 28px rgba(244, 114, 182, 0.24),
    inset 0 1px 2px rgba(255, 255, 255, 0.15);
}

/* Silky Diagonal Water-Light Sweep */
.water-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -130%;
  width: 90%;
  height: 100%;
  background: linear-gradient(110deg,
      rgba(255, 255, 255, 0) 15%,
      rgba(255, 255, 255, 0.55) 50%,
      rgba(255, 255, 255, 0) 85%);
  transform: skewX(-18deg);
  transition: left 0.75s var(--ease-silk);
  pointer-events: none;
  z-index: 1;
}

/* Floating liquid blob accent */
.water-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 70%;
  height: 140%;
  background: radial-gradient(ellipse at center,
    rgba(236, 72, 153, 0.15) 0%,
    rgba(234, 179, 8, 0.08) 50%,
    transparent 70%);
  border-radius: 50%;
  animation: liquidBlob 7s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

.water-btn-accent::after {
  background: radial-gradient(ellipse at center,
    rgba(253, 224, 71, 0.2) 0%,
    rgba(236, 72, 153, 0.12) 50%,
    transparent 70%);
}

.water-btn:hover:not(:disabled)::before {
  left: 145%;
}

.water-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: var(--pink);
  box-shadow:
    0 12px 28px rgba(236, 72, 153, 0.2),
    0 4px 10px rgba(234, 179, 8, 0.1),
    inset 0 1px 3px rgba(255, 255, 255, 0.5);
}

.water-btn-light:hover:not(:disabled) {
  background: linear-gradient(120deg,
    rgba(255, 255, 255, 0.3),
    rgba(253, 224, 71, 0.3),
    rgba(244, 114, 182, 0.25),
    rgba(255, 255, 255, 0.3));
  background-size: 300% 300%;
  border-color: #fde047;
  box-shadow:
    0 12px 32px rgba(250, 204, 21, 0.32),
    inset 0 1px 3px rgba(255, 255, 255, 0.2);
}

.water-btn:active:not(:disabled) {
  transform: scale(0.96);
  box-shadow:
    0 2px 10px rgba(236, 72, 153, 0.26),
    inset 0 2px 4px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.water-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn-label {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Floral Corner Watermark */
@keyframes flowerFloat {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-3px) rotate(4deg);
  }
}

.card-flower-corner {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  opacity: 0.85;
  pointer-events: none;
  z-index: 0;
}

.card-flower-corner svg {
  animation: flowerFloat 6.5s ease-in-out infinite;
}

/* Intro Screen (Twilight Puddle -> Continuous Vertical Camera Pan -> Dawn) */
.intro-screen {
  position: fixed;
  inset: -4px;
  min-height: 100lvh;
  z-index: 40;
  overflow: hidden;
  transition: opacity 0.75s var(--ease-silk), background 1.1s var(--ease-silk);
}

.camera-track {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 200dvh;
  transform: translateY(-50%);
  transition: transform 1.25s var(--ease-silk);
  will-change: transform;
}

.camera-track.panned-up {
  transform: translateY(0%);
}

.camera-panel {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.twilight-sky {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.twilight-stars-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.twilight-stars {
  display: none;
}

.twilight-horizon {
  position: absolute;
  left: 50%;
  bottom: -22vh;
  width: 140vw;
  height: 52vh;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(244, 114, 182, 0.32) 0%, rgba(250, 204, 21, 0.16) 42%, transparent 72%);
  filter: blur(32px);
  animation: twilightPulse 8s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes starTwinkle {
  0% {
    opacity: 0.55;
  }

  100% {
    opacity: 1;
  }
}

.landing-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  margin-bottom: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(253, 224, 71, 0.32);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #fde68a;
}

.landing-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f472b6;
  box-shadow: 0 0 10px #f472b6;
  animation: neonBreath 2.4s ease-in-out infinite;
}

.landing-divider {
  width: 120px;
  height: 1.5px;
  margin: 0 auto 22px;
  background: linear-gradient(90deg, transparent, #fde047, #f472b6, transparent);
  opacity: 0.85;
}

.intro-screen.twilight-mode {
  background:
    radial-gradient(circle at 50% 32%, rgba(76, 29, 68, 0.78) 0%, rgba(32, 13, 29, 0.92) 52%, #0b060c 100%),
    radial-gradient(ellipse at 80% 20%, rgba(236, 72, 153, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 20% 80%, rgba(234, 179, 8, 0.08) 0%, transparent 50%);
  color: #fff6fb;
}

.intro-screen.crash-mode {
  background: radial-gradient(circle at 50% 45%, #3d1226 0%, #190b13 70%, #0b0509 100%);
}

.intro-screen.dawn-mode {
  background: linear-gradient(155deg, #fff9d6 0%, #ffe6ef 100%);
}

.intro-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.glitch-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: repeating-linear-gradient(to bottom,
      rgba(255, 255, 255, 0.04) 0px,
      rgba(255, 255, 255, 0.04) 2px,
      rgba(0, 0, 0, 0.22) 2px,
      rgba(0, 0, 0, 0.22) 4px);
  animation: scanlineScroll 3s linear infinite;
  transition: opacity 0.4s ease;
  z-index: 2;
}

.intro-screen.crash-mode .glitch-scanlines {
  opacity: 1;
}

/* Stage 1: Landing */
.puddle-stage {
  position: relative;
  z-index: 3;
  text-align: center;
  max-width: 520px;
  width: 100%;
  padding: 20px;
  animation: cardEnter 0.85s var(--ease-silk) both;
  transition: opacity 0.75s var(--ease-silk), transform 0.85s var(--ease-silk);
}

/* Continuous upward vertical camera pan out */
.puddle-stage.horizon-rise-out {
  opacity: 0;
  transform: translateY(-68vh);
}

.puddle-eyebrow {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fde047;
}

.landing-title-wrap {
  position: relative;
  margin-bottom: 22px;
}

.neon-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 7.5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.15;
  color: #ffe4f1;
  animation: neonBreath 3.2s ease-in-out infinite;
}

.puddle-sub {
  margin: 0 auto 26px;
  max-width: 380px;
  color: #f3d6e4;
  font-size: 0.96rem;
}

.puddle-cta {
  max-width: 280px;
  margin: 0 auto;
}

/* System Card (Day 1 -> Crash -> Verify -> Bundle) */
.system-card {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 450px;
  background: var(--surface-strong);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  transition:
    background-color 0.45s var(--ease-silk),
    border-color 0.45s var(--ease-silk),
    color 0.45s var(--ease-silk),
    box-shadow 0.45s var(--ease-silk);
}

@media (max-width: 420px) {
  .system-card {
    padding: 18px 16px;
  }
}

.system-card .card-flower-corner {
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
}

.system-card.is-glitching {
  animation: realGlitchJerk 0.5s steps(2, end) both;
}

.system-card.crash-card {
  background: rgba(24, 12, 20, 0.92);
  border-color: #f43f5e;
  color: #fff1f5;
  box-shadow: 0 22px 60px rgba(244, 63, 94, 0.35);
}

.system-card.crash-card .system-banner {
  background: rgba(244, 63, 94, 0.24);
  color: #fda4af;
  animation: rgbSplit 0.35s infinite;
}

.system-card.crash-card .status-bar {
  color: #fde047;
}

.system-card.crash-card .system-title {
  animation: rgbSplit 0.45s infinite;
}

.system-card.crash-card .system-message {
  color: #fbcfe8;
}

.system-card.crash-card .water-btn {
  color: #fff1f5;
  background: linear-gradient(120deg,
    rgba(255, 255, 255, 0.18),
    rgba(253, 224, 71, 0.2),
    rgba(244, 114, 182, 0.16),
    rgba(255, 255, 255, 0.18));
  background-size: 300% 300%;
  animation: liquidDrift 6s ease-in-out infinite;
  border-color: #fde047;
  box-shadow:
    0 4px 16px rgba(250, 204, 21, 0.18),
    inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.system-card.stage-swap {
  animation: cardEnter 0.55s var(--ease-silk) both;
}

.system-banner {
  font-family: var(--font-mono);
  font-size: clamp(0.62rem, 2.7vw, 0.74rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent-dark);
  background: var(--surface-soft);
  padding: 7px 10px;
  margin-right: 40px;
  border-radius: 10px;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-bar {
  font-family: var(--font-mono);
  font-size: clamp(0.62rem, 2.6vw, 0.75rem);
  color: var(--pink-dark);
  margin-bottom: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.system-title {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1.25;
}

.system-message {
  margin: 0 0 20px;
}

/* Repair Progress & Verify */
.repair-progress-wrap {
  margin-bottom: 18px;
}

.repair-progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
  border: 1px solid rgba(253, 224, 71, 0.45);
}

.repair-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #facc15, #f472b6);
  transition: width 0.38s var(--ease-silk);
}

.repair-progress-label {
  margin: 8px 0 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #fde047;
}

.name-verify-form {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.verify-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--pink-dark);
}

.verify-input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: rgba(255, 253, 240, 0.92);
  color: var(--text);
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.verify-input:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 4px rgba(236, 72, 153, 0.14);
}

.verify-feedback {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--pink-dark);
  min-height: 1.2em;
}

/* Fixed Top Header (Pinned Outside Animated Shell) */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 35;
  padding: max(14px, env(safe-area-inset-top)) 18px 14px;
  background: rgba(255, 253, 240, 0.88);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-bottom: 1px solid var(--border);
}

.app-header-inner {
  max-width: 740px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.header-brand {
  min-width: 0;
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.eyebrow {
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pink-dark);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-title {
  margin: 1px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 4.2vw, 1.65rem);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* App Shell */
.app-shell {
  max-width: 740px;
  margin: 0 auto;
  padding: calc(106px + env(safe-area-inset-top)) 16px calc(110px + env(safe-area-inset-bottom));
  animation: cardEnter 0.65s var(--ease-silk) both;
}

/* Seamless Episode Reader */
.reader-stage {
  touch-action: pan-y;
}

.reader-card {
  position: relative;
  touch-action: pan-y;
  background: var(--surface);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  will-change: transform;
}

.reader-card.slide-next {
  animation: slideFromRight 0.42s cubic-bezier(0.18, 0.89, 0.32, 1.12) both;
}

.reader-card.slide-prev {
  animation: slideFromLeft 0.42s cubic-bezier(0.18, 0.89, 0.32, 1.12) both;
}

.reader-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
  margin-bottom: 18px;
  padding-right: 44px;
}

.reader-ep-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--pink-soft);
  color: var(--pink-dark);
  margin-bottom: 8px;
}

.reader-title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 4vw, 1.7rem);
  line-height: 1.25;
}

.reader-teaser {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.reader-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.reader-footer .water-btn {
  padding: 12px 12px;
  font-size: clamp(0.8rem, 3.3vw, 0.94rem);
}

.reader-footer .btn-label {
  white-space: nowrap;
}

/* Locked Inline Countdown */
.locked-stage-box {
  text-align: center;
  padding: 24px 12px;
  border-radius: 18px;
  background: linear-gradient(155deg, rgba(255, 248, 214, 0.82), rgba(255, 230, 240, 0.82));
  border: 2px dashed rgba(236, 72, 153, 0.45);
  box-shadow: 0 8px 24px rgba(236, 72, 153, 0.08);
  box-sizing: border-box;
  overflow: hidden;
}

.countdown-tiles {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  max-width: 288px;
  margin: 14px auto 10px;
  box-sizing: border-box;
}

.cd-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 8px 4px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid rgba(236, 72, 153, 0.28);
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.1);
  box-sizing: border-box;
}

.cd-val {
  font-family: var(--font-mono);
  font-size: clamp(1.1rem, 4.2vw, 1.4rem);
  font-weight: 800;
  color: var(--pink-dark);
  line-height: 1;
}

.cd-unit {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 3px;
  line-height: 1;
}

.cd-sep {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--pink);
  margin: 0;
  text-align: center;
  line-height: 1;
  padding-bottom: 7px;
}

.cd-tile.cd-pulse {
  animation: pulseSeconds 1.5s ease-in-out infinite alternate;
}

@keyframes pulseSeconds {
  0% {
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.1);
  }
  100% {
    box-shadow: 0 4px 18px rgba(236, 72, 153, 0.35);
    border-color: var(--pink);
  }
}

.locked-clock {
  margin: 10px 0 4px;
}

/* Overview Grid (Blurry Mystery Preview for Unopened/Locked Cards) */
.episode-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  animation: cardEnter 0.45s var(--ease-silk) both;
}

@media (min-width: 560px) {
  .episode-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.ep-card {
  position: relative;
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  cursor: pointer;
  overflow: hidden;
  opacity: 0;
  animation: cardEnter 0.5s var(--ease-silk) forwards;
  animation-delay: calc(var(--stagger, 0) * 50ms);
  transition: transform 0.3s var(--ease-silk), border-color 0.25s ease;
}

.ep-card:hover {
  transform: translateY(-3px);
  border-color: var(--pink);
}

.ep-card.locked {
  background: linear-gradient(145deg, rgba(255, 253, 244, 0.65), rgba(255, 240, 246, 0.55));
  border-style: dashed;
  border-color: rgba(236, 72, 153, 0.38);
}

.ep-card.locked:hover {
  border-color: var(--pink);
  background: linear-gradient(145deg, rgba(255, 253, 244, 0.8), rgba(255, 240, 246, 0.7));
}

.ep-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-right: 52px;
}

.ep-code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-dark);
}

.ep-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent-dark);
}

.ep-card.opened .ep-pill {
  background: var(--pink-soft);
  color: var(--pink-dark);
}

.ep-title {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 1.12rem;
}

.ep-teaser {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.mystery-blur-preview {
  display: grid;
  gap: 8px;
  margin: 6px 0 4px;
}

.blur-bar {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(250, 204, 21, 0.55), rgba(244, 114, 182, 0.55));
  filter: blur(5px);
  animation: blurPulse 2.8s ease-in-out infinite;
}

.blur-bar.short {
  width: 68%;
  height: 11px;
  animation-delay: 0.4s;
}

.ep-countdown {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--pink-dark);
}

.replay-intro-wrap {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 16px 0 8px;
}

.replay-intro-btn {
  width: auto;
  min-width: 140px;
  font-size: 0.84rem;
  padding: 9px 18px;
  background: var(--surface-strong);
  border-color: rgba(236, 72, 153, 0.4);
}

/* Now-Playing Glass Toast */
.audio-toast {
  position: fixed;
  top: max(22px, env(safe-area-inset-top, 22px));
  left: 50%;
  transform: translateX(-50%) translateY(-14px);
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1.5px solid rgba(236, 72, 153, 0.4);
  box-shadow: 0 10px 30px rgba(44, 36, 22, 0.12), 0 2px 8px rgba(236, 72, 153, 0.12);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s var(--ease-silk), transform 0.35s var(--ease-silk);
  white-space: nowrap;
}

.audio-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.audio-toast.below-header {
  top: calc(78px + env(safe-area-inset-top, 0px));
}

/* Floating Capsule Pill Dock */
.floating-pill-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 35;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: center;
  gap: 6px;
  width: calc(100% - 24px);
  max-width: 500px;
  margin: 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 253, 244, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1.5px solid rgba(236, 72, 153, 0.28);
  box-shadow: 0 10px 32px rgba(44, 36, 22, 0.12), 0 2px 8px rgba(236, 72, 153, 0.14);
}

.pill-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 8px 0;
  width: 100%;
  text-align: center;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 0.35s cubic-bezier(0.22, 1.35, 0.36, 1),
    background 0.25s ease,
    color 0.25s ease,
    box-shadow 0.25s ease,
    border-color 0.25s ease;
}

.pill-lock-icon {
  font-size: 0.52rem;
  opacity: 0.72;
  display: inline-block;
  line-height: 1;
  margin-left: 1px;
}

.pill-dot:hover {
  transform: translateY(-2px);
  color: var(--pink-dark);
  border-color: rgba(236, 72, 153, 0.25);
}

.pill-dot:active {
  transform: scale(0.92);
}

.pill-dot.active {
  background: linear-gradient(120deg, #fde047 0%, #f472b6 50%, #fde047 100%);
  background-size: 200% 200%;
  animation: liquidDrift 5s ease-in-out infinite;
  color: #2c2416;
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 16px rgba(236, 72, 153, 0.35);
  transform: translateY(-2px);
}

.pill-dot.locked-dot {
  opacity: 0.6;
  background: rgba(255, 255, 255, 0.35);
}

/* Episode Widgets */
.photo-frame {
  margin: 0 auto 20px;
  max-width: 360px;
  background: #ffffff;
  padding: 10px 10px 16px;
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(44, 36, 22, 0.08), 0 2px 6px rgba(236, 72, 153, 0.08);
  border: 1.5px solid rgba(245, 215, 120, 0.55);
  transition: transform 0.35s var(--ease-silk), box-shadow 0.35s var(--ease-silk);
}

.photo-frame:hover {
  transform: translateY(-2px) rotate(-0.5deg);
  box-shadow: 0 14px 34px rgba(44, 36, 22, 0.12), 0 3px 10px rgba(236, 72, 153, 0.1);
}

.photo-frame .ep-photo {
  width: 100%;
  border-radius: 12px;
  object-fit: cover;
  max-height: 360px;
  display: block;
  margin-bottom: 0;
}

.ep-photo {
  width: 100%;
  border-radius: 16px;
  object-fit: cover;
  max-height: 360px;
  display: block;
  margin-bottom: 16px;
}

.story-text {
  white-space: pre-line;
  margin: 0 0 18px;
  line-height: 1.75;
  font-size: 1.01rem;
}

.poem-box {
  position: relative;
  white-space: pre-line;
  margin: 0 0 20px;
  background: linear-gradient(155deg, rgba(255, 252, 238, 0.95) 0%, rgba(255, 241, 246, 0.95) 100%);
  border: 1.5px solid rgba(236, 72, 153, 0.3);
  border-left: 5px solid var(--pink);
  border-radius: 16px;
  padding: 22px 20px 20px 24px;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-style: italic;
  line-height: 1.8;
  color: #3b2c20;
  box-shadow: 0 6px 20px rgba(236, 72, 153, 0.08);
}

.poem-box::before {
  content: "“";
  position: absolute;
  top: -8px;
  left: 12px;
  font-family: Georgia, serif;
  font-size: 3.5rem;
  color: rgba(236, 72, 153, 0.2);
  line-height: 1;
  pointer-events: none;
}

/* 3D Flip Cards (EP 02) */
.flip-grid {
  display: grid;
  gap: 12px;
  perspective: 1000px;
}

.flip-card-3d {
  display: block;
  width: 100%;
  min-height: 108px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.flip-inner {
  display: block;
  position: relative;
  width: 100%;
  min-height: 108px;
  transition: transform 0.65s var(--ease-silk);
  transform-style: preserve-3d;
}

.flip-card-3d.revealed .flip-inner {
  transform: rotateX(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow-y: auto;
  scrollbar-width: none;
}

.flip-face::-webkit-scrollbar {
  display: none;
}

.flip-front {
  background: var(--surface-soft);
  border: 1.5px solid var(--border);
  font-weight: 700;
  color: var(--text);
}

.flip-back {
  background: var(--pink-soft);
  border: 1.5px solid var(--pink);
  color: var(--text);
  transform: rotateX(180deg);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Soundtrack (EP 03) */
.track-list {
  display: grid;
  gap: 12px;
}

.track-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.72);
}

.track-item h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.track-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.eq-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 20px;
  flex-shrink: 0;
}

.eq-bars span {
  width: 3px;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(to top, var(--accent), var(--pink));
  animation: eqBar 1.1s ease-in-out infinite;
}

.eq-bars span:nth-child(2) {
  animation-delay: 0.2s;
}

.eq-bars span:nth-child(3) {
  animation-delay: 0.45s;
}

.eq-bars span:nth-child(4) {
  animation-delay: 0.1s;
}

/* Scratch Foil (EP 04) */
.scratch-container {
  position: relative;
  margin-top: 18px;
  border-radius: 18px;
  border: 2px solid #facc15;
  background: linear-gradient(135deg, #fffbeb 0%, #fff0f5 100%);
  overflow: hidden;
  min-height: 142px;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  box-shadow: 0 10px 28px rgba(234, 179, 8, 0.16), 0 2px 8px rgba(236, 72, 153, 0.12);
}

.scratch-reward {
  position: relative;
  z-index: 1;
}

.scratch-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  cursor: crosshair;
  touch-action: none;
  transition: opacity 0.45s ease;
}

.scratch-canvas.cleared {
  opacity: 0;
  pointer-events: none;
}

.scratch-hint-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
  gap: 8px;
}

/* Quiz & Bucket List */
.quiz-item {
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 4px 14px rgba(44, 36, 22, 0.04);
}

.quiz-options {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.quiz-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface-strong);
  font: inherit;
  font-size: 0.93rem;
  cursor: pointer;
  transition: transform 0.25s var(--ease-silk), background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.quiz-opt:hover {
  transform: translateX(4px);
  border-color: var(--pink);
}

.quiz-opt.selected {
  border-color: var(--pink);
  background: linear-gradient(135deg, rgba(255, 241, 246, 0.95) 0%, rgba(255, 230, 240, 0.95) 100%);
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.14);
}

.quiz-opt.selected::after {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--pink);
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 700;
  margin-left: 8px;
  flex-shrink: 0;
}

.quiz-reaction {
  margin: 12px 0 0;
  font-size: 0.9rem;
  color: var(--pink-dark);
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(236, 72, 153, 0.08);
  border-left: 3px solid var(--pink);
  animation: cardEnter 0.35s ease both;
}

.quiz-reaction:empty {
  display: none;
}

.bucket-progress {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(254, 240, 138, 0.5), rgba(251, 207, 232, 0.5));
  border: 1px solid rgba(236, 72, 153, 0.3);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--pink-dark);
}

.bucket-list {
  display: grid;
  gap: 10px;
}

.bucket-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.2s ease;
}

.bucket-item:hover {
  transform: translateX(3px);
  border-color: var(--pink);
}

.bucket-item.checked {
  border-color: rgba(236, 72, 153, 0.45);
  background: rgba(255, 240, 246, 0.75);
}

.bucket-item.checked span {
  text-decoration: line-through;
  color: var(--muted);
  opacity: 0.75;
}

.bucket-item.checked::after {
  content: "💖";
  margin-left: auto;
  font-size: 0.9rem;
}

.bucket-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--pink);
  flex-shrink: 0;
}

.collage-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.collage-grid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 14px;
}

/* Memory Panel */
.memory-panel {
  margin-top: 22px;
  background: var(--surface-strong);
  backdrop-filter: blur(20px);
  border: 2px solid var(--pink);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.memory-panel h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
}

.memory-panel p {
  margin: 0 0 16px;
  color: var(--muted);
}

.memory-actions {
  display: grid;
  gap: 10px;
}

@media (prefers-reduced-motion: reduce) {

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

.print-keepsake {
  display: none;
}

@media print {
  body {
    background: #ffffff;
  }

  .aurora-bg,
  #ambient-canvas,
  #confetti-canvas,
  .intro-screen,
  .app-shell,
  .app-header,
  .floating-pill-nav {
    display: none !important;
  }

  .print-keepsake {
    display: block !important;
    padding: 20px;
  }

  .keepsake-ep {
    page-break-inside: avoid;
    border-bottom: 1px solid #ddd;
    padding: 14px 0;
  }

  .keepsake-ep img {
    max-width: 280px;
    border-radius: 8px;
  }
}