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

:root {
  --bg-dark: #080c14;
  --panel-bg: rgba(10, 16, 28, 0.82);
  --panel-border: rgba(0, 210, 255, 0.25);
  --accent-cyan: #00d2ff;
  --accent-blue: #2575fc;
  --accent-amber: #ffb300;
  --accent-red: #ff3366;
  --accent-gold: #ffcc00;
  --text-main: #f0f4fc;
  --text-muted: #b4c0d4;
  --font-mono: "JetBrains Mono", "SF Mono", "Consolas", monospace;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-ui);
  color: var(--text-main);
  font-size: 16px;
}

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

/* 21:9 电影宽银幕黑边 */
.cinema-letterbox {
  position: absolute;
  left: 0;
  width: 100%;
  height: 0;
  background-color: #000;
  z-index: 5;
  transition: height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.cinema-letterbox.top { top: 0; }
.cinema-letterbox.bottom { bottom: 0; }

body.cinema-mode .cinema-letterbox {
  height: 9.5vh;
}

/* 晕影与闪电层 */
.vignette-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(circle at center, transparent 35%, rgba(4, 7, 14, 0.72) 100%);
}

.lightning-flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
  background: rgba(220, 240, 255, 0.55);
  opacity: 0;
  transition: opacity 0.08s ease-out;
}

/* 沉浸式音效开启横幅 */
.audio-banner {
  position: absolute;
  top: 85px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: linear-gradient(135deg, rgba(20, 35, 60, 0.92), rgba(10, 20, 40, 0.95));
  border: 1px solid rgba(0, 210, 255, 0.45);
  border-radius: 30px;
  padding: 8px 20px;
  box-shadow: 0 0 25px rgba(0, 210, 255, 0.35);
  backdrop-filter: blur(12px);
  transition: all 0.3s ease;
  animation: banner-float 2.5s infinite ease-in-out;
}

@keyframes banner-float {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-5px); }
}

.audio-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.audio-icon {
  font-size: 18px;
  animation: pulse-glow 1.2s infinite;
}

.audio-text {
  font-size: 13px;
  color: #e2f0ff;
}

.audio-text strong {
  color: var(--accent-cyan);
}

.audio-btn {
  background: linear-gradient(135deg, #00d2ff, #0072ff);
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.6);
  transition: all 0.2s;
}

.audio-btn:hover {
  transform: scale(1.06);
  filter: brightness(1.15);
}

/* 玻璃拟态卡片公用样式 */
.glass-card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  pointer-events: auto;
}

/* 顶部 Header */
.hud-header {
  position: absolute;
  top: 16px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 210, 255, 0.14);
  border: 1px solid rgba(0, 210, 255, 0.35);
  padding: 3px 12px;
  border-radius: 20px;
  width: fit-content;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #00ff88;
  border-radius: 50%;
  box-shadow: 0 0 10px #00ff88;
  animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.status-text {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--accent-cyan);
}

.title-group h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #ffffff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9);
}

.title-group .subtitle {
  font-size: 13px;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 500;
}

/* 顶部 KPI 卡片 */
.header-kpis {
  display: flex;
  gap: 10px;
}

.kpi-card {
  background: rgba(8, 14, 25, 0.88);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 110px;
}

.kpi-card.highlight {
  border-color: rgba(255, 179, 0, 0.5);
  background: rgba(32, 22, 10, 0.88);
}

.kpi-card.hot {
  border-color: rgba(0, 210, 255, 0.5);
  background: rgba(10, 28, 45, 0.88);
}

.kpi-card.warn {
  border-color: rgba(255, 51, 102, 0.5);
  background: rgba(32, 12, 20, 0.88);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.kpi-value small {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

.kpi-card.highlight .kpi-value { color: var(--accent-amber); }
.kpi-card.hot .kpi-value { color: var(--accent-cyan); }
.kpi-card.warn .kpi-value { color: var(--accent-red); }

/* 侧边遥测面板 */
.hud-panel {
  position: absolute;
  top: 92px;
  bottom: 126px;
  width: 350px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
}

.hud-left { left: 20px; }
.hud-right { right: 20px; }

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

.panel-header-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.panel-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.panel-close-btn:hover {
  background: rgba(255, 51, 102, 0.4);
  border-color: var(--accent-red);
}

.hud-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.hud-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.btn-restore-hud {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  background: linear-gradient(135deg, #0072ff, #00d2ff);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0, 210, 255, 0.5);
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s;
}

.btn-restore-hud:hover {
  transform: scale(1.05);
}

body.clean-hud .hud-header,
body.clean-hud .hud-footer,
body.clean-hud .audio-banner,
body.clean-hud .hud-panel {
  display: none !important;
}

body.clean-hud .btn-restore-hud {
  display: flex !important;
}

.panel-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
}

.hud-panel h2 {
  font-size: 17px;
  font-weight: 600;
  color: #ffffff;
}

.sim-clock {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-amber);
}

/* 仪表组与进度条 */
.meter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meter-header {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-muted);
}

