/* ============================================================
   飞机大战 · STAR RAID — 样式表
   布局思路：整页 flex 纵向布局，舞台 (canvas 容器) 用 aspect-ratio
   保持 3:5 比例并自适应，桌面端限高，手机端铺满可视区域。
   ============================================================ */

:root {
  --bg: #05060f;
  --bg-2: #0a0e1f;
  --panel: rgba(13, 19, 38, 0.82);
  --line: rgba(120, 200, 255, 0.18);
  --cyan: #5ce1ff;
  --cyan-deep: #1b8cff;
  --magenta: #ff4fa3;
  --amber: #ffcf5c;
  --danger: #ff5f6d;
  --text: #e8f3ff;
  --muted: #8ea2c4;
  --font-display: "Orbitron", "Noto Sans SC", system-ui, sans-serif;
  --font-body: "Noto Sans SC", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --radius: 18px;
  --stage-max-w: 470px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1100px 700px at 20% -10%, rgba(27, 140, 255, 0.20), transparent 62%),
    radial-gradient(900px 620px at 88% 112%, rgba(255, 79, 163, 0.16), transparent 60%),
    linear-gradient(180deg, #05060f 0%, #070b18 45%, #04050c 100%);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  /* 细网格背景，增强街机质感 */
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(120, 200, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 200, 255, 0.045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 78%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- 应用外壳 ---------- */
.app {
  position: relative;
  z-index: 1;
  height: 100%;
  height: 100dvh;
  max-width: var(--stage-max-w);
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- 顶部数据条 ---------- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02) inset, 0 10px 30px rgba(0, 0, 0, 0.45);
}

.stat {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}
.stat--center { flex: 1; align-items: center; }
.stat--end { align-items: flex-end; }

.stat__label {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
}

.stat__value {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 12px rgba(92, 225, 255, 0.65);
  font-variant-numeric: tabular-nums;
}
.stat__value--gold { color: var(--amber); text-shadow: 0 0 14px rgba(255, 207, 92, 0.6); }
.stat__value--cyan { color: var(--cyan); }

.tools { display: flex; gap: 6px; margin-left: 4px; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(92, 225, 255, 0.07);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
}
.icon-btn:hover { background: rgba(92, 225, 255, 0.16); border-color: rgba(92, 225, 255, 0.45); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* 暂停图标（纯 CSS 两根竖条） */
.icon-pause,
.icon-pause::before {
  display: block;
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: currentColor;
}
.icon-pause { position: relative; }
.icon-pause::before { content: ""; position: absolute; left: 8px; top: 0; }

/* ---------- 舞台 ---------- */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(92, 225, 255, 0.25);
  background: #03040b;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 0 40px rgba(27, 140, 255, 0.18),
    0 24px 60px rgba(0, 0, 0, 0.55);
  touch-action: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

/* 炸弹按钮 */
.bomb-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 1px solid rgba(255, 207, 92, 0.55);
  background: radial-gradient(circle at 35% 30%, rgba(255, 207, 92, 0.28), rgba(12, 16, 32, 0.86) 72%);
  color: var(--amber);
  display: grid;
  place-content: center;
  gap: 1px;
  cursor: pointer;
  z-index: 4;
  box-shadow: 0 0 22px rgba(255, 207, 92, 0.22), 0 8px 20px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s, opacity 0.2s;
  user-select: none;
}
.bomb-btn:active { transform: scale(0.92); }
.bomb-btn:disabled { opacity: 0.35; cursor: default; }
.bomb-btn__key { font-size: 9px; letter-spacing: 0.12em; opacity: 0.75; }
.bomb-btn__txt { font-size: 13px; font-weight: 700; line-height: 1; }
.bomb-btn__num {
  font-family: var(--font-display);
  font-size: 11px;
  color: #fff;
  opacity: 0.9;
}

/* ---------- 遮罩与界面 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  place-items: center;
  padding: 18px;
  background: radial-gradient(circle at 50% 45%, rgba(6, 10, 24, 0.72), rgba(3, 4, 11, 0.94));
  backdrop-filter: blur(4px);
}
.overlay.is-visible { display: grid; }

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  width: 100%;
  max-width: 340px;
}
.screen.is-active { display: flex; }

.eyebrow {
  margin: 0;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.4em;
  color: var(--cyan);
  text-transform: uppercase;
  opacity: 0.85;
}

.title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 11vw, 46px);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.05;
  background: linear-gradient(180deg, #ffffff 0%, #8bf6ff 46%, #1b8cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(92, 225, 255, 0.45));
}

.title-sub {
  margin: -2px 0 4px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.34em;
  color: var(--muted);
}

.screen__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 0 20px rgba(92, 225, 255, 0.55);
}
.screen__title--danger {
  color: #ffdfe4;
  text-shadow: 0 0 22px rgba(255, 95, 109, 0.75);
}

.screen__hint {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.best-line {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.best-line strong {
  font-family: var(--font-display);
  color: var(--amber);
  font-size: 15px;
}

/* 按钮 */
.btn {
  width: 100%;
  padding: 13px 20px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s, background 0.2s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.btn--primary {
  margin-top: 6px;
  color: #041018;
  background: linear-gradient(180deg, #9df3ff 0%, var(--cyan) 42%, #22a4ff 100%);
  box-shadow: 0 0 26px rgba(92, 225, 255, 0.42), 0 10px 24px rgba(0, 0, 0, 0.45);
}
.btn--primary:hover { box-shadow: 0 0 34px rgba(92, 225, 255, 0.62), 0 10px 24px rgba(0, 0, 0, 0.45); }

.btn--ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.1); }

/* 开始页图例 */
.legend {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 7px;
  width: 100%;
  font-size: 12.5px;
  color: #b9cbe6;
  text-align: left;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.dot--cyan { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.dot--magenta { background: var(--magenta); box-shadow: 0 0 10px var(--magenta); }
.dot--amber { background: var(--amber); box-shadow: 0 0 10px var(--amber); }

/* 结算面板 */
.result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin: 4px 0 0;
}
.result__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 10px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.result__item span { font-size: 10.5px; letter-spacing: 0.12em; color: var(--muted); }
.result__item strong {
  font-family: var(--font-display);
  font-size: 19px;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.new-record {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--amber);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.97); }
}

