/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', Arial, sans-serif;
    background-color: #000;
    color: #fff;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
}

.hidden {
    display: none !important;
}

/* 手机方向提示 */
#orientation-guard {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
    overflow: hidden;
    text-align: center;
    background:
        radial-gradient(circle at 50% 35%, rgba(86, 137, 207, 0.3), transparent 35%),
        linear-gradient(145deg, #070b18 0%, #121d38 52%, #261a35 100%);
}

#orientation-guard::before {
    content: "";
    position: absolute;
    width: 130vw;
    height: 1px;
    top: 34%;
    left: -15vw;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.32), transparent);
    transform: rotate(-16deg);
    box-shadow: 0 0 30px rgba(120, 177, 255, 0.28);
}

.orientation-card {
    position: relative;
    width: min(100%, 360px);
    padding: 34px 26px 28px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 18px;
    background: rgba(7, 11, 25, 0.68);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(18px) saturate(125%);
}

.rotate-phone {
    position: relative;
    width: 45px;
    height: 76px;
    margin: 4px auto 30px;
    border: 3px solid rgba(255, 255, 255, 0.9);
    border-radius: 9px;
    animation: turnLandscape 2.4s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

.rotate-phone::before {
    content: "";
    position: absolute;
    inset: 7px 5px 10px;
    border-radius: 3px;
    background: linear-gradient(145deg, rgba(100, 176, 255, 0.45), rgba(232, 133, 180, 0.32));
}

.rotate-phone span {
    position: absolute;
    bottom: 3px;
    left: 50%;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #fff;
    transform: translateX(-50%);
}

.orientation-kicker {
    margin-bottom: 8px;
    color: #9fc9ff;
    font-size: 0.75rem;
    letter-spacing: 0.28rem;
}

#orientation-title {
    margin-bottom: 12px;
    font-size: clamp(1.65rem, 8vw, 2.1rem);
    font-weight: 400;
    letter-spacing: 0.08rem;
}

#orientation-status {
    margin-bottom: 22px;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.95rem;
    line-height: 1.7;
}

#landscape-btn {
    width: 100%;
    min-height: 48px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 7px;
    color: #fff;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.1);
}

@keyframes turnLandscape {
    0%, 18% { transform: rotate(0deg); }
    48%, 78% { transform: rotate(90deg); }
    100% { transform: rotate(0deg); }
}

/* 开场界面 */
#intro-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    z-index: 100;
}

#intro-screen h1 {
    font-size: 4rem;
    font-weight: 300;
    letter-spacing: 1rem;
    margin-bottom: 1rem;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
    animation: fadeInUp 1.5s ease;
}

.intro-text {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 3rem;
    animation: fadeInUp 1.5s ease 0.3s backwards;
}

#start-btn {
    padding: 1rem 3rem;
    font-size: 1.2rem;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: fadeInUp 1.5s ease 0.6s backwards;
}

#start-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
    transform: scale(1.05);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 场景容器 */
#scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
}

/* 场景背景 */
#scene-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: var(--scene-position, center center);
    background-repeat: no-repeat;
    transition: opacity 1s ease, transform 2s ease;
    transform: scale(1);
    overflow: hidden;
}

#scene-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(5, 9, 22, 0.2) 0%, rgba(5, 9, 22, 0.03) 44%, rgba(5, 9, 22, 0.62) 100%);
    transition: background 0.8s ease;
}

#scene-bg[data-tone="dream"]::after {
    background:
        radial-gradient(circle at 68% 28%, rgba(190, 164, 255, 0.18), transparent 38%),
        linear-gradient(180deg, rgba(12, 21, 52, 0.16), rgba(12, 18, 48, 0.62));
}

#scene-bg[data-tone="playful"]::after,
#scene-bg[data-tone="warm"]::after,
#scene-bg[data-tone="journey"]::after {
    background:
        linear-gradient(180deg, rgba(40, 22, 10, 0.08) 0%, rgba(31, 17, 13, 0.08) 48%, rgba(22, 12, 14, 0.6) 100%);
}

#scene-bg[data-tone="pastoral"]::after,
#scene-bg[data-tone="reunion"]::after {
    background:
        linear-gradient(180deg, rgba(13, 35, 40, 0.08) 0%, rgba(8, 17, 27, 0.04) 48%, rgba(7, 13, 27, 0.56) 100%);
}

#scene-bg[data-tone="city"]::after,
#scene-bg[data-tone="celestial"]::after {
    background:
        radial-gradient(circle at 28% 18%, rgba(69, 155, 255, 0.2), transparent 36%),
        linear-gradient(180deg, rgba(5, 20, 47, 0.1), rgba(6, 11, 31, 0.66));
}

#scene-bg[data-tone="lonely"]::after {
    background:
        linear-gradient(180deg, rgba(5, 14, 37, 0.38) 0%, rgba(3, 8, 23, 0.28) 42%, rgba(2, 5, 16, 0.76) 100%);
}

#scene-bg[data-tone="sacred"]::after {
    background:
        radial-gradient(circle at 48% 42%, rgba(116, 161, 120, 0.08), transparent 34%),
        linear-gradient(180deg, rgba(5, 17, 23, 0.28), rgba(3, 10, 19, 0.7));
}

#scene-bg[data-tone="urgent"]::after,
#scene-bg[data-tone="disaster"]::after {
    background:
        radial-gradient(circle at 50% 22%, rgba(255, 92, 68, 0.12), transparent 38%),
        linear-gradient(180deg, rgba(31, 9, 20, 0.22), rgba(12, 5, 17, 0.74));
}

