:root {
  --color-bg: #fff8f6;
  --color-bg-alt: #ffeef2;
  --color-surface: #ffffff;
  --color-primary: #e8637f;
  --color-primary-dark: #c94764;
  --color-accent: #f6a6bd;
  --color-gold: #e8b34f;
  --color-danger: #e5484d;
  --color-text: #3a2a2f;
  --color-text-muted: #7a6066;

  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 4rem;
  --space-xl: 6rem;

  --font-display: "Fraunces", serif;
  --font-body: "DM Sans", sans-serif;
  --font-accent: "Caveat", cursive;

  --font-size-body: clamp(1rem, 0.95rem + 0.3vw, 1.125rem);
  --font-size-eyebrow: clamp(0.8rem, 0.75rem + 0.2vw, 0.95rem);
  --font-size-h2: clamp(1.75rem, 1.4rem + 2vw, 3rem);

  --ease-out-soft: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--font-size-body);
  color: var(--color-text);
  background: var(--color-bg);
  background-image:
    radial-gradient(ellipse 60% 40% at 15% 10%, var(--color-bg-alt) 0%, transparent 60%),
    radial-gradient(ellipse 50% 35% at 90% 80%, var(--color-bg-alt) 0%, transparent 60%);
  background-attachment: fixed;
  line-height: 1.6;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 var(--space-sm);
}

p { margin: 0 0 var(--space-sm); }

button {
  font-family: var(--font-body);
  cursor: pointer;
}

[hidden] { display: none !important; }

@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;
  }
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--space-sm);
}

.chapter {
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: var(--space-lg) 0;
  position: relative;
}

.chapter-inner {
  width: 100%;
}

.eyebrow {
  font-family: var(--font-accent);
  font-size: var(--font-size-eyebrow);
  color: var(--color-primary-dark);
  margin-bottom: var(--space-xs);
}

.chapter-title {
  font-size: var(--font-size-h2);
  color: var(--color-text);
}

.chapter-image {
  margin: var(--space-md) 0;
}

.section-image {
  width: 100%;
  border-radius: 1.25rem;
  display: block;
  object-fit: cover;
  max-height: 60vh;
}

.section-image--placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 1.25rem;
  background: linear-gradient(135deg, var(--color-bg-alt), var(--color-accent) 120%);
}

.chapter-slideshow {
  position: relative;
  border-radius: 1.25rem;
  overflow: hidden;
}

.slideshow-track {
  display: flex;
  transition: transform 400ms var(--ease-out-soft);
}

.slideshow-slide {
  flex: 0 0 100%;
  min-width: 0;
}

.slideshow-slide .section-image,
.slideshow-slide .section-image--placeholder {
  border-radius: 0;
  margin: 0;
}

.slideshow-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  color: var(--color-primary-dark);
  font-size: 1.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(232, 99, 127, 0.2);
  transition: background 150ms var(--ease-out-soft);
}

.slideshow-arrow:hover,
.slideshow-arrow:focus-visible {
  background: var(--color-surface);
}

.slideshow-arrow--prev { left: var(--space-xs); }
.slideshow-arrow--next { right: var(--space-xs); }

.slideshow-dots {
  position: absolute;
  bottom: var(--space-xs);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.slideshow-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  transition: background 150ms var(--ease-out-soft), transform 150ms var(--ease-out-soft);
}

.slideshow-dot--active {
  background: var(--color-surface);
  transform: scale(1.3);
}

@media (max-width: 480px) {
  .slideshow-arrow { font-size: 1.2rem; }
}

.pin-gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
  background: var(--color-bg);
  background-image:
    radial-gradient(ellipse 60% 40% at 20% 20%, var(--color-bg-alt) 0%, transparent 60%),
    radial-gradient(ellipse 50% 35% at 85% 85%, var(--color-accent) 0%, transparent 55%);
  z-index: 100;
}

.pin-card {
  background: var(--color-surface);
  border-radius: 1.5rem;
  padding: var(--space-lg) var(--space-md);
  max-width: 22rem;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(232, 99, 127, 0.15);
}

.pin-eyebrow {
  font-family: var(--font-accent);
  color: var(--color-primary-dark);
  font-size: 1.25rem;
  margin-bottom: 0;
}

.pin-title {
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem);
  margin-bottom: var(--space-md);
}

