/* G1 太空站值守 — Space Watch 样式
 * 美术圣经：§2 色彩系统 / §5 HUD / §8 动效 / §9 可访问性
 * 纯 CSS + emoji，不引用任何 SVG 资产文件。
 */
:root {
  --bg: #070B14;        /* Deep Space */
  --panel: #0A1020;     /* Space Panel */
  --panel2: #111A32;    /* Panel Lift */
  --blue: #2EC4FF;      /* Electric Blue */
  --cyan: #3FD0E0;      /* Cyan Glow */
  --azure: #1A7AB8;     /* Deep Azure */
  --mist: #6BB8FF;      /* Pale Mist */
  --amber: #F5A623;     /* Warning Amber */
  --red: #FF4D4D;       /* Critical Red */
  --mint: #4DFF91;      /* Success Mint */
  --white: #FFFFFF;
  --dusk: #A0B4C8;      /* Dusk Text */
  --grid: #1C3A5E;      /* Grid Line */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Noto Sans TC', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--white);
}

/* 大厅全屏背景（底层，z-2） */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background: url('img/bg-main-hall.webp') center/cover no-repeat;
}
/* 网格叠加层（装饰，z-1，降低到 0.08） */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.08;
  pointer-events: none;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--azure);
}
.game-title {
  margin: 0;
  line-height: 0;
}
.title-logo {
  height: 40px;
  width: auto;
  vertical-align: middle;
}

/* ---------- HUD 资源条（§5.1） ---------- */
.hud {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  flex-wrap: wrap;
}
.resource-bar {
  flex: 1 1 200px;
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--azure);
  border-radius: 12px;
  padding: 10px 12px;
}
.resource-label { font-size: 14px; color: var(--dusk); margin-bottom: 6px; }
.bar-track {
  height: 14px;
  background: #0c1426;
  border-radius: 8px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 80%;
  border-radius: 8px;
  /* §8.2 资源回血/缓降：宽度过渡 300ms ease-out */
  transition: width 300ms ease-out, background 300ms ease-out;
  /* 基色交还 CSS 接管（boot.js 内联 RES_COLORS 已移除）；ENERGY 用默认蓝，OXYGEN/SHIELD 见下方覆盖 */
  background: var(--blue);
}
/* 各资源基色（美术圣经 §2.2 RES_COLORS） */
.resource-bar[data-key="OXYGEN"] .bar-fill { background: #3FD0E0; }
.resource-bar[data-key="SHIELD"] .bar-fill { background: #6BB8FF; }
/* 超充（overfill：max→max+overfill 区间）暖橙渐变指示 */
.bar-fill.overcharged {
  background: linear-gradient(90deg, #FFD24D, #FF9F1C) !important;
  box-shadow: 0 0 8px rgba(255, 176, 32, 0.7);
  animation: overchargeBreathe 2s ease-in-out infinite;
}
@keyframes overchargeBreathe {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 176, 32, 0.5); }
  50%      { box-shadow: 0 0 16px 3px rgba(255, 176, 32, 0.9); }
}
.resource-value {
  font-family: 'Rajdhani', sans-serif;
  font-size: 20px;
  font-weight: 600;
  text-align: right;
  margin-top: 4px;
  display: inline-block;
  transform-origin: right center;
}

/* —— Phase 6：数值变化弹跳（boot.js 检测加/减触发，200ms）—— */
.resource-value.value-bump {
  animation: valueBump 0.2s ease-out;
}
@keyframes valueBump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
/* —— Phase 6：加减色闪（bar-fill box-shadow，300ms）—— */
.bar-fill.bar-gain {
  animation: barGain 0.3s ease-out;
}
@keyframes barGain {
  0%   { box-shadow: 0 0 0 0 rgba(77, 255, 145, 0); }
  30%  { box-shadow: 0 0 14px 3px rgba(77, 255, 145, 0.8); }
  100% { box-shadow: 0 0 0 0 rgba(77, 255, 145, 0); }
}
.bar-fill.bar-loss {
  animation: barLoss 0.3s ease-out;
}
@keyframes barLoss {
  0%   { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
  30%  { box-shadow: 0 0 14px 3px rgba(255, 77, 77, 0.8); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
}
.resource-bar.survival { flex: 0 0 auto; text-align: center; }
.survival-value { font-family: 'Orbitron', sans-serif; font-size: 24px; color: var(--mist); }

/* 告警 <30%：琥珀脉冲（§5.1 / §8.2） */
.alert-warning {
  border-color: var(--amber);
  animation: pulseWarn 0.8s ease-in-out infinite;
}
.alert-warning .bar-fill { background: var(--amber) !important; }

/* 危急 <10%：红色快闪（§5.1 / §8.2） */
.alert-critical {
  border-color: var(--red);
  animation: flashCrit 0.4s steps(1) infinite;
}
.alert-critical .bar-fill { background: var(--red) !important; }

@keyframes pulseWarn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0); }
  50%      { box-shadow: 0 0 12px 2px rgba(245, 166, 35, 0.6); }
}
@keyframes flashCrit {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
  50%      { box-shadow: 0 0 16px 3px rgba(255, 77, 77, 0.9); }
}