/* ---------- 底部状态条 ---------- */
.bottombar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  backdrop-filter: blur(10px);
}

.vitals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.vital { display: flex; align-items: center; gap: 8px; }
.vital__label {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
}

.hearts, .pips { display: flex; gap: 4px; align-items: center; }

.heart {
  width: 13px;
  height: 13px;
  background: var(--danger);
  clip-path: polygon(50% 100%, 3% 43%, 3% 24%, 15% 8%, 32% 6%, 50% 20%, 68% 6%, 85% 8%, 97% 24%, 97% 43%);
  box-shadow: 0 0 8px rgba(255, 95, 109, 0.7);
  transition: background 0.2s, opacity 0.2s;
}
.heart.is-empty { background: rgba(255, 255, 255, 0.14); box-shadow: none; }

.pip {
  width: 18px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.2s, box-shadow 0.2s;
}
.pip.is-on { background: var(--magenta); box-shadow: 0 0 10px rgba(255, 79, 163, 0.8); }

.hint {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: center;
}
.hint--touch { display: none; }

@media (hover: none) and (pointer: coarse) {
  .hint--kb { display: none; }
  .hint--touch { display: block; }
}

.noscript {
  position: fixed;
  inset: auto 0 0 0;
  margin: 0;
  padding: 14px;
  text-align: center;
  background: var(--danger);
  color: #1a0000;
  font-weight: 700;
  z-index: 99;
}

/* ---------- 桌面端：限制舞台尺寸并居中 ---------- */
@media (min-width: 720px) and (min-height: 640px) {
  :root { --stage-max-w: 440px; }
  .app { padding-top: 16px; padding-bottom: 16px; gap: 10px; }
  .title { font-size: 46px; }
}

/* 极矮的横屏手机：压缩装饰元素 */
@media (max-height: 560px) {
  .bottombar { display: none; }
  .legend { display: none; }
  .title { font-size: 30px; }
  .title-sub { display: none; }
  .bomb-btn { width: 54px; height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  .new-record { animation: none; }
  * { scroll-behavior: auto; }
}
