:root {
  --orange: #FF8A3D;
  --orange-deep: #F26E1B;
  --gold: #FFC53D;
  --cyan: #38D9FF;
  --cyan-soft: #9BEDFF;
  --ink: #050817;
  --navy: #141A3D;
  --navy-2: #202A63;
  --glass: rgba(12, 18, 44, 0.72);
  --glass-line: rgba(150, 190, 255, 0.22);
  --text: #F4FBFF;
  --muted: #A8BAD6;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #050817;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

button {
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.game {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #050817;
  isolation: isolate;
}

/* ================================================================
 * 首页
 * ================================================================ */

.home {
  position: absolute;
  inset: 0;
  z-index: 15;
  overflow: hidden;
  background: #0B1026;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.home.is-off {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.home-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

.home-art {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  transform: scale(1);
  transform-origin: 50% 44%;
  transition: transform 0.72s cubic-bezier(0.5, 0.02, 0.72, 0.42), opacity 0.55s ease, filter 0.6s ease;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.home.leaving .home-art {
  transform: scale(1.9);
  opacity: 0;
  filter: brightness(0.5) blur(2px);
}

.home-tone {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(4, 8, 28, 0.18) 0%, rgba(4, 8, 28, 0.02) 10%, rgba(4, 8, 28, 0) 24%, rgba(4, 8, 28, 0) 84%, rgba(4, 8, 28, 0.14) 94%, rgba(4, 8, 28, 0.3) 100%);
}

.home-vignette {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(120% 72% at 50% 45%, rgba(0, 0, 0, 0) 52%, rgba(2, 6, 22, 0.24) 78%, rgba(2, 6, 22, 0.5) 100%),
    radial-gradient(80% 40% at 50% 0%, rgba(3, 8, 26, 0.22), rgba(3, 8, 26, 0) 70%);
}

/* 透明热区，精确覆盖图里的「开始游戏」按钮 */
.home-start {
  position: absolute;
  z-index: 5;
  display: block;
  left: 24%;
  top: 63.6%;
  width: 52.2%;
  height: 11.45%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  outline: none;
}

.home-start-halo {
  position: absolute;
  inset: -9px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    0 0 0 2px rgba(255, 213, 122, 0.26),
    0 0 22px 4px rgba(255, 163, 59, 0.3),
    inset 0 0 18px rgba(255, 224, 150, 0.14);
  animation: startHalo 2.7s ease-in-out infinite;
}

@keyframes startHalo {
  0%, 100% {
    opacity: 0.55;
    transform: scale(0.992);
  }
  50% {
    opacity: 1;
    transform: scale(1.014);
  }
}

.home-start-shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.85;
}

.home-start-shine::before {
  content: "";
  position: absolute;
  top: -30%;
  bottom: -30%;
  left: -45%;
  width: 26%;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.5) 48%, rgba(255, 255, 255, 0) 100%);
  transform: skewX(-18deg);
  mix-blend-mode: screen;
  animation: startShine 3.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes startShine {
  0% { left: -45%; }
  38% { left: 118%; }
  100% { left: 118%; }
}

.home-start:focus-visible {
  outline: 3px solid rgba(255, 222, 154, 0.85);
  outline-offset: 4px;
}

.home-start:active {
  background: rgba(255, 255, 255, 0.09);
}

.home-start:active .home-start-halo {
  animation: none;
  transform: scale(0.975);
  box-shadow:
    0 0 0 3px rgba(255, 225, 150, 0.4),
    0 0 30px 8px rgba(255, 163, 59, 0.42),
    inset 0 0 26px rgba(255, 236, 183, 0.28);
}

/* 开始按钮下方的一行目标说明，补上图片里没有的限时信息 */
.home-goal {
  position: absolute;
  left: 50%;
  top: 76.3%;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 206, 120, 0.3);
  background: linear-gradient(180deg, rgba(18, 22, 52, 0.8), rgba(8, 10, 28, 0.88));
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  color: #F4FBFF;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.home-goal .mp-icon {
  width: 15px;
  height: 15px;
  color: var(--gold);
  filter: drop-shadow(0 0 6px rgba(255, 190, 60, 0.45));
}
.home-goal b {
  color: #FFD06E;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.home.leaving .home-start,
.home.leaving .home-goal,
.home.leaving .home-record {
  opacity: 0;
  transition: opacity 0.28s ease;
}

.home-record {
  position: absolute;
  left: 50%;
  bottom: calc(12px + var(--safe-bottom));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100% - 32px);
  padding: 7px 14px 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 207, 116, 0.32);
  background: linear-gradient(180deg, rgba(24, 31, 74, 0.84), rgba(8, 12, 34, 0.9));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #FFE9B8;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transform: translateX(-50%);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.home-record .mp-icon {
  width: 17px;
  height: 17px;
  color: var(--gold);
  filter: drop-shadow(0 0 5px rgba(255, 190, 60, 0.5));
}

