/* ==========================================================================
   Planet Clicker - design tokens, reset, and the space backdrop.
   ========================================================================== */

:root {
  /* Surfaces, darkest to lightest. */
  --void: #04050d;
  --deep: #080b1a;
  --surface: #0e1226;
  --surface-2: #151b35;
  --surface-3: #1d2547;
  --line: #262f57;
  --line-soft: #1a2143;

  /* Text. */
  --text: #eef1ff;
  --text-muted: #99a3cc;
  --text-dim: #6b76a3;

  /* Brand: electric cyan energy against a violet cosmos. */
  --energy: #38e1d0;
  --energy-bright: #6ff5e8;
  --energy-dim: #1d8a80;
  --violet: #8b5cf6;
  --violet-bright: #a78bfa;
  --magenta: #f062c8;
  --amber: #fbbf5c;
  --danger: #f2606b;
  --success: #4ade80;

  /* Medals. */
  --gold: #ffd45e;
  --silver: #cfd8ec;
  --bronze: #d99358;

  /* Type. */
  --font-ui: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-num: 'SF Mono', 'Cascadia Mono', 'Roboto Mono', 'Courier New', monospace;

  /* Geometry. */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;

  /* Elevation and glow. */
  --shadow-1: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 12px 34px rgba(0, 0, 0, 0.5);
  --shadow-3: 0 26px 70px rgba(0, 0, 0, 0.62);
  --glow-energy: 0 0 26px rgba(56, 225, 208, 0.36);
  --glow-violet: 0 0 30px rgba(139, 92, 246, 0.34);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 240ms;
}

/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

html {
  /* Stops iOS from inflating text in landscape. */
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-ui);
  background: var(--void);
  color: var(--text);
  line-height: 1.5;
  /* The board scrolls internally; the page itself never should. */
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, p, dl, dd, ol, ul, figure {
  margin: 0;
}

ol, ul {
  padding: 0;
  list-style: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* Any class that sets `display` would otherwise beat the [hidden] attribute.
   Elements are hidden and shown by toggling `hidden` all over this project, so
   make that attribute win everywhere. */
[hidden] { display: none !important; }

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

img, svg { display: block; max-width: 100%; }

/* --------------------------------------------------------------------------
   Focus: always visible, never only a colour change.
   -------------------------------------------------------------------------- */

:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--energy-bright);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Backdrop: a static starfield plus two slow nebula washes.
   Both are composited layers, so they cost nothing per frame.
   -------------------------------------------------------------------------- */

.starfield,
.nebula {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.starfield { overflow: hidden; }

.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  opacity: var(--star-opacity, 0.5);
  animation: twinkle var(--twinkle-duration, 4s) ease-in-out infinite;
  animation-delay: var(--twinkle-delay, 0s);
  will-change: opacity;
}

@keyframes twinkle {
  0%, 100% { opacity: calc(var(--star-opacity, 0.5) * 0.35); }
  50%      { opacity: var(--star-opacity, 0.5); }
}

.nebula {
  background:
    radial-gradient(58% 46% at 14% 8%, rgba(139, 92, 246, 0.20), transparent 62%),
    radial-gradient(50% 42% at 88% 18%, rgba(56, 225, 208, 0.14), transparent 60%),
    radial-gradient(70% 55% at 50% 108%, rgba(240, 98, 200, 0.13), transparent 64%);
  animation: drift 34s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes drift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1.02); }
  to   { transform: translate3d(1.5%, 1.5%, 0) scale(1.07); }
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--void);
  color: var(--text);
  padding: 24px;
  text-align: center;
  z-index: 999;
}

/* --------------------------------------------------------------------------
   Reduced motion: keep every state change, drop the movement.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .nebula { animation: none; }
  .star { animation: none; opacity: var(--star-opacity, 0.5); }
}

/* Same, but driven by the in-game setting rather than the OS. */
body.reduced-effects .nebula { animation: none; }
body.reduced-effects .star { animation: none; }
body.reduced-effects .float-num { animation-duration: 600ms; }