#scene-bg[data-tone="twilight"]::after {
    background:
        radial-gradient(circle at 50% 36%, rgba(255, 184, 107, 0.16), transparent 32%),
        linear-gradient(180deg, rgba(52, 29, 85, 0.16), rgba(19, 9, 40, 0.66));
}

#scene-bg.fade-out {
    opacity: 0;
    transform: scale(1.1);
}

#scene-bg.fade-in {
    opacity: 1;
    transform: scale(1);
}

/* 场景标题 */
#scene-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 0.5rem;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    opacity: 0;
    transition: opacity 0.8s ease;
    text-align: center;
    z-index: 10;
}

#scene-title.show {
    opacity: 1;
}

/* 字幕区域 */
#subtitle-box {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    max-width: 900px;
    background: linear-gradient(135deg, rgba(5, 9, 22, 0.82), rgba(14, 18, 35, 0.7));
    padding: 25px 35px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    text-align: center;
    z-index: 20;
    backdrop-filter: blur(9px) saturate(120%);
    box-shadow: 0 18px 54px rgba(0, 0, 0, 0.24);
}

#subtitle-text {
    font-size: 1.3rem;
    line-height: 1.8;
    margin-bottom: 20px;
    min-height: 2.6rem;
}

#subtitle-text.inner {
    font-style: italic;
    color: rgba(255, 255, 255, 0.85);
}

#subtitle-text.dialogue {
    color: #fff;
}

#subtitle-text.narration {
    color: rgba(255, 255, 255, 0.9);
}

#continue-btn {
    padding: 10px 30px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px;
}

#continue-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
}

#continue-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 进度指示器 */
#progress-container {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 20;
}

#scene-indicator {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
}

#progress-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* 返回按钮 */
#back-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 30;
}

#back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 结束界面 */
#end-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a3e 100%);
    z-index: 100;
}

#end-screen h1 {
    font-size: 3rem;
    font-weight: 300;
    margin-bottom: 1rem;
    animation: fadeInUp 1s ease;
}

#end-screen p {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 3rem;
    font-style: italic;
    animation: fadeInUp 1s ease 0.3s backwards;
}

.end-buttons {
    display: flex;
    gap: 20px;
    animation: fadeInUp 1s ease 0.6s backwards;
}

#replay-btn, .btn-link {
    padding: 1rem 2.5rem;
    font-size: 1rem;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    border-radius: 4px;
}

#replay-btn:hover, .btn-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
}

/* 场景切换遮罩 */
.scene-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 60;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
}

.scene-transition.active {
    opacity: 1;
}

/* 响应式适配 */
@media (max-width: 768px) {
    #scene-bg {
        background-position: var(--scene-position-mobile, var(--scene-position, center center));
    }

    #intro-screen,
    #end-screen {
        height: 100dvh;
        padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
        text-align: center;
    }

    #intro-screen h1 {
        font-size: 2.5rem;
        letter-spacing: 0.5rem;
    }

    .intro-text {
        font-size: 1rem;
        padding: 0 20px;
        text-align: center;
    }

    #subtitle-box {
        width: calc(100% - 24px);
        max-height: 48dvh;
        padding: 16px;
        bottom: calc(68px + env(safe-area-inset-bottom));
        overflow-y: auto;
    }

    #subtitle-text {
        font-size: 1.1rem;
    }

    #scene-title {
        font-size: 1.8rem;
        padding: 0 20px;
        width: 100%;
        letter-spacing: 0.22rem;
    }

    #continue-btn {
        width: 100%;
        min-height: 44px;
    }

    #progress-container {
        bottom: calc(18px + env(safe-area-inset-bottom));
    }

    #progress-bar {
        width: 120px;
    }

    #back-btn {
        top: max(12px, env(safe-area-inset-top));
        right: max(12px, env(safe-area-inset-right));
        width: 44px;
        height: 44px;
    }

    #end-screen h1 {
        font-size: clamp(2rem, 10vw, 3rem);
    }

    .end-buttons {
        width: min(100%, 320px);
        flex-direction: column;
        gap: 12px;
    }

    #replay-btn,
    .btn-link {
        width: 100%;
        min-height: 48px;
        padding: 12px 18px;
    }
}

@media (max-width: 768px) and (orientation: portrait) {
    #orientation-guard {
        display: flex;
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    #scene-bg {
        background-position: var(--scene-position-mobile, var(--scene-position, center center));
    }

    #intro-screen h1 {
        margin-bottom: 8px;
        font-size: 2rem;
    }

    .intro-text {
        margin-bottom: 18px;
    }

    #start-btn {
        padding: 10px 28px;
    }

    #scene-title {
        top: 24%;
        font-size: 1.4rem;
    }

    #subtitle-box {
        width: min(76%, 760px);
        max-height: 46dvh;
        bottom: calc(48px + env(safe-area-inset-bottom));
        padding: 10px 16px;
    }

    #subtitle-text {
        margin-bottom: 8px;
        font-size: 0.95rem;
        line-height: 1.45;
    }

    #continue-btn {
        min-height: 38px;
        padding: 6px 22px;
    }

    #progress-container {
        bottom: calc(10px + env(safe-area-inset-bottom));
    }

    #back-btn {
        top: max(10px, env(safe-area-inset-top));
        right: max(10px, env(safe-area-inset-right));
    }
}
