:root {
  --bg: #070b14;
  --bg2: #0c1220;
  --panel: rgba(18, 24, 38, 0.72);
  --panel-solid: #121826;
  --line: rgba(143, 180, 255, 0.16);
  --ink: #eaf1ff;
  --ink2: #9fb0cf;
  --mut: #6a7a95;
  --acc: #8fb4ff;
  --acc2: #6f8fd8;
  --acc-rgb: 143, 180, 255;
  --moon: #e8eefc;
  --ok: #5fd6a6;
  --err: #f2606a;
  --gold: #ffcf7a;
  --font: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  min-height: 100%;
  background: #070b14;
}
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(143, 180, 255, 0.14), transparent 60%),
    radial-gradient(900px 600px at 12% 108%, rgba(111, 143, 216, 0.12), transparent 60%),
    #070b14;
  background-color: #070b14;
  background-attachment: fixed;
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
.starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  z-index: 0;
  pointer-events: none;
}
.aurora {
  position: fixed;
  inset: -30% -10% auto -10%;
  height: 70vh;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(50% 60% at 30% 30%, rgba(143, 180, 255, 0.18), transparent 70%),
    radial-gradient(45% 55% at 70% 40%, rgba(95, 214, 166, 0.10), transparent 70%);
  filter: blur(30px);
  opacity: 0.7;
  animation: auroraDrift 24s ease-in-out infinite alternate;
}
@keyframes auroraDrift {
  0% { transform: translate3d(-4%, -2%, 0) scale(1); }
  100% { transform: translate3d(6%, 4%, 0) scale(1.12); }
}

.shell {
  position: relative;
  z-index: 1;
  width: min(560px, 94vw);
  margin: 0 auto;
  padding: 32px 0 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark {
  filter: drop-shadow(0 4px 14px rgba(143, 180, 255, 0.4));
  animation: markFloat 6s ease-in-out infinite;
}
@keyframes markFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.brand h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(120deg, #eaf1ff, #8fb4ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand .tag { font-size: 12px; color: var(--ink2); margin-top: 2px; letter-spacing: .5px; }

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink2);
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.ghost:hover { border-color: var(--acc); color: var(--ink); background: rgba(143, 180, 255, 0.08); }

.announce {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  backdrop-filter: blur(12px);
}
.announce-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--acc);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.announce-item { padding: 6px 0; border-top: 1px solid var(--line); }
.announce-item:first-child { border-top: none; }
.announce-item .a-title { font-size: 14px; font-weight: 600; }
.announce-item .a-title .pin { color: var(--gold); margin-right: 4px; }
.announce-item .a-body { font-size: 13px; color: var(--ink2); margin-top: 2px; white-space: pre-wrap; line-height: 1.5; }

.card, .workspace {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 24px;
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  animation: riseIn .5s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.card h2 { font-size: 18px; font-weight: 700; }
.card .hint { font-size: 13px; color: var(--ink2); margin: 8px 0 18px; line-height: 1.5; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12px; color: var(--ink2); margin-bottom: 6px; letter-spacing: .5px; }
.field input, .field textarea, .input-glow input {
  width: 100%;
  background: rgba(7, 11, 20, 0.6);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--ink);
  font-size: 16px;
  letter-spacing: 2px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  box-sizing: border-box;
}
.field textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.45;
  letter-spacing: 0.4px;
  font-size: 14px;
}
.field input:focus, .field textarea:focus, .input-glow input:focus {
  border-color: var(--acc);
  box-shadow: 0 0 0 3px rgba(143, 180, 255, 0.16);
}
.invite-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: -6px 0 10px;
}
.ghost.tool {
  width: auto;
  padding: 8px 12px;
  font-size: 13px;
}
.parse-pill {
  font-size: 12px;
  color: var(--ink2);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(143, 180, 255, 0.35);
  background: rgba(143, 180, 255, 0.08);
}
.parse-pill b { color: var(--acc); letter-spacing: 1.5px; margin-left: 4px; }
.field-tip {
  font-size: 12px;
  color: var(--mut);
  margin: 0 0 14px;
  line-height: 1.45;
}
.mono { font-family: var(--mono); }

.primary {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  color: #0a0e17;
  cursor: pointer;
  background: linear-gradient(120deg, #a9c2ff, #8fb4ff);
  box-shadow: 0 8px 24px rgba(143, 180, 255, 0.32);
  transition: transform .12s, box-shadow .2s, opacity .2s;
}
.primary:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(143, 180, 255, 0.42); }
.primary:active { transform: translateY(0); }
.primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.danger {
  width: 100%;
  border: 1px solid rgba(242, 96, 106, 0.5);
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #ffd7da;
  background: rgba(242, 96, 106, 0.12);
  cursor: pointer;
  transition: background .2s, transform .12s;
}
.danger:hover { background: rgba(242, 96, 106, 0.2); }
.danger:disabled { opacity: .5; cursor: not-allowed; }

.err { color: var(--err); font-size: 13px; margin-top: 10px; line-height: 1.5; }
.run-note { color: var(--ink2); font-size: 12px; margin-top: 10px; line-height: 1.5; }
.run-note.warn { color: var(--gold); }
.run-wait {
  font-size: 12px;
  color: var(--gold);
  line-height: 1.5;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 207, 122, 0.28);
  background: rgba(255, 207, 122, 0.08);
}

.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.pill {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(143, 180, 255, 0.06);
  color: var(--ink2);
}
.pill.mono { color: var(--ink); letter-spacing: 2px; }
.pill-tier { color: var(--acc); border-color: rgba(143, 180, 255, 0.35); }

