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

:root {
  --cyan: #57e6ff;
  --blue: #4a7cff;
  --violet: #a06bff;
  --gold: #ffd76a;
  --ink: #eaf2ff;
}

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #05081c;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}

#app { position: fixed; inset: 0; overflow: hidden; }
#game { display: block; width: 100%; height: 100%; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0 0 auto 0; padding: max(14px, env(safe-area-inset-top)) 16px 0; z-index: 5; pointer-events: none; }
.hud-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; max-width: 1100px; margin: 0 auto; }

.hud-card {
  background: rgba(12, 20, 52, .55);
  border: 1px solid rgba(140, 190, 255, .22);
  border-radius: 14px;
  padding: 6px 14px;
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .25);
  display: flex; flex-direction: column; align-items: center; min-width: 76px;
}
.hud-label { font-size: 10px; letter-spacing: 2px; opacity: .62; }
.hud-card strong { font-size: clamp(18px, 3.4vw, 26px); line-height: 1.15; font-variant-numeric: tabular-nums; text-shadow: 0 0 14px rgba(87, 230, 255, .55); }

.hud-center { flex: 1; text-align: center; padding-top: 4px; min-width: 0; }
#levelName { font-size: clamp(11px, 2.2vw, 14px); letter-spacing: 1px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-track { margin: 8px auto 0; width: min(260px, 70%); height: 5px; border-radius: 6px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.progress-track i { display: block; height: 100%; width: 0%; border-radius: 6px; background: linear-gradient(90deg, var(--cyan), var(--violet)); box-shadow: 0 0 12px var(--cyan); transition: width .12s linear; }

.hud-right { display: flex; gap: 8px; align-items: flex-start; pointer-events: auto; }
.best-card strong { color: var(--gold); text-shadow: 0 0 14px rgba(255, 215, 106, .5); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; cursor: pointer;
  border: 1px solid rgba(140, 190, 255, .22);
  background: rgba(12, 20, 52, .55); color: var(--ink);
  font-size: 17px; backdrop-filter: blur(10px); transition: .2s;
}
.icon-btn:hover { background: rgba(87, 230, 255, .18); transform: translateY(-2px); }
.icon-btn.off { opacity: .4; }

.toast {
  position: fixed; left: 50%; top: 20%; z-index: 8; transform: translate(-50%, -8px);
  font-size: clamp(16px, 3.6vw, 24px); font-weight: 700; letter-spacing: 3px;
  color: #fff; text-shadow: 0 0 24px var(--cyan), 0 2px 12px rgba(0,0,0,.6);
  opacity: 0; transition: opacity .35s, transform .35s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 全屏面板 ---------- */
.screen {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 40%, rgba(24, 36, 92, .35), rgba(3, 6, 22, .82));
  backdrop-filter: blur(3px);
  animation: fadeIn .35s ease both;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.panel {
  width: min(440px, 100%);
  max-height: 96vh; overflow: auto;
  padding: clamp(22px, 4vw, 38px) clamp(20px, 4vw, 36px) clamp(20px, 3.4vw, 30px);
  text-align: center;
  background: linear-gradient(160deg, rgba(30, 44, 100, .72), rgba(10, 16, 46, .82));
  border: 1px solid rgba(150, 200, 255, .22);
  border-radius: 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .12);
  scrollbar-width: none;
}
.panel::-webkit-scrollbar { display: none; }
.small-panel { width: min(380px, 100%); }