.home-record .record-label {
  color: rgba(255, 240, 205, 0.78);
}

.home-record strong {
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(255, 194, 75, 0.36);
}

/* 竖长屏专用：左上角真实成绩卡，同时遮住被裁切的图中货币条 */
.home-record-tall {
  display: none;
  left: 0;
  top: 0;
  bottom: auto;
  transform: none;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  width: 64px;
  min-height: calc(76px + var(--safe-top));
  padding: calc(7px + var(--safe-top)) 4px 7px;
  border-radius: 0 0 20px 0;
  border-top: 0;
  border-left: 0;
  background:
    linear-gradient(150deg, rgba(23, 29, 72, 0.97) 0%, rgba(11, 15, 42, 0.95) 62%, rgba(11, 15, 42, 0.72) 100%);
  box-shadow: 7px 12px 26px rgba(2, 5, 22, 0.3), inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

.home-record-tall .mp-icon {
  width: 19px;
  height: 19px;
}

.home-record-tall .record-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  line-height: 1.15;
  text-align: center;
}

.home-record-tall .record-label {
  font-size: 8.5px;
  letter-spacing: 0.06em;
  color: rgba(255, 232, 186, 0.72);
}

.home-record-tall strong {
  font-size: 16px;
  line-height: 1.15;
}

.home-record-tall.is-wide {
  flex-direction: row;
  gap: 8px;
}

.home-record-tall.is-wide .record-copy {
  align-items: flex-start;
  text-align: left;
}

.home.is-tall .home-record:not(.home-record-tall) {
  display: none;
}

.home.is-tall .home-record-tall {
  display: flex;
}

/* ================================================================
 * 游戏画面
 * ================================================================ */

.play {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background: #07141f;
  isolation: isolate;
  transition: opacity 0.5s ease 0.06s, visibility 0.5s ease;
}

.play.on {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.scene-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(3, 14, 24, 0.44) 0%, rgba(3, 14, 24, 0.06) 18%, rgba(3, 14, 24, 0) 34%),
    linear-gradient(0deg, rgba(3, 12, 20, 0.46) 0%, rgba(3, 12, 20, 0) 22%),
    radial-gradient(120% 70% at 50% 46%, rgba(0, 0, 0, 0) 58%, rgba(0, 8, 16, 0.26) 100%);
}

