:root {
  --space: #0b1026;
  --ink: #f4f6ff;
  --muted: #9aa5d1;
  --accent: #ffcf5c;
  --card: rgba(20, 26, 60, 0.92);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--space);
  color: var(--ink);
  font-family: "Trebuchet MS", system-ui, sans-serif;
}

#stage, #stage canvas { position: fixed; inset: 0; display: block; }

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, rgba(20, 26, 70, 0.25), rgba(5, 8, 22, 0.7));
  z-index: 10;
}
.overlay[hidden] { display: none; }

.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 32px 36px;
  width: min(380px, calc(100vw - 32px));
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

h1 { margin: 0 0 4px; font-size: 44px; letter-spacing: 1px; }
h1 span { color: var(--accent); }
h2 { margin: 0 0 12px; }
.tagline, .hint, .status { color: var(--muted); }
.tagline { margin: 0 0 20px; }
.hint { font-size: 13px; margin: 14px 0 0; }
.status { min-height: 1.2em; font-size: 13px; margin: 6px 0 0; }

input, button {
  width: 100%;
  font: inherit;
  font-size: 18px;
  border-radius: 12px;
  padding: 12px 14px;
  border: none;
}
input {
  background: rgba(255, 255, 255, 0.95);
  color: #141a3a;
  margin-bottom: 12px;
  text-align: center;
}
button {
  background: var(--accent);
  color: #2a1d00;
  font-weight: bold;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.6; cursor: wait; }

#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#hud[hidden] { display: none; }

