/* ============================================================
   NEON RING — HUD / overlay styling
   ============================================================ */

:root {
  --red: #ff3b5c;
  --red-deep: #8d0f24;
  --cyan: #46e6ff;
  --cyan-deep: #0d5f74;
  --amber: #ffc46b;
  --ink: #05070d;
  --panel: rgba(8, 12, 20, 0.62);
  --stroke: rgba(120, 200, 230, 0.16);
  --txt: #e8f4fb;
  --dim: #8fa6b6;
  --mono: "JetBrains Mono", "Cascadia Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--txt);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#cam { position: fixed; width: 2px; height: 2px; opacity: 0; pointer-events: none; left: -10px; top: -10px; }

/* ---------------- camera preview ---------------- */
#preview-wrap {
  position: fixed;
  right: 18px;
  bottom: 104px;
  width: 208px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(4, 8, 14, 0.85);
  border: 1px solid var(--stroke);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), inset 0 0 24px rgba(70, 230, 255, 0.05);
  opacity: 0.35;
  transition: opacity 0.4s ease, border-color 0.4s ease;
  z-index: 12;
}
#preview-wrap.on { opacity: 1; border-color: rgba(70, 230, 255, 0.4); }
#preview-wrap.off { display: none; }
#preview { display: block; width: 100%; height: auto; }
.preview-label {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px;
  font-size: 11px; color: var(--dim);
  letter-spacing: 0.04em;
  border-top: 1px solid rgba(120, 200, 230, 0.1);
}
#cam-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4a5a68;
  transition: background 0.3s, box-shadow 0.3s;
}
#cam-dot.live { background: #3ef08a; box-shadow: 0 0 10px #3ef08a; }

#gesture-badge {
  position: absolute;
  top: 8px; right: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #06121a;
  background: rgba(70, 230, 255, 0.85);
  box-shadow: 0 0 18px rgba(70, 230, 255, 0.5);
  transition: background 0.15s, box-shadow 0.15s, color 0.15s;
}
#gesture-badge.hot { background: rgba(255, 59, 92, 0.92); color: #1a0308; box-shadow: 0 0 22px rgba(255, 59, 92, 0.7); }

/* ---------------- HUD shell ---------------- */
#hud {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: opacity 0.5s ease;
}
#hud.dim { opacity: 0.18; }

#hud-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 18px;
  padding: 16px 22px 0;
}

.hp-block { min-width: 0; }
.hp-block.you { display: flex; flex-direction: column; align-items: flex-end; }
.hp-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
}
.hp-block.you .hp-head { flex-direction: row-reverse; }
.hp-head .who { font-size: 15px; font-weight: 800; letter-spacing: 0.06em; text-shadow: 0 0 18px rgba(70, 230, 255, 0.35); }
.hp-block.npc .who { color: #ffd9e0; text-shadow: 0 0 18px rgba(255, 59, 92, 0.45); }
.hp-head .tag {
  font-family: var(--mono);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--dim);
  border: 1px solid var(--stroke);
}