.pin-label {
  display: block;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.pin-input {
  width: 100%;
  min-height: 44px;
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 0.3em;
  padding: var(--space-xs);
  border: 2px solid var(--color-accent);
  border-radius: 0.75rem;
  margin-bottom: var(--space-sm);
}

.pin-submit {
  width: 100%;
  min-height: 44px;
  border: none;
  border-radius: 0.75rem;
  background: var(--color-primary);
  color: white;
  font-weight: 700;
  font-size: 1rem;
  transition: background 150ms var(--ease-out-soft);
}

.pin-submit:hover { background: var(--color-primary-dark); }

.pin-error {
  color: var(--color-primary-dark);
  font-size: 0.9rem;
  margin-top: var(--space-sm);
  margin-bottom: 0;
}

.progress-nav {
  position: fixed;
  right: var(--space-xs);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  display: block;
  transition: background 150ms var(--ease-out-soft), transform 150ms var(--ease-out-soft);
}

.progress-dot--active {
  background: var(--color-primary);
  transform: scale(1.4);
}

@media (max-width: 480px) {
  .progress-nav { right: 6px; gap: 8px; }
  .progress-dot { width: 6px; height: 6px; }
}

.chapter {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 700ms var(--ease-out-soft), transform 700ms var(--ease-out-soft);
}

.chapter.in-view {
  opacity: 1;
  transform: translateY(0);
}

.zebra {
  position: absolute;
  z-index: 5;
}

.zebra--top-left { top: var(--space-sm); left: var(--space-sm); }
.zebra--top-right { top: var(--space-sm); right: var(--space-sm); }
.zebra--bottom-left { bottom: var(--space-sm); left: var(--space-sm); }
.zebra--bottom-right { bottom: var(--space-sm); right: var(--space-sm); }

.zebra-button {
  width: 64px;
  height: 72px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 42% 42% 46% 46% / 46% 46% 42% 42%;
  background: var(--color-surface);
  box-shadow: 0 8px 20px rgba(232, 99, 127, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  padding: 0;
}

.zebra-img { width: 70%; height: 70%; object-fit: contain; }

.zebra-fallback { width: 82%; height: 82%; display: flex; }
.zebra-state { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.zebra-fallback .zebra-illustration { width: 100%; height: 100%; display: block; overflow: visible; }

.zebra--bounce .zebra-button {
  animation: zebra-bounce 600ms var(--ease-out-soft);
}

@keyframes zebra-bounce {
  0% { transform: translateY(0) rotate(0deg); }
  30% { transform: translateY(-14px) rotate(-8deg); }
  55% { transform: translateY(0) rotate(6deg); }
  75% { transform: translateY(-6px) rotate(-3deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

.zebra-bubble {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  max-width: 12rem;
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  border-radius: 1rem;
  padding: var(--space-xs) var(--space-sm);
  font-family: var(--font-accent);
  font-size: 1.1rem;
  color: var(--color-text);
  box-shadow: 0 8px 20px rgba(232, 99, 127, 0.15);
}

@media (max-width: 480px) {
  .zebra-button { width: 52px; height: 60px; }
  .zebra-bubble { max-width: 9rem; font-size: 1rem; }
}

.widget {
  position: relative;
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--color-surface);
  border-radius: 1.25rem;
  box-shadow: 0 8px 20px rgba(232, 99, 127, 0.1);
}

.widget-question {
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.widget-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice-btn {
  min-height: 44px;
  padding: 0.65rem 1rem;
  border: 2px solid var(--color-accent);
  border-radius: 0.75rem;
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 600;
  text-align: left;
  transition: background 150ms var(--ease-out-soft), color 150ms var(--ease-out-soft), border-color 150ms var(--ease-out-soft);
}

.choice-btn:hover,
.choice-btn:focus-visible {
  border-color: var(--color-primary);
}

.choice-btn--selected {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.choice-btn--wrong {
  background: var(--color-danger);
  color: white;
  border-color: var(--color-danger);
}

.choice-btn--shake {
  animation: choice-shake 400ms var(--ease-out-soft);
}

@keyframes choice-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}

.widget-feedback {
  margin-top: var(--space-sm);
  margin-bottom: 0;
  font-weight: 700;
  color: var(--color-primary-dark);
}

.choice-confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  border-radius: inherit;
  z-index: 5;
}

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

#finale .chapter-inner {
  position: relative;
  z-index: 2;
  text-align: center;
}

.chapter-closing {
  margin-top: var(--space-lg);
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-primary);
  font-size: clamp(1.75rem, 1.2rem + 3.2vw, 3.25rem);
  line-height: 1.2;
}
