/* 天降甘露 · 接水滴 — 冰蓝主题（tokens 对齐 scene-poc DESIGN.md，视觉增强版） */

:root {
  --bg: #070b12;
  --bg-elev: #0c121c;
  --card: rgba(16, 24, 38, 0.6);
  --text: #f4f4f5;
  --muted: #94a3b8;
  --accent: #7eb0ff;
  --accent-2: #d6e7ff;
  --accent-dim: rgba(126, 176, 255, .14);
  --on-accent: #0a1220;
  --line: rgba(126, 176, 255, .18);
  --line-soft: rgba(255, 255, 255, .06);
  --gold: #e8c86a;
  --danger: #f0a3a3;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-pill: 999px;
}

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

html, body { height: 100%; }

body {
  background: url('../img/bg.jpg') center/cover no-repeat;
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
}

/* Dynamic Ambient Glow */
body::before, body::after {
  content: '';
  position: absolute;
  width: 40vmax; height: 40vmax;
  border-radius: 50%;
  filter: blur(80px);
  z-index: 0;
  opacity: 0.15;
  animation: float-glow 15s ease-in-out infinite alternate;
  pointer-events: none;
}
body::before {
  background: var(--accent);
  top: -20vmax; left: -10vmax;
}
body::after {
  background: var(--gold);
  bottom: -20vmax; right: -10vmax;
  animation-delay: -7.5s;
  opacity: 0.08;
}

@keyframes float-glow {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(10vw, 5vh) scale(1.1); }
  100% { transform: translate(-5vw, 15vh) scale(0.9); }
}

.game-shell { display:flex; flex-direction:column; height:100dvh; max-width:560px; margin:0 auto; position:relative; z-index:1; background: rgba(0,0,0,0.65); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }

/* ---- HUD ---- */
.hud {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 15, 25, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.hud-back {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-pill);
  text-decoration: none;
  background: rgba(255,255,255,0.03);
  transition: all 0.2s ease;
}
.hud-back svg { width: 18px; height: 18px; }
.hud-back:active { transform: scale(.92); }
.hud-back:hover { background: rgba(255,255,255,0.1); color: var(--text); border-color: rgba(255,255,255,0.15); }

.hud-mid { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.hud-kicker { font-size: 10px; letter-spacing: .22em; color: var(--accent); font-weight: 700; text-shadow: 0 0 8px var(--accent-dim); }
.hud-title { font-size: 17px; font-weight: 700; letter-spacing: 0.02em; }

.hud-stats { display: flex; align-items: baseline; gap: 12px; }
.hud-score {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: right;
  text-shadow: 0 0 15px rgba(126, 176, 255, 0.4);
}
.hud-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 4px 10px;
  background: rgba(126, 176, 255, 0.05);
  box-shadow: 0 0 10px inset rgba(126, 176, 255, 0.05);
}
.hud-time.is-low { 
  color: var(--danger); 
  border-color: rgba(240, 163, 163, .6); 
  background: rgba(240, 163, 163, 0.1);
  animation: pulse-danger 1s infinite alternate;
}
@keyframes pulse-danger {
  0% { box-shadow: 0 0 0 inset rgba(240, 163, 163, 0); }
  100% { box-shadow: 0 0 12px inset rgba(240, 163, 163, 0.3); }
}

/* ---- Stage ---- */
.stage-wrap { position: relative; flex: 1; min-height: 0; }

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---- Overlays ---- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.overlay.is-open { opacity: 1; pointer-events: auto; }

.overlay-card {
  width: 100%;
  max-width: 340px;
  background: rgba(20, 30, 45, 0.4);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .15) inset, 0 30px 60px rgba(0, 0, 0, .6), 0 0 40px rgba(126, 176, 255, 0.2);
  padding: 32px 24px calc(28px + env(safe-area-inset-bottom));
  text-align: center;
  position: relative;
  overflow: hidden;
}
.overlay-card::before {
  content: '';
  position: absolute;
  top: -50px; left: -50px; right: -50px; height: 150px;
  background: radial-gradient(ellipse at top, rgba(126, 176, 255, 0.15), transparent 70%);
  pointer-events: none;
}
.overlay.is-open .overlay-card { animation: card-in .4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: none; }
}

.overlay-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: linear-gradient(135deg, var(--accent-dim), transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: 0 8px 20px rgba(126, 176, 255, 0.15);
  position: relative;
}
.overlay-icon::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  z-index: -1;
  background: var(--accent);
  opacity: 0.15;
  filter: blur(8px);
}
.overlay-icon svg { width: 32px; height: 32px; }

.overlay-kicker { font-size: 11px; letter-spacing: .2em; color: var(--accent); font-weight: 700; text-shadow: 0 0 10px var(--accent-dim); }

.overlay-card h1, .overlay-card h2 { 
  font-size: 1.7rem; 
  font-weight: 800; 
  letter-spacing: .02em; 
  margin: 8px 0 12px; 
  background: linear-gradient(to right, #fff, var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.overlay-card p { font-size: 14px; color: var(--muted); line-height: 1.7; margin-bottom: 24px; }

.end-score {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-bottom: 8px;
  text-shadow: 0 0 30px rgba(126, 176, 255, 0.5);
  background: linear-gradient(to bottom, #fff, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overlay-best { 
  font-size: 12px; 
  letter-spacing: .08em; 
  color: rgba(148, 163, 184, 0.8); 
  margin: 16px 0 0 !important; 
  font-weight: 600;
}

.end-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }

.btn-primary {
  display: block;
  width: 100%;
  padding: 14px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border: none;
  border-radius: var(--r-pill);
  box-shadow: 0 8px 24px rgba(126, 176, 255, .4);
  cursor: pointer;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}
.btn-primary::after {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: skewX(-20deg);
  animation: shine 3s infinite;
}
@keyframes shine {
  0% { left: -100%; }
  20% { left: 200%; }
  100% { left: 200%; }
}
.btn-primary:active { transform: scale(.96); box-shadow: 0 4px 12px rgba(126, 176, 255, .2); }
.btn-primary:hover { box-shadow: 0 12px 30px rgba(126, 176, 255, .4); }
.btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(126, 176, 255, 0.5); }

.btn-ghost {
  display: block;
  width: 100%;
  padding: 13px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-ghost:active { transform: scale(.96); }
.btn-ghost:hover { background: rgba(255,255,255,0.08); border-color: rgba(126, 176, 255, 0.4); color: #fff; }
.btn-ghost:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(126, 176, 255, 0.3); }

.is-hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .overlay { transition: none; }
  .overlay.is-open .overlay-card { animation: none; }
  body::before, body::after, .btn-primary::after { animation: none; }
}

