:root {
  --ink: #f4efe6;
  --ink-soft: #c9c3d6;
  --glass: rgba(14, 12, 28, 0.66);
  --glass-edge: rgba(255, 214, 160, 0.18);
  --hot: #ffb35c;
  --hot-deep: #ff7a2f;
  --cool: #8fd3ff;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #03040a;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#scene:active {
  cursor: grabbing;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.topbar {
  position: fixed;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: clamp(10px, 2vw, 18px) clamp(12px, 2.4vw, 24px);
  pointer-events: none;
}

.brand {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: clamp(15px, 2vw, 19px);
  letter-spacing: 0.01em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.7);
}

.brand-sub {
  font-weight: 500;
  color: var(--ink-soft);
}

.brand-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #000;
  box-shadow: 0 0 0 3px var(--hot), 0 0 14px 4px rgba(255, 150, 60, 0.7);
}

.top-actions {
  pointer-events: auto;
}

.pill {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--glass-edge);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-weight: 700;
  font-size: 14px;
}

.pill:hover {
  border-color: rgba(255, 214, 160, 0.45);
}

.story {
  position: fixed;
  left: clamp(12px, 2.4vw, 28px);
  bottom: clamp(12px, 2.4vw, 28px);
  width: min(440px, calc(100% - 24px));
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s;
}

body.exploring .story {
  transform: translateY(calc(100% + 40px));
  opacity: 0;
  pointer-events: none;
}

.card {
  padding: clamp(16px, 2.4vw, 24px);
  border-radius: 24px;
  border: 1px solid var(--glass-edge);
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.card.enter {
  animation: card-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.step {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--hot);
}

.read {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(135deg, var(--hot), var(--hot-deep));
  color: #2a1204;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(255, 122, 47, 0.35);
}

.read svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.read.speaking {
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 8px rgba(255, 150, 60, 0.18), 0 6px 20px rgba(255, 122, 47, 0.35);
  }
}

h1 {
  margin: 12px 0 8px;
  font-size: clamp(24px, 3.6vw, 34px);
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.kid {
  margin: 0;
  font-size: clamp(17px, 2.1vw, 20px);
  line-height: 1.45;
  color: var(--ink);
}

.kid strong {
  color: var(--hot);
}

.replay {
  margin-top: 12px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(143, 211, 255, 0.4);
  background: rgba(143, 211, 255, 0.12);
  color: var(--cool);
  font-weight: 800;
  font-size: 15px;
}

.grownup {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.grownup summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink-soft);
  list-style-position: inside;
}

.grownup p {
  margin: 8px 0 0;
}

.grownup a {
  color: var(--cool);
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
  font-size: 17px;
}

.nav-btn svg {
  width: 22px;
  height: 22px;
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.nav-btn.next {
  padding: 0 14px 0 20px;
  border: 0;
  background: var(--ink);
  color: #120c1e;
}

.dots {
  flex: 1;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dots button {
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.22);
  transition: background 0.2s, transform 0.2s;
}

.dots button[aria-current="step"] {
  background: var(--hot);
  transform: scale(1.35);
}

.hint {
  position: fixed;
  right: clamp(12px, 2.4vw, 24px);
  bottom: clamp(12px, 2.4vw, 24px);
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--ink-soft);
  font-size: 13px;
  pointer-events: none;
  transition: opacity 0.6s;
}

.labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.label {
  position: absolute;
  left: 0;
  top: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(10, 8, 22, 0.72);
  border: 1px solid rgba(255, 214, 160, 0.35);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 14px));
  transition: opacity 0.4s;
}

.label::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -12px;
  width: 2px;
  height: 11px;
  background: rgba(255, 214, 160, 0.6);
}

.fallback {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  font-size: 18px;
}

:focus-visible {
  outline: 3px solid var(--cool);
  outline-offset: 2px;
}

/* Embedded in the project page: compact the story card so the scene stays visible. */
body.embed .story {
  width: min(360px, calc(100% - 20px));
  left: 10px;
  bottom: 10px;
}

body.embed .card {
  padding: 14px 16px;
  border-radius: 18px;
}

body.embed h1 {
  font-size: 22px;
  margin: 8px 0 6px;
}

body.embed .kid {
  font-size: 16px;
}

body.embed .grownup {
  margin-top: 10px;
  padding-top: 8px;
}

body.embed .nav {
  margin-top: 10px;
}

body.embed .nav-btn {
  min-width: 42px;
  min-height: 42px;
}

body.embed .hint,
body.embed .brand-sub {
  display: none;
}

@media (max-width: 640px) {
  .hint {
    display: none;
  }

  .story {
    left: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
  }

  .brand-sub {
    display: none;
  }

  .dots {
    gap: 4px;
  }

  .dots button {
    width: 8px;
    height: 8px;
  }
}

@media (max-height: 560px) {
  .grownup {
    display: none;
  }

  .card {
    padding: 12px 16px;
  }

  h1 {
    font-size: 20px;
    margin: 6px 0 4px;
  }

  .kid {
    font-size: 15px;
  }

  .nav {
    margin-top: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story,
  .card.enter,
  .read.speaking {
    transition: none;
    animation: none;
  }
}