.avatar-ring {
  width: clamp(108px, 24vw, 146px); height: clamp(108px, 24vw, 146px);
  margin: 0 auto 16px; border-radius: 50%; padding: 4px;
  background: linear-gradient(135deg, var(--cyan), var(--violet) 55%, var(--gold));
  box-shadow: 0 0 34px rgba(87, 230, 255, .45), 0 0 70px rgba(160, 107, 255, .28);
  animation: floaty 3.6s ease-in-out infinite;
}
.small-ring { width: 86px; height: 86px; margin-bottom: 12px; }
.avatar { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 26%; display: block; background: #fff; }
@keyframes floaty { 0%,100% { transform: translateY(0) rotate(-2deg) } 50% { transform: translateY(-9px) rotate(2deg) } }

.title {
  font-size: clamp(28px, 7vw, 42px); font-weight: 900; letter-spacing: 2px; line-height: 1.2;
  background: linear-gradient(100deg, #8ff3ff, #c9b3ff 45%, #ffd76a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 18px rgba(120, 170, 255, .5));
}
.title.small { font-size: clamp(24px, 5.4vw, 32px); }
.subtitle { margin-top: 6px; font-size: 10px; letter-spacing: 3px; opacity: .55; }
.desc { margin: 18px 0 4px; font-size: clamp(12px, 2.7vw, 14px); line-height: 1.9; opacity: .8; }

.how { display: flex; justify-content: center; gap: 10px; margin: 20px 0 24px; }
.how-item {
  flex: 1; max-width: 110px; padding: 12px 4px;
  border: 1px solid rgba(150, 200, 255, .16); border-radius: 14px;
  background: rgba(255, 255, 255, .04);
}
.how-item span { display: block; font-size: 20px; color: var(--cyan); text-shadow: 0 0 14px rgba(87,230,255,.7); }
.how-item small { display: block; margin-top: 5px; font-size: 11px; opacity: .7; }

.primary-btn {
  width: 100%; padding: 15px 20px; border: 0; border-radius: 16px; cursor: pointer;
  font-size: 17px; font-weight: 800; letter-spacing: 3px; color: #06122e;
  background: linear-gradient(100deg, #6ff0ff, #7ea6ff 50%, #b98cff);
  box-shadow: 0 10px 30px rgba(90, 160, 255, .38), inset 0 1px 0 rgba(255,255,255,.6);
  transition: transform .18s, box-shadow .18s;
}
.primary-btn:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 16px 40px rgba(90, 160, 255, .55); }
.primary-btn:active { transform: translateY(0) scale(.98); }
.ghost-btn {
  display: block; width: 100%; margin-top: 10px; padding: 11px;
  border: 1px solid rgba(150, 200, 255, .22); border-radius: 14px; cursor: pointer;
  background: transparent; color: var(--ink); font-size: 13px; opacity: .75; transition: .2s;
}
.ghost-btn:hover { opacity: 1; background: rgba(255,255,255,.07); }
.foot-tip { margin-top: 16px; font-size: 10px; line-height: 1.8; opacity: .45; }

.result { display: flex; justify-content: space-around; gap: 8px; margin: 22px 0 18px; }
.result div { display: flex; flex-direction: column; gap: 5px; }
.result span { font-size: 11px; opacity: .6; }
.result strong { font-size: clamp(20px, 5vw, 28px); font-variant-numeric: tabular-nums; color: var(--cyan); }
.result div:last-child strong { color: var(--gold); }
.new-record { color: var(--gold); font-size: 13px; letter-spacing: 1px; margin: -6px 0 16px; text-shadow: 0 0 16px rgba(255,215,106,.7); animation: floaty 2s ease-in-out infinite; }

/* ---------- 触屏方向键 ---------- */
#touchControls {
  position: absolute; left: 0; right: 0; bottom: max(22px, env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; padding: 0 22px; z-index: 6;
  pointer-events: none;
}
#touchControls button {
  pointer-events: auto; width: 74px; height: 74px; border-radius: 50%;
  border: 1px solid rgba(150, 200, 255, .3);
  background: rgba(16, 28, 70, .42); backdrop-filter: blur(8px);
  color: rgba(230, 245, 255, .85); font-size: 24px; cursor: pointer;
  box-shadow: 0 8px 26px rgba(0,0,0,.3); transition: .12s;
}
#touchControls button:active { transform: scale(.9); background: rgba(87, 230, 255, .3); }

@media (max-height: 620px) {
  .avatar-ring { width: 84px; height: 84px; margin-bottom: 8px; }
  .how { margin: 12px 0 14px; }
  .desc { margin: 10px 0 4px; }
  .foot-tip { margin-top: 10px; }
}
