:root {
  --bg: #070f12;
  --ink: #e8f6f8;
  --muted: #8fb2b8;
  --cyan: #4fe3d4;
  --cyan-dim: rgba(79, 227, 212, 0.25);
  --orange: #ffb347;
  --red: #ff5a5a;
  --panel: rgba(8, 24, 28, 0.72);
  --stroke: rgba(120, 220, 220, 0.18);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#app,
#app canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

/* 软件渲染（没有 GPU）时由 environment.js 给 body 加这个类：
   毛玻璃 backdrop-filter 会逐帧重新模糊整个面板背后的画面，软渲染下极其昂贵。 */
.sw-soft .panel,
.sw-soft .boss {
  backdrop-filter: none;
}

.sw-soft .overlay {
  backdrop-filter: none;
  background: rgba(4, 12, 15, 0.92);
}

/* ---------------- HUD ---------------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 12px 14px;
  backdrop-filter: blur(8px);
}

.stats {
  min-width: min(460px, 52vw);
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.bar {
  position: relative;
  height: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.bar.xp {
  height: 8px;
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: 8px;
  transition: width 0.12s linear;
}

.bar.hp .bar-fill {
  background: linear-gradient(90deg, #ff6a5a, #ffb347);
  box-shadow: 0 0 14px rgba(255, 120, 80, 0.5);
}

.bar.xp .bar-fill {
  background: linear-gradient(90deg, #35c9e8, #7cf5ff);
  box-shadow: 0 0 12px rgba(90, 230, 255, 0.6);
}

.bar span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.stat-line {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.stat-line b {
  color: var(--ink);
}

.dot {
  opacity: 0.4;
}

.moves {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.move-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  color: #cdeef2;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

.clock {
  text-align: right;
  min-width: 118px;
}

.timer {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: #d9fbff;
}

.timer.danger {
  color: var(--red);
  text-shadow: 0 0 18px rgba(255, 80, 80, 0.65);
}

.phase {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

/* Boss 血条 */
.boss {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  width: min(680px, 82vw);
  background: var(--panel);
  border: 1px solid rgba(255, 90, 90, 0.28);
  border-radius: 12px;
  padding: 10px 12px;
  backdrop-filter: blur(8px);
}

.boss-label {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  color: #ffc4c4;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}

.boss-track {
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.boss-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #b4232c, #ff7a5c);
  box-shadow: 0 0 16px rgba(255, 90, 60, 0.55);
  transition: width 0.1s linear;
}

.hint {
  align-self: center;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(190, 225, 230, 0.45);
  padding-bottom: 4px;
}

/* 受击红闪 */
#damage-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 30, 30, 0.55) 100%);
  transition: opacity 0.25s ease-out;
}

#damage-vignette.show {
  opacity: 1;
  transition: opacity 0.05s;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(6, 20, 24, 0.86);
  border: 1px solid var(--stroke);
  color: #d7fbff;
  font-size: 14px;
  letter-spacing: 0.1em;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------- 通用 overlay ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(10, 40, 46, 0.75), rgba(3, 8, 10, 0.94));
  backdrop-filter: blur(6px);
  z-index: 10;
}

.kicker {
  font-size: 10.5px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--cyan);
  opacity: 0.85;
}

/* ---------------- 开始界面 ---------------- */
.start-card {
  width: min(620px, 88vw);
  padding: 42px 44px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(12, 34, 40, 0.94), rgba(6, 16, 20, 0.96));
  border: 1px solid var(--stroke);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  text-align: left;
}

.start-card h1 {
  margin: 10px 0 10px;
  font-size: clamp(34px, 5.4vw, 52px);
  letter-spacing: 0.06em;
  background: linear-gradient(120deg, #fff2cf, #ffb347 55%, #4fe3d4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  color: #a9c8cd;
  line-height: 1.75;
  font-size: 14.5px;
  margin: 0 0 22px;
}

.keys {
  list-style: none;
  padding: 0;
  margin: 0 0 28px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 14px;
}

.keys li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

kbd {
  font-family: var(--font);
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom-width: 2px;
  color: #e6fbfd;
}

.btn {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  border-radius: 12px;
  padding: 14px 26px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s;
}

.btn.primary {
  color: #062024;
  background: linear-gradient(120deg, #7cf5ff, #4fe3d4 45%, #ffd88a);
  box-shadow: 0 12px 34px rgba(79, 227, 212, 0.28);
}

.btn.primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.btn:active {
  transform: translateY(0);
}

.tiny {
  margin: 14px 0 0;
  font-size: 11.5px;
  color: rgba(160, 200, 206, 0.55);
}

/* ---------------- 选卡 ---------------- */
#cards {
  grid-auto-rows: min-content;
  align-content: center;
  gap: 26px;
  z-index: 12;
}

.cards-head {
  text-align: center;
}

.cards-head h2 {
  margin: 8px 0 6px;
  font-size: 26px;
  letter-spacing: 0.08em;
}

.cards-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.06em;
}

.card-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 16px;
}

.card {
  width: 232px;
  min-height: 250px;
  text-align: left;
  cursor: pointer;
  padding: 20px 18px;
  border-radius: 18px;
  color: var(--ink);
  background: linear-gradient(165deg, rgba(18, 46, 52, 0.96), rgba(7, 20, 24, 0.98));
  border: 1px solid rgba(120, 220, 220, 0.2);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  transition: transform 0.14s ease, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: var(--font);
}

.card:hover {
  transform: translateY(-6px);
  border-color: rgba(124, 245, 255, 0.6);
  box-shadow: 0 26px 54px rgba(30, 200, 210, 0.18);
}