/* 最后 10 秒的红色压迫感，只压画面不挡操作 */
.play::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(118% 76% at 50% 50%, rgba(255, 60, 40, 0) 54%, rgba(255, 48, 32, 0.3) 100%);
  transition: opacity 0.45s ease;
}
.play.time-low::after {
  opacity: 1;
  animation: lowTimePulse 1.1s ease-in-out infinite;
}
@keyframes lowTimePulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.touch {
  position: absolute;
  inset: 0;
  z-index: 2;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  padding: calc(10px + var(--safe-top)) 14px 0;
  pointer-events: none;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.icon-btn {
  pointer-events: auto;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 47px;
  height: 47px;
  padding: 0;
  border-radius: 16px;
  border: 1px solid rgba(165, 195, 255, 0.26);
  background: linear-gradient(180deg, rgba(42, 53, 116, 0.9), rgba(15, 21, 56, 0.92));
  color: #F4FBFF;
  box-shadow: 0 8px 20px rgba(2, 6, 24, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: transform 0.12s ease, background 0.2s ease;
  cursor: pointer;
}
.icon-btn .mp-icon { width: 23px; height: 23px; }
.icon-btn:active {
  transform: scale(0.92);
  background: linear-gradient(180deg, rgba(60, 74, 150, 0.95), rgba(22, 30, 74, 0.95));
}

/* ---------- 倒计时 ---------- */
.timer-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 47px;
  min-width: 104px;
  padding: 0 13px 0 10px;
  border-radius: 16px;
  border: 1px solid rgba(255, 202, 110, 0.3);
  background: linear-gradient(180deg, rgba(50, 46, 96, 0.9), rgba(18, 17, 48, 0.92));
  box-shadow: 0 10px 24px rgba(2, 6, 24, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #fff;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.timer-chip .mp-icon {
  width: 21px;
  height: 21px;
  color: var(--gold);
  filter: drop-shadow(0 0 6px rgba(255, 190, 60, 0.4));
  transition: color 0.25s ease;
}
.timer-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
}
.timer-copy strong {
  font-size: 16.5px;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
.timer-bar {
  display: block;
  width: 47px;
  height: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}
.timer-bar > i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #FFD25E, #FF8A3D);
  box-shadow: 0 0 8px rgba(255, 160, 70, 0.55);
  transition: width 0.25s linear, background 0.25s ease;
}
.timer-chip.urgent {
  border-color: rgba(255, 106, 74, 0.62);
  background: linear-gradient(180deg, rgba(108, 40, 42, 0.94), rgba(52, 14, 20, 0.94));
  box-shadow: 0 10px 24px rgba(2, 6, 24, 0.4), 0 0 20px rgba(255, 80, 60, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  animation: timerPulse 0.9s ease-in-out infinite;
}
.timer-chip.urgent .mp-icon { color: #FF8C74; }
.timer-chip.urgent .timer-bar > i {
  background: linear-gradient(90deg, #FF8C74, #FF4A3D);
  box-shadow: 0 0 9px rgba(255, 80, 60, 0.8);
}
@keyframes timerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.055); }
}

.level-card {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  max-width: 560px;
  margin: 7px auto 0;
  padding: 5px 11px 5px 5px;
  border-radius: 16px;
  border: 1px solid rgba(165, 195, 255, 0.26);
  background: linear-gradient(180deg, rgba(38, 48, 105, 0.88), rgba(12, 17, 47, 0.9));
  box-shadow: 0 10px 24px rgba(2, 6, 24, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.mini-hole {
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #000 0 40%, #05051a 52%, #4722a8 64%, #8a5cff 76%, #d9c7ff 87%, rgba(120, 80, 255, 0) 95%);
  box-shadow: 0 0 14px rgba(120, 86, 255, 0.8), inset 0 0 8px rgba(154, 118, 255, 0.7);
  animation: holeBreathe 2.6s ease-in-out infinite;
}
.mini-hole::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid rgba(154, 118, 255, 0.34);
  animation: holeRing 2.6s ease-in-out infinite;
}

@keyframes holeBreathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.93); }
}
@keyframes holeRing {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(1.06); }
}

.bar-wrap { flex: 1 1 auto; min-width: 0; }

.bar {
  height: 11px;
  border-radius: 999px;
  background: rgba(2, 6, 20, 0.72);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.07);
}
.bar > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #37D95B 0%, #8FEF52 58%, #D7FF7E 100%);
  box-shadow: 0 0 10px rgba(126, 255, 106, 0.5);
  transition: width 0.28s cubic-bezier(0.22, 0.9, 0.32, 1);
}

.bar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: rgba(202, 226, 255, 0.78);
  white-space: nowrap;
}
#lvText {
  color: #FFFFFF;
  font-weight: 800;
  font-size: 10.5px;
  padding-left: 6px;
}

.score-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  height: 47px;
  margin-left: auto;
  padding: 0 12px 0 9px;
  border-radius: 16px;
  border: 1px solid rgba(255, 202, 110, 0.28);
  background: linear-gradient(180deg, rgba(49, 45, 96, 0.9), rgba(18, 17, 48, 0.92));
  box-shadow: 0 10px 24px rgba(2, 6, 24, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-weight: 800;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
.score-chip .mp-icon {
  width: 21px;
  height: 21px;
  color: var(--gold);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}

.hint {
  display: flex;
  align-items: center;
  gap: 5px;
  width: max-content;
  max-width: 100%;
  margin: 10px auto 0;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(9, 14, 38, 0.62);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #E5F3FF;
  font-size: 12px;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.hint .mp-icon { width: 15px; height: 15px; color: var(--cyan); }
.hint.hide { opacity: 0; transform: translateY(-6px); }

/* ---------- floating joystick ---------- */
.stick {
  position: fixed;
  z-index: 4;
  width: 126px;
  height: 126px;
  margin: -63px 0 0 -63px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 0.14s ease, transform 0.14s ease;
  background: radial-gradient(circle at 50% 50%, rgba(37, 43, 110, 0.14) 0 55%, rgba(10, 13, 40, 0.4) 56% 100%);
  border: 1.5px solid rgba(160, 210, 255, 0.36);
  box-shadow: inset 0 0 26px rgba(100, 150, 255, 0.16), 0 8px 24px rgba(0, 0, 0, 0.24);
}
.stick.on { opacity: 1; transform: scale(1); }
.stick-ring {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  border: 1px dashed rgba(196, 230, 255, 0.24);
}
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #FFFFFF 0%, #EDF8FF 34%, #C4DDF2 72%, #93B4CE 100%);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.4), inset 0 -3px 7px rgba(40, 82, 104, 0.28), inset 0 2px 2px rgba(255, 255, 255, 0.9);
}

/* ---------- bottom stats ---------- */
.bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(10px + var(--safe-bottom));
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  pointer-events: none;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(9, 14, 38, 0.66);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #D6E7FF;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}
.pill .mp-icon { width: 14px; height: 14px; color: var(--orange); }
.pill-best .mp-icon { color: var(--gold); }

/* ---------- toast ---------- */
.toast-layer {
  position: absolute;
  top: calc(176px + var(--safe-top));
  left: 0;
  right: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(34, 43, 96, 0.94), rgba(10, 14, 40, 0.94));
  border: 1px solid rgba(150, 195, 255, 0.36);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4), 0 0 18px rgba(90, 140, 255, 0.14);
  color: #E8FBFF;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  animation: toastIn 0.32s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}
