:root {
  --bg: #100e0c;
  --ink: #e9e3d5;
  --ink-dim: #93897a;
  --accent: #c9a86a;
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Courier Prime', 'Courier New', monospace;
  -webkit-font-smoothing: antialiased;
}

body { height: auto; }

::selection { background: var(--accent); color: var(--bg); }

/* пространство для скролла: одна «длина» зала */
#hallScrollSpace {
  position: relative;
  width: 1px;
  height: 620vh;
  pointer-events: none;
}

#webgl {
  position: fixed;
  inset: 0;
  z-index: 1;
}
#webgl canvas { display: block; }

/* --- overlays --- */
.hall-vignette {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.42) 100%);
}

.hall-grain {
  position: fixed;
  inset: -100px;
  z-index: 11;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.05;
  mix-blend-mode: overlay;
  animation: grain 0.9s steps(4) infinite;
}
@keyframes grain {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-30px, 20px); }
  50%  { transform: translate(20px, -25px); }
  75%  { transform: translate(-15px, -10px); }
  100% { transform: translate(0, 0); }
}

/* --- loader --- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0c0a08;
  transition: opacity 0.9s ease, visibility 0.9s ease;
}
#loader.done { opacity: 0; visibility: hidden; }
.loader-inner { text-align: center; }
.loader-title {
  margin: 0 0 28px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 2.2rem;
  letter-spacing: 0.06em;
}
.loader-track {
  width: 220px;
  height: 1px;
  margin: 0 auto 16px;
  background: rgba(147, 137, 122, 0.3);
}
.loader-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}
.loader-pct {
  margin: 0;
  font-size: 0.66rem;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* --- title / hud --- */
.hall-title {
  position: fixed;
  top: 9vh;
  left: 0; right: 0;
  z-index: 20;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.8s ease;
}
.hall-title .kicker {
  margin: 0 0 12px;
  font-size: 0.66rem;
  letter-spacing: 0.55em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.hall-title h1 {
  margin: 0;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: 0.03em;
  line-height: 1;
}
.hall-title .hint {
  margin: 18px 0 0;
  font-size: 0.64rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.hall-title.faded { opacity: 0; }

.progress {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, 46vw);
  height: 1px;
  z-index: 20;
  background: rgba(147, 137, 122, 0.28);
}
.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
}

.frame-counter {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  font-size: 0.64rem;
  letter-spacing: 0.5em;
  color: var(--ink-dim);
  pointer-events: none;
}

.back-link {
  position: fixed;
  top: 26px;
  left: 26px;
  z-index: 20;
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 0.66rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  transition: color 0.25s ease;
}
.back-link:hover { color: var(--accent); }

/* --- lightbox --- */
.hall-lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 9, 8, 0.96);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  cursor: zoom-out;
}
.hall-lightbox.open { opacity: 1; visibility: visible; }
.hall-lightbox img {
  max-width: 92vw;
  max-height: 86vh;
  object-fit: contain;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.7);
  user-select: none;
  -webkit-user-drag: none;
}
.hl-counter {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.66rem;
  letter-spacing: 0.45em;
  color: var(--ink-dim);
}

@media (max-width: 640px) {
  #hallScrollSpace { height: 480vh; }
  .hall-title { top: 6vh; }
}

/* --- мобильное управление --- */
#webgl canvas { touch-action: none; }

.walk-btns {
  display: none;
  position: fixed;
  bottom: 56px;
  left: 26px;
  z-index: 30;
  flex-direction: column;
  gap: 14px;
}
.walk-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1px solid rgba(201, 168, 106, 0.4);
  background: rgba(20, 18, 16, 0.45);
  color: rgba(201, 168, 106, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.15s ease, transform 0.15s ease;
}
.walk-btn:active {
  background: rgba(201, 168, 106, 0.4);
  transform: scale(0.92);
}

body.mobile {
  position: fixed;
  inset: 0;
  overflow: hidden;
}
body.mobile .walk-btns { display: flex; }
body.mobile #hallScrollSpace { display: none; }
