:root {
    --bg-color: #050505;
    --text-color: #e0e0e0;
    --glow-color: rgba(147, 112, 219, 0.3);
    /* Soft purple glow */
    --accent-color: #9370db;
    /* Medium Purple */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    /* 禁止移动端下拉刷新和橡皮筋效果 */
    overscroll-behavior: none;
    position: fixed;
    width: 100%;
}

/* 爆款级氛围背景：深邃星云 */
body::before {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    transform: translate(-50%, -50%);
    background: radial-gradient(
        circle at 50% 50%,
        rgba(147, 112, 219, 0.08) 0%,
        rgba(0, 255, 255, 0.03) 25%,
        rgba(5, 5, 5, 1) 60%
    );
    z-index: -1;
    pointer-events: none;
    animation: nebulaBreathe 20s ease-in-out infinite alternate;
}

@keyframes nebulaBreathe {
    from { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
    to { opacity: 0.8; transform: translate(-50%, -50%) scale(1.1); }
}

/* 音频切换按钮 */
#audio-control {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 2000;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

#audio-control:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(0, 255, 255, 0.4);
}

#audio-icon {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 5px rgba(0, 255, 255, 0.5));
}


canvas {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1;
}

#container {
    position: relative;
    z-index: 10;
    text-align: center;
    max-width: 600px;
}

#prompt {
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: 2px;
    margin-bottom: 2rem;
    opacity: 0.8;
    animation: fadeIn 2s ease-out;
}

#final-words {
    background: transparent;
    border: none;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 4rem;
    text-align: center;
    width: 250px;
    padding: 10px;
    outline: none;
    transition: all 0.5s ease;
    animation: breathing 4s infinite ease-in-out;
}

#final-words:focus {
    border-bottom-color: var(--accent-color);
}

#result-section {
    margin-top: 2rem;
    transition: opacity 3s ease;
}

#reset-btn {
    background: transparent;
    border: 1px solid rgba(147, 112, 219, 0.4);
    color: var(--accent-color);
    padding: 12px 30px;
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 30px;
    transition: all 0.8s ease;
    opacity: 0;
    /* Animated via JS */
}

#reset-btn:hover {
    background: rgba(147, 112, 219, 0.1);
    border-color: var(--accent-color);
    box-shadow: 0 0 20px var(--glow-color);
}

.hidden {
    display: none;
    opacity: 0;
}

@keyframes breathing {

    0%,
    100% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0);
        text-shadow: 0 0 5px rgba(255, 255, 255, 0);
    }

    50% {
        box-shadow: 0 4px 30px var(--glow-color);
        text-shadow: 0 0 15px var(--glow-color);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 0.8;
        transform: translateY(0);
    }
}

input::placeholder {
    color: rgba(255, 255, 255, 0.1);
}

/* 星系图层样式 */
.galaxy-map-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, rgba(5, 5, 5, 0.85) 0%, rgba(2, 2, 2, 0.98) 100%);
    display: none;
    /* 默认隐藏 */
    pointer-events: auto;
    z-index: 100;
    justify-content: center;
    align-items: center;
    color: #00ffff;
    text-shadow:
        0 0 5px #00ffff,
        0 0 10px #00ffff,
        0 0 20px #9370db;
    font-family: 'PingFang SC', sans-serif;
    letter-spacing: 4px;
    opacity: 0.8;
    /* 屏蔽所有触控引起的滚动行为，交给 JS 或 CSS 动画 */
    touch-action: none;
    overscroll-behavior: none;
}


#galaxy-close {
    position: absolute;
    top: 24px;
    right: 32px;
    font-size: 1rem;
    color: rgba(147, 112, 219, 0.6);
    cursor: pointer;
    letter-spacing: 2px;
    transition: color 0.3s ease;
    text-shadow: none;
    z-index: 110;
}

#galaxy-close:hover {
    color: var(--accent-color);
}

