/* ==========================================================================
   民机迷 · 低空穿越 —— 样式
   深色霓虹主题：这是街机游戏，场景刻意用暗底 + 高饱和霓虹，
   与站点其他页面的浅色文档风不是同一套视觉语境。
   文本一律保证与背景的对比度 ≥ 4.5:1（HUD 与面板文字都用了近白 #e8f2ff 以上）。
   ========================================================================== */

:root {
  --bg: #050a14;
  --panel: rgba(8, 16, 30, 0.92);
  --panel-line: rgba(96, 190, 255, 0.28);
  --ink: #eaf4ff;
  --ink-dim: #a8c2dc;
  --ink-faint: #7d97b4;
  --cyan: #22d3ee;
  --blue: #4aa8ff;
  --gold: #ffd166;
  --warn: #ff7a4d;
  --danger: #ff5252;
  --font: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Cascadia Mono", monospace;

  /* 页脚（ICP 备案号）占用的底部空间 —— 与 .site-foot 共用同一组值。
     页脚是绝对定位、z-index 高于浮层，所以**浮层的滚动区必须把它让出来**：
     否则浮层虽然能滚，滚到底时最后一行仍被页脚压住
     （实测 360×640 初始位置就压住了「要点」里的一条）。
     单一来源：改这里，两处同时生效。 */
  --site-foot-line: 14px;
  --site-foot-gap: max(6px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
}

body { overflow: hidden; }

.stage-wrap {
  position: fixed;
  inset: 0;
  /* 移动端地址栏收放时 100vh 会跳，dvh 才稳 */
  height: 100dvh;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  background: #03060f;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================ HUD ============================ */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 14px max(14px, env(safe-area-inset-left));
}
.hud.is-hidden { opacity: 0; }

.hud-row {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 380px) 1fr;
  align-items: start;
  gap: 14px;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(10,22,40,.66), rgba(6,14,26,.42));
  border: 1px solid rgba(96,190,255,.18);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  width: max-content;
  max-width: 100%;
}
.hud-right { justify-self: end; text-align: right; }

.hud-label {
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--ink-faint);
  text-transform: uppercase;
}
.hud-value {
  font-family: var(--mono);
  font-size: clamp(20px, 3.4vw, 30px);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 0 14px rgba(70,190,255,.55);
}

.hud-mid { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }

.energy {
  padding: 9px 14px 8px;
  background: linear-gradient(180deg, rgba(10,22,40,.66), rgba(6,14,26,.42));
  border: 1px solid rgba(96,190,255,.18);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.energy-track {
  height: 9px;
  border-radius: 99px;
  background: rgba(255,255,255,.10);
  overflow: hidden;
}
.energy-fill {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, #22d3ee, #7dd3fc);
  transition: background .25s linear;
  will-change: transform;
}
.energy-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--ink-faint);
}
.energy-meta b {
  font-family: var(--mono);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.energy.is-low { animation: warnPulse 1s ease-in-out infinite; }
@keyframes warnPulse {
  0%, 100% { border-color: rgba(255,122,77,.35); box-shadow: 0 0 0 0 rgba(255,122,77,0); }
  50% { border-color: rgba(255,122,77,.85); box-shadow: 0 0 18px 0 rgba(255,122,77,.35); }
}

.combo {
  text-align: center;
  font-size: 12px;
  letter-spacing: .14em;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.toast {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -6px);
  padding: 8px 18px;
  border-radius: 99px;
  border: 1px solid rgba(255,209,102,.5);
  background: rgba(10,18,32,.82);
  color: var(--gold);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .06em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  white-space: nowrap;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.boost-btn {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  width: 84px; height: 84px;
  border-radius: 50%;
  border: 1px solid rgba(120,220,255,.55);
  background: radial-gradient(circle at 50% 40%, rgba(34,211,238,.34), rgba(8,18,34,.72));
  color: #dff4ff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
  pointer-events: auto;
  display: none;
  touch-action: none;
}
body.is-touch .boost-btn { display: block; }
.boost-btn:active { transform: scale(.94); }

/* ============================ 覆盖层 ============================ */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  /* ★ 底部额外多留一条页脚的高度：浮层可滚动，但页脚是浮在它上面的，
     不留出来就会出现"能滚到那一行、却永远被页脚盖着"。 */
  padding-bottom: calc(20px + var(--site-foot-line) + var(--site-foot-gap) + 6px);
  overflow-y: auto;
  background:
    radial-gradient(1100px 620px at 50% 26%, rgba(34,120,220,.24), rgba(0,0,0,0) 62%),
    rgba(3,7,14,.80);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  z-index: 5;
}
.overlay[hidden] { display: none; }

.panel {
  width: 100%;
  max-width: 560px;
  margin: auto;
  padding: clamp(22px, 3.4vw, 34px);
  border-radius: 16px;
  border: 1px solid var(--panel-line);
  background: var(--panel);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.03) inset,
    0 28px 70px rgba(0,0,0,.6),
    0 0 60px rgba(34,140,255,.14);
}
.panel-wide { max-width: 780px; }
.panel-narrow { max-width: 440px; text-align: center; }

.kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: .34em;
  color: var(--cyan);
  text-transform: uppercase;
}
.title {
  margin: 0;
  font-size: clamp(38px, 7vw, 68px);
  line-height: 1;
  letter-spacing: .06em;
  background: linear-gradient(100deg, #ffffff 8%, #7de3ff 46%, #4aa8ff 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 46px rgba(60,180,255,.28);
}
.title-sm {
  margin: 0 0 4px;
  font-size: clamp(24px, 3.6vw, 32px);
  letter-spacing: .04em;
}
.subtitle {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .42em;
  color: var(--ink-faint);
}
.lede {
  margin: 18px 0 0;
  color: var(--ink-dim);
  line-height: 1.75;
  font-size: 14.5px;
}
.lede b { color: var(--gold); }

.big-score {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: clamp(42px, 8vw, 66px);
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 34px rgba(70,190,255,.55);
}
.stats {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid rgba(96,190,255,.16);
  background: rgba(4,10,20,.6);
  color: var(--ink-dim);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}
.btn {
  appearance: none;
  cursor: pointer;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid rgba(120,200,255,.32);
  background: rgba(14,28,48,.72);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  transition: transform .12s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.btn:hover { border-color: rgba(120,220,255,.75); background: rgba(20,42,72,.86); box-shadow: 0 0 22px rgba(34,160,255,.22); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.btn-primary {
  border-color: rgba(120,220,255,.85);
  background: linear-gradient(180deg, rgba(34,150,240,.95), rgba(18,94,190,.95));
  color: #fff;
  box-shadow: 0 0 26px rgba(34,150,255,.4);
}
.btn-primary:hover { background: linear-gradient(180deg, rgba(52,172,255,1), rgba(24,110,215,1)); }

.best-line {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--ink-faint);
}
.best-line b { font-family: var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }

.net-state { font-size: 12px; color: var(--ink-faint); }
.net-state.is-ok { color: #6ee7b7; }
.net-state.is-bad { color: var(--warn); }

.how {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 18px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid rgba(96,190,255,.16);
}
.how h3 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: .16em;
  color: var(--cyan);
  font-weight: 700;
}
.how ul { margin: 0; padding-left: 18px; color: var(--ink-dim); font-size: 13px; line-height: 1.95; }
.how b { color: var(--gold); }

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  margin: 0 1px;
  border-radius: 5px;
  border: 1px solid rgba(140,200,255,.35);
  border-bottom-width: 2px;
  background: rgba(20,38,62,.9);
  font-family: var(--mono);
  font-size: 11.5px;
  color: #d9ecff;
}

.foot-note {
  margin: 18px 0 0;
  font-size: 12px;
  line-height: 1.8;
  color: var(--ink-faint);
}

/* 页脚备案号：常驻在画面最底部，压在浮层之上（浮层 z-index 是 5）。
   用 pointer-events 分级：容器不吃事件，只有里面的链接可点。 */
.site-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--site-foot-gap);   /* 与 .overlay 的 padding-bottom 同源，见 :root */
  z-index: 6;
  margin: 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: .02em;
  color: var(--ink-faint);
  /* 画布底色深浅不定，给一点描边保证可读 */
  text-shadow: 0 1px 3px rgba(0, 0, 0, .85);
  pointer-events: none;
}

.site-foot[hidden] { display: none; }

.site-foot a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
  pointer-events: auto;
}

.site-foot a:hover { color: var(--ink); }

/* ============================ 排行榜 ============================ */
.board-wrap {
  margin-top: 12px;
  max-height: min(48vh, 380px);
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid rgba(96,190,255,.16);
  background: rgba(4,10,20,.6);
}
.board { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.board thead th {
  position: sticky; top: 0;
  padding: 9px 10px;
  text-align: left;
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--ink-faint);
  text-transform: uppercase;
  background: rgba(8,18,34,.96);
  border-bottom: 1px solid rgba(96,190,255,.18);
}
.board tbody td { padding: 8px 10px; border-bottom: 1px solid rgba(96,190,255,.07); }
.board tbody tr:last-child td { border-bottom: 0; }
.board tr.is-me td { background: rgba(34,150,255,.14); color: #fff; }
.board .rk { width: 40px; font-family: var(--mono); color: var(--ink-faint); }
.board .nm { color: var(--ink); word-break: break-all; }
.board .sc { font-family: var(--mono); color: var(--gold); font-variant-numeric: tabular-nums; text-align: right; }
.board .ex, .board .tm { font-family: var(--mono); color: var(--ink-faint); white-space: nowrap; }
.board .ex { text-align: right; }
.board tbody tr:nth-child(1) .sc { color: #fff; }

.submit-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid rgba(120,200,255,.3);
  background: rgba(6,14,26,.9);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}
.input::placeholder { color: #6f89a6; }
.input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,211,238,.18); }
.submit-state { margin: 10px 0 0; font-size: 12.5px; color: var(--ink-faint); min-height: 1.4em; }

/* ============================ 响应式 ============================ */
@media (max-width: 720px) {
  .hud-row { grid-template-columns: 1fr 1fr; grid-template-areas: "score speed" "mid mid"; row-gap: 10px; }
  .hud-cell:first-child { grid-area: score; }
  .hud-right { grid-area: speed; }
  .hud-mid { grid-area: mid; }
  .hud-value { font-size: 22px; }
  .toast { top: 27%; font-size: 13px; }
  .panel { padding: 22px 18px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .overlay { align-items: flex-start; }
  .title { font-size: 34px; }
  .big-score { font-size: 38px; }
  .how { display: none; }
}

/* ============================ 无障碍 ============================ */
@media (prefers-reduced-motion: reduce) {
  .energy.is-low { animation: none; border-color: rgba(255,122,77,.7); }
  .toast { transition: none; }
  .btn { transition: none; }
}

/* 打印没有意义，直接给个友好提示 */
@media print {
  .overlay::after { content: "这是个游戏，打印出来玩不了 :)"; }
}
