:root {
  color-scheme: light;
  --ink: #123037;
  --muted: #577177;
  --paper: #fffaf0;
  --sky: #bdefff;
  --sea: #1b8ca8;
  --leaf: #35b96b;
  --sun: #ffcf4d;
  --coral: #ff6b64;
  --berry: #8c5bd9;
  --card: rgba(255, 255, 255, 0.88);
  --shadow: 0 18px 45px rgba(13, 60, 72, 0.18);
  --radius: 28px;
  font-family: "Avenir Next", "Baloo 2", "Trebuchet MS", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 207, 77, 0.34), transparent 24%),
    radial-gradient(circle at 88% 16%, rgba(140, 91, 217, 0.24), transparent 28%),
    linear-gradient(160deg, #eafaff 0%, #d7f7f0 40%, #fff5d8 100%);
  color: var(--ink);
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}

button:disabled { cursor: not-allowed; opacity: 0.55; }

button:focus-visible, audio:focus-visible, video:focus-visible {
  outline: 4px solid #ff9f1c;
  outline-offset: 3px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 16px clamp(12px, 3vw, 34px) 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 14px;
  max-width: 1360px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  animation: pulse 2.4s ease-in-out infinite;
  border-radius: 50%;
  display: block;
  height: 20px;
  width: 20px;
  background: radial-gradient(circle, #35b96b 0 30%, #ffcf4d 32% 72%, transparent 75%);
}

.privacy-chip {
  background: rgba(18, 48, 55, 0.12);
  border-radius: 999px;
  color: #244c56;
  font-size: 0.8rem;
  line-height: 1.2;
  max-width: 430px;
  padding: 7px 12px;
  text-align: right;
}

.progress-track {
  display: flex;
  gap: 7px;
  margin: 0 auto 14px;
  max-width: 1360px;
}

.progress-step {
  align-items: center;
  background: rgba(255, 255, 255, 0.58);
  border: 3px solid transparent;
  border-radius: 999px;
  display: flex;
  gap: 6px;
  padding: 6px 11px 6px 7px;
  font-size: 0.78rem;
  font-weight: 750;
}

.progress-step i {
  background: #b8cdd3;
  border-radius: 50%;
  display: block;
  height: 13px;
  width: 13px;
}

.progress-step.done i { background: var(--leaf); }
.progress-step.current { border-color: var(--sun); background: #fff; box-shadow: 0 5px 15px rgba(18, 48, 55, 0.12); }
.progress-step.current i { background: var(--sun); }

.main-frame {
  background: var(--card);
  border: 5px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(310px, 0.78fr);
  margin: 0 auto;
  max-width: 1360px;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.stage {
  min-height: 560px;
  position: relative;
}

.stage-art {
  inset: 0;
  object-fit: cover;
  position: absolute;
  width: 100%;
  height: 100%;
}

.stage-char {
  bottom: 16px;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.2));
  left: 20px;
  position: absolute;
  width: clamp(130px, 17vw, 210px);
  z-index: 3;
}

.stage-caption {
  background: linear-gradient(0deg, rgba(8, 34, 42, 0.82), transparent);
  color: white;
  padding: 72px 28px 22px;
  position: absolute;
  inset: auto 0 0;
  z-index: 3;
}

.stage-caption h2 { font-size: clamp(1.35rem, 2.4vw, 2.1rem); margin: 0 0 7px; }
.stage-caption p { font-size: clamp(1rem, 1.5vw, 1.22rem); margin: 0; max-width: 680px; }

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(18px, 2.2vw, 28px);
}

