/* ── Theme variables ─────────────────────────────────────────── */
:root[data-theme="dark"] {
  --bg: #05080f;
  --accent: #e9b949;        /* gold */
  --accent-bright: #ffd97a;
  --ink: #e8edf5;
  --muted: #8a96ab;
  --hud-fade: rgba(5, 8, 15, .82);
  --tip-bg: rgba(10, 14, 22, .94);
  --tip-border: rgba(233, 185, 73, .35);
  --toggle-bg: rgba(255, 255, 255, .08);
}
:root[data-theme="light"] {
  --bg: #eef1f6;
  --accent: #1f4e8c;        /* deep navy for UI accents */
  --accent-bright: #14385f;
  --ink: #1a2233;
  --muted: #5b6678;
  --hud-fade: rgba(238, 241, 246, .85);
  --tip-bg: rgba(255, 255, 255, .96);
  --tip-border: rgba(31, 78, 140, .35);
  --toggle-bg: rgba(20, 30, 50, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transition: background .5s ease, color .5s ease; }
#globe { position: fixed; inset: 0; }

#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  padding: 18px 26px;
  padding-top: max(18px, env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--hud-fade) 0%, transparent 100%);
  pointer-events: none;
}
.brand { font-weight: 800; letter-spacing: .14em; font-size: 15px; color: var(--accent); padding-top: 6px; }
.brand span { color: var(--muted); font-weight: 600; letter-spacing: .06em; }

.hud-info { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.stats { display: flex; gap: 26px; }
.stat { text-align: center; line-height: 1; }
.hud-status-row { display: flex; align-items: center; gap: 10px; }
.stat span { font-size: 30px; font-weight: 800; color: var(--accent-bright);
  font-variant-numeric: tabular-nums; }
.stat label { display: block; margin-top: 5px; font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); }

.status { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(160, 160, 160, .5); }
  70% { box-shadow: 0 0 0 9px rgba(160, 160, 160, 0); }
  100% { box-shadow: 0 0 0 0 rgba(160, 160, 160, 0); }
}

#theme-toggle, #spin-toggle {
  pointer-events: auto; cursor: pointer; border: none; border-radius: 50%;
  width: 34px; height: 34px; background: var(--toggle-bg); color: var(--ink);
  font-size: 15px; line-height: 1; display: grid; place-items: center;
  transition: background .2s; }
#theme-toggle:hover, #spin-toggle:hover { background: rgba(128, 128, 128, .22); }
:root[data-theme="dark"] .t-light, :root[data-theme="light"] .t-dark { display: none; }
/* spin button shows ⏸ while spinning, ▶ while paused */
#spin-toggle .i-play { display: none; }
#spin-toggle[data-spinning="0"] .i-pause { display: none; }
#spin-toggle[data-spinning="0"] .i-play { display: inline; }

#legend {
  position: fixed; left: 26px; bottom: 34px; z-index: 10; pointer-events: none;
  display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted);
}
#legend span { display: flex; align-items: center; gap: 8px; }
#legend .sw { width: 11px; height: 11px; border-radius: 50%; box-shadow: 0 0 6px currentColor; }
#legend .sw.live { background: #ff5a1f; color: #ff5a1f; }
#legend .sw.active { background: #e9b949; color: #e9b949; }

#tooltip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--tip-bg); border: 1px solid var(--tip-border);
  color: var(--ink);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; transform: translate(-50%, -130%);
  white-space: nowrap; box-shadow: 0 6px 22px rgba(0, 0, 0, .35);
}
#tooltip b { color: var(--accent-bright); }
#tooltip small { color: var(--muted); }

#foot { position: fixed; left: 0; right: 0; z-index: 10; text-align: center;
  bottom: max(12px, env(safe-area-inset-bottom));
  font-size: 11px; color: var(--muted); pointer-events: none; padding: 0 16px; }

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Center the whole HUD as a tidy stack: brand, stats, status+controls */
  #hud {
    flex-direction: column; align-items: center; justify-content: flex-start;
    gap: 8px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
    text-align: center;
  }
  .brand { font-size: 12px; padding-top: 0; }
  .hud-info { align-items: center; gap: 7px; }
  .stats { gap: 30px; }
  .stat span { font-size: 22px; }
  .hud-status-row { flex-wrap: wrap; justify-content: center; gap: 8px; }
  .status { font-size: 10px; }

  /* Lift the legend clear of the (now single-line) footer */
  #legend { left: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 46px); font-size: 11px; }
  #foot { font-size: 10px; bottom: max(10px, env(safe-area-inset-bottom)); }
  .foot-extra { display: none; }  /* drop "drag to rotate · refreshes every minute" on mobile */
}
