/* Test-only story episode UI, isolated inside /story-test/ */
#storyTestWatermark{position:absolute;top:4px;left:50%;transform:translateX(-50%);
  z-index:130;pointer-events:none;color:#ffe6afaa;background:#34213a7a;border-radius:30px;
  padding:3px 12px;font-size:10px;white-space:nowrap;letter-spacing:.06em}
.storyLayer,.storyBossScene{position:fixed;inset:0;z-index:140;display:flex;align-items:center;
  justify-content:center;background:linear-gradient(180deg,#0b1027d9,#251336eb);
  padding:16px;box-sizing:border-box}
.storyLayer.hidden,.storyBossScene.hidden,.storyBossScene .hidden{display:none!important}
.storyPanel{width:min(100%,430px);max-height:95dvh;overflow:auto;text-align:center;
  border:3px solid #f1c576;border-radius:24px;
  background:linear-gradient(156deg,#493051,#261d39 62%,#211c34);
  box-shadow:0 0 0 5px #211323,0 16px 45px #000a;
  padding:16px;color:#fff5df;box-sizing:border-box}
.storyEpisode{font-size:12px;font-weight:900;letter-spacing:.1em;color:#f9c86e}
.storyArtwork{height:clamp(175px,34dvh,305px);position:relative;display:flex;
  align-items:center;justify-content:center;margin:8px 0 12px;gap:3px;
  border-radius:14px;background:radial-gradient(circle at 50% 65%,#bc675b61,#15152b99 70%),
    url('./assets/maps/halloween/07-q94-v1.webp') center/cover;overflow:hidden}
.storyArtwork img{width:62%;max-height:100%;object-fit:contain;
 filter:drop-shadow(0 5px 9px #0008);transition:opacity .25s}
.storyArtwork img.storyHostagePortrait{width:42%;margin-left:-20%;align-self:flex-end}
.storyArtwork img.storyBangtanPortrait{width:76%;height:90%;object-fit:contain}
.storyPanel h2{font-size:clamp(18px,4.8vw,25px);line-height:1.35;color:#ffe3a2;margin:5px 0}
.storySpeaker{font-size:14px;font-weight:900;color:#ffcf8d}
#storyDialogue{font-size:clamp(16px,4.2vw,20px);min-height:3.2em;margin:8px 0 17px;
 line-height:1.6;word-break:keep-all;font-weight:700;white-space:pre-line}
.storyActions{display:flex;gap:8px}
.storyActions button,.storyBossScene button{flex:1;min-height:50px;border-radius:15px;
 border:2px solid #ffe5a9;padding:8px;background:linear-gradient(#ffe1a5,#fc9e62);
 color:#3f2631;font-weight:1000;font-size:16px}
#storyExit{flex:0 0 100px;background:#4e425d;color:#fff0d8;border-color:#8e7996}
.storyModeChoice{border-color:#faab58!important;background:linear-gradient(#65445b,#2d243a)!important}
.storyModeChoice small{display:block;color:#fff0c8;font-size:12px}
.storyBossScene{background:linear-gradient(#10132380,#221726d0),
 url('./assets/maps/halloween/10-q94-v1.webp') center/cover;flex-direction:column}
.storyBossTitle{align-self:center;position:absolute;top:7%;
 color:#ffe3a0;background:#21152acf;padding:10px 16px;border:2px solid #e6b877;
 border-radius:16px;font-size:clamp(18px,4vw,23px);font-weight:900}
.storyBossActors{width:min(94vw,510px);height:220px;position:relative;margin-top:35vh;display:flex;
 justify-content:space-between;align-items:flex-end}
.storyBossActors img{object-fit:contain;filter:drop-shadow(0 6px 7px #0008);position:relative}
#storyHero{width:38%;max-height:80%;z-index:2;transition:transform .75s cubic-bezier(.25,.95,.7,.9)}
#storyMonster{width:49%;max-height:100%;z-index:1;transition:opacity .6s,transform .7s}
#storyHostage{width:24%;max-height:55%;position:absolute;right:10%;bottom:2%;z-index:3;
 transition:transform .6s}
.storyBossScene.charge #storyHero{transform:translateX(145%)}
.storyBossScene.hit #storyMonster{transform:translateX(35%) rotate(16deg)}
.storyBossScene.vanish #storyMonster{opacity:0;transform:translate(50%,-45%) scale(.3)}
.storyBossScene.vanish #storyHostage{transform:translate(-70%,0)}
.storyBossGround{width:min(95vw,510px);height:33px;z-index:1;border-radius:9px;
 background:repeating-linear-gradient(90deg,#907d72 0 42px,#776767 43px 47px);
 border-top:5px solid #cec0a2;box-shadow:0 8px 0 #514148}
#storyImpact{position:absolute;width:min(42%,200px);top:40%;left:45%;z-index:4}
#storyBossSubtitle{margin:19px 8px;color:#fff4d4;text-align:center;font-weight:950;font-size:19px;
 text-shadow:0 2px 4px #000}
#storyBossContinue{flex:none;width:min(80%,330px);margin-top:16px}
.storyGoal{position:absolute;top:112px;left:50%;transform:translateX(-50%);z-index:9;
 pointer-events:none;color:#ffe7af;background:#34223b9a;border:1px solid #e7b8799c;
 border-radius:15px;padding:2px 13px;font-size:12px;font-weight:900;white-space:nowrap}
.storyGoal.hidden{display:none}
.storyCharacterGallery{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
.storyCharacter{border:2px solid #e6be80;background:#fff5dc;border-radius:15px;padding:11px;
 text-align:center;color:#503936}
.storyCharacter img{width:100%;height:100px;object-fit:contain}
.storyCharacter strong{display:block;font-size:16px}
.storyCharacter small{display:block;font-size:12px;color:#86573a;margin:4px}
.storyCharacter button{font-weight:900;border:1px solid #b06e44;border-radius:11px;
 background:#ffc988;padding:7px 10px}
@media(max-height:630px){.storyArtwork{height:155px}.storyPanel{padding:9px}
 .storyBossActors{margin-top:30vh;height:150px}.storyGoal{top:100px}}


/* V2 — in-world visual-novel dialogue rather than a centered modal.
   Transparent overlay retains the LIVE Halloween canvas and idle dog. */
.storyLayer{
  position:absolute!important;inset:0!important;
  display:flex!important;flex-direction:column!important;
  align-items:stretch!important;justify-content:flex-end!important;
  background:linear-gradient(180deg,transparent 0%,transparent 45%,#120c239c 100%)!important;
  padding:0 11px max(19px,env(safe-area-inset-bottom))!important;
  z-index:140!important;overflow:hidden!important;
}
.storyLayer.hidden{display:none!important}
.storyLayer .storyPanel{
  width:100%!important;max-width:100%!important;max-height:none!important;
  overflow:visible!important;
  position:relative!important;
  padding:0 12px 12px!important;
  margin-bottom:6px;
  background:transparent!important;border:0!important;box-shadow:none!important;
  display:flex;flex-direction:column;gap:4px;
  text-align:left!important;
}
.storyLayer .storyEpisode{
  position:absolute;bottom:100%;right:9px;
  color:#ffe9a8;font-size:10px;text-align:right;
  text-shadow:0 2px 4px #120c1f;
}
.storyLayer .storyArtwork{
  position:absolute!important;
  width:min(48%,210px)!important;height:clamp(120px,25dvh,245px)!important;
  bottom:calc(100% - 14px);left:-3px;
  margin:0!important;border-radius:0!important;
  background:none!important;overflow:visible!important;
  display:flex;align-items:flex-end;justify-content:center;
  pointer-events:none!important;
  filter:drop-shadow(0 4px 5px #000c);
}
.storyLayer .storyArtwork[data-speaker=pumpkin]{
  left:auto;right:-5px;justify-content:flex-end;
}
.storyLayer .storyArtwork[data-speaker=kkomi]{
  left:0;right:auto;
}
.storyLayer .storyArtwork img{
 width:auto!important;max-width:100%!important;
 height:100%!important;max-height:100%!important;
 object-fit:contain!important;
}
.storyLayer .storyArtwork .storyHostagePortrait{
 width:48%!important;height:58%!important;
 margin-left:-30%!important;align-self:flex-end!important;
}
.storyLayer .storyArtwork.speaker-enter img{
 animation:storySpeakerPop .34s both cubic-bezier(.15,.85,.2,1.15);
}
.storyLayer .storyArtwork[data-speaker=pumpkin].speaker-enter img{
 animation-name:storySpeakerPopRight;
}
@keyframes storySpeakerPop{from{opacity:0;transform:translateX(-28px) scale(.94)}to{opacity:1;transform:translateX(0) scale(1)}}
@keyframes storySpeakerPopRight{from{opacity:0;transform:translateX(28px) scale(.94)}to{opacity:1;transform:translateX(0) scale(1)}}
.storyLayer .storySpeaker{
 display:inline-flex;align-items:center;align-self:flex-start;
 border:2px solid #f6d38e;border-radius:13px 13px 4px 4px;
 background:#4a304f;color:#ffe3ab;font-size:14px;
 font-weight:1000;padding:5px 12px;z-index:2;
 margin:0 0 -7px 10px;
 text-shadow:0 1px 2px #0008;
}
.storyLayer .storyPanel:has(.storyArtwork[data-speaker=pumpkin]) .storySpeaker{
 align-self:flex-end;margin:0 11px -7px 0;
}
.storyLayer #storyHeading{display:none!important}
.storyLayer #storyDialogue{
 display:block;box-sizing:border-box;
 min-height:70px!important;margin:0!important;
 padding:18px 18px 14px!important;
 border:2px solid #ffe1a4;border-radius:20px 20px 20px 9px;
 background:linear-gradient(160deg,#35243cea,#20182bef)!important;
 box-shadow:inset 0 2px #ffffff20,0 5px 0 #b8835d,0 9px 15px #05020a7f;
 color:#fff7e7!important;font-weight:900!important;
 text-align:left;font-size:clamp(15px,4vw,20px)!important;
 line-height:1.55!important;word-break:keep-all;
 text-shadow:0 1px 2px #0005;
}
.storyLayer .storyPanel:has(.storyArtwork[data-speaker=pumpkin]) #storyDialogue{
 border-radius:20px 20px 9px 20px;
}
.storyLayer .storyActions{justify-content:space-between!important;gap:8px!important;margin-top:7px}
.storyLayer .storyActions button{
 flex:0 0 auto!important;min-height:39px!important;font-size:13px!important;
 border-width:1px!important;border-radius:12px!important;padding:7px 14px!important;
}
.storyLayer #storyExit{background:#41334cd9;color:#fff2df}
.storyLayer #storyNext{margin-left:auto;min-width:108px}
body.story-dialogue-active #paused{display:none!important}
body.story-dialogue-active #hud,body.story-dialogue-active #controls,
body.story-dialogue-active .topActions,body.story-dialogue-active #storyGoal{display:none!important}
@media(max-height:640px){
.storyLayer .storyArtwork{height:clamp(105px,22dvh,165px)!important}
.storyLayer #storyDialogue{font-size:14px!important;min-height:60px!important;padding:15px!important}
.storyLayer .storyPanel{padding-bottom:7px!important}
}
@media(prefers-reduced-motion:reduce){
.storyLayer .storyArtwork.speaker-enter img{animation:none!important}
}


/* V3 Rooftop remains visible during the full outro / reward conversation. */
#storyBossScene{
 background:
   linear-gradient(180deg,rgba(12,13,30,.12),rgba(17,14,30,.24) 64%,rgba(24,14,35,.53)),
   url('./assets/maps/halloween/07-q94-v1.webp') center center / cover no-repeat!important;
}
#storyBossScene::before{
 content:"";pointer-events:none;position:absolute;inset:0;
 background:radial-gradient(ellipse at 50% 65%,transparent 5%,rgba(27,20,50,.24) 100%);
}
#storyBossScene.dialogue{z-index:141!important;pointer-events:none!important}
#storyBossScene.dialogue #storyBossSubtitle,
#storyBossScene.dialogue #storyBossContinue,
#storyBossScene.dialogue .storyBossTitle{display:none!important}
#storyBossScene.dialogue .storyBossActors{margin-top:0!important}
#storyBossScene.dialogue #storyHero{transform:translateX(56%)!important}
#storyBossScene.dialogue #storyMonster{opacity:0!important}
#storyBossScene.dialogue #storyHostage{transform:translate(-80%,0)!important}
body.story-boss-dialogue .storyLayer{z-index:151!important}
body.story-boss-dialogue .storyLayer .storyArtwork{height:clamp(110px,19dvh,180px)!important}
body.story-boss-dialogue .storyLayer{
 background:linear-gradient(180deg,transparent 0%,transparent 53%,rgba(17,10,26,.45) 100%)!important;
}
.storyLayer .storySpriteIdle,.storyCharacter .storySpriteIdle{
 object-fit:cover!important;object-position:left top;
 clip-path:inset(0 83.33333% 75% 0);
 width:600%!important;max-width:none!important;height:400%!important;
 transform-origin:top left;transform:scale(.1666667,.25);
}
.storyLayer .storyArtwork .storySpriteIdle{position:absolute;top:0;left:0}
.storyCharacter{overflow:hidden}
.storyCharacter .storySpriteIdle{height:100px!important;width:100px!important;max-width:100%!important;object-fit:contain!important;
 transform:none!important;clip-path:none!important}
@media(max-height:680px){#storyBossScene.dialogue .storyBossActors{height:145px!important}}

/* One trimmed idle pose for dialogue/selection. Atlas remains for gameplay. */
.storyLayer .storyArtwork .storySpriteIdle{position:static!important;width:auto!important;max-width:100%!important;height:100%!important;transform:none!important;clip-path:none!important;object-fit:contain!important}
.storyCharacter .storySpriteIdle{width:100%!important;max-width:100%!important;height:100px!important;transform:none!important;clip-path:none!important;object-fit:contain!important}
#storyHostage{object-fit:contain}
@media(min-width:700px){
 #storyBossScene{width:min(100vw,calc(100dvh * 9 / 16));left:50%;right:auto;transform:translateX(-50%)}
}

/* V4: higher-contrast mode card and properly centered character thumbnails */
#modeChooser #modeStory{
  background:linear-gradient(150deg,#fff0ca,#ffca79)!important;
  border:3px solid #fbbf63!important;
  color:#4b2d22!important;
  box-shadow:0 4px 0 #8c4d34,0 6px 14px #150e2d65!important;
}
#modeChooser #modeStory strong,
#modeChooser #modeStory small,
#modeChooser #modeStory span{
  color:#4b2d22!important;
  text-shadow:0 1px 0 #fff8e1!important;
}
#modeChooser #modeStory strong{font-size:clamp(16px,4vw,20px)!important}
#modeChooser #modeStory small{font-size:clamp(11px,2.8vw,13px)!important;color:#68432d!important}
.storyCharacterGallery .storyCharacter{min-width:0!important;overflow:hidden!important}
.storyCharacterGallery .storyCharacter img{
 width:100%!important;
 max-width:100%!important;
 height:120px!important;
 display:block!important;
 margin:0 auto 6px!important;
 object-fit:contain!important;
 object-position:center center!important;
 clip-path:none!important;
 transform:none!important;
}
.storyCharacterGallery .storyCharacter img.storySpriteIdle{
 width:100%!important;max-width:100%!important;height:120px!important;
 object-fit:contain!important;clip-path:none!important;transform:none!important;
}
.storyCharacterGallery .storyCharacter strong{overflow-wrap:anywhere;font-size:clamp(12px,3vw,15px)}
.storyCharacterGallery .storyCharacter small{font-size:11px}
@media(max-width:375px){
 .storyCharacterGallery{gap:7px}
 .storyCharacterGallery .storyCharacter{padding:7px}
 .storyCharacterGallery .storyCharacter img{height:100px!important}
}

/* Production mode picker: all mode titles begin on one vertical line. */
#modeChooser .modeChoice>strong{display:flex;align-items:center;gap:10px;min-height:36px}
#modeChooser #modeStory>strong::before{content:"🎃";display:grid;place-items:center;flex:0 0 36px;width:36px;font-size:21px}
#modeChooser #modeStory>strong{color:#4b2d22!important}
#modeChooser #modeStory>small{padding-left:46px}
#modeChooser .modeChoice>small{padding-left:46px}