/* ---------- 色盲模式（§9.1）：蓝/橙替代红绿 ---------- */
.colorblind .alert-warning {
  border-color: #0072B2;
  animation: none;
  background: rgba(0, 114, 178, 0.15);
}
.colorblind .alert-warning .bar-fill { background: #0072B2 !important; }
.colorblind .alert-critical {
  border-color: #D55E00;
  animation: none;
  background: rgba(213, 94, 0, 0.15);
}
.colorblind .alert-critical .bar-fill { background: #D55E00 !important; }
/* 形状 + 图标三重编码（不纯靠颜色） */
.colorblind .alert-warning::after { content: ' ⚠'; color: #0072B2; }
.colorblind .alert-critical::after { content: ' ⚡'; color: #D55E00; }

/* ================================================================
   § 设施卡片（G1-quality-spec §2）— 替代旧的 .facility-btn
   ================================================================ */
.facilities {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
  padding: 24px;
}

.facility-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 160px;
  padding: 24px 20px 20px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  font-family: 'Noto Sans TC', system-ui, sans-serif;
  color: #FFFFFF;
  background: rgba(17, 26, 50, 0.7);
  flex: 1 1 160px;
  max-width: 240px;
}

/* 三卡片各自背景色 */
#btn-oxygen-room {
  background: rgba(15, 40, 71, 0.85);
  border-color: rgba(63, 208, 224, 0.3);
}
#btn-reactor {
  background: rgba(59, 31, 15, 0.85);
  border-color: rgba(46, 196, 255, 0.3);
}
#btn-radar {
  background: rgba(31, 15, 59, 0.85);
  border-color: rgba(107, 184, 255, 0.3);
}

/* 卡片图标 */
.card-icon {
  font-size: 36px;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(46, 196, 255, 0.4));
  transition: transform 0.2s ease;
}

/* 卡片标题 */
.card-title {
  font-family: 'Orbitron', 'Rajdhani', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* 资源效果描述 */
.card-effect {
  font-size: 12px;
  color: #A0B4C8;
  font-weight: 400;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ---- 状态 ---- */
.facility-card:hover {
  transform: scale(1.02);
  border-color: #2EC4FF !important;
  box-shadow: 0 0 12px rgba(46, 196, 255, 0.5);
}
.facility-card:hover .card-icon {
  transform: scale(1.1);
}

.facility-card:active {
  transform: scale(0.97);
}

.facility-card:focus-visible {
  outline: 2px solid #2EC4FF;
  outline-offset: 3px;
}

/* ---- 告警态（资源 <30%，复用现有 alert-warning 逻辑）---- */
.facility-card.alert-warning {
  border-color: #F5A623 !important;
  animation: cardPulseWarn 0.8s ease-in-out infinite;
}
.facility-card.alert-warning .card-icon {
  filter: drop-shadow(0 0 8px rgba(245, 166, 35, 0.7));
}

@keyframes cardPulseWarn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0); }
  50%      { box-shadow: 0 0 16px 4px rgba(245, 166, 35, 0.5); }
}

/* ---- 色盲模式适配 ---- */
.colorblind .facility-card.alert-warning {
  border-color: #0072B2 !important;
  animation: none;
  background: rgba(0, 114, 178, 0.2);
}

/* ---- 涟漪（与现有 .ripple 兼容） ---- */
.facility-card .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(46, 196, 255, 0.3);
  transform: scale(0);
  animation: rippleExpand 0.5s ease-out forwards;
  pointer-events: none;
}

/* ---- 涟漪动画（通用，被 .facility-card .ripple 引用） ---- */
@keyframes rippleExpand {
  to { transform: scale(4); opacity: 0; }
}

