@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&family=Share+Tech+Mono&display=swap');

:root {
    --bg-dark: #07090e;
    --panel-bg: rgba(5, 8, 14, 0.34);
    --panel-bg-soft: rgba(5, 8, 14, 0.22);
    --border-color: rgba(255, 255, 255, 0.11);
    --text-primary: #f0f4f8;
    --text-secondary: #8a9cae;
    
    /* 阶段色彩 */
    --color-stage-1: #00e5ff; /* 霓虹天蓝 - 星云 */
    --color-stage-2: #ff7600; /* 高能橙色 - 塌缩/喷流 */
    --color-stage-3: #ffb000; /* 聚变建立琥珀色 - 预主序过渡 */
    --color-stage-4: #ffea00; /* 恒星明黄 - 主序星 */
    
    --active-accent: var(--color-stage-1);
    --font-sans: 'Outfit', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* UI 覆盖层容器 */
.hud-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* 穿透鼠标，但子元素需要单独启用 pointer-events */
}

.hud-overlay > * {
    pointer-events: auto; /* 恢复子元素的交互 */
}

/* 玻璃拟物化通用面板 */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(14px) saturate(1.15);
    -webkit-backdrop-filter: blur(14px) saturate(1.15);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 14px 46px rgba(0, 0, 0, 0.38);
    padding: 16px;
    transition: border-color 0.5s ease, box-shadow 0.5s ease, background 0.5s ease;
}

.glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

/* 顶部标题栏 */
header {
    position: absolute;
    top: 22px;
    left: 24px;
    width: min(560px, calc(100vw - 48px));
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 22px;
}

.title-container h1 {
    font-size: 1.28rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: linear-gradient(90deg, #ffffff, var(--active-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: background 0.5s ease;
}

.title-container p {
    font-size: 0.62rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-top: 2px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.035);
    padding: 7px 12px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--active-accent);
    box-shadow: 0 0 10px var(--active-accent);
    animation: pulse 2s infinite;
}

.status-text {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--active-accent);
    text-transform: uppercase;
    white-space: nowrap;
}

/* 左侧面板：物理参数仪表盘 */
aside.left-panel {
    position: absolute;
    left: 24px;
    top: 116px;
    width: 252px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--panel-bg-soft);
}

.panel-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    border-left: 3px solid var(--active-accent);
    padding-left: 8px;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.metric-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.045);
    border-radius: 8px;
    padding: 9px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metric-label {
    font-size: 0.62rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.metric-value-container {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.metric-value {
    font-family: var(--font-mono);
    font-size: 1.02rem;
    font-weight: 600;
    color: #ffffff;
}

.metric-unit {
    font-size: 0.64rem;
    color: var(--text-secondary);
    margin-left: 4px;
}

/* 金斯不稳定性状态指示器 */
.jeans-bar-container {
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
    position: relative;
}

.jeans-bar {
    height: 100%;
    width: 0%;
    background: var(--active-accent);
    box-shadow: 0 0 8px var(--active-accent);
    transition: width 0.3s ease, background-color 0.5s ease;
}

.instability-alert {
    font-size: 0.62rem;
    font-family: var(--font-mono);
    text-align: right;
    margin-top: 4px;
    color: var(--text-secondary);
}

.instability-alert.active {
    color: var(--color-stage-3);
    animation: flash 1s infinite;
}

/* 右侧面板：科学科普日志 */
aside.right-panel {
    position: absolute;
    right: 32px;
    top: 118px;
    width: 330px;
    max-height: calc(100vh - 245px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(5, 8, 14, 0.28);
}

.science-narrative {
    flex-grow: 0;
    font-size: 0.78rem;
    line-height: 1.7;
    color: #cbd5e1;
    overflow-y: auto;
    padding-right: 5px;
    max-height: 168px;
}

.science-narrative p {
    margin-bottom: 12px;
}

/* 滚轮美化 */
.science-narrative::-webkit-scrollbar {
    width: 4px;
}
.science-narrative::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* 压力平衡表盘 */
.equilibrium-display {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.045);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.eq-meter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 30px;
    position: relative;
}

.eq-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 600;
}

.eq-label.gravity { color: var(--color-stage-2); }
.eq-label.pressure { color: var(--color-stage-1); }

.eq-pointer-container {
    flex-grow: 1;
    margin: 0 15px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    position: relative;
}

.eq-pointer {
    position: absolute;
    top: -4px;
    left: 50%;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 10px #ffffff;
    transition: left 0.3s cubic-bezier(0.1, 0.8, 0.3, 1);
}

.eq-pointer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: var(--active-accent);
    border-radius: 50%;
}

.eq-status {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 1px;
}

