/* 开源商用字体 JetBrains Mono（SIL OFL 1.1，许可见 fonts/OFL.txt） */
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #05080f;
  --panel: rgba(10, 17, 30, 0.88);
  --line: rgba(120, 170, 255, 0.16);
  --text: #dbe7ff;
  --dim: #8fa3c7;
  --cyan: #67e8f9;
  --mint: #7ef0c0;
  --red: #ff6b81;
  --gold: #ffd166;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(1200px 600px at 50% -10%, #14213a 0%, #05080f 60%);
  color: var(--text);
  font-family: "JetBrains Mono", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px 12px;
}

.topbar {
  width: min(960px, 100%, calc((100vh - 140px) * 1.6));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #eaf6ff;
}

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 14px var(--cyan);
}

.brand .tag {
  font-size: 11px;
  font-weight: 500;
  color: #7dd3fc;
  border: 1px solid rgba(103, 232, 249, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
}

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  cursor: pointer;
  border: 1px solid rgba(120, 170, 255, 0.28);
  background: rgba(120, 170, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 9px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

button:hover {
  border-color: rgba(103, 232, 249, 0.7);
  background: rgba(103, 232, 249, 0.14);
}

button:active {
  transform: translateY(1px);
}

.stage {
  position: relative;
  /* 同时受宽度与视口高度限制，保证顶部按钮始终可见 */
  width: min(960px, 100%, calc((100vh - 140px) * 1.6));
  aspect-ratio: 960 / 600;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(103, 232, 249, 0.18);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.6) inset;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

/* ---------------------------------------------------------------- HUD */
.hud {
  position: absolute;
  inset: 0;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  font-size: 12px;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 240px;
}

.bar {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: rgba(4, 9, 18, 0.72);
  border: 1px solid var(--line);
  overflow: hidden;
}

.bar .fill {
  height: 100%;
  width: 100%;
  transition: width 0.12s linear;
}

.bar.hp .fill {
  background: linear-gradient(90deg, #ff6b81, #ff9f43);
}

.bar.xp {
  height: 10px;
}

.bar.xp .fill {
  width: 0%;
  background: linear-gradient(90deg, #67e8f9, #7ef0c0);
  box-shadow: 0 0 10px rgba(103, 232, 249, 0.6);
}

.bar span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.badge {
  align-self: flex-start;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  color: var(--cyan);
  background: rgba(103, 232, 249, 0.12);
  border: 1px solid rgba(103, 232, 249, 0.35);
}

.hud-center {
  text-align: center;
  min-width: 140px;
}

.timer {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: #f2f8ff;
  text-shadow: 0 0 18px rgba(103, 232, 249, 0.35);
}

.hud-center .sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--dim);
}

.hud-right {
  text-align: right;
}

.kills {
  font-size: 13px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  font-size: 11px;
  color: rgba(190, 210, 240, 0.55);
  letter-spacing: 0.04em;
  pointer-events: none;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- 弹层 */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 6, 12, 0.72);
  backdrop-filter: blur(4px);
  padding: 20px;
}

.overlay.show {
  display: flex;
}

.panel {
  width: min(760px, 100%);
  background: var(--panel);
  border: 1px solid rgba(103, 232, 249, 0.22);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.panel.small {
  width: min(380px, 100%);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 20px;
  letter-spacing: 0.04em;
}

.panel .line {
  margin: 6px 0;
  font-size: 14px;
  color: #eaf2ff;
}

.panel .line.dim {
  color: var(--dim);
  font-size: 12px;
}

.panel button {
  margin-top: 16px;
  padding: 9px 22px;
  border-color: rgba(103, 232, 249, 0.55);
  background: rgba(103, 232, 249, 0.14);
}

.tip {
  margin-top: 14px;
  font-size: 11px;
  color: var(--dim);
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.card {
  text-align: left;
  padding: 14px 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(12, 22, 38, 0.85);
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: rgba(103, 232, 249, 0.6);
  box-shadow: 0 12px 30px rgba(103, 232, 249, 0.12);
}

.card .key {
  font-size: 10px;
  color: var(--dim);
}

.card .title {
  margin: 6px 0 6px;
  font-size: 16px;
  font-weight: 700;
}

.card .desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--dim);
}

.foot {
  width: min(960px, 100%, calc((100vh - 140px) * 1.6));
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  text-align: center;
  font-size: 11px;
  color: rgba(150, 175, 215, 0.6);
}

.foot-links {
  display: flex;
  gap: 12px;
}

.foot-links a {
  color: #7dd3fc;
  text-decoration: none;
}

.foot-links a:hover {
  text-decoration: underline;
}

/* 激励视频复活按钮：金色描边，和普通按钮区分 */
button.rewarded {
  margin-right: 8px;
  border-color: rgba(255, 209, 102, 0.6);
  background: rgba(255, 209, 102, 0.14);
  color: #ffe6a7;
}

/* ---------------------------------------------------------------- 触屏摇杆 */
.joystick {
  display: none;
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 1px solid rgba(103, 232, 249, 0.35);
  background: radial-gradient(circle, rgba(103, 232, 249, 0.12), rgba(5, 8, 15, 0.35) 70%);
  box-shadow: 0 0 30px rgba(103, 232, 249, 0.12) inset;
  /* 阻止浏览器把拖动识别成页面滚动 */
  touch-action: none;
  user-select: none;
  z-index: 5;
}

body.touch .joystick {
  display: block;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(126, 240, 192, 0.85);
  box-shadow: 0 0 18px rgba(126, 240, 192, 0.55);
  transition: transform 0.06s linear;
  pointer-events: none;
}

body.touch .hint {
  display: none;
}

@media (max-width: 720px) {
  .app {
    justify-content: flex-start;
    gap: 8px;
    padding: 10px 8px 16px;
  }
  .brand .tag {
    display: none;
  }
  .hud-left {
    width: 170px;
  }
  .hud-center {
    min-width: 110px;
  }
  .timer {
    font-size: 20px;
  }
  .kills {
    font-size: 11px;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .panel {
    max-height: 100%;
    overflow-y: auto;
  }
  .controls button {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* SEO：视觉隐藏的 h1（Canvas 页不放显式大标题，但需要文档标题结构） */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