/* ---- 动态减弱 ---- */
@media (prefers-reduced-motion: reduce) {
  .facility-card { transition: none; }
  .facility-card:hover { transform: none; box-shadow: none; }
  .facility-card:active { transform: none; }
  .facility-card .ripple { display: none !important; }
}

/* ---------- 通用按钮（§5.3） ---------- */
.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--azure));
  color: #fff; border: none; border-radius: 12px;
  padding: 12px 20px; font-size: 16px; cursor: pointer; min-height: 44px;
}
.btn-secondary {
  background: transparent; color: var(--blue);
  border: 2px solid var(--blue); border-radius: 12px;
  padding: 10px 16px; cursor: pointer; min-height: 44px;
}
.btn-danger {
  background: var(--red); color: #fff; border: none; border-radius: 12px;
  padding: 12px 20px; cursor: pointer; min-height: 44px;
}
button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- 小游戏 iframe 挂载（模态） ---------- */
/* Phase 6：淡入淡出转场（opacity + visibility），由 .active class 控制 */
.game-root {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 11, 20, 0.5);
  z-index: 50;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.game-root.active {
  opacity: 1;
  visibility: visible;
}
.game-root iframe {
  width: min(880px, 96vw);
  height: min(640px, 94vh);
  border: 1px solid var(--azure);
  border-radius: 16px;
  background: var(--panel);
}

/* ---------- 弹窗 / 结算（§5.4） ---------- */
.modal-frame {
  background: var(--panel);
  border: 1px solid var(--azure);
  border-radius: 16px;
  padding: 24px;
}
.gameover-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 11, 20, 0.9);
  z-index: 100;
}
.gameover-overlay[hidden] { display: none; }
.gameover-content { text-align: center; max-width: 420px; }
.gameover-content h2 { color: var(--red); font-family: 'Orbitron', sans-serif; }

/* ---------- 玩法说明弹窗（自包含样式，不依赖 leaderboard.js 注入） ---------- */
.help-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.80);
  z-index: 300;
}
.help-overlay[hidden] { display: none; }
.help-panel {
  width: min(560px, 92vw);
  max-height: 86vh;
  overflow: auto;
  position: relative;
  background: var(--panel);
  border: 1px solid var(--azure);
  border-radius: 16px;
  padding: 24px;
}
.help-title {
  font-family: 'Orbitron', sans-serif;
  color: var(--cyan);
  margin: 0 0 16px;
  font-size: 20px;
}
.help-body { font-size: 15px; line-height: 1.7; color: var(--white); }
.help-body p { margin: 8px 0; }
.help-summary { color: var(--dusk); }
.help-goal { color: var(--mint); font-weight: 600; }
.help-resources { color: var(--cyan); margin-top: 14px; }
.help-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.help-list li {
  background: var(--panel2);
  border: 1px solid var(--azure);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 16px;
}
.help-flow {
  background: rgba(46, 196, 255, 0.1);
  border-left: 3px solid var(--blue);
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  margin: 14px 0;
}
.help-tips {
  background: rgba(245, 166, 35, 0.12);
  border: 1px solid var(--amber);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--amber);
  font-size: 14px;
}
#help-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--azure);
  background: rgba(46, 196, 255, 0.15);
  color: var(--blue);
  font-size: 18px;
  cursor: pointer;
  min-width: 44px; min-height: 44px;
}
#help-close:hover { background: var(--blue); color: var(--bg); }
#help-ok {
  display: block;
  margin: 18px auto 0;
  min-width: 160px;
}

/* ---------- 响应式：窄屏资源条竖排 ---------- */
@media (max-width: 640px) {
  .hud { flex-direction: column; }
  .resource-bar { flex: 1 1 auto; width: 100%; }
}

/* ---------- 动态减弱（§9 Comprehensive） ---------- */
@media (prefers-reduced-motion: reduce) {
  .alert-warning, .alert-critical { animation: none !important; }
  .bar-fill.overcharged { animation: none !important; }
  .resource-value.value-bump { animation: none !important; }
  .bar-fill.bar-gain, .bar-fill.bar-loss { animation: none !important; }
  .star { animation: none !important; }
  .game-root { transition: none !important; }
}

/* ---------- Phase 6：全屏氛围特效（星空粒子 + 扫描线 + 边缘暗角）---------- */
/* z-index:-1 叠在 body::before(z-2 背景图) 与 body::after(z-1 网格) 之上，
   但在正常内容(z auto/0)之下；pointer-events:none 保证点击穿透到交互层。 */