.toast .toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 10px rgba(255, 138, 61, 0.9);
}
.toast.out { animation: toastOut 0.34s ease both; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-8px) scale(0.96); }
}

/* ---------- loader ---------- */
.loader {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: radial-gradient(80% 60% at 50% 42%, #171a4a 0%, #080b22 68%, #050817 100%);
  transition: opacity 0.4s ease;
}
.loader.hide { opacity: 0; pointer-events: none; }
.loader-hole {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #000 0 42%, #08071f 54%, #4A1EA8 66%, #8A5CFF 78%, #D9C7FF 88%, rgba(120, 80, 255, 0) 95%);
  box-shadow: 0 0 30px rgba(120, 86, 255, 0.7);
  animation: loaderSpin 1.4s linear infinite;
}
@keyframes loaderSpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}
.loader-text {
  color: #B3BFE8;
  font-size: 12.5px;
  letter-spacing: 0.12em;
}

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 22px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(90% 70% at 50% 42%, rgba(22, 26, 72, 0.7), rgba(4, 6, 22, 0.92));
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  transition: opacity 0.24s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.panel {
  width: min(344px, 100%);
  padding: 24px 20px 20px;
  border-radius: 28px;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(112, 80, 255, 0.24), rgba(112, 80, 255, 0) 56%),
    linear-gradient(165deg, rgba(31, 38, 88, 0.98) 0%, rgba(9, 12, 36, 0.99) 72%);
  border: 1px solid rgba(160, 195, 255, 0.26);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  text-align: center;
  animation: panelIn 0.3s cubic-bezier(0.2, 1.15, 0.36, 1) both;
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.panel-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  margin: -52px auto 10px;
  border-radius: 20px;
  border: 1px solid rgba(160, 195, 255, 0.38);
  background: linear-gradient(180deg, #3A428F, #161A48);
  color: #D8E7FF;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), 0 0 26px rgba(112, 100, 255, 0.24);
}
.panel-badge .mp-icon { width: 31px; height: 31px; }
.panel-badge.warn {
  border-color: rgba(255, 138, 61, 0.5);
  color: #FFD0A8;
  background: linear-gradient(180deg, #6A3A20, #2A160A);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), 0 0 26px rgba(255, 138, 61, 0.26);
}
.panel-badge.win {
  border-color: rgba(255, 201, 74, 0.52);
  color: #FFE39B;
  background: linear-gradient(180deg, #65501C, #2A1F06);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), 0 0 28px rgba(255, 201, 74, 0.28);
}

.panel h2 {
  margin: 4px 0 6px;
  font-size: 23px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-weight: 800;
}
.panel-sub {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}
.panel-sub b { color: #FFC08C; font-weight: 700; }

.bonus-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: -7px 0 14px;
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 200, 110, 0.34);
  background: rgba(255, 190, 90, 0.08);
  color: #FFE0A8;
  font-size: 11.5px;
  letter-spacing: 0.02em;
}
.bonus-line .mp-icon { width: 14px; height: 14px; color: var(--gold); }
.bonus-line b { color: #FFF3D2; font-size: 13px; }

.stats {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
}
.stats.four { gap: 6px; }
.stats.four .stat { padding-left: 2px; padding-right: 2px; }
.stats.four .stat b { font-size: 15.5px; }
.stats.four .stat span { font-size: 9.5px; }
.stat {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 4px 9px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.085);
}
.stat b {
  display: block;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #FFFFFF;
}
.stat span {
  display: block;
  margin-top: 3px;
  font-size: 10.5px;
  color: #94A9C8;
  letter-spacing: 0.04em;
}
.stat-accent b { color: #FFB15C; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 50px;
  margin-top: 10px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.18s ease, background 0.18s ease;
}
.btn .mp-icon { width: 20px; height: 20px; }
.btn:active { transform: translateY(1px) scale(0.985); }
.btn.primary {
  color: #3A1B02;
  background: linear-gradient(180deg, #FFD25E 0%, #FFB02E 30%, #FF8A3D 72%, #F57521 100%);
  box-shadow: 0 12px 26px rgba(255, 138, 61, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.btn.ghost {
  color: #E1EEFF;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
}
.btn.ghost:active { background: rgba(255, 255, 255, 0.11); }

.best-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
  color: #93A7C7;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.best-row .mp-icon { width: 14px; height: 14px; color: var(--gold); }
.best-row b { color: #E3EDFF; font-weight: 700; }

@media (max-width: 350px) {
  .hud { padding-left: 10px; padding-right: 10px; }
  .score-chip { padding-right: 9px; font-size: 15px; }
  .timer-chip { min-width: 92px; padding: 0 10px 0 8px; gap: 6px; }
  .timer-copy strong { font-size: 15px; }
  .timer-bar { width: 40px; }
  .level-card { gap: 6px; padding-right: 8px; }
  .mini-hole { width: 32px; height: 32px; }
  .bar-meta { font-size: 9.5px; }
  .hint { font-size: 11.5px; }
  .home-record { font-size: 11px; padding: 6px 11px 6px 9px; }
}

@media (max-height: 640px) {
  .home-record {
    bottom: calc(8px + var(--safe-bottom));
    padding: 5px 11px 5px 9px;
    font-size: 10.5px;
  }
}

/* 宽屏 / 平板：画面保持 2:3 的竖屏舞台居中，两侧用同一张图做氛围底 */
@media (min-aspect-ratio: 2/3) {
  .home-stage {
    left: 50%;
    right: auto;
    width: calc(100vh * 2 / 3);
    max-width: 100vw;
    height: 100%;
    transform: translateX(-50%);
    box-shadow: 0 0 70px rgba(0, 0, 0, 0.5);
  }
}

@media (min-aspect-ratio: 2/3) {
  .home::before {
    content: "";
    position: absolute;
    inset: -56px;
    z-index: 0;
    background: url("images/gen/gptimg_1795494556_look.png") center / cover no-repeat;
    filter: blur(30px) brightness(0.4) saturate(1.15);
    transform: scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-start-halo,
  .home-start-shine::before,
  .mini-hole,
  .mini-hole::after,
  .timer-chip.urgent,
  .play.time-low::after,
  .loader-hole {
    animation: none;
  }
}

/* 首页皮肤选择：展开时在入口上方展示，不改变开始热区位置。 */
.skin-picker{position:absolute;z-index:8;left:50%;bottom:calc(var(--safe-bottom) + 48px);transform:translateX(-50%);width:min(88vw,360px);color:#fff;text-align:center}
.skin-picker summary{display:inline-flex;align-items:center;justify-content:center;gap:12px;min-height:44px;padding:0 18px;border:1px solid var(--orange);border-radius:14px;background:#211a33;box-shadow:0 4px 14px #08071888;font-weight:750;cursor:pointer;list-style:none}
.skin-picker summary::-webkit-details-marker{display:none}.skin-picker summary span{color:#ffd3ab;font-size:12px}.skin-picker summary:after{content:'▴';color:var(--orange)}.skin-picker[open] summary:after{content:'▾'}
.skin-list{position:absolute;bottom:calc(100% + 6px);width:100%;display:grid;grid-template-columns:repeat(3,1fr);gap:8px;padding:10px;border:1px solid #62546a;border-radius:16px;background:linear-gradient(#181726dc,#181726f7),url('images/gen/gptimg_1795838849_look.jpg') center/cover;box-shadow:0 5px 24px #0008}
.skin-list button{position:relative;display:grid;justify-items:center;gap:5px;border:2px solid #62576a;border-radius:11px;background:#292739;color:white;padding:8px 3px;font-size:14px;font-weight:bold;cursor:pointer}.skin-list img{width:55px;max-width:95%;height:40px;object-fit:contain;image-rendering:pixelated}.skin-list [aria-pressed=true]{border-color:var(--orange);background:#493244}.skin-list [aria-pressed=true]:after{content:'✓';position:absolute;top:0;right:0;background:var(--orange);color:#291720;border-radius:0 7px 0 7px;padding:1px 4px;font-size:12px}.skin-picker :focus-visible{outline:3px solid white;outline-offset:2px}.home.leaving .skin-picker{visibility:hidden}
