/* 全局样式 */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&family=Orbitron:wght@400;700&display=swap');

:root {
    --primary-color: #9f5dff;
    --secondary-color: #0d0a1a;
    --text-color: #e0e0e0;
    --glow-color: rgba(159, 93, 255, 0.8);
    --font-tech: 'Orbitron', sans-serif;
    --font-body: 'Roboto', sans-serif;
    
    /* 状态颜色 */
    --locked-color: #1a1a1a;
    --unlocked-color: #555;
    --visited-color: #3a7bd5;
    --completed-color: #4caf50;
    --reward-color: #ffd700;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--secondary-color);
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    inset: 0;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: none;
    overflow: hidden;
    clip-path: circle(200% at 50% 50%);
}

#loading-screen.loading-fade-out {
    animation: loading-clip-shrink 1.5s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

@keyframes loading-clip-shrink {
    0% { clip-path: circle(200% at 50% 50%); }
    100% { clip-path: circle(0% at 50% 50%); }
}

.loading-content {
    width: min(480px, 80%);
    text-align: center;
    color: #0d1117;
    position: relative;
    z-index: 9999;
}

.loading-text {
    font: 700 24px/1.2 var(--font-tech);
    margin-bottom: 18px;
    opacity: 0;
    transform: translateY(10px);
    animation: loadingFadeIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s forwards;
}

.loading-bar { 
    height: 4px; 
    width: 33%; 
    background: #d0d0d0; 
    border-radius: 999px; 
    overflow: hidden; 
    margin: 0 auto;
    opacity: 0;
    transform: scale(0.8);
    animation: loadingFadeIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s forwards;
}

.loading-bar-fill { 
    height: 100%; 
    width: 0%; 
    background: #000000; 
    border-radius: inherit; 
    transition: width .2s ease-out; 
}

/* Loading 内容缓入动画 */
@keyframes loadingFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 游戏容器 */
#game-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* 顶部标题区 */
#page-header {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;
    text-align: center;
    pointer-events: none; /* 不阻挡下方交互 */
}

.site-title {
    margin: 0;
    font-family: var(--font-tech);
    font-weight: 800;
    letter-spacing: 1px;
    font-size: clamp(22px, 4vw, 42px);
    line-height: 1.1;
    text-shadow: 0 0 18px rgba(159, 93, 255, 0.25);
}

.brand-nebula { color: #ffffff; }
.brand-atlas { color: #9F5DFF; margin-left: 2px; }

.site-subtitle {
    margin-top: 6px;
    font-family: var(--font-body);
    font-weight: 300;
    letter-spacing: 0.4em;
    font-size: clamp(10px, 1.6vw, 14px);
    color: rgba(255,255,255,0.85);
    opacity: 0.9;
}

/* 星图背景 */
#star-map {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* SVG动态连接线层 */
#connection-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

/* 关卡容器 */
#levels-container {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    /* 下移一点,给顶部标题留空间 */
    transform: translateY(calc(-50% + 36px));
    z-index: 10;
    display: flex;
    flex-wrap: nowrap;
    gap: 80px;
    align-items: center;
    padding: 80px max(calc(50vw - 140px), 5vw); /* 使用max确保最小padding */
    overflow-x: auto;
    overflow-y: visible; /* 改为visible,让发光效果可见 */
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    scroll-snap-type: x mandatory; /* 添加滚动吸附 */
}

#levels-container:active {
    cursor: grabbing;
}

#levels-container::-webkit-scrollbar {
    display: none;
}

/* 关卡卡片 */
.level-card, .reward-card {
    position: relative;
    min-width: 280px;
    max-width: 280px;
    background: rgba(26, 22, 45, 0.95);
    border: 2px solid rgba(159, 93, 255, 0.3);
    border-radius: 20px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    scroll-snap-align: center; /* 卡片居中吸附 */
    flex-shrink: 0; /* 防止收缩 */
}

.level-card:hover, .reward-card:hover {
    transform: translateY(-15px) scale(1.05);
    box-shadow: 0 15px 50px var(--glow-color);
    border-color: var(--primary-color);
}