.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
.starfield { position: absolute; top: 0; left: 0; right: 0; height: 50vh; overflow: hidden; }
.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 4px rgba(255,255,255,0.5);
  animation-name: starTwinkle, starDrift;
  animation-iteration-count: infinite, infinite;
  animation-timing-function: ease-in-out, linear;
}
@keyframes starTwinkle {
  0%, 100% { opacity: var(--star-opacity, 0.9); }
  50%      { opacity: 0.4; }
}
/* 向下漂移 37vh：位移减少 2/3，星点只在舷窗区域（上半 50%）缓慢漂移 */
@keyframes starDrift {
  from { transform: translateY(0); }
  to   { transform: translateY(37vh); }
}
/* ② 扫描线：4px 周期（2px 透明 + 1px 暗线 + 1px 透明），opacity 0.4 极微弱 */
.ambient::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 3px,
    transparent 4px
  );
  opacity: 0.4;
}
/* ③ 边缘暗角：中心 50% 完全透明，向外渐暗到 0.4 黑色 */
.ambient::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0, 0, 0, 0.4) 100%
  );
}

/* ================================================================
   § 首次引导遮罩（G1-quality-spec §1）
   ================================================================ */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.onboarding-overlay:not([hidden]) {
  opacity: 1;
}
.onboarding-overlay[hidden] {
  display: none !important;
}

.onboarding-step {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.onboarding-highlight {
  position: absolute;
  border: 2px solid #2EC4FF;
  border-radius: 12px;
  box-shadow:
    0 0 12px rgba(46, 196, 255, 0.6),
    0 0 24px rgba(46, 196, 255, 0.3),
    inset 0 0 12px rgba(46, 196, 255, 0.1);
  pointer-events: none;
  animation: highlightPulse 2s ease-in-out infinite;
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}

@keyframes highlightPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(46, 196, 255, 0.6), 0 0 24px rgba(46, 196, 255, 0.3); }
  50%      { box-shadow: 0 0 16px rgba(46, 196, 255, 0.8), 0 0 32px rgba(46, 196, 255, 0.5); }
}

.onboarding-text {
  position: absolute;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: #FFFFFF;
  max-width: 480px;
  width: 90%;
  pointer-events: none;
}

.onboarding-title {
  margin: 0;
  font-family: 'Noto Sans TC', system-ui, sans-serif;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.6;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.onboarding-counter {
  margin: 12px 0 0;
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  color: #A0B4C8;
  letter-spacing: 2px;
}

.onboarding-hint {
  position: absolute;
  bottom: 4%;
  right: 5%;
  font-size: 12px;
  color: rgba(160, 180, 200, 0.6);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .onboarding-overlay { transition: none; }
  .onboarding-highlight { animation: none; }
}

/* ================================================================
   § 结算分数弹出（G1-quality-spec §3）
   ================================================================ */
.gameover-score {
  font-family: 'Orbitron', 'Rajdhani', sans-serif;
  font-size: 48px;
  font-weight: 800;
  color: #2EC4FF;
  margin: 16px 0 8px;
  text-shadow: 0 0 20px rgba(46, 196, 255, 0.5);
  line-height: 1;
}

.rating-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: bold;
  font-family: 'Orbitron', sans-serif;
  margin: 0 auto 12px;
  opacity: 0;
  transform: scale(0);
}

.rating-badge.s {
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: #1a1a2e;
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.7);
}
.rating-badge.a {
  background: linear-gradient(135deg, #2EC4FF, #1A7AB8);
  color: #FFFFFF;
  box-shadow: 0 0 16px rgba(46, 196, 255, 0.7);
}
.rating-badge.b {
  background: linear-gradient(135deg, #1A7AB8, #0F2847);
  color: #FFFFFF;
  box-shadow: 0 0 12px rgba(26, 122, 184, 0.5);
}
.rating-badge.c {
  background: linear-gradient(135deg, #6B7280, #374151);
  color: #D1D5DB;
  box-shadow: 0 0 8px rgba(107, 114, 128, 0.3);
}

@keyframes badgeBounce {
  0%   { opacity: 0; transform: scale(0); }
  50%  { opacity: 1; transform: scale(1.2); }
  70%  { transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .gameover-score { transition: none; }
  .rating-badge { animation: none !important; opacity: 1; transform: scale(1); }
}

/* ================================================================
   § 品牌启动画面（G1-quality-spec §4）
   ================================================================ */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0B1428;
  gap: 16px;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.splash-screen.splash-fadeout {
  opacity: 0;
  pointer-events: none;
}

.splash-logo {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 0 20px rgba(46, 196, 255, 0.6))
          drop-shadow(0 0 40px rgba(46, 196, 255, 0.3));
  animation: splashLogoPulse 2s ease-in-out infinite;
}

.splash-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: 4px;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(46, 196, 255, 0.5);
  margin: 0;
}

.splash-loading {
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  color: #A0B4C8;
  letter-spacing: 2px;
  animation: splashLoadingBlink 1.5s ease-in-out infinite;
  margin: 4px 0 0;
}

@keyframes splashLogoPulse {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(46, 196, 255, 0.6)) drop-shadow(0 0 40px rgba(46, 196, 255, 0.3)); }
  50%      { filter: drop-shadow(0 0 30px rgba(46, 196, 255, 0.8)) drop-shadow(0 0 60px rgba(46, 196, 255, 0.4)); }
}

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

