* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05060f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #e8f0ff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 竖屏时把整个游戏旋转 90° 变成横版（配合 js 中的坐标换算） */
#app.rotated {
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  width: 100vh;
  height: 100vw;
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center center;
}

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

.hidden {
  display: none !important;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) calc(env(safe-area-inset-right, 0px) + 18px) 0 calc(env(safe-area-inset-left, 0px) + 18px);
  pointer-events: none;
  z-index: 5;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-score {
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 0 14px rgba(80, 220, 255, 0.9), 0 0 4px rgba(80, 220, 255, 0.9);
}

.hud-best {
  font-size: 13px;
  color: #8fb4e0;
  letter-spacing: 1px;
}

.icon-btn {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(120, 200, 255, 0.35);
  background: rgba(30, 50, 90, 0.4);
  color: #cfe6ff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  backdrop-filter: blur(6px);
  cursor: pointer;
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ---------- 连击徽章 ---------- */
.combo-chip {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 14px;
  border-radius: 14px;
  color: #ffe680;
  background: rgba(255, 190, 60, 0.12);
  border: 1px solid rgba(255, 200, 90, 0.35);
  box-shadow: 0 0 12px rgba(255, 190, 60, 0.25);
  opacity: 0.4;
  transition: opacity 0.2s ease, transform 0.12s ease, box-shadow 0.2s ease;
}

.combo-main {
  display: flex;
  align-items: baseline;
  font-weight: 900;
  font-size: 26px;
  line-height: 1;
}

.combo-chip .combo-x {
  font-size: 14px;
  margin-right: 1px;
}

.combo-sub {
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: 1px;
  color: #ffcf8a;
}

.combo-chip.active {
  opacity: 1;
  border-color: rgba(255, 210, 110, 0.7);
  box-shadow: 0 0 18px rgba(255, 190, 60, 0.5);
}

.combo-chip.hot {
  color: #fff;
  background: rgba(255, 120, 60, 0.22);
  border-color: rgba(255, 160, 90, 0.9);
  box-shadow: 0 0 26px rgba(255, 140, 70, 0.75);
}

.combo-chip.bump {
  transform: scale(1.35);
}

/* ---------- 护盾徽章 ---------- */
.shield-badge {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 84px);
  left: 18px;
  z-index: 5;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #7dffd0;
  background: rgba(60, 255, 200, 0.12);
  border: 1px solid rgba(90, 255, 210, 0.5);
  box-shadow: 0 0 16px rgba(90, 255, 210, 0.4);
  animation: shieldPulse 1.4s ease-in-out infinite;
}

@keyframes shieldPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(90, 255, 210, 0.3); }
  50% { box-shadow: 0 0 22px rgba(90, 255, 210, 0.7); }
}

/* ---------- 增益状态条 ---------- */
.buff-bar {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 60px);
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px;
  pointer-events: none;
}

.buff-tag {
  position: relative;
  padding: 4px 10px 7px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--c);
  background: rgba(10, 14, 34, 0.55);
  border: 1px solid var(--c);
  box-shadow: 0 0 14px -4px var(--c);
}

.buff-tag .buff-time {
  margin-left: 6px;
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
}

.buff-tag .buff-underline {
  position: absolute;
  left: 6px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--c);
  box-shadow: 0 0 6px var(--c);
  transition: width 0.1s linear;
}

/* ---------- 加速横幅 ---------- */
.banner {
  position: absolute;
  top: 32%;
  left: 0;
  right: 0;
  z-index: 8;
  text-align: center;
  pointer-events: none;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 20px rgba(120, 220, 255, 0.95), 0 0 8px rgba(180, 120, 255, 0.9);
  animation: bannerIn 1.2s ease forwards;
}

@keyframes bannerIn {
  0% { opacity: 0; transform: translateY(14px) scale(0.9); }
  18% { opacity: 1; transform: translateY(0) scale(1); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px) scale(1.04); }
}

/* ---------- 顶部能量条 ---------- */
.energy-hud {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  width: min(340px, 40vw);
  pointer-events: none;
}