.meter-header span:last-child {
  font-family: var(--font-mono);
  font-weight: 600;
  color: #fff;
}

.val-hot { color: var(--accent-amber) !important; }

.meter-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.meter-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.15s ease-out;
}

.meter-bar-fill.rain { background: linear-gradient(90deg, #0088ff, #00d2ff); }
.meter-bar-fill.speed { background: linear-gradient(90deg, #ff9900, #ff3366); }
.meter-bar-fill.elev { background: linear-gradient(90deg, #00c6ff, #0072ff); }
.meter-bar-fill.pressure { background: linear-gradient(90deg, #ffaa00, #ff0055); }

/* 剖面图画布 */
.profile-chart-container {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.profile-title {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

#profile-canvas {
  width: 100%;
  height: 85px;
  display: block;
  border-radius: 4px;
}

/* 风险警报徽章 */
.disaster-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 179, 0, 0.12);
  border: 1px solid rgba(255, 179, 0, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.4;
  color: #ffe082;
  margin-top: auto;
}

.disaster-badge.alert {
  background: rgba(255, 51, 102, 0.16);
  border-color: rgba(255, 51, 102, 0.45);
  color: #ff8ca3;
}

/* 右侧面板详情 */
.stage-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-cyan);
  line-height: 1.3;
}

.stage-body {
  font-size: 15px;
  line-height: 1.55;
  color: #c4d0e5;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px;
  border-radius: 8px;
  border-left: 3px solid var(--accent-cyan);
}

.threat-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.threat-summary h4 {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.threat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
}

.threat-label { color: #d0d8e8; }

.threat-status {
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 2px 6px;
  border-radius: 4px;
}

.threat-status.safe { background: rgba(0, 230, 118, 0.15); color: #00e676; }
.threat-status.warning { background: rgba(255, 179, 0, 0.2); color: #ffb300; }
.threat-status.destroyed { background: rgba(255, 51, 102, 0.28); color: #ff3366; font-weight: 700; }

.hud-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.action-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e0e8f8;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: rgba(0, 210, 255, 0.2);
  border-color: var(--accent-cyan);
  color: #fff;
}

.action-btn.highlight {
  background: linear-gradient(135deg, rgba(255, 51, 102, 0.2), rgba(255, 179, 0, 0.2));
  border-color: rgba(255, 51, 102, 0.5);
  color: #fff;
}

/* 底部交互控制坞 */
.hud-footer {
  position: absolute;
  bottom: 16px;
  left: 20px;
  right: 20px;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

/* 时间轴 */
.timeline-container {
  display: flex;
  align-items: center;
  gap: 14px;
}

.time-readout {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-cyan);
  min-width: 95px;
}

.timeline-track-wrap {
  position: relative;
  flex: 1;
  height: 24px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.timeline-track-bg {
  position: absolute;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

.timeline-track-fill {
  position: absolute;
  height: 6px;
  background: linear-gradient(90deg, #00c6ff, #0072ff 50%, #ff5252);
  border-radius: 3px;
  width: 0%;
}

.timeline-scrubber-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border: 2px solid var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.8);
  transform: translateX(-50%);
  left: 0%;
  pointer-events: none;
}

.timeline-node {
  position: absolute;
  top: 14px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.timeline-node i {
  width: 2px;
  height: 6px;
  background: rgba(255, 255, 255, 0.35);
  margin-bottom: 2px;
}

.timeline-node span {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* 控制按钮组 */
.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.group-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-right: 2px;
}

.btn-ctrl, .btn-stage, .btn-cam, .btn-rate, .btn-icon {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  padding: 7px 11px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-ctrl:hover, .btn-stage:hover, .btn-cam:hover, .btn-rate:hover, .btn-icon:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-ctrl.primary {
  background: linear-gradient(135deg, #0072ff, #00c6ff);
  border: none;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 114, 255, 0.4);
}

.btn-ctrl.primary:hover {
  filter: brightness(1.15);
  box-shadow: 0 4px 14px rgba(0, 198, 255, 0.6);
}

.btn-stage.active, .btn-cam.active, .btn-rate.active, .btn-icon.active {
  background: rgba(0, 210, 255, 0.24);
  border-color: var(--accent-cyan);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.35);
}

.btn-cam.special.active {
  background: linear-gradient(135deg, rgba(255, 179, 0, 0.3), rgba(0, 210, 255, 0.3));
  border-color: var(--accent-gold);
  box-shadow: 0 0 12px rgba(255, 204, 0, 0.5);
}

/* ==================== 响应式与移动端适配 ==================== */

@media (min-width: 901px) {
  .mobile-drawer-btn {
    display: none;
  }
}

@media (max-width: 1200px) and (min-width: 901px) {
  .hud-panel {
    width: 290px;
    padding: 12px;
  }
  .kpi-card {
    min-width: 85px;
    padding: 6px 8px;
  }
}

@media (max-width: 900px) {
  /* 头部极简化：单行标题 + 紧凑指标 */
  .hud-header {
    top: 8px;
    left: 8px;
    right: 8px;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    pointer-events: none;
  }

  .header-left {
    pointer-events: auto;
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .title-group h1 {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
  }

  .title-group .subtitle {
    display: none;
  }

  .status-indicator {
    padding: 2px 8px;
    gap: 5px;
  }

  .status-text {
    font-size: 10px;
  }

  /* KPI 指标卡片为单行横向滚动条，极度紧凑且绝不挡视线 */
  .header-kpis {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    gap: 6px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
  }

  .header-kpis::-webkit-scrollbar {
    display: none;
  }

  .kpi-card {
    min-width: fit-content;
    padding: 4px 8px;
    border-radius: 6px;
    flex-shrink: 0;
    background: rgba(8, 14, 25, 0.78);
    backdrop-filter: blur(8px);
  }

  .kpi-label {
    font-size: 10px;
    margin-bottom: 0;
  }

  .kpi-value {
    font-size: 13.5px;
  }

  .kpi-value small {
    font-size: 10px;
  }

  /* 侧边面板全部转换为上拉抽屉，移动端默认完全隐藏，留出 100% 3D 视野 */
  .hud-panel {
    position: fixed;
    top: auto;
    bottom: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    max-width: 480px;
    margin: 0 auto;
    max-height: 72vh;
    overflow-y: auto;
    z-index: 50;
    transform: translateY(130%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, visibility 0.32s;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(0, 210, 255, 0.35);
  }

  .hud-panel.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .panel-close-btn {
    display: flex;
  }

  /* 底部交互坞紧凑化与横滑控制条 */
  .hud-footer {
    bottom: 8px;
    left: 8px;
    right: 8px;
    padding: 8px 10px;
    gap: 6px;
  }

  .timeline-container {
    gap: 8px;
  }

  .time-readout {
    font-size: 12px;
    min-width: 76px;
  }

  .timeline-node span {
    display: none;
  }

  .controls-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding: 2px 0;
    width: 100%;
  }

  .controls-row::-webkit-scrollbar {
    display: none;
  }

  .control-group {
    flex-shrink: 0;
    gap: 4px;
  }

  .group-label {
    display: none;
  }

  .btn-ctrl, .btn-stage, .btn-cam, .btn-rate, .btn-icon {
    padding: 6px 9px;
    font-size: 12px;
    white-space: nowrap;
  }

  .mobile-drawer-btn {
    background: rgba(0, 210, 255, 0.18);
    border-color: rgba(0, 210, 255, 0.45);
    color: #e0f2fe;
    font-weight: 600;
  }

  /* 声音横幅 */
  .audio-banner {
    top: 70px;
    width: calc(100% - 20px);
    max-width: 360px;
    padding: 6px 12px;
  }

  .audio-text {
    font-size: 11px;
    line-height: 1.3;
  }

  .audio-btn {
    font-size: 11px;
    padding: 4px 10px;
    flex-shrink: 0;
  }
}

@media (max-width: 480px) {
  .title-group h1 {
    font-size: 13.5px;
    max-width: 200px;
  }

  .time-readout {
    font-size: 11px;
    min-width: 70px;
  }

  .btn-ctrl, .btn-stage, .btn-cam, .btn-rate, .btn-icon {
    padding: 5px 8px;
    font-size: 11.5px;
  }
}
