/* Creature Lab add-on: Story Theater — all selectors scoped under .st-root */
.st-root {
  position: relative; box-sizing: border-box; width: 100%; height: 100%; min-height: 560px;
  display: flex; flex-direction: column; overflow: hidden;
  font-family: "Baloo 2", "Comic Sans MS", "Chalkboard SE", "Comic Neue", "Trebuchet MS", system-ui, sans-serif;
  color: #2b2350;
  background: radial-gradient(circle at 20% 10%, #ffe0f7 0%, #c9b6ff 45%, #8f7bff 100%);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.st-root *, .st-root *::before, .st-root *::after { box-sizing: border-box; }

.st-root .st-btn {
  font: inherit; border: 5px solid #2b2350; border-radius: 28px; background: #fff; color: #2b2350; font-weight: 900;
  cursor: pointer; box-shadow: 0 7px 0 #2b2350; transition: transform .08s, box-shadow .08s, opacity .2s;
  min-width: 72px; min-height: 72px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 10px; line-height: 1;
}
.st-root .st-btn:active { transform: translateY(6px); box-shadow: 0 1px 0 #2b2350; }
.st-root .st-btn:disabled { opacity: .3; pointer-events: none; }
.st-root .st-btn-icon { font-size: 38px; line-height: 1; }
.st-root .st-round { width: 76px; height: 76px; border-radius: 50%; padding: 0; }
.st-root .st-green { background: #3ddc84; } .st-root .st-yellow { background: #ffd93b; }
.st-root .st-blue { background: #5ab8ff; } .st-root .st-pink { background: #ff8fc7; }

.st-root .st-topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; flex: 0 0 auto; }
.st-root .st-steps { flex: 1; display: flex; justify-content: center; gap: 10px; }
.st-root .st-step {
  width: 62px; height: 62px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 32px;
  background: rgba(255,255,255,.4); border: 4px dashed rgba(43,35,80,.35); opacity: .7;
}
.st-root .st-step.st-done { background: #b6f5c9; border: 4px solid #2b2350; opacity: 1; }
.st-root .st-step.st-on { background: #ffd93b; border: 5px solid #2b2350; opacity: 1; transform: scale(1.15); animation: st-pulse 1.2s ease-in-out infinite; }

.st-root .st-heading {
  display: flex; align-items: center; justify-content: center; gap: 14px; flex: 0 0 auto; padding: 0 12px 8px;
  font-size: clamp(34px, 6vw, 56px); font-weight: 900; color: #fff; -webkit-text-stroke: 2px #2b2350; text-shadow: 0 5px 0 #2b2350;
}
.st-root .st-heading-icon { font-size: 1.2em; -webkit-text-stroke: 0; text-shadow: none; animation: st-hop 1.4s ease-in-out infinite; }

.st-root .st-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 32px; font-weight: 800; }
.st-root .st-empty-emoji { font-size: 120px; }

/* item grid */
.st-root .st-grid {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 18px 24px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; align-content: start;
}
.st-root .st-card {
  font: inherit; position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px;
  background: #fff; border: 5px solid #2b2350; border-radius: 26px; cursor: pointer; box-shadow: 0 7px 0 #2b2350; transition: transform .12s;
}
.st-root .st-card:active { transform: scale(.95); }
.st-root .st-card.st-on { background: #fff59d; transform: scale(1.06) rotate(-2deg); box-shadow: 0 0 0 7px #ffd93b, 0 7px 0 #2b2350; }
.st-root .st-card.st-on::after { content: "✔"; position: absolute; top: -14px; right: -12px; width: 52px; height: 52px; border-radius: 50%; background: #3ddc84; color: #fff; font-size: 32px; line-height: 46px; text-align: center; border: 4px solid #fff; }
.st-root .st-card .st-art { width: 100%; aspect-ratio: 1; background: #eef6ff; border-radius: 18px; }
.st-root .st-card-name { font-size: 20px; font-weight: 900; text-align: center; line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-root .st-card-type { position: absolute; top: 8px; left: 10px; font-size: 24px; }
.st-root .st-card-dice { background: #ffd93b; justify-content: center; }
.st-root .st-dice { font-size: 96px; animation: st-spin 3s ease-in-out infinite; }

.st-root .st-art { display: flex; align-items: center; justify-content: center; overflow: hidden; }
.st-root .st-art img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.st-root .st-art-emoji { font-size: 70px; }

/* places */
.st-root .st-places {
  flex: 1; min-height: 0; overflow-y: auto; padding: 10px 18px 24px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: minmax(170px, 1fr); gap: 18px;
}
.st-root .st-place {
  font: inherit; position: relative; overflow: hidden; border: 6px solid #2b2350; border-radius: 30px; cursor: pointer;
  box-shadow: 0 8px 0 #2b2350; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: transform .12s;
}
.st-root .st-place:active { transform: scale(.96); }
.st-root .st-place.st-on { transform: scale(1.05); box-shadow: 0 0 0 8px #ffd93b, 0 8px 0 #2b2350; }
.st-root .st-place-deco { position: absolute; top: 8px; left: 0; right: 0; text-align: center; font-size: 30px; letter-spacing: 14px; opacity: .85; }
.st-root .st-place-emoji { font-size: clamp(70px, 11vw, 110px); line-height: 1; filter: drop-shadow(0 6px 0 rgba(0,0,0,.25)); animation: st-hop 2s ease-in-out infinite; }
.st-root .st-place:nth-child(2n) .st-place-emoji { animation-delay: -.7s; }
.st-root .st-place-label {
  margin-top: 6px; font-size: clamp(22px, 3.4vw, 32px); font-weight: 900; color: #fff; background: rgba(43,35,80,.75); padding: 2px 18px; border-radius: 20px;
}

/* magic transition */
.st-root .st-magic { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.st-root .st-magic-book { font-size: 180px; animation: st-spin-in 1.3s cubic-bezier(.3,1.5,.5,1); }
.st-root .st-magic-sparkles { font-size: 60px; animation: st-twinkle .4s ease-in-out infinite alternate; }

/* book */
.st-root .st-book { position: relative; flex: 1; min-height: 0; margin: 0 16px; perspective: 2200px; }
.st-root .st-page {
  position: absolute; inset: 0; display: flex; flex-direction: column; background: #fffaf0; border: 6px solid #2b2350; border-radius: 30px;
  overflow: hidden; box-shadow: 0 10px 0 #2b2350; transform-origin: left center; backface-visibility: hidden; will-change: transform;
}
.st-root .st-page.st-leaving { z-index: 2; pointer-events: none; }
.st-root .st-scene { position: relative; flex: 1 1 60%; min-height: 0; overflow: hidden; border-bottom: 5px solid #2b2350; cursor: pointer; }
.st-root .st-scene.st-dark::after { content: ""; position: absolute; inset: 0; background: rgba(40,0,60,.35); pointer-events: none; }
.st-root .st-scene-deco { position: absolute; inset: 0; pointer-events: none; }
.st-root .st-deco { position: absolute; font-size: clamp(40px, 7vw, 80px); opacity: .9; }
.st-root .st-deco0 { left: 3%; bottom: 8%; font-size: clamp(60px, 11vw, 120px); }
.st-root .st-deco1 { right: 4%; top: 8%; animation: st-float 4s ease-in-out infinite; }
.st-root .st-deco2 { right: 6%; bottom: 6%; }
.st-root .st-deco3 { left: 30%; top: 6%; animation: st-float 5s ease-in-out infinite reverse; }

.st-root .st-actor { position: absolute; bottom: 6%; width: 34%; max-width: 300px; aspect-ratio: 1; z-index: 2; filter: drop-shadow(0 10px 0 rgba(0,0,0,.25)); }
.st-root .st-actor img { border-radius: 26px; border: 5px solid #fff; background: rgba(255,255,255,.85); }
.st-root .st-actor .st-art-emoji { font-size: clamp(80px, 14vw, 160px); }
.st-root .st-actor.st-center { left: 50%; margin-left: -17%; }
.st-root .st-actor.st-big { width: 40%; margin-left: -20%; }
.st-root .st-actor.st-left { left: 8%; }
.st-root .st-actor.st-right { right: 8%; }
.st-root .st-flip img, .st-root .st-flip .st-art-emoji { transform: scaleX(-1); }
.st-root .st-helper { position: absolute; bottom: 8%; font-size: clamp(90px, 16vw, 180px); z-index: 2; filter: drop-shadow(0 8px 0 rgba(0,0,0,.25)); }
.st-root .st-helper.st-right { right: 12%; }
.st-root .st-vs, .st-root .st-theend {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%,-50%) rotate(-8deg); z-index: 3;
  font-size: clamp(50px, 9vw, 100px); font-weight: 900; color: #ffd93b; -webkit-text-stroke: 3px #ff3b5c; text-shadow: 5px 5px 0 #2b2350;
  animation: st-vs 1.2s ease-in-out infinite alternate; white-space: nowrap;
}
.st-root .st-theend { top: 30%; font-size: clamp(44px, 8vw, 90px); }
.st-root .st-prop { position: absolute; z-index: 3; font-size: clamp(36px, 6vw, 64px); pointer-events: none; }
.st-root .st-prop0 { left: 42%; top: 12%; animation: st-float 2.4s ease-in-out infinite; }
.st-root .st-prop1 { left: 12%; top: 18%; animation: st-float 3s ease-in-out infinite reverse; }
.st-root .st-prop2 { right: 14%; top: 22%; animation: st-spin 4s linear infinite; }
.st-root .st-prop3 { left: 48%; bottom: 10%; animation: st-hop 1.6s ease-in-out infinite; }
.st-root .st-prop4 { right: 40%; top: 40%; animation: st-twinkle .8s ease-in-out infinite alternate; }

.st-root .st-text { flex: 0 0 auto; max-height: 42%; overflow-y: auto; padding: 14px 24px 16px; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.st-root .st-words { font-size: clamp(22px, 3.2vw, 34px); line-height: 1.35; font-weight: 700; text-align: center; }
.st-root .st-words.st-glow, .st-root .st-title.st-glow { animation: st-glow 1.2s ease-out; }
.st-root .st-title { font-size: clamp(30px, 5vw, 52px); font-weight: 900; text-align: center; line-height: 1.1; color: #6a3df0; }
.st-root .st-sub { font-size: 24px; font-weight: 800; opacity: .8; }
.st-root .st-pnum { position: absolute; right: 16px; bottom: 6px; font-size: 18px; font-weight: 800; opacity: .45; }
.st-root.st-speaking .st-read { background: #ffd93b; animation: st-pulse .7s ease-in-out infinite; }

.st-root .st-end-btns { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; padding-top: 4px; }
.st-root .st-big { width: 116px; height: 116px; }
.st-root .st-big .st-btn-icon { font-size: 50px; }
.st-root .st-btn-sub { font-size: 18px; margin-top: 6px; }

/* nav */
.st-root .st-nav { flex: 0 0 auto; display: flex; align-items: center; gap: 14px; padding: 16px; }
.st-root .st-arrow { width: 120px; height: 96px; border-radius: 48px; background: #3ddc84; }
.st-root .st-arrow .st-btn-icon { font-size: 54px; color: #fff; -webkit-text-stroke: 2px #2b2350; }
.st-root .st-read, .st-root .st-auto { width: 90px; height: 90px; border-radius: 50%; }
.st-root .st-auto.st-on { background: #ff8fc7; }
.st-root .st-dots { flex: 1; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.st-root .st-dot { width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.6); border: 3px solid #2b2350; }
.st-root .st-dot.st-on { background: #ffd93b; transform: scale(1.4); }

/* page turn */
.st-root .st-turn-out-next { animation: st-out-next .7s ease-in forwards; transform-origin: left center; }
.st-root .st-turn-out-prev { animation: st-out-prev .7s ease-in forwards; transform-origin: right center; }
.st-root .st-turn-in-next { animation: st-in-under .7s ease-out; }
.st-root .st-turn-in-prev { animation: st-in-under .7s ease-out; }
.st-root .st-turn-in-first { animation: st-in-first .7s cubic-bezier(.3,1.4,.5,1); }

/* actor animations */
.st-root .st-hop { animation: st-hop 1.6s ease-in-out infinite; }
.st-root .st-wiggle { animation: st-wiggle 1.4s ease-in-out infinite; }
.st-root .st-dance { animation: st-dance 1s ease-in-out infinite; }
.st-root .st-dance2 { animation-delay: -.5s; }
.st-root .st-charge { animation: st-charge 2.2s ease-in-out infinite; }
.st-root .st-recoil { animation: st-recoil 2.2s ease-in-out infinite; }

@keyframes st-hop { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-18px); } }
@keyframes st-wiggle { 0%,100% { transform: rotate(-5deg) scale(1); } 50% { transform: rotate(5deg) scale(1.06); } }
@keyframes st-dance { 0%,100% { transform: rotate(-10deg) translateY(0); } 50% { transform: rotate(10deg) translateY(-24px); } }
@keyframes st-charge { 0%,60%,100% { transform: translateX(0); } 70% { transform: translateX(40%) rotate(10deg); } 80% { transform: translateX(0); } }
@keyframes st-recoil { 0%,66%,100% { transform: translateX(0) rotate(0); } 72% { transform: translateX(20%) rotate(20deg); } 78% { transform: translateX(-6%) rotate(-10deg); } }
@keyframes st-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes st-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes st-twinkle { from { opacity: .4; transform: scale(.9); } to { opacity: 1; transform: scale(1.1); } }
@keyframes st-pulse { 0%,100% { transform: scale(1.1); } 50% { transform: scale(1.22); } }
@keyframes st-vs { from { transform: translate(-50%,-50%) rotate(-8deg) scale(1); } to { transform: translate(-50%,-50%) rotate(6deg) scale(1.12); } }
@keyframes st-glow { 0% { background: #fff27a; } 100% { background: transparent; } }
@keyframes st-spin-in { from { transform: scale(0) rotate(-540deg); } to { transform: scale(1) rotate(0); } }
@keyframes st-out-next { 0% { transform: rotateY(0); } 100% { transform: rotateY(-105deg); box-shadow: -30px 10px 40px rgba(0,0,0,.3); } }
@keyframes st-out-prev { 0% { transform: rotateY(0); } 100% { transform: rotateY(105deg); } }
@keyframes st-in-under { 0% { filter: brightness(.6); } 100% { filter: brightness(1); } }
@keyframes st-in-first { from { transform: scale(.6) rotate(-4deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }

@media (max-aspect-ratio: 4/5) {
  .st-root .st-places { grid-template-columns: repeat(2, 1fr); }
  .st-root .st-arrow { width: 96px; }
}
@media (max-height: 640px) {
  .st-root .st-heading { font-size: 30px; padding-bottom: 2px; }
  .st-root .st-nav { padding: 8px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .st-root *, .st-root *::before, .st-root *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
/* AI story switch (optional) */
.st-root .st-ai-toggle { align-self: center; margin: 0 auto 10px; font: inherit; font-size: 20px; font-weight: 700; padding: 10px 20px; border-radius: 999px; border: 4px solid #2b2140; background: #fff; box-shadow: 0 4px 0 #2b2140; cursor: pointer; }
.st-root .st-ai-toggle.st-on { background: linear-gradient(135deg, #f06595, #7b5cff); color: #fff; }
.st-root .st-ai-note { font-size: 15px; margin-left: 6px; opacity: .85; }
.st-root .st-magic-msg { font-size: 26px; font-weight: 700; color: #fff; text-shadow: 0 3px 0 #2b2140; margin-top: 12px; text-align: center; }