.energy-head {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.energy-label {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #cfe6ff;
}

.energy-hint {
  font-size: 11px;
  color: #8fb4e0;
  letter-spacing: 0.5px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.energy-bar {
  height: 18px;
  border-radius: 999px;
  background: rgba(20, 34, 62, 0.75);
  border: 1px solid rgba(110, 190, 255, 0.35);
  overflow: hidden;
}

.energy-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5ff0ff, #7aa2ff, #c07bff);
  box-shadow: 0 0 12px rgba(120, 180, 255, 0.7);
  transition: width 0.12s linear;
}

.energy-fill.full {
  background: linear-gradient(90deg, #ffe680, #ff9a3d, #ff5a7a);
  box-shadow: 0 0 16px rgba(255, 190, 60, 0.9);
}

.energy-fill.dashing {
  background: linear-gradient(90deg, #b96bff, #ff6ec7);
  box-shadow: 0 0 18px rgba(200, 110, 255, 0.9);
}

/* ---------- 底部冲刺按钮 ---------- */
.skill-bar {
  position: absolute;
  right: calc(env(safe-area-inset-right, 0px) + 18px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  z-index: 6;
  pointer-events: none;
}

.dash-btn {
  pointer-events: auto;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 2px solid rgba(120, 200, 255, 0.35);
  background: radial-gradient(circle at 50% 35%, rgba(60, 90, 150, 0.55), rgba(20, 30, 60, 0.75));
  color: #6f8bb5;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: transform 0.12s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.dash-title {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 2px;
}

.dash-sub {
  font-size: 10px;
  letter-spacing: 3px;
  opacity: 0.8;
}

.dash-btn:disabled {
  opacity: 0.55;
}

.dash-btn.ready {
  color: #04121e;
  border-color: rgba(255, 220, 130, 0.9);
  background: radial-gradient(circle at 50% 35%, #fff0b8, #ff9a3d 62%, #ff5a7a);
  box-shadow: 0 0 26px rgba(255, 180, 60, 0.85), 0 0 8px rgba(255, 220, 130, 0.9);
  animation: dashPulse 1s ease-in-out infinite;
}

.dash-btn:active {
  transform: scale(0.93);
}

@keyframes dashPulse {
  0%, 100% { box-shadow: 0 0 18px rgba(255, 180, 60, 0.6); }
  50% { box-shadow: 0 0 34px rgba(255, 210, 90, 0.95); }
}

/* ---------- 操作提示（首次开局） ---------- */
.controls-hint {
  position: absolute;
  top: 42%;
  left: 0;
  right: 0;
  z-index: 7;
  text-align: center;
  pointer-events: none;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #e8f6ff;
  text-shadow: 0 0 14px rgba(110, 240, 255, 0.9), 0 2px 6px rgba(0, 0, 0, 0.6);
  animation: hintFade 2.4s ease forwards;
}

.controls-hint .k {
  color: #6ef0ff;
}

.controls-hint .k2 {
  color: #ffd76e;
}

@keyframes hintFade {
  0% { opacity: 0; transform: translateY(12px); }
  15% { opacity: 1; transform: translateY(0); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
  background: radial-gradient(
    circle at 50% 40%,
    rgba(20, 30, 70, 0.55),
    rgba(5, 6, 15, 0.86) 70%
  );
  backdrop-filter: blur(3px);
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.panel {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 30px 22px;
  border-radius: 22px;
  background: linear-gradient(
    160deg,
    rgba(30, 48, 96, 0.55),
    rgba(12, 18, 40, 0.75)
  );
  border: 1px solid rgba(110, 190, 255, 0.28);
  box-shadow: 0 0 40px rgba(60, 130, 255, 0.18),
    inset 0 0 30px rgba(60, 130, 255, 0.06);
}

.title {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(90deg, #5ff0ff, #b96bff, #ff6ec7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 16px rgba(120, 180, 255, 0.55));
}

.title.small {
  font-size: 28px;
  margin-bottom: 18px;
}

.subtitle {
  margin-top: 4px;
  font-size: 12px;
  letter-spacing: 6px;
  color: #7fa6d8;
}

.best-badge {
  margin: 18px 0 6px;
  font-size: 14px;
  color: #9fc2ee;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(80, 150, 255, 0.12);
  border: 1px solid rgba(100, 180, 255, 0.25);
}

.best-badge span {
  color: #5ff0ff;
  font-weight: 800;
}

.primary-btn {
  width: 100%;
  margin-top: 18px;
  padding: 15px;
  border: none;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #04121e;
  cursor: pointer;
  background: linear-gradient(135deg, #6ef0ff, #7aa2ff 55%, #c07bff);
  box-shadow: 0 6px 22px rgba(90, 170, 255, 0.42);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.primary-btn:active {
  transform: scale(0.97);
  box-shadow: 0 3px 12px rgba(90, 170, 255, 0.35);
}

.ghost-btn {
  width: 100%;
  margin-top: 10px;
  padding: 13px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #cfe6ff;
  cursor: pointer;
  background: transparent;
  border: 1px solid rgba(120, 200, 255, 0.4);
}

.ghost-btn:active {
  transform: scale(0.97);
  background: rgba(80, 150, 255, 0.12);
}

.text-btn {
  margin-top: 12px;
  padding: 8px 10px;
  background: none;
  border: none;
  color: #8fb4e0;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  border-radius: 8px;
}

.text-btn:active {
  color: #5ff0ff;
}

.tips {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 13px;
  color: #8ba9cf;
}

.gesture {
  display: inline-block;
  min-width: 96px;
  margin-right: 6px;
  padding: 3px 10px;
  border-radius: 8px;
  background: rgba(90, 150, 255, 0.14);
  border: 1px solid rgba(110, 190, 255, 0.28);
  color: #bcd8ff;
  font-weight: 600;
}

.score-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 4px;
  color: #9fc2ee;
  font-size: 14px;
}

.score-row strong {
  font-size: 38px;
  color: #fff;
  text-shadow: 0 0 14px rgba(80, 220, 255, 0.8);
}

.final-score {
  font-size: 64px;
  font-weight: 900;
  line-height: 1.1;
  color: #fff;
  text-shadow: 0 0 22px rgba(90, 220, 255, 0.85),
    0 0 8px rgba(150, 120, 255, 0.8);
}

.new-record {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ffd76e;
  text-shadow: 0 0 14px rgba(255, 200, 80, 0.8);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.06);
  }
}

@media (max-height: 560px) {
  .title {
    font-size: 32px;
  }
  .panel {
    padding: 20px 18px;
  }
  .tips {
    display: none;
  }
}

/* ---------- 菜单金币与模式按钮 ---------- */
.menu-badges {
  display: flex;
  gap: 8px;
  align-items: center;
}

.menu-badges .best-badge {
  margin: 18px 0 6px;
}

.menu-row {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
}

.menu-row .ghost-btn {
  flex: 1;
  margin-top: 0;
}

.coins-badge {
  margin: 18px 0 6px;
  font-size: 14px;
  color: #ffe6a0;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 190, 60, 0.1);
  border: 1px solid rgba(255, 200, 90, 0.35);
}

.coins-badge span {
  color: #ffd76e;
  font-weight: 800;
}

/* ---------- 关卡进度条 ---------- */
.level-progress {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%);
  z-index: 6;
  width: min(320px, 34vw);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.level-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #cfe6ff;
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(90, 200, 255, 0.8);
}

.level-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(20, 34, 62, 0.75);
  border: 1px solid rgba(110, 190, 255, 0.35);
  overflow: hidden;
}

.level-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5ff0ff, #7dffb0);
  box-shadow: 0 0 10px rgba(110, 240, 255, 0.8);
  transition: width 0.12s linear;
}

/* ---------- 金币结算文本 ---------- */
.coin-result {
  margin-top: 10px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ffd76e;
  text-shadow: 0 0 12px rgba(255, 190, 60, 0.6);
}

.coin-result.big {
  font-size: 22px;
}

.coin-tag {
  margin-top: 4px;
  font-size: 12px;
  color: #9fc2ee;
}

.coins-inline {
  margin: 6px 0 4px;
  font-size: 13px;
  color: #9fc2ee;
}

.coins-inline span {
  color: #ffd76e;
  font-weight: 800;
}

/* ---------- 宽面板（关卡 / 角色） ---------- */
.panel.wide {
  max-width: 640px;
  padding: 22px 18px;
}

/* ---------- 关卡网格 ---------- */
.level-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 12px 0 8px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 4px;
}

.level-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border-radius: 14px;
  border: 1px solid rgba(110, 190, 255, 0.3);
  background: rgba(30, 50, 96, 0.45);
  color: #cfe6ff;
  cursor: pointer;
}

.level-cell .level-num {
  font-size: 22px;
  font-weight: 900;
}

.level-cell .level-state {
  font-size: 10px;
  letter-spacing: 1px;
  color: #8fb4e0;
}

.level-cell .level-goal {
  font-size: 9px;
  color: #6d89b8;
}

.level-cell.unlocked {
  border-color: rgba(110, 240, 255, 0.6);
  box-shadow: 0 0 14px -6px rgba(110, 240, 255, 0.9);
}

.level-cell.cleared {
  border-color: rgba(125, 255, 176, 0.55);
  background: rgba(30, 90, 70, 0.4);
}

.level-cell.cleared .level-state {
  color: #7dffb0;
}

.level-cell.locked {
  opacity: 0.4;
  cursor: default;
  filter: grayscale(0.6);
}

/* ---------- 角色网格 ---------- */
.char-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0 8px;
  max-height: 48vh;
  overflow-y: auto;
  padding: 4px;
}

.char-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 16px;
  border: 1px solid rgba(110, 190, 255, 0.25);
  background: rgba(24, 38, 80, 0.45);
}

.char-card.selected {
  border-color: rgba(255, 220, 130, 0.85);
  box-shadow: 0 0 18px -6px rgba(255, 200, 80, 0.9);
  background: rgba(60, 50, 24, 0.4);
}

.char-card.locked {
  opacity: 0.82;
}

.char-visual {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.char-name {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #e8f4ff;
}

.char-skill {
  font-size: 11px;
  color: #7dffd0;
}

.char-desc {
  font-size: 10px;
  line-height: 1.5;
  color: #8fa8cc;
  min-height: 30px;
}

.char-btn {
  width: 100%;
  margin-top: 4px;
  padding: 7px 0;
  border-radius: 10px;
  border: 1px solid rgba(110, 190, 255, 0.4);
  background: rgba(40, 70, 130, 0.6);
  color: #cfe6ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
}

.char-btn.cur {
  border-color: rgba(255, 220, 130, 0.8);
  color: #ffe6a0;
  background: rgba(80, 66, 20, 0.5);
  cursor: default;
}

.char-btn.buy {
  border-color: rgba(255, 200, 90, 0.8);
  color: #ffd76e;
  background: rgba(90, 70, 20, 0.5);
}

.char-btn.poor {
  opacity: 0.55;
}