.level-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.level-card.locked:hover {
    transform: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* 关卡 Emoji */
.level-emoji {
    font-size: 80px;
    line-height: 1;
    margin-bottom: 20px;
    display: inline-block;
    filter: drop-shadow(0 0 20px var(--glow-color));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* 关卡标题 */
.level-title {
    font-family: var(--font-tech);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #fff;
    text-shadow: 0 0 10px var(--glow-color);
}

/* 关卡描述 */
.level-description {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 15px;
    color: var(--text-color);
    opacity: 0.9;
}

/* 难度标签 */
.level-difficulty {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-tech);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.difficulty-入门 {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.5);
}

.difficulty-进阶 {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
    box-shadow: 0 0 15px rgba(255, 152, 0, 0.5);
}

.difficulty-挑战 {
    background: linear-gradient(135deg, #F44336, #D32F2F);
    color: white;
    box-shadow: 0 0 15px rgba(244, 67, 54, 0.5);
}

/* 底部状态栏 */
#status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: rgba(13, 10, 26, 0.95);
    border-top: 2px solid rgba(159, 93, 255, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 40px;
    overflow: visible; /* 允许指示器放大时不被裁切 */
}

#status-indicators {
    display: flex;
    gap: 12px;
    align-items: center;
    overflow-x: auto;
    overflow-y: visible; /* 改为visible,让放大效果可见 */
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 20px 20px; /* 增加上下padding,避免放大被裁切 */
    position: relative;
}

#status-indicators::-webkit-scrollbar {
    display: none;
}

/* 状态指示器 */
.status-indicator {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    z-index: 1; /* 基础层级 */
}

/* 状态指示器之间的连接线 */
/* 移除状态指示器之间的连线 */
/* .status-indicator:not(:last-child)::after { } */

.status-indicator:hover {
    transform: scale(1.5); /* 增加放大倍数 */
    z-index: 10; /* 悬浮时提升层级 */
}

.status-indicator.locked {
    background: var(--locked-color);
    border: 1px solid #333;
}

.status-indicator.unlocked {
    background: var(--unlocked-color);
    border: 1px solid #777;
    box-shadow: 0 0 5px rgba(85, 85, 85, 0.4);
}

.status-indicator.visited {
    background: var(--visited-color);
    border: 1px solid #5a9bd5;
    box-shadow: 0 0 8px rgba(58, 123, 213, 0.6);
}

.status-indicator.completed {
    background: var(--completed-color);
    border: 1px solid #66bb6a;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.status-indicator.reward {
    background: var(--reward-color);
    border: 1px solid #ffed4e;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
    animation: pulse-gold 2s ease-in-out infinite;
}

@keyframes pulse-gold {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.6); }
    50% { box-shadow: 0 0 16px rgba(255, 215, 0, 0.4); }
}

/* 模态框 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-container {
    position: relative;
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    background: linear-gradient(135deg, rgba(26, 22, 45, 0.98), rgba(13, 10, 26, 0.98));
    border: 2px solid var(--primary-color);
    border-radius: 25px;
    padding: 40px;
    box-shadow: 0 0 50px var(--glow-color);
    overflow-y: auto;
    animation: scaleIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(255, 255, 255, 0.1);
}

@keyframes scaleIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-container::-webkit-scrollbar {
    width: 8px;
}

.modal-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.modal-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: rotate(90deg);
}

.modal-content {
    font-family: var(--font-body);
    color: var(--text-color);
}

/* 通关庆祝动画 */
.celebration-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.celebration-overlay.active {
    display: flex;
}

.celebration-modal {
    background: linear-gradient(135deg, rgba(159, 93, 255, 0.95), rgba(123, 31, 162, 0.95));
    border: 3px solid var(--primary-color);
    border-radius: 30px;
    padding: 60px 80px;
    text-align: center;
    box-shadow: 0 20px 80px rgba(159, 93, 255, 0.6);
    transform: scale(0);
    opacity: 0;
    animation: celebrationPopIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    position: relative;
    z-index: 10;
}

.celebration-overlay.fade-out .celebration-modal {
    animation: celebrationPopOut 0.5s ease-in forwards;
}

@keyframes celebrationPopIn {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes celebrationPopOut {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.8);
        opacity: 0;
    }
}

.celebration-icon {
    font-size: 100px;
    line-height: 1;
    margin-bottom: 20px;
    animation: celebrationBounce 1s infinite;
}

@keyframes celebrationBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.celebration-title {
    font-family: var(--font-tech);
    font-size: 48px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 15px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
}

.celebration-message {
    font-size: 24px;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

/* 彩带容器 */
.confetti-container {
    position: fixed;
    bottom: 0;
    width: 400px;
    height: 100vh;
    overflow: visible; /* 改为visible,不裁切 */
    opacity: 0;
    z-index: 5;
    pointer-events: none;
}

#confetti-left {
    left: -50px; /* 向左偏移,留出喷射空间 */
}