.card .tag {
  align-self: flex-start;
  font-size: 10px;
  letter-spacing: 0.22em;
  padding: 4px 9px;
  border-radius: 999px;
  color: #9ceef2;
  background: rgba(79, 227, 212, 0.1);
  border: 1px solid rgba(79, 227, 212, 0.22);
}

.card .icon {
  font-size: 34px;
  line-height: 1;
}

.card h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.04em;
}

.card p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: #a8c7cc;
}

.card .idx {
  margin-top: auto;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: rgba(160, 200, 206, 0.5);
}

/* ---------------- 结果 ---------------- */
.result-card {
  width: min(520px, 88vw);
  padding: 40px 40px 34px;
  border-radius: 22px;
  text-align: center;
  background: linear-gradient(160deg, rgba(12, 34, 40, 0.95), rgba(6, 16, 20, 0.97));
  border: 1px solid var(--stroke);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.result-card h1 {
  margin: 10px 0 8px;
  font-size: 40px;
  letter-spacing: 0.08em;
}

.result-card h1.win {
  background: linear-gradient(120deg, #d8fff0, #4fe3d4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result-card h1.lose {
  background: linear-gradient(120deg, #ffd9d0, #ff5a5a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#result-sub {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  margin: 0 0 22px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 26px;
}

.result-stats div {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 12px;
  color: var(--muted);
}

.result-stats b {
  display: block;
  font-size: 19px;
  color: var(--ink);
  margin-bottom: 3px;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 暂停 ---------------- */
.pause-card {
  text-align: center;
  padding: 34px 46px;
  border-radius: 18px;
  background: rgba(8, 22, 26, 0.92);
  border: 1px solid var(--stroke);
}

.pause-card h2 {
  margin: 0 0 8px;
  letter-spacing: 0.16em;
}

.pause-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

@media (max-width: 720px) {
  .stats {
    min-width: 0;
    flex: 1;
  }
  .hint {
    display: none;
  }
  .start-card {
    padding: 28px 24px;
  }
  .card {
    width: min(320px, 84vw);
    min-height: 0;
  }
}

/* ---------------- 伤害数字 ---------------- */
.floaters {
  position: fixed;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.float-dmg {
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--font);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: #dcf6ff;
  /* 描边 + 外发光：在任何背景（草地、绿色怪、Boss 身体）上都能读清楚 */
  text-shadow:
    0 1px 0 rgba(4, 16, 20, 0.9),
    1px 0 0 rgba(4, 16, 20, 0.9),
    -1px 0 0 rgba(4, 16, 20, 0.9),
    0 -1px 0 rgba(4, 16, 20, 0.9),
    0 0 14px rgba(140, 240, 255, 0.5);
  will-change: transform, opacity;
  pointer-events: none;
}

/* ---------------- 触屏操作 ---------------- */
.touch {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  touch-action: none;
}

.stick {
  position: absolute;
  left: 26%;
  top: 70%;
  width: 122px;
  height: 122px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1.5px solid rgba(120, 240, 230, 0.26);
  background: radial-gradient(circle, rgba(79, 227, 212, 0.13), rgba(8, 24, 28, 0.18));
  opacity: 0.32;
  transition: opacity 0.15s ease-out;
}

.stick.active {
  opacity: 0.92;
}

.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #a8fdf2, #2bb6ac 72%);
  box-shadow: 0 0 20px rgba(79, 227, 212, 0.45), inset 0 -4px 10px rgba(0, 0, 0, 0.35);
}

.touch-actions {
  position: absolute;
  right: 20px;
  bottom: 30px;
  display: grid;
  gap: 14px;
  justify-items: end;
  pointer-events: none;
}

.touch-btn {
  pointer-events: auto;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 1.5px solid rgba(120, 240, 230, 0.34);
  background: radial-gradient(circle at 35% 30%, rgba(30, 82, 88, 0.92), rgba(8, 20, 24, 0.86));
  color: #d9fbff;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.08em;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease-out, background 0.08s ease-out;
}

.touch-btn.down {
  transform: scale(0.92);
  background: radial-gradient(circle at 35% 30%, rgba(90, 214, 204, 0.95), rgba(12, 42, 46, 0.92));
}

.touch-btn.dash {
  width: 88px;
  height: 88px;
  border-color: rgba(255, 179, 71, 0.5);
  color: #ffe2b0;
}

.touch-btn.pause {
  width: 46px;
  height: 46px;
  font-size: 12px;
  opacity: 0.75;
}

/* 触屏设备上禁掉浏览器的滚动/缩放/长按菜单，否则打游戏会不停触发页面手势 */
@media (pointer: coarse) {
  html,
  body {
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
  }
  #app,
  #app canvas {
    touch-action: none;
  }
}

/* 触屏上也给一行操作提示：按钮再多，新玩家第一次也不知道能拖动看视角 */
@media (pointer: coarse) {
  .hint {
    display: block;
    font-size: 10px;
    opacity: 0.75;
  }
}

/* 窄屏 HUD：默认布局会把 "Lv 2"、"3 击杀" 拆成竖排，这里强制不换行 + 整体缩一号 */
@media (max-width: 720px) {
  #hud {
    padding: 12px 14px;
  }
  .hud-top {
    gap: 10px;
  }
  .panel {
    padding: 10px 12px;
    border-radius: 12px;
  }
  .stat-line {
    flex-wrap: wrap;
    gap: 4px 8px;
    font-size: 11.5px;
  }
  .stat-line > span {
    white-space: nowrap;
  }
  .move-chip {
    padding: 1px 6px;
    font-size: 10px;
  }
  .clock {
    min-width: 88px;
    padding: 8px 10px;
  }
  .timer {
    font-size: 21px;
  }
  .bar span {
    font-size: 10px;
  }
}
