/* Story layer: speech bubbles, wish-star counter, ending card (js/narrator.js), plus small play-test fixes. */

/* ---- speech bubble (never blocks taps underneath) */
.narrator { position: absolute; left: 590px; top: 14px; z-index: 85; display: flex; align-items: flex-start; gap: 10px; pointer-events: none !important;
  opacity: 0; translate: 0 -14px; transition: opacity .25s, translate .25s; }
.narrator.show { opacity: 1; translate: 0 0; }
.narrator.low { top: auto; bottom: 24px; left: 130px; align-items: flex-end; }
.narrator.low .nar-bubble { max-width: 400px; }
.narrator.left, .narrator.leftn { top: 96px; left: 24px; }
.narrator.leftn .nar-bubble { max-width: 370px; }
.narrator.left .nar-bubble { max-width: 460px; }
.nar-avatar { flex: none; width: 104px; height: 104px; display: grid; place-items: center; }
.nar-avatar.guide img { width: 104px; filter: drop-shadow(0 6px 6px rgba(0,0,0,.25)); animation: narBob 1.1s ease-in-out infinite; }
.nar-avatar.girl .portrait, .nar-avatar.girl > * { border-radius: 50%; border: 5px solid #fff; box-shadow: 0 6px 14px rgba(0,0,0,.2); overflow: hidden; background: #ffe9f3; }
.nar-bubble { position: relative; max-width: 570px; margin-top: 6px; padding: 8px 26px 14px; border-radius: 28px; background: #fff; border: 4px solid #ffc4df;
  box-shadow: 0 8px 22px rgba(120, 30, 70, .22); }
.nar-bubble::before { content: ''; position: absolute; left: -18px; top: 30px; border: 12px solid transparent; border-right: 16px solid #ffc4df; }
.nar-name { font-size: 20px; font-weight: 800; color: var(--pink-dark); line-height: 1.1; letter-spacing: .3px; }
.nar-text { font-size: 31px; font-weight: 700; color: #4a2340; line-height: 1.18; }
@keyframes narBob { 0%, 100% { translate: 0 0; rotate: -4deg; } 50% { translate: 0 -6px; rotate: 4deg; } }

/* ---- wish stars */
.star-pill { position: absolute; right: 128px; top: 26px; z-index: 55; display: flex; align-items: center; gap: 8px; padding: 6px 22px 10px 16px; border-radius: 40px;
  background: #fff; border: 4px solid #ffe08a; box-shadow: 0 6px 0 #e6b43c, 0 10px 18px rgba(0,0,0,.15); font-size: 32px; font-weight: 800; color: #c98a00; pointer-events: none; }
.star-pill .star-ico, .end-stars .star-ico { color: var(--gold); font-size: 40px; line-height: 1; text-shadow: 0 2px 0 #d38a00; }
.star-pill.bump { animation: starBump .6s ease; }
@keyframes starBump { 0% { scale: 1; } 40% { scale: 1.35; } 100% { scale: 1; } }
.star-fly { position: absolute; left: 800px; top: 380px; z-index: 75; font-size: 150px; color: var(--gold); text-shadow: 0 0 24px #fff, 0 6px 0 #d38a00; pointer-events: none;
  translate: -50% -50%; animation: starFly 1.2s cubic-bezier(.5, -.3, .6, 1) forwards; }
@keyframes starFly { 0% { scale: .2; opacity: 0; } 25% { scale: 1.2; opacity: 1; left: 800px; top: 380px; } 100% { scale: .25; opacity: .9; left: 1395px; top: 52px; } }
.star-caption { position: absolute; right: 120px; top: 100px; z-index: 74; padding: 6px 24px 10px; border-radius: 30px; background: linear-gradient(#ffd45e, var(--gold));
  color: #fff; font-size: 28px; font-weight: 800; text-shadow: 0 2px 0 #c07800; border: 4px solid #fff; box-shadow: 0 6px 14px rgba(0,0,0,.15); white-space: nowrap; pointer-events: none;
  animation: captionIn 2.2s ease forwards; }
@keyframes captionIn { 0% { opacity: 0; translate: 0 -10px; } 12% { opacity: 1; translate: 0 0; } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---- ending card */
.end-card { position: absolute; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; background: rgba(90, 20, 60, .35); animation: fadeIn .4s; }
.end-panel { width: 1040px; padding: 26px 50px 30px; border-radius: 44px; background: #fff; border: 8px solid #ffc1dc; text-align: center;
  box-shadow: 0 14px 0 #f59ac4, 0 30px 60px rgba(0,0,0,.3); animation: endPop .5s cubic-bezier(.3, 1.6, .5, 1); }
.end-title { font-size: 72px; font-weight: 800; color: #fff; line-height: 1.05; -webkit-text-stroke: 2px var(--pink); text-shadow: 0 5px 0 var(--pink-dark); }
.end-line { font-size: 34px; font-weight: 800; color: #4a2340; line-height: 1.2; margin-top: 6px; }
.end-line.small { font-size: 28px; font-weight: 700; color: #7a4a68; }
.end-stars { display: inline-flex; align-items: center; gap: 10px; margin-top: 10px; padding: 4px 24px 8px; border-radius: 30px; background: #fff6d8; font-size: 32px; font-weight: 800; color: #c98a00; }
.end-prompt { margin-top: 14px; font-size: 30px; font-weight: 800; color: var(--pink-dark); }
.end-gifts { display: flex; justify-content: center; gap: 26px; margin-top: 6px; min-height: 210px; }
.end-gift { position: relative; width: 180px; height: 220px; padding: 0; border: none; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
.end-gift:not(.opened) .giftbox { animation: giftShake 2.2s ease-in-out infinite; }
.end-gift:nth-child(2) .giftbox { animation-delay: .3s; } .end-gift:nth-child(3) .giftbox { animation-delay: .6s; } .end-gift:nth-child(4) .giftbox { animation-delay: .9s; }
.end-gift .giftbox { position: relative; }
.end-gift-img { width: 140px; max-height: 150px; object-fit: contain; filter: drop-shadow(0 8px 8px rgba(0,0,0,.2)); }
.end-from { display: flex; align-items: center; gap: 6px; font-size: 24px; font-weight: 800; color: var(--pink-dark); }
.end-from > :first-child { border-radius: 50%; overflow: hidden; border: 3px solid #ffc4df; }
.end-btns { display: flex; justify-content: center; gap: 30px; margin-top: 18px; }
.end-btn { padding: 12px 40px 16px; border-radius: 50px; font: 800 36px var(--font); color: #fff; border: 5px solid #fff; cursor: pointer; }
.end-btn.keep { background: linear-gradient(#ffd45e, var(--gold)); box-shadow: 0 7px 0 #d38a00, 0 12px 20px rgba(0,0,0,.2); }
.end-btn.again { background: linear-gradient(#ff7cb8, var(--pink)); box-shadow: 0 7px 0 var(--pink-dark), 0 12px 20px rgba(0,0,0,.2); }
.end-btn:active { transform: translateY(5px); }
@keyframes endPop { from { scale: .6; opacity: 0; } to { scale: 1; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes giftShake { 0%, 70%, 100% { rotate: 0deg; } 75% { rotate: -6deg; } 80% { rotate: 6deg; } 85% { rotate: -4deg; } 90% { rotate: 3deg; } }

/* ---- play-test fixes */
/* dragging clothes onto the doll */
.drag-ghost { pointer-events: none; opacity: .92; filter: drop-shadow(0 14px 12px rgba(0,0,0,.25)); }
/* step 9: the gift can be dragged into the box */
.floating.held-drag { animation: none; cursor: grabbing; scale: 1.06; }
/* step 10: each ingredient shows up on its own in the bowl */
.bowl img.bowl-part { position: absolute; left: 0; top: 0; display: none; filter: none; }
.bowl img.bowl-part.in { display: block; animation: partIn .35s ease-out; }
@keyframes partIn { from { opacity: 0; translate: 0 -30px; } }
/* step 15: a slice for every friend */
.guest-slice { filter: drop-shadow(0 6px 6px rgba(0,0,0,.2)); transition: opacity .3s; }
/* step 16: the twirl no longer squashes the girl into a thin line for a long time: quick flips at the top of a hop */
.dancer.twirl .doll-inner { animation: partyTwirl 1.6s ease-in-out infinite; }
@keyframes partyTwirl {
  0% { transform: scaleX(1) translateY(0) rotate(0); } 20% { transform: scaleX(1) translateY(-40px) rotate(-6deg); }
  26% { transform: scaleX(-1) translateY(-46px) rotate(0); } 50% { transform: scaleX(-1) translateY(0) rotate(0); }
  70% { transform: scaleX(-1) translateY(-40px) rotate(6deg); } 76% { transform: scaleX(1) translateY(-46px) rotate(0); } 100% { transform: scaleX(1) translateY(0) rotate(0); } }