/* Moon-phase stage */
.progress-stage { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.moon-wrap { position: relative; width: 240px; height: 240px; }
.moon-orbit {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  opacity: 0;
  transition: opacity .35s;
  pointer-events: none;
}
.orbit-track {
  fill: none;
  stroke: rgba(143, 180, 255, 0.12);
  stroke-width: 1.5;
}
.orbit-arc {
  fill: none;
  stroke: rgba(143, 180, 255, 0.85);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 48 304;
  transform-origin: 60px 60px;
}
.moon { position: relative; z-index: 1; width: 100%; height: 100%; overflow: visible; }
.moon-halo {
  fill: none;
  stroke: rgba(143, 180, 255, 0.3);
  stroke-width: 1.5;
  filter: drop-shadow(0 0 18px rgba(143, 180, 255, 0.35));
  animation: haloPulse 5s ease-in-out infinite;
}
@keyframes haloPulse {
  0%, 100% { opacity: .5; }
  50% { opacity: 1; }
}
.crater { fill: rgba(90, 116, 170, 0.35); }
.moon-shadow {
  fill: #070b14;
  transform: translateX(0);
  transition: transform 1s cubic-bezier(.4, 0, .2, 1);
}
.moon-center {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.moon-center .pct {
  font-size: 40px;
  font-weight: 700;
  color: var(--moon);
  text-shadow: 0 1px 10px rgba(7, 11, 20, 0.7);
  transition: color .6s;
}
.moon-center .phase {
  font-size: 13px;
  color: var(--ink2);
  margin-top: 2px;
  font-weight: 600;
  text-shadow: 0 1px 6px rgba(7, 11, 20, 0.7);
  transition: color .6s;
}
.moon-wrap.lit .moon-center .pct {
  color: #0a0e17;
  text-shadow: 0 1px 10px rgba(255, 255, 255, 0.55);
}
.moon-wrap.lit .moon-center .phase {
  color: #1a2438;
  text-shadow: 0 1px 6px rgba(255, 255, 255, 0.5);
}

/* Running: orbit + breathe so 0% still feels alive */
.moon-wrap.is-running .moon-orbit { opacity: 1; }
.moon-wrap.is-running .orbit-arc {
  animation: orbitSpin 2.4s linear infinite;
}
.moon-wrap.is-running .moon {
  animation: moonBreathe 3.2s ease-in-out infinite;
}
.moon-wrap.is-running .moon-halo {
  animation: haloPulse 1.8s ease-in-out infinite;
  stroke: rgba(143, 180, 255, 0.55);
}
.moon-wrap.is-running .phase {
  color: var(--acc);
}
@keyframes orbitSpin {
  to { transform: rotate(360deg); }
}
@keyframes moonBreathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

.run-live {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 22px;
  font-size: 13px;
  color: var(--ink2);
  letter-spacing: 0.2px;
}
.run-live[hidden] { display: none; }
.run-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--acc);
  box-shadow: 0 0 10px rgba(143, 180, 255, 0.65);
  animation: livePulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
.run-live-elapsed {
  color: var(--mut);
  font-size: 12px;
  letter-spacing: 0.5px;
}
@keyframes livePulse {
  0%, 100% { opacity: .35; transform: scale(.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.counts { display: flex; align-items: baseline; gap: 6px; font-size: 20px; }
.counts .mono { font-size: 26px; font-weight: 700; color: var(--ink); }
.counts .sep { color: var(--mut); }
.counts #targetVal { color: var(--acc); }
.counts .unit { font-size: 13px; color: var(--ink2); }

@media (prefers-reduced-motion: reduce) {
  .moon-wrap.is-running .orbit-arc,
  .moon-wrap.is-running .moon,
  .moon-wrap.is-running .moon-halo,
  .run-live-dot,
  .moon-halo {
    animation: none !important;
  }
  .moon-wrap.is-running .moon-orbit { opacity: .7; }
}

.run-panel { margin-top: 24px; }
.actions { display: flex; gap: 10px; }
.actions .primary, .actions .danger { flex: 1; }

.foot-note { text-align: center; font-size: 11px; color: var(--mut); margin-top: 6px; line-height: 1.5; }

/* Celebrate / meteor shower */
.celebrate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 7, 14, 0.72);
  backdrop-filter: blur(6px);
  animation: fadeIn .4s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.celebrate[hidden] { display: none; }
#meteorCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.celebrate-card {
  position: relative;
  text-align: center;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 34px 30px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: cardPop .55s cubic-bezier(.22, 1.2, .36, 1) both;
}
@keyframes cardPop {
  from { opacity: 0; transform: scale(.85) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.celebrate-logo { filter: drop-shadow(0 4px 16px rgba(143, 180, 255, 0.5)); }
.celebrate-kicker { font-size: 12px; letter-spacing: 3px; color: var(--acc); text-transform: uppercase; margin-top: 10px; }
.celebrate-title {
  font-size: 30px;
  font-weight: 800;
  margin: 6px 0;
  background: linear-gradient(120deg, #eaf1ff, #8fb4ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.celebrate-reward { font-size: 14px; color: var(--ink2); margin-bottom: 8px; }
.celebrate-receipt {
  font-size: 15px;
  font-weight: 600;
  color: var(--gold);
  line-height: 1.5;
  margin: 0 0 22px;
  max-width: 280px;
}
.celebrate-btn { width: auto; padding: 11px 32px; }

@media (prefers-reduced-motion: reduce) {
  .aurora, .brand .mark, .moon-halo { animation: none !important; }
  .card, .workspace, .celebrate, .celebrate-card { animation: none !important; }
  .moon-shadow { transition: none !important; }
}