#galaxy-svg {
    width: min(90vw, 90vh);
    height: min(90vw, 90vh);
    position: relative;
    z-index: 5; /* 确保在排行榜和控件之下 */
}

.galaxy-map-overlay.active {
    display: flex;
}

/* 俯冲动态模糊效果 */
.galaxy-map-overlay.dive-mode {
    filter: blur(3px) brightness(1.15) contrast(1.1);
    transform: scale(1.05);
    transition: filter 0.6s ease-in-out, transform 0.8s ease-in-out;
}

/* 引力波闪烁特效 */
.galaxy-map-overlay.wave-active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 200;
    animation: gravitationalWave 0.6s ease-out;
}

@keyframes gravitationalWave {
    0% { 
        opacity: 0; 
    }
    30% { 
        opacity: 0.08; 
        filter: blur(4px);
    }
    100% { 
        opacity: 0; 
        filter: blur(10px);
    }
}



/* 1. 缓慢旋转动画 */
.galaxy-map-overlay svg {
    animation: slowRotate 60s linear infinite;
    transform-origin: center;
}

/* 俯冲时锁定旋转 */
#galaxy-svg.zoom-locked {
    animation-play-state: paused;
}

/* 屏蔽 burst 环的全局呼吸动画，并赋予爆裂能量感 */
.galaxy-map-overlay circle.burst-ring {
    animation: burstEnergy 1s cubic-bezier(0.15, 0.85, 0.35, 1) forwards;
    filter: url(#chromatic-aberration) drop-shadow(0 0 15px #00ffff);
}

@keyframes burstEnergy {
    0% {
        stroke-width: 4;
        filter: url(#chromatic-aberration) brightness(3) blur(2px);
    }

    50% {
        stroke-width: 2;
        filter: url(#chromatic-aberration) brightness(1.5) blur(0px);
    }

    100% {
        stroke-width: 0.5;
        filter: none;
    }
}

/* Heatmap: Top 5 星球强光动效 */
.top-planet {
    filter: drop-shadow(0 0 10px #00ffff);
    animation: planet-pulse 2s infinite ease-in-out !important;
    z-index: 10; /* 虽然 SVG 内部主要靠 DOM 顺序，但此处声明以备层级参考 */
    transform-origin: center;
    transform-box: fill-box;
}

@keyframes planet-pulse {
    0%, 100% { 
        transform: scale(1);
        filter: drop-shadow(0 0 10px #00ffff) brightness(1);
    }
    50% { 
        transform: scale(1.2);
        filter: drop-shadow(0 0 20px #00ffff) brightness(1.8);
    }
}



@keyframes slowRotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* 2. 单词圆圈的模糊呼吸动画 */
.galaxy-map-overlay circle,
.galaxy-map-overlay text {
    animation: blurBreathe 4s ease-in-out infinite;
}

@keyframes blurBreathe {

    0%,
    100% {
        filter: blur(0px);
        opacity: 0.7;
        transform: scale(1);
    }

    50% {
        filter: blur(1.5px);
        opacity: 1;
        transform: scale(1.05);
    }
}

/* 排行榜面板 */
#rankings-panel {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(5, 5, 5, 0.72);
    border: 1px solid rgba(147, 112, 219, 0.18);
    border-radius: 10px;
    padding: 16px 20px;
    min-width: 148px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
    z-index: 120;
}

#rankings-panel.visible {
    opacity: 1;
    pointer-events: auto;
}

.rankings-title {
    font-size: 0.72rem;
    color: rgba(147, 112, 219, 0.65);
    letter-spacing: 3px;
    margin-bottom: 12px;
    text-shadow: none;
}

#rankings-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#rankings-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 7px 0;
    font-size: 0.88rem;
    color: rgba(224, 224, 224, 0.65);
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: color 0.2s ease;
    letter-spacing: 1px;
    text-shadow: none;
}

#rankings-list li:last-child {
    border-bottom: none;
}

#rankings-list li:hover {
    color: #00ffff;
}

.rank-count {
    font-size: 0.72rem;
    color: rgba(147, 112, 219, 0.5);
    font-variant-numeric: tabular-nums;
}

/* 探索模式光标 */
.galaxy-map-overlay.explorable {
    cursor: grab;
}

.galaxy-map-overlay.explorable.dragging {
    cursor: grabbing;
}

/* 3. 流星背景效果 */
.shooting-stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 5;
    /* 在背景 Canvas(1) 之上，但在文字容器(10)之下 */
    pointer-events: none;
    overflow: hidden;
}