#confetti-right {
    right: -50px; /* 向右偏移,留出喷射空间 */
}

.confetti-container.active {
    animation: confettiFadeIn 0.3s ease-out forwards;
}

.confetti-container.fade-out {
    animation: confettiFadeOut 0.5s ease-in forwards;
}

@keyframes confettiFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes confettiFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* 彩带纸片 */
.confetti {
    position: absolute;
    bottom: 0;
    width: 10px;
    height: 20px;
    background: var(--primary-color);
}

/* 左侧彩带 - 向右上扇形喷射 */
#confetti-left .confetti {
    animation: confettiFallLeft 3s ease-out forwards;
}

/* 右侧彩带 - 向左上扇形喷射 */
#confetti-right .confetti {
    animation: confettiFallRight 3s ease-out forwards;
}

@keyframes confettiFallLeft {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) rotate(720deg);
        opacity: 0;
    }
}

@keyframes confettiFallRight {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) rotate(-720deg);
        opacity: 0;
    }
}

/* 调试面板 */
.debug-panel {
    position: fixed;
    top: 0;
    right: -470px;
    width: 420px;
    height: 100vh;
    background: linear-gradient(135deg, rgba(26, 22, 45, 0.98), rgba(13, 10, 26, 0.98));
    border-left: 2px solid var(--primary-color);
    box-shadow: -5px 0 30px rgba(159, 93, 255, 0.5);
    z-index: 10000;
    transition: right 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(255, 255, 255, 0.1);
}

.debug-panel::-webkit-scrollbar {
    width: 8px;
}

.debug-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.debug-panel::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.debug-panel.active {
    right: 0;
}

.debug-header {
    position: sticky;
    top: 0;
    background: rgba(13, 10, 26, 0.98);
    padding: 20px;
    border-bottom: 1px solid rgba(159, 93, 255, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1;
}

.debug-header h3 {
    margin: 0;
    font-family: var(--font-tech);
    color: var(--primary-color);
    font-size: 18px;
}

.debug-close {
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.debug-close:hover {
    background: var(--primary-color);
    transform: rotate(90deg);
}

.debug-content {
    padding: 20px;
    padding-bottom: 30px;
    height: calc(100vh - 71px); /* 100vh - header height */
    overflow-y: auto;
}

.debug-group {
    margin-bottom: 20px;
}

.debug-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-color);
}

.debug-group label span {
    color: var(--primary-color);
    font-weight: bold;
    float: right;
}

.debug-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: rgba(159, 93, 255, 0.2);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.debug-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(159, 93, 255, 0.8);
}

.debug-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(159, 93, 255, 0.8);
}

.debug-export {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    background: linear-gradient(135deg, #9f5dff, #7a3fd9);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 14px;
    font-family: var(--font-tech);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(159, 93, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.debug-export:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(159, 93, 255, 0.8);
}

.debug-reset {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.8), rgba(251, 140, 0, 0.8));
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 14px;
    font-family: var(--font-tech);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(255, 152, 0, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.debug-reset:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(255, 152, 0, 0.8);
}

.debug-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(159, 93, 255, 0.2);
}

.debug-section:last-of-type {
    border-bottom: none;
}

.debug-section h4 {
    margin: 0 0 15px 0;
    font-size: 13px;
    color: rgba(159, 93, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

/* 响应式设计 */
@media (max-width: 768px) {
    #levels-container {
        gap: 40px;
        padding: 20px calc(50vw - 120px); /* 移动端卡片宽度240px, 一半是120px */
    }

    .level-card, .reward-card {
        min-width: 240px;
        max-width: 240px;
        padding: 25px 15px;
    }

    .level-emoji {
        font-size: 60px;
    }

    .level-title {
        font-size: 20px;
    }

    .level-description {
        font-size: 13px;
    }

    .level-connector {
        right: -40px;
        width: 40px;
    }

    #status-bar {
        height: 60px;
        padding: 0 20px;
    }

    .status-indicator {
        width: 16px;
        height: 16px;
    }

    .modal-container {
        padding: 30px 20px;
        width: 95%;
    }
    
    /* 移动端:横向滚动 */
    #levels-container {
        flex-wrap: nowrap;
        justify-content: flex-start;
        scroll-snap-type: x mandatory;
    }

    .level-card, .reward-card {
        scroll-snap-align: center;
    }

    /* 移动端: 通关庆祝弹窗缩小一倍（整体缩放） */
    .celebration-overlay {
        transform: scale(0.5);
        transform-origin: center center;
    }
}
