:root {
    --bg-dark: #070b14;
    --panel-bg: rgba(15, 23, 42, 0.85);
    --panel-border: rgba(99, 102, 241, 0.35);
    --panel-glow: rgba(99, 102, 241, 0.15);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --accent-cyan: #06b6d4;
    --accent-pink: #ec4899;
    --accent-violet: #8b5cf6;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --accent-green: #10b981;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--text-main);
}

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 1024px;
    margin: 0 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    background: #090d16;
}

.scene-background {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: radial-gradient(circle at 50% 30%, #1e1b4b 0%, #090d16 85%);
    transition: background 0.8s ease;
}

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
    pointer-events: none;
}

.scanline-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
    background-size: 100% 4px;
    opacity: 0.6;
    pointer-events: none;
}

.glow-orb {
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    top: 20%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(99, 102, 241, 0.25) 0%, transparent 70%);
    filter: blur(40px);
    transition: all 1s ease;
    pointer-events: none;
}

.game-header {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: rgba(11, 15, 25, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.5);
    color: #ffffff;
}

.nav-btn.active {
    background: var(--accent-violet);
    border-color: var(--accent-violet);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.5);
}

.scene-tag {
    font-family: monospace;
    font-size: 11px;
    color: var(--accent-cyan);
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.25);
    letter-spacing: 0.05em;
}

.stage-area {
    position: relative;
    z-index: 5;
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 20px;
    overflow: hidden;
}

.character-wrapper {
    position: relative;
    width: 320px;
    height: 480px;
    max-height: 80vh;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    animation: breathing 4s ease-in-out infinite alternate;
}

@keyframes breathing {
    0% { transform: translateY(0); }
    100% { transform: translateY(-8px); }
}

.character-sprite {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    filter: drop-shadow(0 10px 25px rgba(6, 182, 212, 0.25));
}

.character-sprite svg {
    max-width: 100%;
    max-height: 100%;
    height: auto;
}

.dialogue-box {
    position: relative;
    z-index: 10;
    margin: 0 16px 16px;
    min-height: 140px;
    padding: 18px 24px 22px;
    border-radius: 14px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 0 20px var(--panel-glow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dialogue-box:hover {
    border-color: rgba(99, 102, 241, 0.6);
}

.speaker-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--accent-cyan);
    margin-bottom: 10px;
    padding: 3px 10px;
    border-radius: 6px;
    background: rgba(6, 182, 212, 0.12);
    border-left: 3px solid var(--accent-cyan);
}

.speaker-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
}

.text-content {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-main);
    min-height: 52px;
    word-break: break-word;
}

.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 14px;
    vertical-align: middle;
    margin-left: 4px;
    background-color: var(--accent-cyan);
    animation: blink 0.8s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.dialogue-prompt {
    position: absolute;
    right: 20px;
    bottom: 14px;
    color: var(--accent-cyan);
    animation: bounceRight 1s infinite alternate;
}

@keyframes bounceRight {
    0% { transform: translateX(0); opacity: 0.5; }
    100% { transform: translateX(4px); opacity: 1; }
}

.choices-container {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: rgba(7, 11, 20, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

.choices-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-cyan);
    letter-spacing: 0.05em;
    margin-bottom: 24px;
    text-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
}

.choices-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 480px;
}

.choice-btn {
    padding: 14px 22px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.choice-btn:hover {
    transform: translateY(-2px) scale(1.02);
    border-color: var(--accent-cyan);
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.3), rgba(6, 182, 212, 0.3));
    box-shadow: 0 8px 24px rgba(6, 182, 212, 0.25);
}

.modal-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-window {
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.modal-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.modal-close:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.log-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.log-entry {
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-left: 3px solid var(--panel-border);
}

.log-speaker {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-bottom: 4px;
}

.log-text {
    font-size: 13px;
    color: var(--text-main);
    line-height: 1.5;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}

.gallery-card {
    padding: 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gallery-card.unlocked {
    border-color: rgba(16, 185, 129, 0.5);
    background: rgba(16, 185, 129, 0.06);
}

.gallery-card.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.gallery-tag {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
}

.gallery-card.unlocked .gallery-tag {
    color: var(--accent-green);
}

.gallery-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.gallery-desc {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.4;
}

.ending-screen {
    position: absolute;
    inset: 0;
    z-index: 40;
    background: rgba(4, 7, 14, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.8s ease;
}

.ending-content {
    max-width: 520px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ending-type {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: var(--accent-cyan);
    margin-bottom: 16px;
}

.ending-title {
    font-size: clamp(24px, 4vw, 32px);
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 16px;
    line-height: 1.3;
}

.ending-desc {
    font-size: 15px;
    color: var(--text-dim);
    line-height: 1.8;
    margin-bottom: 32px;
}

.ending-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.action-button {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.action-button.primary {
    background: var(--accent-violet);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}

.action-button.primary:hover {
    background: #7c3aed;
    transform: translateY(-2px);
}

.action-button.secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-main);
}

.action-button.secondary:hover {
    background: rgba(255, 255, 255, 0.14);
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 640px) {
    .game-header {
        padding: 8px 12px;
    }

    .scene-tag {
        display: none;
    }

    .character-wrapper {
        width: 260px;
        height: 380px;
    }

    .dialogue-box {
        margin: 0 10px 10px;
        min-height: 130px;
        padding: 14px 16px 18px;
    }

    .text-content {
        font-size: 14px;
    }
}
