:root {
  --bg: #050508;
  --bg-deep: #020203;
  --obsidian: #0a0908;
  --amber: #ffb000;
  --amber-bright: #ffd050;
  --amber-dim: #c4922a;
  --amber-glow: rgba(255, 176, 0, 0.35);
  --text: #c9c3b6;
  --text-dim: #6f6a5e;
  --white: #e8e6df;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse 90% 60% at 50% 42%, rgba(255, 150, 20, 0.11) 0%, transparent 55%),
    radial-gradient(ellipse 80% 50% at 50% 58%, rgba(255, 120, 0, 0.05) 0%, transparent 70%),
    radial-gradient(ellipse 120% 80% at 50% 100%, rgba(8, 6, 4, 0.95) 0%, var(--bg-deep) 70%),
    var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse 72% 58% at 50% 48%, transparent 38%, rgba(0, 0, 0, 0.42) 100%);
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 1;
  touch-action: none;
}

#fallback {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

#fallback[hidden] { display: none !important; }

#fallback img {
  width: min(100%, 1280px);
  height: auto;
  max-height: 100%;
  object-fit: contain;
  filter: saturate(1.05) brightness(0.95);
}

.overlay {
  position: fixed;
  z-index: 5;
  pointer-events: none;
}

.brand-block {
  top: clamp(1.25rem, 4vh, 2.75rem);
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: min(92vw, 40rem);
  animation: rise-in 1.1s ease-out both;
}

.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.55rem;
  position: relative;
  padding-bottom: 0.65rem;
}

.eyebrow::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2.5rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--amber-dim), transparent);
  opacity: 0.75;
}

.brand {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: clamp(2.4rem, 7vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
  color: var(--white);
  text-shadow: 0 0 40px var(--amber-glow);
}

.tagline {
  margin-top: 0.7rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--amber-dim);
}

.readout {
  bottom: clamp(2.75rem, 8vh, 4.5rem);
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  animation: rise-in 1.3s 0.15s ease-out both;
  pointer-events: auto;
}

.chassis-panel {
  display: inline-block;
  padding: 0.9rem 1.6rem 0.7rem;
  background: linear-gradient(180deg, rgba(10, 9, 7, 0.92), rgba(4, 3, 2, 0.92));
  border: 1px solid rgba(196, 146, 42, 0.28);
  border-radius: 10px;
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.7), 0 0 26px rgba(255, 176, 0, 0.08);
}

/* The digits now live in the 3D nixie tubes on the model itself, so the
   flat DOM readout is visually hidden in 3D mode (kept for a11y/live
   region + the no-WebGL fallback, where it's the only display). */
.clock {
  display: none;
  font-family: "JetBrains Mono", monospace;
  font-weight: 400;
  font-size: clamp(1.1rem, 3.2vw, 1.65rem);
  letter-spacing: 0.28em;
  color: var(--amber-bright);
  text-shadow: 0 0 18px var(--amber-glow), 0 0 40px rgba(255, 176, 0, 0.2);
}

.units {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 0.55rem;
  width: min(92vw, 22rem);
  margin-inline: auto;
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.drag-hint {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.56rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: 0.55;
}

body.fallback-mode .clock { display: block; }
body.fallback-mode .units { display: grid; }
body.fallback-mode .drag-hint { display: none; }

.serial {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.5rem;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  opacity: 0.6;
}

.threshold-link {
  display: block;
  margin-top: 0.85rem;
  font-size: 0.6rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
}

.threshold-link:hover {
  color: var(--amber-dim);
}

#glitch-flash {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.05s linear;
  background:
    repeating-linear-gradient(0deg, rgba(255, 176, 0, 0.05) 0px, transparent 2px, transparent 4px),
    linear-gradient(90deg, rgba(255, 40, 40, 0.12), transparent 40%, transparent 60%, rgba(0, 220, 255, 0.12));
  mix-blend-mode: screen;
}

.foot {
  bottom: clamp(0.85rem, 2.5vh, 1.4rem);
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
  max-width: 94vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

#veil {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.85s ease-out;
}

#veil.gone {
  opacity: 0;
  pointer-events: none;
}

#veil .pulse {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--amber);
  animation: blink 1.4s ease-in-out infinite;
}

body.fallback-mode #scene { display: none; }
body.fallback-mode #fallback,
body.fallback-mode #fallback[hidden] { display: flex !important; }
body.launched .clock {
  color: var(--white);
  letter-spacing: 0.2em;
}

@keyframes blink {
  0%, 100% { opacity: 0.28; }
  50% { opacity: 1; }
}

@keyframes rise-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

body.force-3d #scene { display: block !important; }
body.force-3d #fallback,
body.force-3d #fallback[hidden] { display: none !important; }

@media (max-width: 720px), (pointer: coarse) {
  /* Always use the static tube still on phones / coarse pointers */
  #scene { display: none !important; }
  #fallback,
  #fallback[hidden] { display: flex !important; }
  .brand { font-size: clamp(2.1rem, 11vw, 3.2rem); }
  .units { width: min(92vw, 18rem); }
  body.force-3d #scene { display: block !important; }
  body.force-3d #fallback,
  body.force-3d #fallback[hidden] { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  #veil .pulse, .brand-block, .readout { animation: none; }
}