@media (prefers-reduced-motion: reduce) {
  .splash-screen { transition: none; }
  .splash-screen.splash-fadeout { opacity: 0; }
  .splash-logo { animation: none; }
  .splash-loading { animation: none; }
}

/* ================================================================
   § 加载过渡（G1-quality-spec §5）
   ================================================================ */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(7, 11, 20, 0.7);
  z-index: 10;
  border-radius: 16px;
}

.loading-overlay[hidden] {
  display: none;
}

.loading-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(46, 196, 255, 0.2);
  border-top-color: #2EC4FF;
  border-radius: 50%;
  animation: spinnerRotate 0.8s linear infinite;
}

@keyframes spinnerRotate {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-family: 'Rajdhani', 'Noto Sans TC', sans-serif;
  font-size: 14px;
  color: #A0B4C8;
  letter-spacing: 1px;
  margin: 0;
  animation: loadingTextPulse 1.5s ease-in-out infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .loading-spinner { animation: none; border-color: #2EC4FF; }
  .loading-text { animation: none; }
}

/* ================================================================
   § G1 Session Report — 结算成绩单
   ================================================================ */

/* 全屏遮罩（嵌套在 #gameover fixed 容器内，用 absolute 填充） */
.report-overlay {
  position: absolute;
  inset: 0;
  z-index: 400;
  background: rgba(7, 11, 20, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  backdrop-filter: blur(4px);
  font-family: 'Noto Sans TC', system-ui, sans-serif;
  color: #FFFFFF;
}

/* 内容容器 */
.report-scroll-container {
  width: 100%;
  max-width: 780px;
  padding: 32px 24px;
  margin: auto;
}

/* === Header === */
.report-header {
  text-align: center;
  margin-bottom: 28px;
}

.rating-badge {
  width: 64px;
  height: 64px;
  font-size: 28px;
}

.report-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #2EC4FF;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin: 12px 0 8px;
  text-shadow: 0 0 12px rgba(46, 196, 255, 0.3);
}

.report-score {
  font-family: 'Orbitron', 'Rajdhani', sans-serif;
  font-size: 56px;
  font-weight: 800;
  color: #FFFFFF;
  margin: 4px 0;
  text-shadow: 0 0 24px rgba(46, 196, 255, 0.4);
  line-height: 1;
}

/* 元信息行 */
.report-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  color: #A0B4C8;
  letter-spacing: 0.5px;
}
.report-divider {
  color: rgba(160, 180, 200, 0.4);
}
.meta-label {
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 12px;
  text-transform: uppercase;
  color: rgba(160, 180, 200, 0.6);
  margin-right: 4px;
}
.meta-value {
  font-family: 'Rajdhani', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: #3FD0E0;
}
#report-failure-reason {
  color: #FF4D4D;
  font-weight: 500;
}

/* === 对比表 === */
.report-comparison {
  margin-bottom: 28px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.report-comparison.visible {
  opacity: 1;
  transform: translateY(0);
}

.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.comparison-col {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(17, 26, 50, 0.5);
  transition: border-color 0.2s ease;
}

.col-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
}
.col-icon {
  font-size: 20px;
  line-height: 1;
}
.col-name {
  font-family: 'Orbitron', 'Rajdhani', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #FFFFFF;
}