.hp-track {
  position: relative;
  height: 15px;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(120, 200, 230, 0.2);
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
}
.hp-fill, .hp-ghost {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: 100%;
  transform-origin: left center;
  transition: width 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.hp-ghost { background: rgba(255, 255, 255, 0.35); transition: width 0.75s ease 0.15s; }
.hp-block.npc .hp-fill {
  background: linear-gradient(90deg, #ff2d55, #ff7a5c 70%, #ffc46b);
  box-shadow: 0 0 18px rgba(255, 59, 92, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.hp-block.you .hp-fill {
  background: linear-gradient(90deg, #24d6f5, #6af0d0 70%, #b6ffdf);
  box-shadow: 0 0 18px rgba(70, 230, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.hp-block.you .hp-fill, .hp-block.you .hp-ghost { left: auto; right: 0; }
.hp-block.you .hp-track { width: 100%; }
.hp-block.you .hp-fill { margin-left: auto; }
.hp-block.you .hp-ghost { margin-left: auto; }

.hp-block.you .hp-track { direction: rtl; }

.stam-track {
  margin-top: 6px;
  width: 68%;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  border: 1px solid rgba(120, 200, 230, 0.12);
}
.stam-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #7d6bff, #b48cff);
  box-shadow: 0 0 12px rgba(150, 120, 255, 0.7);
  transition: width 0.12s linear, background 0.2s;
}
.stam-fill.low { background: linear-gradient(90deg, #ff6b3d, #ffb03d); }

.timer-block {
  text-align: center;
  padding-top: 2px;
  min-width: 92px;
}
.round {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.32em;
  color: var(--dim);
  margin-bottom: 2px;
}
.timer {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 22px rgba(70, 230, 255, 0.5);
  font-variant-numeric: tabular-nums;
}
.timer.urgent { color: #ff5470; text-shadow: 0 0 26px rgba(255, 59, 92, 0.8); }

/* ---------------- center stack ---------------- */
#center-stack {
  position: absolute;
  left: 50%; top: 26%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none;
  text-align: center;
}
#combo {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--amber);
  text-shadow: 0 0 22px rgba(255, 196, 107, 0.65);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.16s, transform 0.16s;
}
#combo.on { opacity: 1; transform: scale(1); }
#callout {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.12em;
  opacity: 0;
  transform: translateY(6px) scale(0.92);
  transition: opacity 0.14s ease, transform 0.22s cubic-bezier(0.2, 1.4, 0.4, 1);
  color: #fff;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.4);
}
#callout.on { opacity: 1; transform: translateY(0) scale(1); }
#callout.counter { color: var(--amber); text-shadow: 0 0 40px rgba(255, 196, 107, 0.9); }
#callout.bad { color: #ff5470; text-shadow: 0 0 40px rgba(255, 59, 92, 0.8); }
#callout.miss { color: #9fb6c4; text-shadow: none; }
#callout.dodge {
  color: #7ef0ff;
  text-shadow: 0 0 40px rgba(70, 230, 255, 0.95), 0 0 80px rgba(70, 230, 255, 0.45);
  letter-spacing: 0.18em;
}

/* ---------------- telegraph ---------------- */
#telegraph {
  position: absolute;
  left: 50%; top: 88px;
  transform: translateX(-50%) scale(0.6);
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 59, 92, 0.14);
  border: 1px solid rgba(255, 59, 92, 0.55);
  box-shadow: 0 0 30px rgba(255, 59, 92, 0.35);
  opacity: 0;
  transition: opacity 0.12s, transform 0.16s;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: #ffb3c0;
}
#telegraph.on { opacity: 1; transform: translateX(-50%) scale(1); animation: tele 0.42s infinite alternate; }
#telegraph.guard {
  animation: none;
  background: rgba(70, 230, 255, 0.12);
  border-color: rgba(70, 230, 255, 0.55);
  color: #a9ecff;
  box-shadow: 0 0 24px rgba(70, 230, 255, 0.25);
}
@keyframes tele {
  from { box-shadow: 0 0 18px rgba(255, 59, 92, 0.25); }
  to   { box-shadow: 0 0 40px rgba(255, 59, 92, 0.75); }
}

/* ---------------- bottom ---------------- */
#hud-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 22px 18px;
  gap: 16px;
}
.telemetry {
  min-width: 168px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
  display: grid;
  gap: 5px;
}
.tel-row { display: flex; justify-content: space-between; gap: 14px; font-size: 11px; }
.tel-row .k { color: var(--dim); letter-spacing: 0.12em; }
.tel-row .v { font-family: var(--mono); color: var(--cyan); font-weight: 600; }
.tel-row .v i { font-style: normal; color: var(--dim); font-size: 9px; }
.power {
  position: relative;
  display: inline-block;
  width: 72px; height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  vertical-align: middle;
}
.power i {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, #2ad4ff, #7dffc4);
  border-radius: 999px;
  transition: width 0.06s linear;
}
.power::after {
  content: '';
  position: absolute; top: -1px; bottom: -1px;
  left: 36%;                     /* 判定阈值刻度：越过去就会出拳 */
  width: 1px;
  background: rgba(255, 196, 107, 0.85);
}

.keys {
  display: flex; flex-wrap: wrap; gap: 6px 12px;
  font-size: 10.5px;
  color: var(--dim);
  letter-spacing: 0.04em;
  justify-content: flex-end;
  max-width: 46vw;
  padding-bottom: 2px;
}
.keys b {
  display: inline-block;
  min-width: 16px;
  text-align: center;
  padding: 1px 5px;
  margin-right: 3px;
  border-radius: 4px;
  color: #cfe8f5;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-family: var(--mono);
  font-size: 10px;
}

/* ---------------- damage floaters ---------------- */
#floaters { position: fixed; inset: 0; pointer-events: none; z-index: 11; }
.floater {
  position: absolute;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 22px;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.8), 0 0 24px rgba(255, 255, 255, 0.35);
  transform: translate(-50%, -50%);
  animation: floatUp 0.9s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
  white-space: nowrap;
}
.floater.crit { font-size: 30px; color: var(--amber); text-shadow: 0 2px 16px rgba(0,0,0,.85), 0 0 30px rgba(255,196,107,.9); }
.floater.hurt { color: #ff5470; }
.floater.info { font-size: 15px; color: #a8c4d4; font-weight: 600; letter-spacing: 0.1em; }
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  18%  { opacity: 1; transform: translate(-50%, -62%) scale(1.14); }
  100% { opacity: 0; transform: translate(-50%, -128%) scale(0.95); }
}

/* ---------------- dodge arrow ---------------- */
#dodge-arrow {
  position: fixed;
  top: 50%;
  width: 46vw;
  height: 260px;
  margin-top: -130px;
  z-index: 11;
  pointer-events: none;
  opacity: 0;
  background-repeat: repeat-x;
  background-position: center;
  background-size: 120px 260px;
  background-image: radial-gradient(ellipse at center, rgba(120, 235, 255, 0.55) 0%, rgba(120, 235, 255, 0) 62%);
  filter: blur(0.5px);
}
#dodge-arrow.left { left: 0; }
#dodge-arrow.right { right: 0; }
#dodge-arrow::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 0; height: 0;
  margin-top: -46px;
  border-top: 46px solid transparent;
  border-bottom: 46px solid transparent;
}
#dodge-arrow.left::after {
  left: 34px;
  border-right: 64px solid rgba(140, 240, 255, 0.75);
  filter: drop-shadow(0 0 22px rgba(70, 230, 255, 0.9));
}
#dodge-arrow.right::after {
  right: 34px;
  border-left: 64px solid rgba(140, 240, 255, 0.75);
  filter: drop-shadow(0 0 22px rgba(70, 230, 255, 0.9));
}
#dodge-arrow.on { animation: dodgeArrow 0.55s ease-out forwards; }
#dodge-arrow.left.on { animation-name: dodgeArrowL; }
#dodge-arrow.right.on { animation-name: dodgeArrowR; }
@keyframes dodgeArrowL {
  0%   { opacity: 0; transform: translateX(40px) scaleX(0.7); }
  18%  { opacity: 1; transform: translateX(0) scaleX(1); }
  100% { opacity: 0; transform: translateX(-70px) scaleX(1.15); }
}
@keyframes dodgeArrowR {
  0%   { opacity: 0; transform: translateX(-40px) scaleX(0.7); }
  18%  { opacity: 1; transform: translateX(0) scaleX(1); }
  100% { opacity: 0; transform: translateX(70px) scaleX(1.15); }
}