/* 底部面板：控制台/时间轴 */
footer {
    position: absolute;
    left: 50%;
    bottom: 26px;
    width: min(880px, calc(100vw - 96px));
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 14px;
    justify-content: center;
    background: rgba(5, 8, 14, 0.24);
    padding: 18px 24px 14px;
}

.timeline-container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 8px;
}

.timeline-labels {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: start;
    padding: 0;
}

.timeline-step {
    position: relative;
    min-height: 54px;
    padding-top: 34px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    transition: color 0.3s ease, text-shadow 0.3s ease;
    text-transform: uppercase;
}

.timeline-step::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 50%;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.88);
    border: 2px solid rgba(255, 255, 255, 0.28);
    box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.035), 0 0 14px rgba(255, 255, 255, 0.18);
    transition: transform 0.25s ease, box-shadow 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.timeline-step.active {
    color: var(--active-accent);
    text-shadow: 0 0 12px color-mix(in srgb, var(--active-accent) 65%, transparent);
}

.timeline-step.active::before {
    transform: translateX(-50%) scale(1.18);
    background: #ffffff;
    border-color: var(--active-accent);
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--active-accent) 13%, transparent), 0 0 22px var(--active-accent);
}

/* 霓虹发光时间滑块 */
.slider-wrapper {
    position: absolute;
    width: 100%;
    height: 26px;
    top: 4px;
    left: 0;
    display: flex;
    align-items: center;
    padding: 0 12.5%;
    z-index: 3;
}

input[type="range"].timeline-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    --timeline-progress: 0%;
    background:
        linear-gradient(90deg, var(--active-accent) 0%, var(--active-accent) var(--timeline-progress), transparent var(--timeline-progress)),
        linear-gradient(90deg, rgba(255,255,255,0.1), rgba(255,255,255,0.24), rgba(255,255,255,0.1));
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 0 18px rgba(255, 255, 255, 0.08);
}

/* 拖动游标：使用小菱形，和阶段圆点明确区分 */
input[type="range"].timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    background: #ffffff;
    border: 2px solid var(--active-accent);
    transform: rotate(45deg);
    box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.44), 0 0 18px var(--active-accent);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.3s;
}

input[type="range"].timeline-slider::-webkit-slider-thumb:hover {
    transform: rotate(45deg) scale(1.14);
}

input[type="range"].timeline-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    background: #ffffff;
    border: 2px solid var(--active-accent);
    transform: rotate(45deg);
    box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.44), 0 0 18px var(--active-accent);
    cursor: pointer;
}

input[type="range"].timeline-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background:
        linear-gradient(90deg, var(--active-accent) 0%, var(--active-accent) var(--timeline-progress), transparent var(--timeline-progress)),
        linear-gradient(90deg, rgba(255,255,255,0.1), rgba(255,255,255,0.24), rgba(255,255,255,0.1));
}

.control-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 0;
}

.btn-ctrl {
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    padding: 8px 18px;
    border-radius: 30px;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-ctrl:hover {
    background: var(--active-accent);
    border-color: var(--active-accent);
    color: #07090e;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
}

.btn-ctrl svg {
    fill: currentColor;
    width: 14px;
    height: 14px;
}

/* 主序建立柔和增亮覆盖层 */
#flash-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(255, 244, 205, 0.95), rgba(255, 176, 0, 0.2) 45%, rgba(255, 255, 255, 0.0) 70%);
    z-index: 100;
    pointer-events: none;
    opacity: 0;
}

/* 自适应与性能统计面板 */
.perf-badge {
    position: absolute;
    bottom: 8px;
    right: 14px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-secondary);
    pointer-events: none;
    z-index: 11;
}

/* 动画定义 */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; box-shadow: 0 0 15px var(--active-accent); }
    100% { transform: scale(1); opacity: 1; }
}

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

/* 自适应屏幕 */
@media (max-width: 1024px) {
    .hud-overlay {
        grid-template-columns: 280px 1fr 280px;
        padding: 10px;
        gap: 10px;
    }
}

/* 3D 科学可视化空间标注投影层样式 */
.ann-label {
    position: absolute;
    background: rgba(10, 14, 23, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 6px 12px;
    color: #ffffff;
    pointer-events: none;
    font-family: var(--font-sans);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    gap: 2px;
    white-space: nowrap;
    transition: opacity 0.4s cubic-bezier(0.1, 0.8, 0.3, 1), transform 0.4s cubic-bezier(0.1, 0.8, 0.3, 1);
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 2;
}

.ann-label.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.ann-title {
    font-weight: 800;
    color: var(--active-accent);
    text-transform: uppercase;
    font-size: 0.62rem;
    letter-spacing: 1px;
    font-family: var(--font-mono);
}

.ann-desc {
    color: var(--text-primary);
    font-size: 0.72rem;
    font-weight: 500;
}
