* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #06050b;
  overflow: hidden;
  color: #ece6f5;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 40%, #171028 0%, #06050b 70%);
}

#wrap {
  position: relative;
  width: min(100vw, 177.78vh);
  aspect-ratio: 16 / 9;
  font-size: 15px;
  background: #000;
  overflow: hidden;
  box-shadow: 0 0 70px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.55em 0.8em;
  font-size: 0.62em;
  letter-spacing: 0.02em;
  pointer-events: none;
  text-shadow: 0 1px 0 #000, 0 0 6px rgba(0, 0, 0, 0.8);
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 0.15em;
}

#hud-level {
  color: #f3edff;
  font-weight: 600;
}

#hud-best {
  color: #9c90b8;
  font-size: 0.9em;
}

#ability-hud {
  position: absolute;
  top: 2.7em;
  left: 0.8em;
  z-index: 5;
  display: flex;
  gap: 0.45em;
  font-size: 0.48em;
  pointer-events: none;
}

.ability {
  padding: 0.35em 0.6em;
  color: #b9ffe6;
  background: rgba(8, 18, 22, 0.72);
  border: 1px solid rgba(105, 227, 194, 0.35);
  border-radius: 0.2em;
  text-shadow: 0 1px 0 #000;
}

.ability b {
  color: #fff;
  font-weight: 600;
}

.ability.cooling {
  color: #9c90b8;
  border-color: rgba(180, 160, 210, 0.2);
}

#ability-hud .hidden {
  display: none;
}

#hud-time {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0.8em;
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.25em;
  color: #e9e2ff;
  letter-spacing: 0.06em;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 0.6em;
}

#hud-deaths {
  color: #ff9aa8;
}

#mute-btn {
  pointer-events: auto;
  font: inherit;
  font-size: 0.95em;
  color: #cfc7e4;
  background: rgba(20, 14, 32, 0.75);
  border: 1px solid rgba(200, 180, 255, 0.28);
  border-radius: 0.2em;
  padding: 0.2em 0.55em;
  cursor: pointer;
}

#mute-btn:hover {
  border-color: rgba(200, 180, 255, 0.6);
  color: #fff;
}

/* ---------- 字幕 ---------- */
#subtitle {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%) translateY(6px);
  z-index: 4;
  max-width: 82%;
  padding: 0.55em 0.9em;
  background: rgba(8, 5, 14, 0.82);
  border-left: 3px solid #b8323f;
  color: #efe8dc;
  font-size: 0.62em;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.16s ease;
  pointer-events: none;
  text-align: center;
}

#subtitle.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 遮罩层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8em;
  padding: 1.2em;
  text-align: center;
  background:
    radial-gradient(circle at 50% 45%, rgba(48, 22, 66, 0.55) 0%, rgba(5, 3, 10, 0.92) 70%),
    rgba(5, 3, 10, 0.86);
  animation: fade-in 0.25s ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.overlay.hidden {
  display: none !important;
}

.overlay h1 {
  margin: 0;
  font-size: 2.6em;
  line-height: 1.02;
  letter-spacing: 0.03em;
  color: #f4ecff;
  text-shadow: 0 0.06em 0 #2a1236, 0 0.12em 0.3em rgba(0, 0, 0, 0.8);
}

.overlay h1 em {
  font-style: normal;
  display: block;
  color: #ff5f74;
  letter-spacing: 0.12em;
  text-shadow: 0 0 0.5em rgba(255, 60, 90, 0.55), 0 0.06em 0 #3a0d18;
}

.overlay h2 {
  margin: 0;
  font-size: 1.7em;
  letter-spacing: 0.04em;
  color: #f8f0ff;
  text-shadow: 0 0.1em 0.3em rgba(0, 0, 0, 0.8);
}

.overlay p {
  margin: 0;
  font-size: 0.66em;
  line-height: 1.75;
  color: #a99cc2;
}

.overlay .sub {
  color: #ffb3bd;
  letter-spacing: 0.08em;
}

.eyebrow {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.55em !important;
  letter-spacing: 0.32em;
  color: #8d7fb0 !important;
}

.overlay .keys {
  list-style: none;
  margin: 0.4em 0 0;
  padding: 0.7em 1.1em;
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  font-size: 0.6em;
  color: #b8add0;
  background: rgba(20, 13, 32, 0.6);
  border: 1px solid rgba(170, 150, 220, 0.18);
  border-radius: 0.3em;
}

.overlay .keys b {
  color: #f0e8ff;
  font-family: Consolas, monospace;
}

.overlay .foot {
  position: absolute;
  bottom: 1.1em;
  font-size: 0.48em;
  color: #6b6280;
}

.overlay button {
  margin-top: 0.4em;
  font: inherit;
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #fff;
  background: linear-gradient(180deg, #c13a4a, #8e2431);
  border: 1px solid #ff8c9a;
  border-radius: 0.25em;
  padding: 0.7em 1.9em;
  cursor: pointer;
  box-shadow: 0 0.25em 0 #4a0f18, 0 0.5em 1.2em rgba(0, 0, 0, 0.55);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.overlay button:hover {
  transform: translateY(-1px);
  box-shadow: 0 0.32em 0 #4a0f18, 0 0.6em 1.4em rgba(0, 0, 0, 0.6);
}

.overlay button:active {
  transform: translateY(2px);
  box-shadow: 0 0.1em 0 #4a0f18;
}

#clear-time {
  color: #ffd9a0;
  font-size: 0.7em;
}

#clear-unlock {
  color: #9fffe1;
  font-size: 0.72em;
  line-height: 1.7;
  text-shadow: 0 0 0.6em rgba(105, 227, 194, 0.35);
}

#clear-unlock:empty {
  display: none;
}

#end-stats {
  color: #d8cdee;
  font-size: 0.66em;
  line-height: 1.9;
}

/* ---------- 触屏按钮 ---------- */
#touch-pad {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 6;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0.8em;
  pointer-events: none;
}

#touch-pad.hidden {
  display: none !important;
}

.pad-left {
  display: flex;
  gap: 0.6em;
}

.pad-right {
  display: flex;
  gap: 0.6em;
}

#touch-pad button.hidden {
  display: none !important;
}

#touch-pad button {
  pointer-events: auto;
  width: 2.9em;
  height: 2.9em;
  border-radius: 50%;
  border: 2px solid rgba(220, 200, 255, 0.45);
  background: rgba(28, 18, 44, 0.55);
  color: #ede6ff;
  font: inherit;
  font-size: 0.85em;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

#touch-pad button:active {
  background: rgba(184, 50, 63, 0.65);
  border-color: #ff9aa8;
}

#btn-jump {
  width: 3.6em !important;
  height: 3.6em !important;
  background: rgba(184, 50, 63, 0.5) !important;
  border-color: rgba(255, 150, 165, 0.7) !important;
}

#btn-attack {
  background: rgba(53, 118, 102, 0.6) !important;
  border-color: rgba(150, 235, 210, 0.7) !important;
}

#btn-blink {
  background: rgba(72, 73, 156, 0.6) !important;
  border-color: rgba(180, 180, 255, 0.7) !important;
}

#btn-ultimate {
  background: rgba(184, 114, 40, 0.65) !important;
  border-color: rgba(255, 209, 102, 0.8) !important;
}

#touch-pad button:disabled {
  opacity: 0.35;
}
