/* 引力弹球 — 深墨蓝发光主题 */
:root {
  --eazo-safe-area-top: max(56px, env(safe-area-inset-top, 0px));
  --eazo-safe-area-bottom: max(34px, env(safe-area-inset-bottom, 0px));
  --bg: #0a0e1f;
  --bg2: #0c1230;
  --ice: #7fd8ff;
  --coral: #ff5f4d;
  --gold: #ffd76a;
  --ink: #e8eefc;
  --ink-dim: #93a4c8;
  --panel: rgba(16, 22, 46, 0.92);
  --line: rgba(127, 216, 255, 0.22);
}

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

html, body { height: 100%; }

body {
  background:
    radial-gradient(110% 85% at 50% 0%, #0e1535 0%, var(--bg) 52%, #060912 100%);
  color: var(--ink);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ---------- 全屏星空层 ---------- */
#space-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- 屏幕骨架 ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  flex-direction: column;
  padding-top: var(--eazo-safe-area-top);
  padding-bottom: var(--eazo-safe-area-bottom);
}
.screen.active { display: flex; }

/* ---------- 标题 ---------- */
#screen-title { align-items: center; justify-content: center; text-align: center; }
.title-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px; }

.logo-orb { position: relative; width: 150px; height: 150px; margin-bottom: 10px; }
.logo-halo {
  position: absolute; inset: -26px;
  background: radial-gradient(circle, rgba(127, 216, 255, 0.22) 0%, rgba(127, 216, 255, 0) 62%);
  animation: haloPulse 3.4s ease-in-out infinite;
}
@keyframes haloPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.12); opacity: 1; }
}
.logo-ring {
  position: absolute; inset: 10px;
  border: 2px dashed rgba(127, 216, 255, 0.6);
  border-radius: 50%;
  animation: spin 9s linear infinite;
}
.logo-ring2 {
  position: absolute; inset: 30px;
  border: 1px solid rgba(180, 150, 255, 0.4);
  border-radius: 50%;
  animation: spin 14s linear infinite reverse;
}
.logo-ball {
  position: absolute; left: 50%; top: 50%;
  width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #cfe6ff 60%, #9cc4ef);
  box-shadow: 0 0 22px rgba(174, 224, 255, 0.95), 0 0 46px rgba(174, 224, 255, 0.4);
  animation: orbitMove 3.2s linear infinite;
}
.logo-planet {
  position: absolute; left: 50%; top: 50%;
  width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.95), rgba(160,220,255,0.5) 26%, rgba(70,140,230,0.55) 60%, rgba(40,70,150,0.9) 100%);
  box-shadow:
    0 0 26px rgba(127, 216, 255, 0.5),
    inset -10px -8px 22px rgba(10, 16, 48, 0.75);
}
.logo-planet::after {
  content: ""; position: absolute; inset: -5px;
  border-radius: 50%;
  border: 1px solid rgba(190, 230, 255, 0.5);
  box-shadow: 0 0 10px rgba(160, 220, 255, 0.35);
}
.logo-spark {
  position: absolute; width: 5px; height: 5px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 10px rgba(255,255,255,0.9);
}
.logo-spark.s1 { left: 8px; top: 24px; animation: sparkle 2.2s ease-in-out infinite; }
.logo-spark.s2 { right: 14px; top: 52px; animation: sparkle 2.8s ease-in-out 0.7s infinite; }
.logo-spark.s3 { left: 38px; bottom: 6px; animation: sparkle 2.5s ease-in-out 1.3s infinite; }
@keyframes sparkle {
  0%, 100% { transform: scale(0.6); opacity: 0.4; }
  50% { transform: scale(1.4); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes orbitMove {
  0% { transform: rotate(0deg) translateX(60px) rotate(0deg); }
  100% { transform: rotate(360deg) translateX(60px) rotate(-360deg); }
}

.logo-title {
  font-size: 48px; font-weight: 800; letter-spacing: 8px;
  color: #cfe6ff;
  filter: drop-shadow(0 0 16px rgba(127, 216, 255, 0.45));
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .logo-title {
    background: linear-gradient(180deg, #ffffff 0%, #bcdcff 45%, #7fb4ff 78%, #a892ff 100%);
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
  }
}
.logo-sub { color: rgba(180, 200, 255, 0.85); letter-spacing: 12px; font-size: 13px; text-transform: uppercase; }
.logo-tag { color: #cfe6ff; font-size: 15px; opacity: 0.85; }
.title-hint { color: var(--ink-dim); font-size: 12px; max-width: 300px; line-height: 1.6; }
.title-meta { display: flex; gap: 12px; align-items: center; margin-top: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: rgba(20, 28, 56, 0.85);
  color: var(--ink); font-size: 15px; font-weight: 600;
  padding: 11px 22px; border-radius: 12px; cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  min-height: 44px;
}
.btn:active { transform: scale(0.96); }
.btn.primary {
  background: linear-gradient(180deg, #1d3a6e, #16305c);
  border-color: rgba(127, 216, 255, 0.55);
  box-shadow: 0 4px 18px rgba(80, 160, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.btn.primary:hover { box-shadow: 0 4px 26px rgba(100, 180, 255, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.16); }
.btn.big { font-size: 18px; padding: 14px 40px; border-radius: 16px; }
.btn.small { font-size: 13px; padding: 8px 14px; min-height: 36px; }
.btn.hidden { display: none; }
.icon-btn {
  appearance: none; border: 1px solid var(--line); background: rgba(16, 22, 46, 0.7);
  color: var(--ink); font-size: 17px; min-width: 42px; min-height: 42px;
  border-radius: 12px; cursor: pointer; padding: 0 8px;
}
.icon-btn:active { transform: scale(0.94); }
select {
  appearance: none; background: rgba(16, 22, 46, 0.8); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 14px; font-size: 13px;
}

/* ---------- 选关 ---------- */
#screen-select { padding: 20px; overflow-y: auto; }
.select-head { text-align: center; margin-bottom: 16px; }
.select-head h2 {
  font-size: 26px; letter-spacing: 3px;
  background: linear-gradient(180deg, #ffffff, #9fd8ff);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 12px rgba(127, 216, 255, 0.3));
}
.select-sub { color: var(--ink-dim); font-size: 13px; margin-top: 6px; }
.level-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  max-width: 480px; width: 100%; margin: 0 auto; padding-bottom: 20px;
}
.level-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px 10px; border-radius: 16px; cursor: pointer;
  background:
    radial-gradient(circle at 50% 0%, rgba(70, 140, 255, 0.16), transparent 60%),
    linear-gradient(180deg, rgba(24, 34, 66, 0.92), rgba(14, 20, 42, 0.92));
  border: 1px solid var(--line); color: var(--ink);
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
}
.level-card:active { transform: scale(0.96); }
.level-card:not(.locked):hover {
  border-color: rgba(127, 216, 255, 0.5);
  box-shadow: 0 0 18px rgba(80, 160, 255, 0.22);
}
.level-card.locked { opacity: 0.45; cursor: default; filter: grayscale(0.7); }
.level-card.locked:active { transform: none; }
.level-card.shake { animation: cardShake 0.35s ease; }
@keyframes cardShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
.level-num { font-size: 30px; font-weight: 800; color: var(--ice); letter-spacing: 1px;
  text-shadow: 0 0 14px rgba(127, 216, 255, 0.35); }
.level-name { font-size: 13px; color: #cfe6ff; min-height: 18px; }
.level-stars { font-size: 15px; color: var(--gold); letter-spacing: 2px; }

/* ---------- HUD ---------- */
.hud {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px 8px;
}
.hud-center { flex: 1; text-align: center; min-width: 0; }
.hud-level { font-size: 14px; font-weight: 700; color: #cfe6ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-balls { font-size: 11px; letter-spacing: 3px; color: var(--ice); margin-top: 2px; }
.hud-targets { font-size: 13px; color: var(--ink); white-space: nowrap; padding: 0 4px; }

/* ---------- 舞台 ---------- */
.stage { position: relative; flex: 1; min-height: 0; }
#game {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  touch-action: none;
  cursor: crosshair;
}
.combo-badge {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  font-size: 20px; font-weight: 800; letter-spacing: 1px;
  text-shadow: 0 0 14px currentColor;
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.combo-badge.show { opacity: 1; }
.hint-bar {
  text-align: center; font-size: 12px; color: #9fc8e8;
  padding: 6px 16px 10px; min-height: 26px;
  opacity: 0; transition: opacity 0.3s;
}
.hint-bar.show { opacity: 1; }

/* ---------- 遮罩 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: none; align-items: center; justify-content: center;
  background: rgba(5, 8, 20, 0.68);
  backdrop-filter: blur(3px);
  padding: 24px;
}
.overlay.show { display: flex; }
.panel, .result-box {
  display: flex; flex-direction: column; gap: 12px; align-items: stretch;
  width: 100%; max-width: 320px; padding: 26px 22px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: 0 14px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.panel h3, .result-box h3 { font-size: 22px; letter-spacing: 2px; }
.row { display: flex; gap: 10px; justify-content: center; align-items: center; }
.panel .btn, .result-box .btn { flex: 1; }

.result-stars { font-size: 40px; letter-spacing: 8px; color: rgba(255, 215, 106, 0.25); }
.result-star.on {
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 215, 106, 0.9);
  animation: popIn 0.45s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes popIn { 0% { transform: scale(0.2); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.result-rule { font-size: 12px; color: var(--ink-dim); }
.fail-left { font-size: 18px; color: var(--ice); font-weight: 700; }
.fail-sub { font-size: 13px; color: var(--ink-dim); line-height: 1.6; }
.final-flower { font-size: 26px; color: var(--gold); letter-spacing: 10px; display: none; text-shadow: 0 0 16px rgba(255, 215, 106, 0.8); }
.final-flower.show { display: block; animation: bloom 2s ease-out; }
@keyframes bloom { 0% { transform: scale(0.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* ---------- 首次玩法引导 ---------- */
.overlay.tutorial { z-index: 50; }
.tutorial-panel { max-width: 340px; }
.tut-stage {
  position: relative;
  height: 128px;
  display: flex; align-items: center; justify-content: center;
}
.tut-orbit {
  position: relative;
  width: 88px; height: 88px;
  border: 1.5px dashed rgba(140, 200, 255, 0.45);
  border-radius: 50%;
}
.tut-spin {
  position: absolute; left: 0; top: 0;
  width: 100%; height: 100%;
  animation: tutLoop 4.8s linear infinite;
  will-change: transform, opacity;
}
.tut-ball {
  position: absolute; left: 50%; top: 0;
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #9fd8ff 55%, #4f8fe0);
  box-shadow: 0 0 12px rgba(120, 200, 255, 0.9);
}
.tut-ball::before {
  content: ""; position: absolute; left: 14px; top: 1px;
  width: 30px; height: 0;
  border-top: 2px dashed rgba(140, 215, 255, 0.95);
}
.tut-ball::after {
  content: ""; position: absolute; left: 42px; top: -3px;
  border-left: 8px solid rgba(140, 215, 255, 0.95);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}
@keyframes tutLoop {
  0%   { transform: rotate(-90deg); opacity: 1; }
  42%  { transform: rotate(630deg); opacity: 1; }   /* 绕两圈，回到顶部 */
  52%  { transform: rotate(630deg); opacity: 1; }   /* 停一下，看清箭头 */
  68%  { transform: rotate(630deg) translateX(96px); opacity: 1; } /* 沿切线飞出 */
  78%  { transform: rotate(630deg) translateX(96px); opacity: 0; }
  100% { transform: rotate(-90deg); opacity: 0; }
}
.tut-steps {
  margin: 0; padding: 0 4px 0 20px;
  text-align: left;
  font-size: 13px; line-height: 1.9;
  color: var(--ink-dim);
}
.tut-steps li::marker { color: var(--ice); font-weight: 700; }
.tut-steps b { color: var(--ice); }

/* ---------- 桌面 ---------- */
@media (min-width: 700px) and (orientation: landscape) {
  #screen-play { flex-direction: column; }
  .stage { max-width: min(92vh, 720px); width: 100%; margin: 0 auto; }
  #game { border-radius: 18px; box-shadow: 0 0 60px rgba(60, 120, 220, 0.12); }
}
