:root {
  --ink:        #0A0D12;
  --slate:      #16202B;
  --slate-line: #2A3742;
  --rain:       #6FA8AE;
  --brass:      #C79A45;
  --paper:      #E9E4D8;
  --paper-dim:  #9BA3AA;

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: var(--ink); }

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  color: var(--paper);
  font-family: var(--font-ui);
}

#scene-canvas {
  position: absolute;
  inset: 0;
  display: block;
}

.hud-fade { transition: opacity 0.35s ease; }
.hidden { opacity: 0; pointer-events: none; }

/* ---------- Illustrated backdrop (behind text-only scenes) ---------- */
#backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}
#backdrop svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Rain overlay (toggled during night dialogue) ---------- */
#rain-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.7s ease;
  background-image: repeating-linear-gradient(
    112deg,
    rgba(180, 205, 214, 0.16) 0px,
    rgba(180, 205, 214, 0.16) 1px,
    transparent 2px,
    transparent 13px
  );
  background-size: 4px 160px;
  animation: rain-fall 0.4s linear infinite;
}
#rain-overlay.active { opacity: 0.55; }
@keyframes rain-fall {
  from { background-position: 0 0; }
  to   { background-position: -46px 160px; }
}

/* ---------- Scene fade transition ---------- */
#scene-fade {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s ease;
}
#scene-fade.active { opacity: 1; }

/* ---------- Scene title ---------- */
#scene-title {
  position: absolute;
  top: 28px;
  left: 32px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--paper-dim);
  letter-spacing: 0.02em;
  z-index: 5;
}

/* ---------- Caption (ambient flavor text, stays in 3D scene) ---------- */
#caption-box {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  text-align: center;
  z-index: 6;
  padding: 10px 20px;
  background: rgba(10, 13, 18, 0.72);
  border: 1px solid var(--slate-line);
  border-radius: 2px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1rem;
  color: var(--paper);
}

/* ---------- Interact / move hints ---------- */
#interact-prompt, #move-hint {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
  font-size: 0.8rem;
  color: var(--paper-dim);
}
#interact-prompt { bottom: 120px; left: 50%; transform: translateX(-50%); }
#move-hint { bottom: 40px; left: 50%; transform: translateX(-50%); }

.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--slate-line);
  border-radius: 4px;
  background: rgba(22, 32, 43, 0.85);
  font-size: 0.7rem;
  color: var(--paper);
}
.label { margin-left: 2px; }

/* ---------- Dialogue layer ---------- */
#dialogue-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
  background: linear-gradient(to top, rgba(10,13,18,0.55) 0%, rgba(10,13,18,0) 45%);
}

#dialogue-box {
  width: min(760px, 88vw);
  margin-bottom: 48px;
  padding: 28px 34px 22px;
  background: rgba(16, 22, 30, 0.92);
  border: 1px solid var(--slate-line);
  border-left: 3px solid var(--brass);
  border-radius: 2px;
  backdrop-filter: blur(6px);
  cursor: pointer;
}

#speaker-name {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--brass);
  margin-bottom: 10px;
  min-height: 1em;
  text-transform: uppercase;
}

#dialogue-text {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.55;
  color: var(--paper);
}

#advance-hint {
  margin-top: 14px;
  font-size: 0.72rem;
  color: var(--paper-dim);
  text-align: right;
}

#choices {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice-btn {
  text-align: left;
  padding: 10px 16px;
  background: transparent;
  border: 1px solid var(--slate-line);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: 0.92rem;
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.choice-btn:hover {
  border-color: var(--brass);
  background: rgba(199, 154, 69, 0.08);
}

/* ---------- Start screen ---------- */
#start-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(111,168,174,0.10), transparent 60%),
    var(--ink);
  transition: opacity 0.6s ease;
}
#start-inner { text-align: center; max-width: 520px; padding: 0 24px; }

#start-eyebrow {
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--rain);
  font-size: 0.78rem;
  margin-bottom: 14px;
}

#start-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  letter-spacing: 0.03em;
  color: var(--paper);
  margin: 0 0 16px;
}

#start-desc {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--paper-dim);
  font-size: 1rem;
  line-height: 1.5;
  margin: 0 0 34px;
}

#start-btn {
  padding: 12px 40px;
  background: transparent;
  border: 1px solid var(--brass);
  color: var(--brass);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
}
#start-btn:hover { background: var(--brass); color: var(--ink); }

#start-screen.fade-out { opacity: 0; pointer-events: none; }