.act-heading { color: #0d5461; font-size: 1.25rem; line-height: 1.2; margin: 0; }

.instruction {
  background: rgba(53, 185, 107, 0.16);
  border-left: 7px solid var(--leaf);
  border-radius: 14px;
  color: #173f48;
  font-size: 1.03rem;
  line-height: 1.45;
  padding: 12px 14px;
}

.phrase-card {
  background: #fff8e0;
  border: 4px dashed #f2b83b;
  border-radius: 20px;
  padding: 14px;
}

.phrase-label { color: #765711; font-size: .78rem; font-weight: 800; letter-spacing: .07em; margin-bottom: 5px; text-transform: uppercase; }
.phrase { font-size: 1.16rem; font-weight: 800; line-height: 1.35; margin: 0; }

.choices {
  display: grid;
  gap: 10px;
}

.choice-button, .stone-button {
  align-items: center;
  background: white;
  border: 4px solid #cfe2e7;
  border-radius: 18px;
  box-shadow: 0 5px 0 #cfe2e7;
  display: flex;
  gap: 12px;
  min-height: 56px;
  padding: 10px 13px;
  text-align: left;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.choice-button:hover, .stone-button:hover { transform: translateY(-1px); }
.choice-button.selected { border-color: var(--leaf); box-shadow: 0 5px 0 var(--leaf); }

.choice-icon {
  border-radius: 13px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  height: 40px;
  width: 40px;
  font-size: 1.15rem;
  font-weight: 900;
}

.apple { background: #ff5b54; }
.banana { background: #ffd84d; }
.berry { background: #6f76e8; color: white; }
.firefly-blue { background: #62c8ff; box-shadow: 0 0 20px #62c8ff; }
.firefly-yellow { background: #ffdc59; box-shadow: 0 0 20px #ffdc59; }
.firefly-pink { background: #ff96d2; box-shadow: 0 0 20px #ff96d2; }
.stone-red { background: #e2503d; }
.stone-blue { background: #4c7ff0; }
.stone-yellow { background: #efc33d; }

.stone-row { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); }
.stone-button { display: grid; place-items: center; min-height: 74px; }
.stone-button .choice-icon { border-radius: 50%; height: 42px; width: 42px; }
.stone-order {
  background: rgba(255, 255, 255, .68);
  border-radius: 14px;
  color: #33565f;
  display: flex;
  gap: 6px;
  font-size: .82rem;
  flex-wrap: wrap;
  min-height: 32px;
  padding: 7px;
}

.show-builder { display: grid; gap: 12px; }
.show-choice-set { border-top: 1px solid #d7e6ea; padding-top: 7px; }
.show-choice-label { color: #33565f; font-size: .76rem; font-weight: 850; margin-bottom: 4px; }
.show-options { display: flex; flex-wrap: wrap; gap: 8px; }
.show-option {
  background: white;
  border: 3px solid #d8e8ec;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  min-width: 88px;
  min-height: 39px;
  padding: 5px 8px;
  text-align: left;
  white-space: nowrap;
}
.show-option br { display: none; }
.show-option.selected { border-color: var(--berry); box-shadow: 0 4px 0 var(--berry); }
.selected-mark { color: #7b3fa0; font-weight: 900; }

.starter-list { display: flex; flex-wrap: wrap; gap: 6px; }
.starter {
  background: rgba(140, 91, 217, .11);
  border-radius: 999px;
  color: #4f2f86;
  font-size: .76rem;
  padding: 5px 8px;
}

.controls { display: grid; gap: 10px; margin-top: auto; }

.primary-button {
  background: linear-gradient(180deg, #ff8a6b, #ef5350);
  border-radius: 20px;
  box-shadow: 0 7px 0 #c93830;
  color: white;
  font-size: 1.12rem;
  font-weight: 900;
  min-height: 58px;
  padding: 12px 20px;
  transition: transform .12s ease, box-shadow .12s ease;
}

.primary-button:hover:not(:disabled) { transform: translateY(-1px); }
.primary-button:active:not(:disabled) { box-shadow: 0 3px 0 #c93830; transform: translateY(3px); }

.secondary-button {
  background: white;
  border: 3px solid #bfd9e0;
  border-radius: 17px;
  box-shadow: 0 5px 0 #bfd9e0;
  min-height: 50px;
  font-weight: 800;
  padding: 10px 15px;
}

.ghost-button {
  background: rgba(18, 48, 55, .07);
  border-radius: 13px;
  color: #33565f;
  font-size: .85rem;
  font-weight: 700;
  min-height: 40px;
  padding: 8px 11px;
}

.listen-button { position: relative; overflow: hidden; }
.listen-button.listening {
  animation: listening 1.1s ease-in-out infinite;
  background: linear-gradient(180deg, #69d68b, #21a25d);
  box-shadow: 0 7px 0 #157843;
}

.listen-meter {
  background: rgba(18, 48, 55, .12);
  border-radius: 999px;
  height: 11px;
  overflow: hidden;
}
.listen-meter span {
  background: linear-gradient(90deg, #ffd166, #ff6b64);
  display: block;
  height: 100%;
  transition: width .08s linear;
  width: 0%;
}

.feedback {
  border-radius: 17px;
  padding: 13px;
}
.feedback.celebrate { background: #e8fff0; border: 3px solid var(--leaf); }
.feedback.partial { background: #fff7dd; border: 3px solid #f2b83b; }
.feedback.retry { background: #f2f7ff; border: 3px solid #7ba7e3; }
.feedback.fallback { background: #f5f0ff; border: 3px solid var(--berry); }
.feedback h3 { font-size: 1.02rem; margin: 0 0 5px; }
.feedback p { font-size: .94rem; line-height: 1.4; margin: 0 0 7px; }
.model-again { color: #33565f; font-size: .87rem; font-style: italic; margin: 0; }

.video-frame {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  position: absolute;
  z-index: 5;
  background: #072229;
}
.video-frame video { height: 100%; width: 100%; object-fit: cover; }
.video-stage-frame {
  display: flex;
  grid-template-columns: none;
  width: min(100%, 1360px);
}

.video-stage-frame .stage { flex: 1; min-height: 0; }

.video-caption {
  background: rgba(6, 32, 39, .78);
  border-radius: 16px;
  bottom: 26px;
  color: white;
  font-size: clamp(1rem, 1.7vw, 1.3rem);
  font-weight: 800;
  left: 50%;
  max-width: min(720px, 82%);
  padding: 13px 20px;
  position: absolute;
  transform: translateX(-50%);
  text-align: center;
}

.video-frame video[controls] + .video-caption { bottom: 84px; }

.skip-button {
  background: rgba(255,255,255,.18);
  border: 2px solid rgba(255,255,255,.5);
  color: white;
  border-radius: 999px;
  position: absolute;
  right: 22px;
  top: 20px;
  z-index: 7;
  padding: 9px 15px;
}

.title-screen {
  display: grid;
  min-height: 90vh;
  place-items: center;
  position: relative;
}
.title-copy {
  background: rgba(255, 250, 240, .84);
  border-radius: 28px;
  box-shadow: var(--shadow);
  max-width: 730px;
  padding: clamp(26px, 4vw, 48px);
  position: relative;
  text-align: center;
  z-index: 4;
}
.eyebrow { color: #0f7189; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.title-copy h1 { font-size: clamp(2.3rem, 6vw, 4.6rem); line-height: .98; margin: 8px 0 12px; }
.title-copy p { color: var(--muted); font-size: clamp(1rem, 1.6vw, 1.2rem); line-height: 1.5; margin: 0 auto 22px; max-width: 590px; }
.title-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.title-actions .primary-button { min-width: 180px; }
.title-cast { display: flex; justify-content: center; gap: 6px; margin-top: 24px; }
.title-cast img { width: 72px; }

.complete-grid { grid-template-columns: minmax(0, 1fr) minmax(300px, .72fr); }
.badge-wall { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  background: #fff8e0;
  border: 3px solid #f2b83b;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
}
.summary {
  background: #f4fbff;
  border: 3px solid #bfe2ef;
  border-radius: 18px;
  padding: 13px;
}
.summary dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; margin: 0; }
.summary dt { font-weight: 850; }
.summary dd { margin: 0; }
.story-moments { display: grid; gap: 9px; }
.story-moment {
  background: white;
  border: 3px solid #d8e8ec;
  border-radius: 14px;
  font-size: .87rem;
  padding: 10px;
  text-align: left;
}
.play-character { display: flex; flex-wrap: wrap; gap: 8px; }
.play-character img { background: white; border: 3px solid #d8e8ec; border-radius: 15px; cursor: pointer; padding: 5px; width: 76px; }

.extension-card {
  background: #fff8e0;
  border: 4px solid #f2b83b;
  border-radius: 20px;
  padding: 15px;
}
.extension-card h3 { margin: 0 0 7px; }
.extension-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.noscript {
  align-items: center;
  display: grid;
  min-height: 100vh;
  place-items: center;
  text-align: center;
}

@keyframes pulse { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.28); opacity: 1; } }
@keyframes listening { 0%,100% { transform: scale(1); } 50% { transform: scale(1.015); } }

@media (max-width: 940px) {
  .app-shell { padding: 10px; }
  .main-frame, .complete-grid { grid-template-columns: 1fr; }
  .stage { min-height: 430px; }
  .video-stage-frame { flex: 0 0 auto; height: auto; }
  .video-stage-frame .stage { aspect-ratio: 16 / 9; flex: 0 0 auto; min-height: 0; width: 100%; }
  .side-panel { border-top: 4px solid rgba(255,255,255,.7); }
  .topbar { align-items: flex-start; flex-direction: column; }
  .privacy-chip { text-align: left; }
  .progress-track { flex-wrap: wrap; }
  .progress-step span { display: none; }
  .progress-step.current span { display: inline; }
  .stage-char { width: 125px; }
}

@media (max-width: 580px) {
  .stage { min-height: 330px; }
  .stone-row { grid-template-columns: repeat(2, 1fr); }
  .video-caption {
    font-size: .9rem;
    left: 10px;
    max-width: none;
    padding: 10px 14px;
    right: 10px;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-height: 760px) and (min-width: 941px) {
  .app-shell { height: 100vh; overflow: hidden; padding: 10px 24px 14px; }
  .topbar { margin-bottom: 7px; }
  .privacy-chip { font-size: .69rem; padding: 5px 9px; }
  .progress-track { margin-bottom: 7px; }
  .progress-step { font-size: .68rem; padding: 4px 8px 4px 5px; }
  .main-frame { border-radius: 24px; }
  .stage { min-height: 0; }
  .side-panel { gap: 9px; overflow-y: auto; padding: 13px 15px; scrollbar-width: thin; }
  .act-heading { font-size: 1.05rem; }
  .instruction { border-radius: 11px; font-size: .9rem; line-height: 1.33; padding: 8px 10px; }
  .phrase-card { border-radius: 14px; border-width: 3px; padding: 9px; }
  .phrase { font-size: 1rem; }
  .choice-button { border-radius: 13px; box-shadow: 0 4px 0 #cfe2e7; gap: 8px; min-height: 45px; padding: 7px 9px; }
  .choice-icon { border-radius: 10px; height: 31px; width: 31px; }
  .controls { gap: 7px; }
  .primary-button { border-radius: 15px; box-shadow: 0 5px 0 #c93830; font-size: .97rem; min-height: 47px; padding: 9px 13px; }
  .secondary-button { border-radius: 12px; box-shadow: 0 4px 0 #bfd9e0; min-height: 42px; padding: 7px 11px; }
  .ghost-button { border-radius: 10px; font-size: .75rem; min-height: 34px; padding: 6px 8px; }
  .show-builder { gap: 6px; }
  .show-choice-set { padding-top: 4px; }
  .show-choice-label { font-size: .68rem; margin-bottom: 3px; }
  .show-options { gap: 5px; }
  .show-option { border-radius: 10px; border-width: 2px; font-size: .72rem; min-height: 30px; min-width: 74px; padding: 3px 6px; }
  .starter { border-radius: 999px; font-size: .66rem; padding: 3px 6px; }
  .phrase-label { font-size: .68rem; }
  .phrase { font-size: .88rem; }
  .feedback { border-radius: 12px; padding: 9px; }
  .feedback h3 { font-size: .9rem; }
  .feedback p { font-size: .8rem; }
}
