/* Flow Field — thousands of particles ride a hidden noise current into silky, glowing ribbons. */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  -webkit-tap-highlight-color: transparent;
  margin: 0; height: 100%; overflow: hidden;
  background: #04070c;
  font-family: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: none; overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
}

#canvas {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  cursor: crosshair; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
  touch-action: none; background: #04070c;
}
#canvas.is-stirring { cursor: grabbing; }

/* ---------- Top buttons ---------- */
.topbtns {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  z-index: 6; display: inline-flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end;
  max-width: calc(100vw - 24px);
}
.pill, .iconbtn {
  appearance: none; font-family: inherit; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.12); background: rgba(12,16,26,0.58);
  color: #e9ecf2; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 120ms ease;
}
.pill { height: 34px; padding: 0 15px; border-radius: 999px; font-size: 0.8rem; font-weight: 800; letter-spacing: 0.02em; }
.iconbtn { width: 34px; height: 34px; border-radius: 50%; font-size: 0.98rem; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.pill:hover, .iconbtn:hover { border-color: rgba(255,255,255,0.34); background: rgba(24,28,42,0.7); }
.pill:active, .iconbtn:active { transform: translateY(1px); }
.pill:focus-visible, .iconbtn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(120,190,255,0.5); }
.iconbtn[aria-pressed="false"] { color: rgba(233,236,242,0.34); }
#paletteBtn { min-width: 74px; }
#reseedBtn { font-size: 0.92rem; color: #cfe4ff; }
#reseedBtn:active { transform: rotate(60deg); }

/* ---------- overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 42%, rgba(8,16,26,0.62), rgba(2,4,9,0.9));
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: opacity 320ms ease;
}
.overlay[hidden] { display: none; }
.overlay.is-hidden { opacity: 0; pointer-events: none; }
.panel {
  text-align: center; max-width: 452px; padding: 34px 30px 30px; border-radius: 24px;
  background: rgba(11,16,26,0.86); border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 34px 90px -22px rgba(0,0,0,0.85), inset 0 1px 0 0 rgba(255,255,255,0.05);
  color: #c7cdd7;
  animation: pop 340ms cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel__title {
  margin: 0 0 10px; font-size: clamp(2.3rem, 9vw, 3.5rem); font-weight: 900; letter-spacing: -0.03em; line-height: 0.96;
  background: linear-gradient(176deg, #9ff2d6 0%, #5ec8f5 42%, #7f9dff 74%, #c58cf0 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 4px 24px rgba(94,200,245,0.26));
}
.panel__text { margin: 0 0 22px; font-size: clamp(0.95rem, 3.2vw, 1.04rem); line-height: 1.55; font-weight: 500; color: #aeb6c2; }
.play-btn {
  appearance: none; font-family: inherit; font-size: 1.05rem; font-weight: 800; color: #071018;
  background: linear-gradient(180deg, #8ff0d6, #5aa8f0); border: 0; padding: 15px 44px; border-radius: 999px;
  cursor: pointer; box-shadow: 0 12px 32px -8px rgba(94,168,240,0.6);
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.play-btn:hover { transform: translateY(-2px); box-shadow: 0 18px 42px -10px rgba(94,168,240,0.72); }
.play-btn:active { transform: translateY(0); }
.play-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(94,168,240,0.5); }

/* ---------- frame + hint ---------- */
.frame { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.frame__corner {
  position: absolute; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(200, 208, 222, 0.4);
}
.frame__corner--tl { top: max(14px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); }
.frame__corner--bl { bottom: 14px; left: 16px; }
.frame__corner a { color: inherit; text-decoration: none; pointer-events: auto; }
.frame__corner a:hover { color: #8ecbff; }

.hint {
  position: fixed; bottom: 15px; left: 50%; transform: translateX(-50%); z-index: 4; margin: 0;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; color: rgba(200, 208, 222, 0.5);
  pointer-events: none; white-space: nowrap; transition: opacity 400ms ease; max-width: 92vw; text-align: center;
}
.hint.is-gone { opacity: 0; }

@media (max-width: 680px) {
  .frame__corner--tl { font-size: 0.62rem; letter-spacing: 0.1em; }
  .frame__corner--bl { display: none; }
  .hint { font-size: 0.66rem; letter-spacing: 0.02em; }
  .pill { padding: 0 12px; font-size: 0.74rem; }
}
@media (max-width: 430px) {
  .hint { white-space: normal; line-height: 1.4; bottom: 10px; }
  #trailsBtn { display: none; } /* keep the control row from wrapping on tiny screens; reseed + palette stay */
}

/* Dock the shared tip-jar / fullscreen badges bottom-right (default is right-CENTRE, which would
   sit over the field). Doubled classes out-specify the components' injected styles; silence the
   right-centre entrance nudge so nothing leaps out of the corner. */
.opt-tipjar.opt-tipjar {
  top: auto; bottom: max(14px, env(safe-area-inset-bottom)); transform: none;
}
.opt-fs.opt-fs {
  top: auto; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 54px); transform: none;
}
.opt-tipjar.opt-tipjar.tj-nudge { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .panel { animation: none; }
  #reseedBtn:active { transform: none; }
}