/* ---------------- overlay ---------------- */
#overlay, #loading, #result {
  position: fixed; inset: 0;
  z-index: 30;
  display: grid; place-items: center;
  background: radial-gradient(120% 90% at 50% 30%, rgba(12, 20, 34, 0.82), rgba(2, 4, 8, 0.96) 70%);
  backdrop-filter: blur(6px);
  transition: opacity 0.45s ease, visibility 0.45s;
}
#overlay.hide, #loading.hide, #result.hide { opacity: 0; visibility: hidden; pointer-events: none; }

.ov-inner {
  width: min(680px, 90vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 34px 34px 28px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(14, 22, 36, 0.9), rgba(6, 10, 18, 0.94));
  border: 1px solid rgba(120, 200, 230, 0.18);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
}
.ov-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.42em;
  color: var(--cyan);
  opacity: 0.8;
  margin-bottom: 12px;
}
.ov-inner h2 {
  margin: 0 0 12px;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.04em;
}
.ov-inner h2 .vs {
  font-family: var(--mono);
  font-size: 20px;
  color: var(--red);
  padding: 0 8px;
  text-shadow: 0 0 24px rgba(255, 59, 92, 0.8);
}
.lead { margin: 0 auto 20px; max-width: 44ch; color: #b7cbd8; font-size: 13.5px; line-height: 1.7; }

.hints {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 8px;
  text-align: left;
}
.hints li {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12.5px;
}
.hints b { color: var(--amber); font-weight: 700; letter-spacing: 0.06em; }
.hints span { color: #9fb6c4; line-height: 1.5; }

.tiny { font-size: 11.5px; color: #7d94a4; line-height: 1.7; margin: 6px 0 0; }
.tiny b { color: #ffb0bf; }

.diff-row {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 18px 0 2px; flex-wrap: wrap;
}
.diff-label {
  font-size: 11px; letter-spacing: 0.22em; color: var(--dim); margin-right: 4px;
}
.diff-pill {
  pointer-events: auto; cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 700;
  letter-spacing: 0.06em;
  padding: 7px 16px; border-radius: 999px;
  color: #a9c0cf;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(120, 200, 230, 0.18);
  transition: color 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.diff-pill:hover { color: #e8f4fb; border-color: rgba(70, 230, 255, 0.45); }
.diff-pill.active {
  color: #04121a;
  background: linear-gradient(180deg, #6af0d0, #2ad4ff);
  border-color: rgba(120, 250, 255, 0.75);
  box-shadow: 0 6px 22px rgba(70, 230, 255, 0.32);
}
.diff-pill[data-diff="hard"].active,
.diff-pill[data-diff="insane"].active {
  color: #1a0308;
  background: linear-gradient(180deg, #ffb36b, #ff3b5c);
  border-color: rgba(255, 150, 160, 0.7);
  box-shadow: 0 6px 22px rgba(255, 59, 92, 0.35);
}
.diff-pill:active { transform: scale(0.97); }

.ov-actions { display: flex; gap: 12px; justify-content: center; margin: 20px 0 6px; flex-wrap: wrap; }

.btn {
  pointer-events: auto;
  cursor: pointer;
  border: 1px solid rgba(120, 200, 230, 0.24);
  background: rgba(255, 255, 255, 0.05);
  color: var(--txt);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 12px 22px;
  border-radius: 11px;
  transition: transform 0.12s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(70, 230, 255, 0.55); box-shadow: 0 10px 30px rgba(70, 230, 255, 0.18); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn.primary {
  background: linear-gradient(180deg, #ff4a67, #c3163a);
  border-color: rgba(255, 130, 150, 0.6);
  box-shadow: 0 12px 34px rgba(255, 59, 92, 0.3);
}
.btn.primary:hover { box-shadow: 0 14px 40px rgba(255, 59, 92, 0.45); }
.btn.ghost { color: #b9cedb; }

/* loading */
.ld-inner { text-align: center; }
.ld-ring {
  width: 46px; height: 46px; margin: 0 auto 16px;
  border-radius: 50%;
  border: 2px solid rgba(70, 230, 255, 0.15);
  border-top-color: var(--cyan);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#ld-text { color: #9fb6c4; font-size: 12.5px; letter-spacing: 0.1em; }

/* result */
.res-inner { text-align: center; padding: 30px 40px; }
.res-title {
  font-family: var(--mono);
  font-size: 86px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 60px rgba(255, 196, 107, 0.75), 0 0 120px rgba(255, 59, 92, 0.4);
  animation: koPop 0.6s cubic-bezier(0.15, 1.5, 0.4, 1);
}
@keyframes koPop {
  0% { transform: scale(2.4); opacity: 0; filter: blur(8px); }
  100% { transform: scale(1); opacity: 1; filter: blur(0); }
}
.res-sub { font-size: 18px; color: #cfe8f5; margin-top: 6px; letter-spacing: 0.2em; }
.res-stats {
  display: flex; gap: 26px; justify-content: center;
  margin: 26px 0 8px;
  font-family: var(--mono);
}
.res-stats div { display: grid; gap: 4px; }
.res-stats span { font-size: 10px; color: var(--dim); letter-spacing: 0.2em; }
.res-stats b { font-size: 22px; color: var(--amber); }
#result .btn { margin-top: 22px; }

/* toast */
#toast {
  position: fixed;
  left: 50%; bottom: 96px;
  transform: translate(-50%, 12px);
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(10, 16, 26, 0.92);
  border: 1px solid rgba(120, 200, 230, 0.22);
  color: #cfe8f5;
  font-size: 12px;
  letter-spacing: 0.06em;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 40;
  pointer-events: none;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 720px) {
  .ov-inner { padding: 20px 24px 16px; }
  .ov-inner h2 { font-size: 26px; margin-bottom: 8px; }
  .lead { margin-bottom: 12px; font-size: 12.5px; }
  .hints li { padding: 6px 10px; font-size: 12px; }
  .tiny { font-size: 10.5px; }
  .diff-row { margin: 12px 0 0; }
  .ov-actions { margin: 14px 0 2px; }
  .btn { padding: 10px 18px; font-size: 12.5px; }
}

@media (max-width: 760px) {
  .ov-inner h2 { font-size: 26px; }
  .hints li { grid-template-columns: 1fr; gap: 4px; }
  #preview-wrap { width: 148px; bottom: 92px; right: 12px; }
  .keys { display: none; }
  .timer { font-size: 26px; }
  .hp-head .who { font-size: 12px; }
}
