:root {
  --bg: #f6f1e8;
  --paper: #fbf8f3;
  --ink: #1e1a17;
  --muted: #6f675f;
  --line: rgba(30, 26, 23, 0.12);
  --accent: #2f6f73;
  --accent-2: #b46f3d;
  --card: #fffdf9;
  --shadow: 0 20px 60px rgba(30, 26, 23, 0.18);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.side-panel[hidden] { display: block !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", sans-serif;
  color: var(--ink);
  background: var(--ink);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

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

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at top left, rgba(180,111,61,0.12), transparent 35%),
    radial-gradient(circle at bottom right, rgba(47,111,115,0.12), transparent 35%),
    var(--bg);
  transition: opacity 0.6s ease;
}
.overlay.fade-out { opacity: 0; pointer-events: none; }
.panel-overlay { background: rgba(30, 26, 23, 0.55); backdrop-filter: blur(6px); }

.loading-inner { text-align: center; max-width: 480px; padding: 2rem; }
.brand-mark {
  width: 64px; height: 64px; margin: 0 auto 1.2rem; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, #fffdf9, #efe6d8);
  font-family: "Cormorant Garamond", serif; font-size: 1.6rem; font-weight: 600;
  box-shadow: var(--shadow);
}
.loading-inner h1 {
  font-family: "Cormorant Garamond", serif; font-weight: 600;
  font-size: clamp(2.4rem, 6vw, 3.4rem); margin: 0 0 0.2rem; letter-spacing: 0.01em;
}
.tagline { color: var(--muted); margin: 0 0 1.8rem; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.78rem; }

.progress {
  height: 3px; border-radius: 2px; background: var(--line);
  overflow: hidden; margin: 0 auto 1.6rem; max-width: 300px;
}
#progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.3s ease; }

.btn {
  font: 600 0.95rem "Inter", sans-serif; letter-spacing: 0.02em;
  padding: 0.85rem 1.9rem; border-radius: 999px; border: 1px solid var(--line);
  cursor: pointer; background: var(--card); color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s;
  text-decoration: none; display: inline-block;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fdfbf7; }
.btn.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(47,111,115,0.35); }
.btn:disabled { opacity: 0.55; cursor: default; }

.hint { color: var(--muted); font-size: 0.82rem; margin-top: 1.6rem; }
.hint b { color: var(--ink); }
.touch-hint { display: none; }
body.touch .touch-hint { display: inline; }
body.touch .desktop-hint { display: none; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#crosshair {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px;
  margin: -3px 0 0 -3px; border-radius: 50%;
  background: rgba(253, 251, 247, 0.85);
  box-shadow: 0 0 0 1.5px rgba(30, 26, 23, 0.35), 0 0 12px rgba(0,0,0,0.35);
  transition: transform 0.15s ease, background 0.15s ease;
}
#crosshair.active { transform: scale(1.9); background: #f0c987; }
#prompt {
  position: absolute; left: 50%; top: 56%; transform: translateX(-50%);
  font-size: 0.85rem; font-weight: 500; letter-spacing: 0.04em;
  color: #fdfbf7; background: rgba(30, 26, 23, 0.72);
  border: 1px solid rgba(253,251,247,0.18);
  padding: 0.5rem 1.1rem; border-radius: 999px; backdrop-filter: blur(8px);
  white-space: nowrap;
}
#prompt b { color: #f0c987; }

/* ---------- pause ---------- */
.panel {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  max-width: 460px; width: calc(100% - 2.5rem); padding: 2.2rem 2.4rem; text-align: center;
}
.panel h2 { font-family: "Cormorant Garamond", serif; font-size: 2rem; margin: 0 0 0.4rem; }
.pause-controls { text-align: left; font-size: 0.88rem; color: var(--muted); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0.8rem 0; margin: 1.2rem 0 1.5rem; }
.pause-controls b { color: var(--ink); }
.muted { color: var(--muted); }

/* ---------- artwork info panel ---------- */
.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 25;
  width: min(430px, 92vw);
  background: var(--paper); box-shadow: -30px 0 80px rgba(30,26,23,0.35);
  padding: 3.2rem 2.4rem 2rem; overflow-y: auto;
  transform: translateX(0); transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.side-panel[hidden] { display: block; transform: translateX(105%); visibility: hidden; }
.side-panel .close {
  position: absolute; top: 1rem; right: 1.2rem; border: none; background: none;
  font-size: 1.9rem; line-height: 1; color: var(--muted); cursor: pointer;
}
.side-panel .close:hover { color: var(--ink); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.72rem; color: var(--accent-2); margin: 0 0 0.5rem; }
.side-panel h2 { font-family: "Cormorant Garamond", serif; font-size: 1.9rem; margin: 0 0 0.3rem; line-height: 1.15; }
#info-meta { font-size: 0.85rem; margin: 0 0 1.2rem; }
#info-desc { font-size: 0.95rem; line-height: 1.65; color: #3d3630; }
.price-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-top: 1.6rem; padding-top: 1.4rem; border-top: 1px solid var(--line);
}
#info-price { font-family: "Cormorant Garamond", serif; font-size: 1.5rem; font-weight: 600; }
.fineprint { font-size: 0.72rem; color: var(--muted); margin-top: 1.1rem; }

/* ---------- dialogue ---------- */
.dialogue {
  position: fixed; left: 50%; bottom: 4vh; transform: translateX(-50%);
  z-index: 25; width: min(620px, 94vw);
}
.dialogue-card {
  background: rgba(251, 248, 243, 0.96); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem 1.8rem 1.3rem;
  border: 1px solid var(--line);
}
.speaker { text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.7rem; color: var(--accent); margin: 0 0 0.55rem; font-weight: 600; }
#dialogue-text { font-family: "Cormorant Garamond", serif; font-size: 1.25rem; line-height: 1.45; margin: 0 0 1.1rem; }
#dialogue-choices { display: flex; flex-direction: column; gap: 0.45rem; }
#dialogue-choices button {
  font: 500 0.9rem "Inter", sans-serif; text-align: left;
  background: none; border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); padding: 0.6rem 0.9rem; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
#dialogue-choices button:hover { background: rgba(47,111,115,0.08); border-color: var(--accent); }
#dialogue-choices button .arrow { color: var(--accent-2); margin-right: 0.5rem; }

/* ---------- touch controls ---------- */
#joystick {
  position: fixed; z-index: 15; width: 118px; height: 118px; border-radius: 50%;
  border: 1.5px solid rgba(253,251,247,0.35); background: rgba(30,26,23,0.25);
  backdrop-filter: blur(4px); display: none;
}
#joystick .nub {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px;
  margin: -24px 0 0 -24px; border-radius: 50%;
  background: rgba(253,251,247,0.75); box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
body.touch #joystick.visible { display: block; }

@media (max-width: 640px) {
  .side-panel { padding: 2.8rem 1.6rem 1.6rem; }
  .dialogue-card { padding: 1.1rem 1.2rem 1rem; }
  #dialogue-text { font-size: 1.05rem; }
}
