:root {
  --bg-0: #0e0b09;
  --bg-1: #171310;
  --ink: #f4ede4;
  --ink-dim: rgba(244, 237, 228, 0.62);
  --ink-faint: rgba(244, 237, 228, 0.38);
  --accent: #e2531f;
  --accent-soft: rgba(226, 83, 31, 0.16);
  --line: rgba(244, 237, 228, 0.14);
  --radius: 999px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: radial-gradient(120% 140% at 50% 0%, var(--bg-1) 0%, var(--bg-0) 62%, #080605 100%);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

#scene-root {
  position: fixed;
  inset: 0;
}

#viewer {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- Loading screen ---------- */

#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: var(--bg-0);
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

#loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-mark {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
}

.loading-mark span {
  font-size: 0.34em;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.loading-bar {
  width: min(240px, 60vw);
  height: 2px;
  background: var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.loading-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.loading-pct {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- HUD ---------- */

#hud-top,
#hud-bottom {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(16px, 3vw, 34px) clamp(18px, 4vw, 44px);
  pointer-events: none;
}

#hud-top {
  top: 0;
}

#hud-bottom {
  bottom: 0;
}

#hud-top .brand,
#hud-top .views,
#hud-bottom .hint,
#hud-bottom .ghost-btn {
  pointer-events: auto;
}

.brand {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand span {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.views {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(20, 16, 13, 0.5);
  backdrop-filter: blur(10px);
}

.view-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.03em;
  padding: 7px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
}

.view-btn:hover {
  color: var(--ink);
}

.view-btn.is-active {
  background: var(--accent);
  color: #1a0e08;
  font-weight: 600;
}

/* ---------- Copy block ---------- */

#hud-copy {
  position: fixed;
  left: clamp(18px, 4vw, 44px);
  bottom: clamp(84px, 14vh, 132px);
  z-index: 8;
  max-width: 420px;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

#hud-copy h1 {
  margin: 0 0 14px;
  font-size: clamp(28px, 4.4vw, 46px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sub {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-dim);
  max-width: 38ch;
}

/* ---------- Bottom hint / controls ---------- */

.hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

.hint-icon {
  display: inline-flex;
  color: var(--accent);
}

.ghost-btn {
  appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--ink-dim);
  background: rgba(20, 16, 13, 0.5);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 16px;
  backdrop-filter: blur(10px);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.ghost-btn:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.ghost-btn[data-on="false"] {
  color: var(--ink-faint);
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  #hud-top {
    align-items: flex-start;
  }

  .views {
    transform: scale(0.92);
    transform-origin: top right;
  }

  #hud-copy {
    bottom: 128px;
    max-width: 78vw;
  }

  #hud-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-bar-fill {
    transition: none;
  }
}
