* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: #0b0a14;
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #eee;
  -webkit-user-select: none;
  user-select: none;
}

body { display: flex; align-items: center; justify-content: center; }

#wrap {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #000;
  touch-action: none;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0,0,0,0.8);
}

#game { width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 14px;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0,0,0,0.7);
  z-index: 5;
}
#hud-left { text-align: left; }
#hearts { font-size: 20px; letter-spacing: 2px; }
#energy { font-size: 15px; color: #4cc9f0; letter-spacing: 3px; margin-top: 3px; }
#hud-mid { text-align: center; }
#score { font-size: 30px; font-weight: 800; }
#dist { font-size: 15px; opacity: 0.9; }
#hud-right { text-align: right; }
#coinhud { font-size: 18px; font-weight: 700; color: #f6c453; }
#powers { margin-top: 6px; min-height: 22px; }
.pb {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 5px;
  color: #fff;
}
.pb-magnet { background: #e03131; }
.pb-shield { background: #1971c2; }
.pb-boost  { background: #f08c00; }
.pb-double { background: #7048e8; }
#pauseBtn {
  pointer-events: auto;
  margin-top: 6px;
  font-size: 16px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
}

/* ---------- 面板 ---------- */
.panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 6, 20, 0.72);
  z-index: 10;
}
.box {
  background: rgba(20, 16, 40, 0.95);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  padding: 26px 34px;
  text-align: center;
  max-width: 88%;
  max-height: 92%;
  overflow-y: auto;
  box-shadow: 0 10px 50px rgba(0,0,0,0.6);
}
h1 {
  font-size: 42px;
  letter-spacing: 6px;
  margin-bottom: 10px;
  background: linear-gradient(180deg, #ffe066, #f08c00);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}
h2 { font-size: 28px; margin-bottom: 14px; color: #ffe066; }
.best { font-size: 14px; opacity: 0.9; margin-bottom: 18px; }
.best b { color: #ffe066; }
.wallet { font-size: 18px; color: #f6c453; font-weight: 700; margin-bottom: 12px; }

button {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #5f3dc4, #4c32a8);
  border: none;
  border-radius: 10px;
  padding: 10px 22px;
  margin: 6px 4px;
  cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}
button:hover { filter: brightness(1.2); }
button:active { transform: scale(0.95); }
button:disabled { filter: grayscale(0.7); cursor: default; }
button.big {
  font-size: 22px;
  padding: 14px 48px;
  background: linear-gradient(180deg, #f59f00, #e67700);
  display: block;
  margin: 8px auto;
}
.row { display: flex; justify-content: center; flex-wrap: wrap; }
.hint { margin-top: 16px; font-size: 13px; line-height: 1.8; opacity: 0.65; }
.backBtn { background: #495057; margin-top: 14px; }

/* ---------- 皮肤 ---------- */
#skinList { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.skinItem {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 10px;
  width: 108px;
}
.skinItem canvas { display: block; margin: 0 auto 4px; }
.skinName { font-size: 14px; margin-bottom: 6px; }
.skinItem button { font-size: 13px; padding: 6px 12px; margin: 0; }

/* ---------- 任务 ---------- */
.mission {
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 8px 0;
  text-align: left;
  min-width: 300px;
}
.mission.done { outline: 1px solid #40c057; }
.mtext { font-size: 15px; margin-bottom: 6px; }
.mbar { height: 8px; background: rgba(255,255,255,0.12); border-radius: 4px; overflow: hidden; }
.mfill { height: 100%; background: linear-gradient(90deg, #f59f00, #ffe066); border-radius: 4px; }
.mprog { font-size: 12px; opacity: 0.8; margin-top: 4px; }

/* ---------- 结算 ---------- */
#overStats { margin-bottom: 14px; }
.stat { font-size: 17px; margin: 6px 0; }
.stat b { color: #ffe066; }
.newbest { font-size: 18px; color: #ffe066; margin-top: 8px; animation: blink 0.8s infinite alternate; }
@keyframes blink { from { opacity: 1; } to { opacity: 0.5; } }

/* ---------- 提示 toast ---------- */
#toast {
  position: absolute;
  bottom: 18%;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 16, 40, 0.92);
  border: 1px solid rgba(255,224,102,0.5);
  color: #ffe066;
  font-size: 16px;
  font-weight: 700;
  padding: 8px 20px;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 700px) {
  h1 { font-size: 30px; }
  .box { padding: 18px 20px; }
  #score { font-size: 24px; }
}