.col-body {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.col-row {
  display: flex;
  flex-direction: column;
  gap: 0px;
  padding: 4px 0;
}
.row-label {
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 10px;
  text-transform: uppercase;
  color: rgba(160, 180, 200, 0.5);
  letter-spacing: 0.8px;
}
.row-value {
  font-family: 'Rajdhani', sans-serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
  transition: color 0.3s ease;
}

/* 本局得分 */
.row-value-session {
  font-size: 26px;
  font-weight: 700;
  color: #3FD0E0;
}
.comparison-col[data-game="pipe"] .row-value-session {
  color: #3FD0E0;
}
.comparison-col[data-game="math"] .row-value-session {
  color: #2EC4FF;
}
.comparison-col[data-game="typing"] .row-value-session {
  color: #6BB8FF;
}

.col-row.row-session {
  border-left: 2px solid #2EC4FF;
  padding-left: 8px;
  margin-bottom: 2px;
}

/* 个人最佳突破 — 金色 */
.row-pb-new-record {
  color: #FFD700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}
.row-value-pb {
  font-size: 18px;
}

/* 排行榜前三 */
.row-value-top3 {
  font-size: 12px;
  color: #A0B4C8;
  font-weight: 400;
  line-height: 1.4;
}

/* 排名 */
.row-value-rank {
  font-size: 14px;
  font-weight: 500;
  color: #A0B4C8;
}

/* === 底部 === */
.report-footer {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease 0.1s, transform 0.4s ease 0.1s;
}
.report-footer.visible {
  opacity: 1;
  transform: translateY(0);
}

.commander-rank {
  background: rgba(17, 26, 50, 0.6);
  border: 1px solid rgba(26, 122, 184, 0.3);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.commander-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #2EC4FF;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0 0 12px;
}

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rank-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: #A0B4C8;
  transition: background 0.2s ease;
}
.rank-pos {
  min-width: 24px;
  text-align: right;
  color: rgba(160, 180, 200, 0.5);
  font-weight: 400;
}
.rank-name {
  flex: 1;
  color: #FFFFFF;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.rank-score {
  font-weight: 700;
  color: #2EC4FF;
}
.rank-ellipsis {
  text-align: center;
  color: rgba(160, 180, 200, 0.2);
  padding: 2px 0;
  font-size: 12px;
}
.rank-unranked {
  color: #A0B4C8;
  font-size: 13px;
  text-align: center;
  padding: 8px 0;
}

/* 当前玩家高亮行 */
.rank-item-current {
  background: rgba(46, 196, 255, 0.12);
  border-left: 3px solid #2EC4FF;
  padding-left: 7px;
}
.rank-item-current .rank-pos {
  color: #2EC4FF;
}
.rank-item-current .rank-name::before {
  content: '▸ ';
  color: #2EC4FF;
}
.rank-item-current .rank-score {
  color: #2EC4FF;
  text-shadow: 0 0 8px rgba(46, 196, 255, 0.4);
}

/* === 按钮组 === */
.report-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.report-actions .btn-primary,
.report-actions .btn-secondary {
  min-width: 160px;
  padding: 12px 24px;
  font-family: 'Orbitron', 'Rajdhani', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.report-actions .btn-primary:hover {
  transform: scale(1.03);
  box-shadow: 0 0 16px rgba(46, 196, 255, 0.5);
}
.report-actions .btn-secondary:hover {
  transform: scale(1.03);
  box-shadow: 0 0 12px rgba(46, 196, 255, 0.3);
}
.report-actions .btn-primary:active,
.report-actions .btn-secondary:active {
  transform: scale(0.97);
}

/* 窄屏响应式 */
@media (max-width: 600px) {
  .comparison-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .report-score {
    font-size: 40px;
  }
  .rating-badge {
    width: 52px;
    height: 52px;
    font-size: 22px;
  }
  .report-scroll-container {
    padding: 20px 12px;
  }
  .col-header {
    padding: 8px 6px;
  }
  .row-value-session {
    font-size: 22px;
  }
}

/* 中屏响应式 */
@media (min-width: 601px) and (max-width: 900px) {
  .comparison-grid {
    gap: 8px;
  }
  .col-body {
    padding: 6px 8px 8px;
  }
  .row-value-session {
    font-size: 22px;
  }
}

/* 动态减弱 */
@media (prefers-reduced-motion: reduce) {
  .report-overlay { backdrop-filter: none; }
  .report-comparison,
  .report-footer {
    transition: none;
    opacity: 1;
    transform: none;
  }
  .rating-badge { animation: none !important; opacity: 1; transform: scale(1); }
  .report-score { transition: none; }
}
