* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #cfe6f5;
  color: #2b3a4a;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
#app { position: fixed; inset: 0; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---- 闪电白屏 ---- */
#flash {
  position: absolute; inset: 0; background: #fff; opacity: 0;
  pointer-events: none; z-index: 40; transition: opacity 0.05s;
}

/* ---- HUD ---- */
#hud { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.hud-top {
  position: absolute; top: 14px; left: 14px; right: 14px;
  display: flex; gap: 10px; align-items: stretch;
}
.hud-card {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(6px);
  border-radius: 14px; padding: 8px 14px;
  box-shadow: 0 3px 14px rgba(30, 50, 80, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.9);
}
.score-card { min-width: 118px; }
.score-card .label { font-size: 11px; color: #7189a3; letter-spacing: 2px; }
.score-card .value { font-size: 30px; font-weight: 800; color: #1f3550; line-height: 1.05; font-variant-numeric: tabular-nums; }
.score-card .sub { font-size: 12px; font-weight: 700; color: #e8891c; }
.hud-card.mid { flex: 1; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.stage-line { display: flex; align-items: baseline; gap: 8px; font-size: 14px; white-space: nowrap; overflow: hidden; }
.stage-idx { color: #93a7bd; font-size: 12px; font-weight: 700; flex: none; }
.stage-name { font-weight: 800; color: #24425f; }
.weather { color: #5d7a99; margin-left: auto; font-size: 13px; flex: none; }
.progress { height: 6px; border-radius: 3px; background: rgba(120, 145, 175, 0.25); margin-top: 6px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; border-radius: 3px; background: linear-gradient(90deg, #ffb54a, #ff8a3c); transition: width 0.3s linear; }
.hud-card.right { min-width: 96px; text-align: right; }
.coin-row { font-size: 19px; font-weight: 800; color: #b07a12; display: flex; gap: 6px; justify-content: flex-end; }
.dist-row { font-size: 12px; color: #5d7a99; font-weight: 600; }

.hud-bottom {
  position: absolute; bottom: 16px; left: 14px; right: 14px;
  display: flex; align-items: flex-end; gap: 14px;
}
.speed-wrap { background: rgba(255,255,255,0.82); border-radius: 14px; padding: 8px 14px; box-shadow: 0 3px 14px rgba(30,50,80,.16); min-width: 150px; }
.speed-num { font-size: 22px; font-weight: 800; color: #1f3550; font-variant-numeric: tabular-nums; }
.speed-num small { font-size: 12px; color: #7189a3; font-weight: 600; }
.speed-bar { height: 6px; border-radius: 3px; background: rgba(120,145,175,.25); margin-top: 4px; overflow: hidden; }
.speed-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #4bc06a, #ffb54a, #e8452c); border-radius: 3px; transition: width .2s; }

.pu-list { display: flex; gap: 8px; flex: 1; justify-content: flex-end; }
.pu-badge {
  background: rgba(255,255,255,.88); border-radius: 12px; padding: 6px 10px 7px;
  box-shadow: 0 3px 10px rgba(30,50,80,.18); min-width: 74px; position: relative; overflow: hidden;
}
.pu-badge .pu-name { font-size: 12px; font-weight: 800; display: flex; gap: 5px; align-items: center; }
.pu-badge .pu-timer { height: 4px; background: rgba(120,145,175,.2); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.pu-badge .pu-timer-fill { height: 100%; background: currentColor; border-radius: 2px; }

.hud-buttons { position: absolute; top: 84px; right: 14px; display: flex; flex-direction: column; gap: 8px; pointer-events: auto; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: none; cursor: pointer;
  background: rgba(255,255,255,.85); box-shadow: 0 3px 10px rgba(30,50,80,.2);
  font-size: 18px; color: #2b4157; transition: transform .12s;
}
.icon-btn:hover { transform: scale(1.08); }

/* ---- 连击浮字 ---- */
.combo-pop {
  position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%) scale(.6);
  font-size: 30px; font-weight: 900; color: #ff8a1c; opacity: 0;
  text-shadow: 0 2px 0 #fff, 0 4px 14px rgba(255,150,40,.55); z-index: 25; pointer-events: none;
}
.combo-pop.pop { animation: popAnim .8s ease-out; }
@keyframes popAnim {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.5); }
  18% { opacity: 1; transform: translate(-50%,-52%) scale(1.15); }
  70% { opacity: 1; transform: translate(-50%,-56%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-62%) scale(.9); }
}

/* ---- 阶段横幅 ---- */
.banner {
  position: absolute; left: 50%; top: 18%; transform: translateX(-50%);
  text-align: center; z-index: 26; pointer-events: none;
  animation: bannerIn 3.4s ease forwards;
}
.banner-sub { font-size: 13px; letter-spacing: 6px; color: #fff; text-shadow: 0 2px 8px rgba(30,50,80,.6); font-weight: 700; }
.banner-name { font-size: 44px; font-weight: 900; color: #fff; text-shadow: 0 3px 0 rgba(40,70,110,.35), 0 8px 26px rgba(20,40,70,.5); }
.banner-mood { display: inline-block; margin-top: 6px; padding: 3px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; color: #fff; }
.banner-mood.serene { background: rgba(70, 150, 90, .85); }
.banner-mood.thrilling { background: rgba(210, 70, 40, .85); }
@keyframes bannerIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(18px); }
  10% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-12px); }
}

/* ---- 中央消息 ---- */
.center-msg {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%,-50%);
  font-size: 110px; font-weight: 900; color: #fff; z-index: 30;
  text-shadow: 0 4px 0 rgba(40,70,110,.3), 0 10px 34px rgba(20,40,70,.45);
  pointer-events: none;
}
.center-msg.small { font-size: 40px; }

/* ---- 覆盖层 ---- */
.overlay {
  position: absolute; inset: 0; z-index: 50;
  background: linear-gradient(180deg, rgba(235, 246, 255, .72), rgba(210, 232, 250, .82));
  backdrop-filter: blur(7px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px; overflow-y: auto;
}
.panel {
  background: #fff; border-radius: 24px; padding: 30px 34px;
  box-shadow: 0 18px 60px rgba(40, 70, 110, .28);
  max-width: 460px; width: 100%; text-align: center;
}

.logo-ico { font-size: 42px; }
.panel h1 { font-size: 40px; font-weight: 900; color: #1f3550; letter-spacing: 2px; margin-top: 4px; }
.logo-sub { font-size: 12px; letter-spacing: 4px; color: #8ba1b8; margin-top: 2px; }

.menu-best {
  margin: 16px auto 4px; padding: 8px 18px; border-radius: 999px; width: fit-content;
  background: #fff4df; color: #b07a12; font-weight: 800; font-size: 15px;
}
.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 14px 0; }
.ctrl {
  display: flex; flex-direction: column; gap: 2px; padding: 7px 8px;
  background: #f3f7fb; border-radius: 12px;
}
.key { font-size: 12px; font-weight: 800; color: #2b4157; }
.act { font-size: 12px; color: #7a92aa; }

.tips { font-size: 12.5px; color: #7a92aa; line-height: 1.7; margin-bottom: 16px; }
.tips b { color: #d2701c; }

.btn {
  border: none; cursor: pointer; border-radius: 14px; font-weight: 800;
  padding: 13px 26px; font-size: 16px; transition: transform .12s, box-shadow .12s;
}
.btn.primary {
  background: linear-gradient(180deg, #ffb54a, #f07f1f); color: #fff;
  box-shadow: 0 6px 18px rgba(232, 137, 28, .45);
}
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(232, 137, 28, .5); }
.btn.big { width: 100%; font-size: 19px; padding: 16px; }
.btn.ghost { background: #eef3f8; color: #41586f; }
.btn.ghost:hover { background: #e2eaf2; }
.menu-foot { display: flex; gap: 18px; justify-content: center; margin-top: 16px; }
.check { font-size: 13px; color: #5d7a99; cursor: pointer; display: flex; gap: 5px; align-items: center; }
.check input { accent-color: #f07f1f; cursor: pointer; }

/* ---- 结束面板 ---- */
.over-panel h2 { font-size: 30px; font-weight: 900; color: #1f3550; }
.new-record {
  margin: 8px auto 0; width: fit-content; padding: 4px 16px; border-radius: 999px;
  background: linear-gradient(90deg, #ffe08a, #ffc23c); color: #7a5200; font-weight: 900;
  animation: recordPulse 1.2s infinite;
}
@keyframes recordPulse { 50% { transform: scale(1.06); } }
.over-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0 6px; }
.stat {
  background: #f3f7fb; border-radius: 14px; padding: 10px 4px; display: flex; flex-direction: column;
}
.stat-v { font-size: 21px; font-weight: 900; color: #1f3550; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 11px; color: #8ba1b8; }
.board-title { margin-top: 12px; font-weight: 800; color: #41586f; font-size: 14px; }
.board { list-style: none; margin: 8px 0 18px; text-align: left; }
.board li {
  display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 10px;
  font-size: 14px; color: #41586f; margin-bottom: 4px; background: #f7fafc;
}
.board li .rank { font-weight: 900; color: #93a7bd; width: 20px; }
.board li .b-score { font-weight: 800; color: #1f3550; margin-left: auto; font-variant-numeric: tabular-nums; }
.board li .b-meta { font-size: 12px; color: #93a7bd; }
.board li.me { background: #fff2dd; outline: 2px solid #ffc23c; }
.over-btns { display: flex; gap: 10px; }
.over-btns .btn { flex: 1; }

@media (max-width: 640px) {
  .hud-card { padding: 6px 10px; }
  .score-card .value { font-size: 22px; }
  .banner-name { font-size: 30px; }
  .center-msg { font-size: 76px; }
  .over-stats { grid-template-columns: repeat(2, 1fr); }
  .speed-wrap { min-width: 120px; }
}