.shooting-star {
    position: absolute;
    top: -50px;
    left: 10%;
    width: 2px;
    height: 80px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(0, 255, 255, 1));
    filter: drop-shadow(0 0 5px #00ffff);
    opacity: 0;
    transform: rotate(45deg);
    animation: shoot 5s linear infinite;
}

@keyframes shoot {
    0% {
        transform: rotate(45deg) translateY(0);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    30% {
        transform: rotate(45deg) translateY(600px);
        opacity: 0;
    }

    100% {
        transform: rotate(45deg) translateY(600px);
        opacity: 0;
    }
}

/* 侧边排行榜：毛玻璃与进场动画 */
#leaderboard {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%) translateX(50px);
    width: 260px;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    opacity: 0;
    transition: all 1.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 150;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

#leaderboard-handle {
    display: none; /* Desktop hidden */
}

#leaderboard.show {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
    pointer-events: auto;
}

#leaderboard h2 {
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--accent-color);
    margin-bottom: 8px;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(147, 112, 219, 0.5);
}

/* 全球统计文字样式 */
#global-stats {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 20px;
    font-weight: 200;
    letter-spacing: 1px;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

#global-soul-count {
    color: #00ffff;
    font-size: 1.1rem;
    font-weight: 400;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.4);
}


.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.95rem;
    font-weight: 200;
    color: rgba(255, 255, 255, 0.8);
    transition: transform 0.3s ease, color 0.3s ease;
    opacity: 0;
    /* 用于交错入场动画 */
    animation: itemStaggerIn 0.8s ease forwards;
}

@keyframes itemStaggerIn {
    from {
        opacity: 0;
        transform: translateX(15px);
        filter: blur(4px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
        filter: blur(0);
    }
}

.leaderboard-word {
    letter-spacing: 2px;
}

.leaderboard-count {
    font-family: 'Courier New', monospace;
    color: #00ffff;
    font-size: 0.85rem;
    opacity: 0.7;
}

/* 交互控件 */
#controls-group {
    position: absolute;
    left: 40px;
    bottom: 40px;
    display: flex;
    gap: 20px;
    z-index: 150;
    opacity: 0;
    transition: opacity 1s ease 0.5s;
}

.active #controls-group {
    opacity: 1;
}

#controls-group button {
    background: transparent;
    border: 1px solid rgba(0, 255, 255, 0.2);
    color: rgba(0, 255, 255, 0.6);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.4s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

#controls-group button:hover {
    border-color: #00ffff;
    color: #00ffff;
    background: rgba(0, 255, 255, 0.05);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

/* 星球悬停提示 */
#planet-tooltip {
    position: fixed;
    pointer-events: none;
    background: rgba(5, 5, 5, 0.85);
    border: 1px solid rgba(147, 112, 219, 0.4);
    padding: 10px 16px;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transform: translate(10px, 10px);
}

#planet-tooltip.visible {
    opacity: 1;
}

.tooltip-word {
    font-size: 1.1rem;
    font-weight: 400;
    color: #00ffff;
}