.panel {
  position: absolute;
  top: 12px;
  background: rgba(12, 16, 40, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 10px 14px;
  backdrop-filter: blur(4px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* leaderboard, top-left */
#leaderboard { left: 12px; width: 220px; font-size: 14px; }
#leaderboard h3 { margin: 0 0 6px; font-size: 15px; color: var(--accent); letter-spacing: 0.5px; }
#lb-list { list-style: none; margin: 0; padding: 0; }
#lb-list li { display: flex; align-items: center; gap: 6px; padding: 2px 0; white-space: nowrap; }
#lb-list li.me { color: var(--accent); font-weight: bold; }
#lb-list .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 6px rgba(255, 255, 255, 0.25); }
#lb-list .nm { overflow: hidden; text-overflow: ellipsis; }
#lb-list .tag { font-size: 10px; color: var(--muted); border: 1px solid rgba(154, 165, 209, 0.5); border-radius: 6px; padding: 0 4px; }
#lb-me { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.12); color: var(--accent); font-weight: bold; }

/* level progress, top-right */
#progress { right: 12px; width: 320px; }
.prog-row { display: flex; align-items: center; gap: 10px; }
.bar { flex: 1; height: 14px; border-radius: 7px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.fill { height: 100%; width: 0; border-radius: 7px; background: linear-gradient(90deg, #7fd1ff, var(--accent)); transition: width 0.25s ease-out; }
.prog-labels { display: flex; justify-content: space-between; font-size: 13px; margin-top: 6px; }
#lvl-cur { font-weight: bold; }
#lvl-next { color: var(--muted); }
#real-mass { font-size: 13px; color: #cfe3ff; margin-top: 4px; }

/* level icons (static for now; animated versions come with the object renderers) */
.lvl-icon {
  --c: #ccc;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8 0%, var(--c) 35%, color-mix(in srgb, var(--c) 45%, #000) 100%);
  box-shadow: 0 0 10px color-mix(in srgb, var(--c) 60%, transparent);
}
.lvl-icon[hidden] { display: none; }
.lvl-icon.live { background: none !important; box-shadow: none; mask: none; border-radius: 0; }
.lvl-icon canvas { display: block; }
.lvl-icon[data-level="black_hole"] { background: radial-gradient(circle, #000 0 38%, #ffb35c 46%, #7a3cff 62%, transparent 72%); box-shadow: none; }
.lvl-icon[data-level="quasar"] { background: radial-gradient(circle, #fff 0 12%, #9f7bff 30%, #2a1650 60%, transparent 72%); }
.lvl-icon[data-level="galaxy"] { background: conic-gradient(from 0deg, #d6b8ff, #6a8cff, #d6b8ff, #6a8cff, #d6b8ff); mask: radial-gradient(circle, #000 0 30%, #000a 55%, transparent 72%); }
.lvl-icon[data-level="dust"] { background: radial-gradient(circle at 30% 40%, var(--c) 0 12%, transparent 14%), radial-gradient(circle at 65% 35%, var(--c) 0 9%, transparent 11%), radial-gradient(circle at 50% 70%, var(--c) 0 14%, transparent 16%); box-shadow: none; }

/* fact toast, top-center */
.toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 600px));
  min-width: 260px;
  background: rgba(20, 26, 60, 0.9);
  border: 1px solid rgba(255, 207, 92, 0.5);
  border-radius: 14px;
  padding: 12px 16px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast[hidden] { display: none; }
.toast.pop { animation: pop 0.35s ease-out; }
.toast-title { font-weight: bold; font-size: 18px; color: var(--accent); margin-bottom: 4px; }
.toast-body { font-size: 14px; line-height: 1.35; }
@keyframes pop { from { transform: translateX(-50%) scale(0.85); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

.fact { color: #cfe3ff; font-size: 14px; line-height: 1.4; }
.fact:not(:empty)::before { content: "Did you know? "; color: var(--accent); font-weight: bold; }

/* ---------- touch controls (phones / tablets) ---------- */
/* the game owns every gesture: no page scrolling, pinch zoom, text selection or callouts */
body { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input { -webkit-user-select: text; user-select: text; }
.touch-hint { display: none; }
body.touch .touch-hint { display: block; }
body.touch .mouse-hint { display: none; }

.touch-ui { display: none; }
body.touch .touch-ui.playing { display: block; }
.stick-zone {
  position: fixed; left: 0; top: 0; bottom: 0; width: 50%;
  z-index: 6; touch-action: none;
}
.stick-base {
  position: absolute;
  left: calc(24px + 70px + env(safe-area-inset-left));
  top: calc(100% - 24px - 70px - env(safe-area-inset-bottom));
  width: 140px; height: 140px; margin: -70px 0 0 -70px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.14));
  border: 2px solid rgba(255, 255, 255, 0.25);
  opacity: 0.55;
  transition: opacity 0.15s;
  pointer-events: none;
}
.stick-base.active { opacity: 1; transition: none; }
.stick-knob {
  position: absolute; left: 50%; top: 50%;
  width: 60px; height: 60px; margin: -30px 0 0 -30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #b9c6ff 60%, #7f8fd8);
  box-shadow: 0 0 14px rgba(160, 180, 255, 0.6);
}
.boost-btn {
  position: fixed;
  right: calc(28px + env(safe-area-inset-right));
  bottom: calc(28px + env(safe-area-inset-bottom));
  width: 104px; height: 104px;
  z-index: 6; touch-action: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #fff1c2, var(--accent) 55%, #c98a12);
  box-shadow: 0 0 20px rgba(255, 207, 92, 0.45);
  color: #3a2700; font-weight: bold; font-size: 16px; letter-spacing: 1px;
  opacity: 0.85;
}
.boost-btn.on { transform: scale(0.92); opacity: 1; box-shadow: 0 0 34px rgba(255, 207, 92, 0.9); }
.boost-btn.disabled { filter: grayscale(1); opacity: 0.35; }

/* ---------- small screens: compact HUD ---------- */
@media (max-width: 700px), (max-height: 500px) {
  .panel { top: calc(8px + env(safe-area-inset-top)); padding: 6px 9px; border-radius: 10px; }
  #leaderboard { left: calc(8px + env(safe-area-inset-left)); width: 140px; font-size: 11px; }
  #leaderboard h3 { font-size: 12px; margin-bottom: 3px; }
  #lb-list li:nth-child(n+6) { display: none; }
  #lb-list .tag { display: none; }
  #lb-list .dot { width: 8px; height: 8px; }
  #progress { right: calc(8px + env(safe-area-inset-right)); width: min(190px, calc(100vw - 172px)); }
  .lvl-icon, .lvl-icon canvas { width: 28px !important; height: 28px !important; }
  .prog-row { gap: 6px; }
  .bar { height: 10px; }
  .prog-labels, #real-mass { font-size: 10px; }
  .toast { top: calc(150px + env(safe-area-inset-top)); width: calc(100vw - 24px); min-width: 0; padding: 8px 12px; }  /* below the panels, clear of the thumbs */
  .toast-title { font-size: 15px; }
  .toast-body { font-size: 12px; }
  .card { padding: 22px 20px; }
  h1 { font-size: 34px; }
}
/* landscape phones: the fact card goes in the gap between the two panels, off the player */
@media (max-height: 500px) and (min-width: 600px) {
  .toast { top: calc(8px + env(safe-area-inset-top)); width: calc(100vw - 420px - env(safe-area-inset-left) - env(safe-area-inset-right)); }
  .toast-body { font-size: 11px; line-height: 1.3; }
  #lb-list li:nth-child(n+4) { display: none; }
}
