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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #070312;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #241146 0%, #0b0518 70%);
}

#game-container {
  position: relative;
  width: min(100vw, 50vh);
  width: min(100vw, 50dvh);
  height: min(200vw, 100vh);
  height: min(200vw, 100dvh);
  max-width: 520px;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(126, 87, 194, 0.35);
}

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

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(11, 5, 24, 0.85), transparent);
}
.hud-group { display: flex; gap: 6px; align-items: center; }
.hud-chip {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 5px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 50px;
  backdrop-filter: blur(6px);
}
.hud-label { font-size: 9px; opacity: 0.65; letter-spacing: 1px; }
.hud-chip b { font-size: 15px; line-height: 1.2; }
.hearts { color: #ff6b9d; font-size: 14px !important; letter-spacing: 1px; }

.icon-btn {
  pointer-events: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.icon-btn:active { transform: scale(0.92); }

/* ---------- 增益条 ---------- */
#effects-bar {
  position: absolute;
  top: 72px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: none;
}
.eff {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  padding: 3px 8px 3px 5px;
  font-size: 12px;
  animation: effIn 0.25s ease-out;
}
.eff span { font-size: 15px; }
.eff small { opacity: 0.8; font-size: 10px; }
@keyframes effIn { from { transform: translateX(-20px); opacity: 0; } }

/* ---------- 发射提示 ---------- */
#ready-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22%;
  text-align: center;
  pointer-events: none;
  animation: pulse 1.5s ease-in-out infinite;
}
.hint-ball {
  width: 16px;
  height: 16px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 18px 4px rgba(127, 216, 255, 0.8);
}
#ready-hint span { display: block; font-size: 15px; font-weight: 700; text-shadow: 0 2px 8px #000; }
#ready-hint small { display: block; margin-top: 4px; font-size: 11px; opacity: 0.7; }
@keyframes pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* ---------- 弹层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 4, 20, 0.78);
  backdrop-filter: blur(8px);
  z-index: 10;
  animation: fadeIn 0.25s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } }

.menu-content { text-align: center; width: 100%; }
.logo-heart {
  font-size: 54px;
  color: #ff5c8a;
  text-shadow: 0 0 28px rgba(255, 92, 138, 0.75);
  animation: beat 1.6s ease-in-out infinite;
}
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.18); } 30% { transform: scale(1); } 45% { transform: scale(1.12); } }
.title {
  margin: 6px 0 0;
  font-size: 38px;
  letter-spacing: 4px;
  background: linear-gradient(90deg, #ff8fb1, #ffd166, #7ee8fa, #b28dff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 10px rgba(178, 141, 255, 0.35));
}
.subtitle { margin: 2px 0 26px; font-size: 11px; letter-spacing: 5px; opacity: 0.55; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; max-width: 260px; margin: 0 auto; }

.btn {
  border: none;
  border-radius: 14px;
  padding: 13px 20px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  transition: transform 0.12s, filter 0.12s;
  font-family: inherit;
}
.btn:active { transform: scale(0.96); filter: brightness(1.15); }
.btn-primary {
  background: linear-gradient(135deg, #ff5c8a, #a66cff);
  box-shadow: 0 6px 22px rgba(255, 92, 138, 0.4);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-small { padding: 9px 14px; font-size: 13px; }

.howto {
  margin: 26px auto 0;
  max-width: 300px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 12px 14px;
  text-align: left;
}
.howto-title { font-size: 12px; font-weight: 700; color: #ffd166; margin-bottom: 6px; }
.howto p { margin: 4px 0; font-size: 11px; line-height: 1.6; opacity: 0.8; }
.footer-tip { margin-top: 18px; font-size: 10px; opacity: 0.45; }

/* ---------- 面板 ---------- */
.panel {
  width: 100%;
  max-width: 300px;
  background: linear-gradient(160deg, rgba(58, 30, 95, 0.95), rgba(24, 12, 46, 0.97));
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  padding: 26px 22px;
  text-align: center;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
}
.panel-wide { max-width: 360px; }
.panel-emoji { font-size: 46px; }
.panel h2 { margin: 6px 0 10px; font-size: 24px; }
.stars { font-size: 34px; color: #ffd166; letter-spacing: 4px; text-shadow: 0 0 14px rgba(255, 209, 102, 0.6); }
.panel-line { font-size: 13px; opacity: 0.85; margin: 10px 0 20px; }
.panel-line b { color: #ffd166; }
.panel-buttons { display: flex; flex-direction: column; gap: 9px; }

/* ---------- 关卡网格 ---------- */
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 16px 0 20px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 2px;
}
.lvl {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(145deg, rgba(166, 108, 255, 0.45), rgba(77, 150, 255, 0.28));
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  font-family: inherit;
}
.lvl:active { transform: scale(0.94); }
.lvl-num { font-size: 18px; font-weight: 800; }
.lvl-stars { font-size: 8px; color: #ffd166; letter-spacing: -1px; }
.lvl.locked { opacity: 0.35; background: rgba(255, 255, 255, 0.06); cursor: not-allowed; }
.lvl.locked .lvl-stars { font-size: 12px; }

@media (max-height: 620px) {
  .howto { display: none; }
  .title { font-size: 30px; }
  .logo-heart { font-size: 40px; }
  .subtitle { margin-bottom: 16px; }
}
