/* =============================================================================
   Overlay styling. The 3D canvas fills the screen; everything else floats on
   top as small "glass" elements. Colours are the variables just below.
   ========================================================================== */
:root {
  --ink: #eef4ff;
  --ink-dim: rgba(238, 244, 255, 0.66);
  --glass: rgba(9, 14, 26, 0.56);
  --line: rgba(255, 255, 255, 0.13);
  --accent-a: #5ee7ff;
  --accent-b: #8f7bff;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: #05080f;
  color: var(--ink);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#fade { position: fixed; inset: 0; background: #03050a; opacity: 0; pointer-events: none; }

/* ---------------------------------------------------------------- loader --- */
#loader {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-content: center; justify-items: center; gap: 22px;
  background: radial-gradient(ellipse at 50% 60%, #0b1a33 0%, #05080f 65%);
  transition: opacity 1.2s ease, visibility 1.2s;
}
#loader p { margin: 0; letter-spacing: 0.28em; text-transform: uppercase; font-size: 11px; color: var(--ink-dim); }
.loader-ring {
  width: 64px; height: 64px; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 25%, var(--accent-a), var(--accent-b), transparent 85%);
  -webkit-mask: radial-gradient(circle, transparent 27px, #000 28px);
  mask: radial-gradient(circle, transparent 27px, #000 28px);
  filter: drop-shadow(0 0 12px rgba(94, 231, 255, 0.6));
  animation: spin 1.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
body.ready #loader { opacity: 0; visibility: hidden; }

/* -------------------------------------------------------------- fallback --- */
#fallback {
  position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at 50% 70%, #0d2a4a 0%, #071022 45%, #05080f 80%);
}
.fallback-card { max-width: 440px; text-align: center; }
.fallback-card h2 { font: 400 26px/1.2 var(--serif); margin: 0 0 12px; }
.fallback-card p { color: var(--ink-dim); margin: 0 0 14px; }
body.no-webgl .bar, body.no-webgl #cta.top, body.no-webgl .explain { display: none; }

/* ----------------------------------------------------------------- brand --- */
.brand {
  position: fixed; z-index: 5;
  top: max(22px, env(safe-area-inset-top)); left: max(24px, env(safe-area-inset-left));
  max-width: 330px; pointer-events: none;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.55);
}
.brand h1 { margin: 0; font: 600 13px/1 var(--sans); letter-spacing: 0.32em; text-transform: uppercase; }
.brand .tagline { margin: 8px 0 0; font: italic 400 22px/1.15 var(--serif); }
.brand .explain { margin: 12px 0 0; font-size: 12.5px; color: var(--ink-dim); }
.hint-touch { display: none; }
@media (pointer: coarse) { .hint-touch { display: inline; } .hint-mouse { display: none; } }

/* ------------------------------------------------------------------- CTA --- */
.cta {
  border: 0; border-radius: 999px; padding: 11px 20px;
  font-weight: 600; font-size: 13.5px; letter-spacing: 0.02em; color: #06101f;
  background: linear-gradient(120deg, var(--accent-a), var(--accent-b));
  box-shadow: 0 6px 28px rgba(94, 200, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 8px 34px rgba(110, 200, 255, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.cta:disabled { opacity: 0.6; cursor: default; }
.cta.top { position: fixed; z-index: 6; top: max(20px, env(safe-area-inset-top)); right: max(22px, env(safe-area-inset-right)); }

/* ----------------------------------------------------------- control bar --- */
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.bar {
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%);
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 12px;
  padding: 8px 10px; border-radius: 22px;
  max-width: calc(100vw - 20px); width: max-content;
}
.seg { display: flex; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); }
.seg button, .pill {
  border: 0; background: transparent; border-radius: 999px;
  padding: 7px 13px; font-size: 13px; color: var(--ink-dim); white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.seg button:hover, .pill:hover { color: var(--ink); }
.seg button.on { background: rgba(255, 255, 255, 0.16); color: #fff; }
.pill { background: rgba(255, 255, 255, 0.06); }
.pill.on { background: linear-gradient(120deg, rgba(94, 231, 255, 0.3), rgba(143, 123, 255, 0.3)); color: #fff; }
button:focus-visible, .swatches label:focus-within { outline: 2px solid var(--accent-a); outline-offset: 2px; }

.swatches { display: flex; align-items: center; gap: 7px; padding: 0 2px; }
.swatches button, .swatches label {
  position: relative; width: 22px; height: 22px; padding: 0; border-radius: 50%;
  border: 2px solid transparent; background: var(--g); background-clip: padding-box;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18); cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.swatches .on { box-shadow: 0 0 0 2px #fff; transform: scale(1.1); }
.swatches label { overflow: hidden; }
.swatches label::after {   /* small "+" so it reads as "pick your own" */
  content: "+"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: rgba(0, 0, 0, 0.55); pointer-events: none;
}
.swatches input[type=color] { position: absolute; inset: -6px; width: 40px; height: 40px; opacity: 0; cursor: pointer; }

/* ------------------------------------------------------------ More panel --- */
#morePanel {
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%);
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 62px);
  display: grid; gap: 12px; width: min(330px, calc(100vw - 24px));
  padding: 14px 16px; border-radius: 18px;
}
#morePanel label, #morePanel .row { display: grid; gap: 6px; font-size: 12.5px; color: var(--ink-dim); }
.seg.small button { flex: 1; padding: 6px 4px; font-size: 12px; }
#morePanel span { display: flex; justify-content: space-between; }
#morePanel output { color: var(--ink); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent-a); }

/* --------------------------------------------------------------- waitlist --- */
dialog {
  width: min(420px, calc(100vw - 28px)); padding: 28px 26px 24px; border-radius: 22px;
  color: var(--ink); background: rgba(10, 16, 30, 0.86); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}
dialog::backdrop { background: rgba(3, 6, 12, 0.55); }
dialog h2 { margin: 0 0 6px; font: 400 26px/1.2 var(--serif); }
dialog .sub { margin: 0 0 18px; color: var(--ink-dim); }
dialog .close {
  position: absolute; top: 10px; right: 12px; width: 34px; height: 34px;
  border: 0; border-radius: 50%; background: transparent; font-size: 22px; line-height: 1; color: var(--ink-dim);
}
dialog .close:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.field { display: grid; gap: 6px; font-size: 12.5px; color: var(--ink-dim); }
.field input {
  padding: 12px 14px; border-radius: 12px; font-size: 16px;   /* 16px stops iOS zooming in */
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); outline: none;
}
.field input:focus { border-color: var(--accent-a); }
fieldset { border: 0; padding: 0; margin: 18px 0 20px; }
legend { padding: 0; margin-bottom: 9px; font-size: 12.5px; color: var(--ink-dim); }
legend em { opacity: 0.7; font-style: normal; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span {
  display: block; padding: 8px 13px; border-radius: 999px; font-size: 13px; cursor: pointer;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); transition: all 0.15s;
}
.chips input:checked + span { background: rgba(94, 231, 255, 0.18); border-color: var(--accent-a); color: #fff; }
.chips input:focus-visible + span { outline: 2px solid var(--accent-a); outline-offset: 2px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
dialog .cta { width: 100%; padding: 13px; font-size: 15px; }
.status { min-height: 1.4em; margin: 10px 0 0; font-size: 12.5px; color: var(--ink-dim); }
.demo { margin: 4px 0 0; font-size: 11.5px; color: #ffc46b; }
#wlDone .pill { margin-top: 4px; }

/* ---------------------------------------------------------------- phones --- */
@media (max-width: 720px) {
  .brand { max-width: calc(100vw - 190px); left: 16px; top: max(16px, env(safe-area-inset-top)); }
  .brand h1 { font-size: 11px; letter-spacing: 0.26em; }
  .brand .tagline { font-size: 18px; }
  .brand .explain { font-size: 12px; max-width: 260px; }
  .cta.top { right: 14px; top: max(14px, env(safe-area-inset-top)); padding: 10px 15px; font-size: 13px; }
  .bar { bottom: max(10px, env(safe-area-inset-bottom)); gap: 8px 8px; padding: 8px; border-radius: 20px; width: calc(100vw - 16px); }
  .seg button, .pill { padding: 8px 10px; font-size: 12.5px; }
  #modes { width: 100%; justify-content: space-between; }
  #modes button { flex: 1; }
  #morePanel { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 162px); }
}
@media (max-width: 380px) {
  .seg button, .pill { padding: 8px 7px; font-size: 12px; }
  .swatches { gap: 5px; }
}
@media (prefers-reduced-motion: reduce) { .loader-ring { animation-duration: 4s; } }
