/* ============ 新手剧情：视觉小说式引导（首页 + 下山历练页加载） ============ */

/* ---------- 全屏舞台 ---------- */
/* 层级约定：低于游戏弹窗(200)/飘字(300)，高于导航(60)/回顶(99)，
 * 教学期间游戏自身的弹窗能正常盖在剧情层之上 */
#storyMask {
    position: fixed; inset: 0; z-index: 150;
    display: none;
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(255, 214, 158, .10), transparent 55%),
        linear-gradient(to bottom, #241a12 0%, #2e2117 46%, #1c140e 100%);
    font-family: 'ZCOOL KuaiLe', 'Microsoft YaHei', sans-serif;
    color: #f5ead8;
    opacity: 0; transition: opacity .45s;
}
#storyMask.show { display: block; }
#storyMask.on { opacity: 1; }

/* ---------- 跳过按钮 ---------- */
.story-skip {
    position: absolute; top: 18px; right: 20px; z-index: 20;
    border: 1.5px solid rgba(245, 234, 216, .4); background: rgba(20, 14, 9, .45);
    color: rgba(245, 234, 216, .85); font-family: inherit; font-size: 13px;
    padding: 7px 16px; border-radius: 50px; cursor: pointer; letter-spacing: 1px;
    transition: border-color .2s, color .2s;
}
.story-skip:hover { border-color: #fdc33f; color: #fdc33f; }

/* ---------- 立绘：已抠底无边框，左宗主 / 右玩家，说话者放大 ---------- */
.story-actor {
    position: absolute; left: max(24px, env(safe-area-inset-left)); bottom: 158px;
    width: min(300px, 36vw); z-index: 5;
    transition: transform .38s cubic-bezier(.3, 1.2, .4, 1), filter .38s, opacity .3s;
    transform-origin: bottom center;
    filter: brightness(.72) saturate(.85);
    opacity: 0; pointer-events: none;
}
.story-actor.shown { opacity: 1; }
.story-actor.active { transform: scale(1.09); filter: brightness(1); }
.story-actor img {
    width: 100%; display: block;
    filter: drop-shadow(0 14px 30px rgba(0, 0, 0, .6));
}
/* 玩家剪影站右侧（镜像朝向宗主） */
.story-actor.actor-me {
    left: auto; right: max(24px, env(safe-area-inset-right));
}
.story-actor.actor-me img { transform: scaleX(-1); }

/* ---------- 大场景图（天魔） ---------- */
.story-scene {
    position: absolute; inset: 0; z-index: 4;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.story-scene img {
    width: min(400px, 62vw); max-height: 58vh; object-fit: contain;
    border-radius: 22px;
    filter: drop-shadow(0 0 44px rgba(120, 40, 160, .35));
    animation: sceneIn .8s ease-out;
}
.story-scene.dark img { filter: drop-shadow(0 0 60px rgba(150, 30, 190, .5)) brightness(.92); animation: sceneIn .8s ease-out, scenePulse 3.2s ease-in-out infinite .8s; }
@keyframes sceneIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
@keyframes scenePulse { 0%, 100% { filter: drop-shadow(0 0 46px rgba(150, 30, 190, .38)) brightness(.9); } 50% { filter: drop-shadow(0 0 74px rgba(190, 40, 120, .55)) brightness(1.02); } }

/* ---------- 对话框 ---------- */
.story-box {
    position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%);
    width: min(760px, calc(100vw - 32px)); z-index: 10;
    background: linear-gradient(to bottom, #fdf6ef, #f6ead9);
    border: 2.5px solid #d9b98c; border-radius: 20px;
    box-shadow: 0 16px 50px rgba(0, 0, 0, .5);
    padding: 52px 26px 20px; cursor: pointer;
    user-select: none;
}
.story-name {
    position: absolute; top: -20px; left: 22px;
    background: linear-gradient(to right, #b06a3a, #8a4a22); color: #ffe7c2;
    font-size: 16px; letter-spacing: 2px;
    padding: 6px 22px; border-radius: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
}
.story-name.me { background: linear-gradient(to right, #4a6a8a, #2f4a66); }
.story-text {
    min-height: 66px; color: #4a3a28; font-size: 17px; line-height: 1.85; letter-spacing: .5px;
}
/* 嘀咕台词：小字、半透明，像压低声音说话 */
.story-text.mutter { font-size: 13px; opacity: .6; letter-spacing: 1.5px; }
.story-caret {
    position: absolute; right: 20px; bottom: 12px; color: #b06a3a; font-size: 14px;
    animation: caretBlink 1s infinite;
}
@keyframes caretBlink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* 玩家选择按钮 */
.story-choices { margin-top: 14px; display: none; }
.story-choices.show { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.story-choice {
    border: 2px solid #e3c79a; background: #fffdf8; color: #6a4a26;
    font-family: inherit; font-size: 15px; letter-spacing: 1px;
    padding: 10px 24px; border-radius: 14px; cursor: pointer;
    transition: transform .15s, border-color .15s, box-shadow .15s;
}
.story-choice:hover { transform: translateY(-2px); border-color: #fd7161; box-shadow: 0 6px 16px rgba(253, 113, 97, .25); }

/* 行动按钮（摇签/下山/孝敬） */
.story-actrow { margin-top: 14px; display: none; text-align: center; }
.story-actrow.show { display: block; }
.story-act {
    border: none; cursor: pointer; color: #fff; font-family: inherit; font-size: 16px; letter-spacing: 3px;
    padding: 12px 42px; border-radius: 50px;
    background: linear-gradient(to right, #fd7161, #fdc33f);
    box-shadow: 0 8px 20px rgba(253, 113, 97, .4);
    transition: transform .15s, box-shadow .15s;
}
.story-act:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(253, 113, 97, .5); }
.story-act[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- 教学模式：顶部提示条 + 聚光灯 ---------- */
.story-hintbar {
    position: fixed; top: 74px; left: 50%; transform: translateX(-50%);
    z-index: 146; max-width: calc(100vw - 28px);
    background: rgba(38, 27, 17, .93); color: #ffe7c2;
    border: 1.5px solid rgba(253, 195, 63, .5); border-radius: 50px;
    padding: 10px 22px; font-size: 14.5px; letter-spacing: 1px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    display: none; align-items: center; gap: 12px; white-space: nowrap;
}
.story-hintbar.show { display: flex; }
.story-hintbar b { color: #fdc33f; }
.story-hintbar .hint-chip {
    border: 1px solid rgba(253, 195, 63, .55); background: transparent; color: #fdc33f;
    font-family: inherit; font-size: 12.5px; padding: 3px 12px; border-radius: 30px; cursor: pointer;
}
.story-hintbar .hint-chip:hover { background: rgba(253, 195, 63, .15); }

#storySpot {
    position: fixed; z-index: 145; border-radius: 16px;
    box-shadow: 0 0 0 200vmax rgba(22, 15, 9, .74);
    border: 2.5px dashed rgba(253, 195, 63, .8);
    pointer-events: none; display: none;
    transition: all .4s cubic-bezier(.4, 0, .2, 1);
    animation: spotGlow 1.6s ease-in-out infinite;
}
#storySpot.show { display: block; }
@keyframes spotGlow {
    0%, 100% { border-color: rgba(253, 195, 63, .8); }
    50% { border-color: rgba(253, 113, 97, .9); }
}

/* ---------- 剧情专属签 ---------- */
.story-slip {
    position: absolute; inset: 0; z-index: 12;
    display: none; align-items: center; justify-content: center; flex-direction: column; gap: 16px;
    background: radial-gradient(80% 70% at 50% 40%, rgba(253, 195, 63, .12), rgba(28, 20, 13, .88));
}
.story-slip.show { display: flex; }
.slip-card {
    width: min(300px, 74vw); background: linear-gradient(160deg, #fff8ea, #f9e9c8);
    border-radius: 14px; padding: 26px 22px; text-align: center; color: #5a3a16;
    border: 2px solid #e0bf85; box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
    animation: slipIn .6s cubic-bezier(.2, 1.4, .4, 1);
    position: relative;
}
.slip-card::before {
    content: ''; position: absolute; top: 10px; bottom: 10px; left: 12px; right: 12px;
    border: 1px dashed rgba(176, 106, 58, .45); border-radius: 8px; pointer-events: none;
}
@keyframes slipIn { from { opacity: 0; transform: translateY(40px) rotate(-4deg); } to { opacity: 1; transform: none; } }
/* 独立层级：即使动画被后台标签页冻结在半途，按钮也始终可点 */
#slipTake { position: relative; z-index: 5; margin-top: 20px; }
.slip-level { font-size: 15px; letter-spacing: 6px; color: #c0392b; }
.slip-name { font-size: 27px; margin: 8px 0 12px; letter-spacing: 3px; }
.slip-poem { font-size: 15px; line-height: 2; color: #7a5228; }
.slip-jie { margin-top: 12px; font-size: 13.5px; line-height: 1.9; color: #8a6a48; border-top: 1px dashed #d9b98c; padding-top: 10px; }

/* ---------- 开场动画：垂钓湖海景 ---------- */
.story-open { position: absolute; inset: 0; z-index: 8; overflow: hidden; cursor: pointer; }
.open-sky {
    position: absolute; inset: 0;
    background: linear-gradient(to bottom, #2a3a55 0%, #5a4a6a 40%, #c88a6a 78%, #e8b088 100%);
}
.open-stars i {
    position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #ffe9c9;
    animation: starTw 2.4s infinite;
}
@keyframes starTw { 0%, 100% { opacity: .15; } 50% { opacity: .9; } }
.open-water {
    position: absolute; left: 0; right: 0; bottom: 0; height: 44%;
    background: linear-gradient(to bottom, #3a5a6a, #1c3038);
}
.open-water::before {
    content: ''; position: absolute; top: -12px; left: -50%; right: -50%; height: 26px;
    background: radial-gradient(50% 100% at 50% 100%, rgba(255, 224, 180, .35), transparent 70%);
    animation: waveMove 5s linear infinite;
}
@keyframes waveMove { from { transform: translateX(0); } to { transform: translateX(25%); } }
.open-bobber {
    position: absolute; left: 50%; top: 53%; width: 16px; height: 16px; border-radius: 50%;
    background: #fd7161; border: 3px solid #fff2df; transform: translateX(-50%);
    animation: bobFloat 2.2s ease-in-out infinite;
}
.open-bobber::after {
    content: ''; position: absolute; left: 50%; top: 50%; width: 60px; height: 60px;
    border: 2px solid rgba(255, 240, 210, .5); border-radius: 50%;
    transform: translate(-50%, -50%) scale(.4); opacity: 0;
    animation: ripple 2.2s ease-out infinite;
}
@keyframes bobFloat { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(9px); } }
@keyframes ripple { 0% { transform: translate(-50%, -50%) scale(.3); opacity: .8; } 100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; } }
.open-player {
    position: absolute; left: 50%; bottom: 6%; width: min(230px, 42vw);
    transform: translateX(-50%) translateY(70%) rotate(6deg);
    animation: playerRise 1.8s 2.2s cubic-bezier(.3, .9, .4, 1) forwards;
    filter: drop-shadow(0 0 26px rgba(120, 200, 255, .4));
}
@keyframes playerRise { to { transform: translateX(-50%) translateY(-4%) rotate(-3deg); } }
.open-line {
    position: absolute; left: 50%; top: 0; width: 2px; height: 0;
    background: linear-gradient(to bottom, rgba(255, 240, 210, 0), rgba(255, 240, 210, .7));
    animation: lineDown .9s .4s ease-out forwards, lineTug .5s 2.2s ease-out;
    transform: translateX(-50%) rotate(9deg); transform-origin: top center;
}
@keyframes lineDown { to { height: 56%; } }
@keyframes lineTug { 50% { transform: translateX(-58%) rotate(-6deg); } 100% { transform: translateX(-50%) rotate(9deg); } }
.open-player {
    position: absolute; left: 50%; bottom: 6%; width: min(230px, 42vw);
    transform: translateX(-50%) translateY(70%) rotate(6deg);
    animation: playerRise 1.8s 2.2s cubic-bezier(.3, .9, .4, 1) forwards;
    filter: drop-shadow(0 0 26px rgba(120, 200, 255, .4));
}
@keyframes playerRise { to { transform: translateX(-50%) translateY(-4%) rotate(-3deg); } }
.open-cap {
    position: absolute; left: 50%; bottom: 12%; transform: translateX(-50%);
    color: #ffeacd; font-size: 16px; letter-spacing: 4px; text-shadow: 0 2px 12px rgba(0, 0, 0, .6);
    opacity: 0; animation: capIn 1s 1s forwards;
}
.open-cap.cap2 { animation-delay: 2.6s; }
@keyframes capIn { to { opacity: 1; } }
.open-skip { position: absolute; right: 18px; bottom: 14px; color: rgba(255, 234, 205, .6); font-size: 12px; letter-spacing: 2px; }

/* ---------- 结束卡 ---------- */
.story-end {
    position: absolute; inset: 0; z-index: 14; display: none;
    align-items: center; justify-content: center; flex-direction: column; gap: 10px; text-align: center;
    background: radial-gradient(90% 80% at 50% 30%, rgba(253, 195, 63, .14), rgba(24, 17, 11, .9));
    padding: 24px;
}
.story-end.show { display: flex; animation: sceneIn .7s ease-out; }
.end-chapter { font-size: 15px; letter-spacing: 8px; color: #fdc33f; }
.end-title { font-size: clamp(30px, 6vw, 44px); letter-spacing: 6px; color: #ffe7c2; text-shadow: 0 4px 24px rgba(253, 113, 97, .35); }
.end-text { font-size: 15px; line-height: 2.1; color: rgba(245, 234, 216, .85); max-width: 520px; }
.end-acts { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }
.end-btn {
    border: none; cursor: pointer; color: #fff; font-family: inherit; font-size: 15px; letter-spacing: 2px;
    padding: 12px 34px; border-radius: 50px; background: linear-gradient(to right, #fd7161, #fdc33f);
    box-shadow: 0 8px 22px rgba(253, 113, 97, .4); transition: transform .15s;
}
.end-btn:hover { transform: translateY(-2px); }
.end-btn.ghost { background: transparent; border: 1.5px solid rgba(245, 234, 216, .45); box-shadow: none; }

/* ---------- 浮动入口 / 进度 HUD ---------- */
.story-chip {
    position: fixed; left: 16px; bottom: 86px; z-index: 140;
    border: none; cursor: pointer; color: #fff; font-family: inherit; font-size: 14px; letter-spacing: 1px;
    padding: 10px 18px; border-radius: 50px;
    background: linear-gradient(to right, #b06a3a, #8a4a22);
    box-shadow: 0 8px 20px rgba(138, 74, 34, .45);
    display: none; align-items: center; gap: 6px;
    animation: chipIn .5s ease-out;
}
.story-chip.show { display: flex; }
@keyframes chipIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.story-hud {
    position: fixed; top: 74px; left: 50%; transform: translateX(-50%);
    z-index: 140; max-width: calc(100vw - 28px);
    background: rgba(38, 27, 17, .93); color: #ffe7c2;
    border: 1.5px solid rgba(253, 195, 63, .5); border-radius: 50px;
    padding: 10px 20px; font-size: 14px; letter-spacing: 1px; white-space: nowrap;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    display: none; align-items: center; gap: 10px;
}
.story-hud.show { display: flex; }
.story-hud b { color: #fdc33f; }
.story-hud .hud-bar { width: 110px; height: 8px; border-radius: 6px; background: rgba(255, 231, 194, .18); overflow: hidden; }
.story-hud .hud-bar i { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(to right, #fd7161, #fdc33f); transition: width .4s; }

/* ---------- 打字机光标 ---------- */
.story-text .tw-caret { color: #fd7161; }

/* ---------- 移动端 ≤ 640px ---------- */
@media (max-width: 640px) {
    .story-actor { width: 150px; bottom: 176px; left: 12px; }
    .story-actor.actor-me { right: 12px; }
    .story-box { padding: 46px 18px 18px; }
    .story-text { font-size: 15.5px; min-height: 58px; }
    .story-choice { font-size: 14px; padding: 9px 18px; }
    .story-skip { top: 14px; right: 14px; font-size: 12px; padding: 6px 13px; }
    .story-hintbar { font-size: 13px; padding: 9px 16px; white-space: normal; text-align: center; flex-wrap: wrap; justify-content: center; }
    .open-player { width: 170px; }
    .story-chip { bottom: 78px; font-size: 13px; }
}

/* ---------- 减少动态 ---------- */
@media (prefers-reduced-motion: reduce) {
    .story-actor, .story-scene img, .slip-card, .story-end.show { animation: none; }
    #storySpot { transition: none; animation: none; }
    .open-player, .open-line, .open-cap { animation-duration: .01s !important; animation-delay: 0s !important; }
}
