:root {
  --bg-0: #0b1220;
  --bg-1: #16233a;
  --fg: #e8eef8;
  --muted: #93a6c2;
  --accent: #4cc2ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(120% 90% at 70% 0%, var(--bg-1) 0%, var(--bg-0) 62%, #060b14 100%);
  color: var(--fg);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.panel {
  position: fixed;
  background: rgba(13, 22, 38, 0.66);
  border: 1px solid rgba(140, 180, 230, 0.16);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
}

.title {
  top: 18px;
  left: 18px;
  padding: 14px 18px;
  max-width: min(70vw, 420px);
}
.title h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: 0.3px; }
.title p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.stats {
  top: 18px;
  right: 18px;
  padding: 12px 16px;
  display: grid;
  gap: 6px;
  font-size: 12px;
  min-width: 148px;
}
.stats div { display: flex; justify-content: space-between; gap: 18px; }
.stats span { color: var(--muted); }
.stats b { font-weight: 600; font-variant-numeric: tabular-nums; }

.toolbar {
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 8px;
  display: flex;
  gap: 6px;
}

button {
  appearance: none;
  border: 1px solid rgba(140, 180, 230, 0.2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  white-space: nowrap;
}
button:hover { background: rgba(76, 194, 255, 0.14); border-color: rgba(76, 194, 255, 0.45); }
button.on { background: rgba(76, 194, 255, 0.2); border-color: rgba(76, 194, 255, 0.6); color: #d6f0ff; }

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 11, 20, 0.72);
  backdrop-filter: blur(6px);
  transition: opacity 0.45s ease;
  z-index: 10;
}
.overlay.done { opacity: 0; pointer-events: none; }

.card {
  width: min(86vw, 340px);
  padding: 26px 24px 22px;
  text-align: center;
  background: rgba(16, 27, 45, 0.92);
  border: 1px solid rgba(140, 180, 230, 0.18);
  border-radius: 18px;
}
.card h2 { margin: 14px 0 6px; font-size: 15px; font-weight: 620; }
.card p { margin: 0; font-size: 12px; color: var(--muted); word-break: break-word; }
.card .pct { margin-top: 10px; font-variant-numeric: tabular-nums; color: var(--accent); font-size: 12px; }

.spinner {
  width: 30px; height: 30px; margin: 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(76, 194, 255, 0.22);
  border-top-color: var(--accent);
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.bar {
  margin-top: 16px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2a9df4, #6ee7ff);
  transition: width 0.2s ease;
}

.error .spinner { display: none; }
.error h2 { color: #ff9f9f; }
.error .bar { display: none; }

@media (max-width: 640px) {
  .title { top: 12px; left: 12px; padding: 10px 14px; }
  .title h1 { font-size: 14px; }
  .stats { display: none; }
  .toolbar { bottom: 14px; width: calc(100% - 24px); justify-content: center; }
  button { padding: 8px 12px; font-size: 12px; }
}