.tooltip-stats {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

/* 响应式调整：底部抽屉 */
@media (max-width: 768px) {
    #leaderboard {
        width: 100% !important;
        right: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        transform: translateY(100%) !important;
        border-radius: 20px 20px 0 0;
        padding: 20px;
        max-height: 48vh;
        display: flex;
        flex-direction: column;
        transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1) !important;
        pointer-events: auto !important;
    }

    #leaderboard.show {
        transform: translateY(0) !important;
    }

    #leaderboard.collapsed {
        transform: translateY(calc(100% - 60px)) !important;
        cursor: pointer;
    }

    #leaderboard-list {
        overflow-y: auto;
        flex: 1;
        padding-right: 5px;
        -webkit-overflow-scrolling: touch;
    }

    #leaderboard-handle {
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
        margin: 0 auto 15px;
        cursor: pointer;
    }

    /* 侧边栏按钮组移到左侧并避开音频控制 */
    #controls-group {
        left: 20px !important;
        bottom: auto !important;
        top: 80px !important;
        flex-direction: column;
        gap: 12px;
    }
}

/* 分享遮罩层 */
#share-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
}

#share-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.share-card {
    width: min(340px, 90vw);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 32px;
    padding: 50px 30px;
    text-align: center;
    box-shadow: 
        0 30px 60px rgba(0, 0, 0, 0.8),
        inset 0 0 20px rgba(255, 255, 255, 0.02);
    transform: translateY(30px);
    transition: transform 1s cubic-bezier(0.16, 1, 0.3, 1);
}

#share-overlay:not(.hidden) .share-card {
    transform: translateY(0);
}

.share-header {
    font-size: 0.8rem;
    color: var(--accent-color);
    letter-spacing: 4px;
    margin-bottom: 40px;
    opacity: 0.7;
}

.share-content p {
    font-size: 1.25rem;
    line-height: 1.8;
    font-weight: 300;
    color: #fff;
    letter-spacing: 2px;
}

#share-n {
    color: #00ffff;
    font-size: 2.2rem;
    font-weight: 400;
    display: block;
    margin: 15px 0;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.share-footer {
    margin-top: 50px;
}

#close-share {
    background: #fff;
    color: #000;
    border: none;
    padding: 12px 30px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#close-share:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.share-hint {
    margin-top: 20px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 1px;
}
    position: absolute;
    bottom: 14%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    opacity: 0;
    transition: opacity 1.2s ease;
    z-index: 120;
    pointer-events: none;
    letter-spacing: 2px;
    line-height: 1.6;
    white-space: nowrap;
}

#resonance-toast.visible {
    opacity: 1;
    animation: resonanceFadeIn 1.5s cubic-bezier(0.2, 0, 0.2, 1) forwards;
}

@keyframes resonanceFadeIn {
    0% {
        opacity: 0;
        letter-spacing: -4px;
        filter: blur(8px);
        transform: translate(-50%, 10px);
    }

    60% {
        opacity: 1;
        filter: blur(0px);
    }

    100% {
        opacity: 1;
        letter-spacing: 2px;
        transform: translate(-50%, 0);
    }
}


.toast-line {
    display: block;
    font-size: 0.95rem;
    color: rgba(224, 224, 224, 0.85);
    text-shadow: none;
}

.toast-count {
    display: block;
    font-size: 3.2rem;
    font-weight: 200;
    color: #00ffff;
    letter-spacing: 4px;
    margin: 0.2rem 0;
    text-shadow:
        0 0 20px #00ffff,
        0 0 50px rgba(0, 255, 255, 0.4),
        0 0 80px rgba(0, 255, 255, 0.15);
}

/* 随机化不同流星的时间延迟和位置 */
.shooting-star:nth-child(2) {
    left: 40%;
    animation-delay: 2s;
    animation-duration: 6s;
}

.shooting-star:nth-child(3) {
    left: 70%;
    animation-delay: 4.5s;
    animation-duration: 7s;
}

.shooting-star:nth-child(4) {
    left: 25%;
    animation-delay: 8s;
    animation-duration: 5.5s;
}

.shooting-star:nth-child(5) {
    left: 85%;
    animation-delay: 11s;
    animation-duration: 8s;
}