/* ——— The Black Hole Room ——— */

:root {
  --bg: #05060d;
  --ink: #eef1f8;
  --ink-dim: #a7aec4;
  --ink-faint: #6d7590;
  --accent: #ffb45e;          /* warm disk amber */
  --accent-hot: #ffd9a0;
  --accent-cool: #7fb2ff;     /* lensed starlight blue */
  --card: rgba(13, 16, 30, 0.82);
  --card-border: rgba(255, 180, 94, 0.16);
  --radius: 18px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  --font-body: "Avenir Next", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  --font-display: "Iowan Old Style", "Palatino", Georgia, serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 58%, rgba(2, 3, 8, 0.55) 100%);
}

/* ——— Brand ——— */

.brand {
  position: fixed;
  top: 20px;
  left: 24px;
  z-index: 10;
  pointer-events: none;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.8);
}
.brand h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
  background: linear-gradient(100deg, var(--accent-hot), var(--accent) 55%, #ff8f5e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand .tagline {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-dim);
  max-width: 300px;
}

/* ——— Top bar tabs ——— */

.topbar {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 20;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: min(62vw, 640px);
}
.tab {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 12, 24, 0.66);
  color: var(--ink);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.tab:hover { border-color: rgba(255, 180, 94, 0.5); transform: translateY(-1px); }
.tab.is-active {
  border-color: rgba(255, 180, 94, 0.65);
  background: rgba(56, 34, 14, 0.72);
  color: var(--accent-hot);
}

/* ——— Readouts ——— */

.readouts {
  position: fixed;
  left: 24px;
  bottom: 22px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.ro {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  background: rgba(8, 10, 20, 0.55);
  border-left: 2px solid rgba(255, 180, 94, 0.55);
  padding: 4px 12px 4px 10px;
  border-radius: 4px 10px 10px 4px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  width: max-content;
  max-width: 78vw;
}
.ro-label { color: var(--ink-faint); white-space: nowrap; }
.ro-value { color: var(--accent-hot); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ——— Cards & panels ——— */

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.journey {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(620px, calc(100vw - 32px));
  z-index: 15;
  padding: 16px 18px 12px;
  transition: opacity 240ms ease, transform 240ms ease;
}
.journey.hidden-card { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(16px); }

.journey-head { display: flex; flex-direction: column; gap: 2px; }
.journey-step {
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
#j-title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  margin: 0 26px 6px 0;
}
.journey-body {
  font-size: 14.5px;
  color: var(--ink-dim);
  max-height: 30vh;
  overflow-y: auto;
}
.journey-body p { margin: 0 0 8px; }
.journey-body strong, .journey-body b { color: var(--ink); }
.journey-body em { color: var(--accent-hot); font-style: normal; }

.journey-action { margin-top: 8px; }
.journey-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.dots { display: flex; gap: 7px; }
.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(255, 180, 94, 0.5);
  background: transparent;
  padding: 0;
  cursor: pointer;
  transition: background 200ms ease, transform 200ms ease;
}
.dot.is-done { background: rgba(255, 180, 94, 0.35); }
.dot.is-current { background: var(--accent); transform: scale(1.25); }

.btn {
  appearance: none;
  border: 1px solid rgba(255, 180, 94, 0.55);
  background: linear-gradient(180deg, rgba(255, 180, 94, 0.22), rgba(255, 140, 60, 0.14));
  color: var(--accent-hot);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: filter 150ms ease, transform 150ms ease;
}
.btn:hover { filter: brightness(1.2); }
.btn:active { transform: scale(0.97); }
.btn.ghost {
  border-color: rgba(255, 255, 255, 0.2);
  background: transparent;
  color: var(--ink-dim);
}
.btn.ghost:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.45); }
.btn[disabled] { opacity: 0.35; pointer-events: none; }

.journey-min {
  position: absolute;
  top: 10px; right: 12px;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink-dim);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.journey-min:hover { color: var(--ink); }

/* ——— Side panels ——— */

.panel {
  position: fixed;
  top: 64px;
  right: 20px;
  width: min(380px, calc(100vw - 40px));
  max-height: calc(100vh - 150px);
  z-index: 25;
  padding: 18px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.panel h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 12px;
}
.panel-hint { display: block; font-size: 12px; font-family: var(--font-body); color: var(--ink-faint); font-weight: 400; }

/* Controls */
.ctl { margin-bottom: 16px; }
.ctl label { display: flex; justify-content: space-between; font-size: 13.5px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.ctl-val { color: var(--accent-hot); font-variant-numeric: tabular-nums; }
.ctl-note { font-size: 12px; color: var(--ink-faint); margin: 6px 0 0; }
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 22px;
  cursor: pointer;
}
.ctl-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.ctl-row label[for] { flex-basis: auto; }
select {
  background: rgba(10, 12, 24, 0.9);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 7px 10px;
  font-family: var(--font-body);
  font-size: 13px;
}
.switch { display: inline-flex !important; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.switch input { accent-color: var(--accent); width: 17px; height: 17px; cursor: pointer; }

/* Extras */
.extras-sec { margin-bottom: 18px; }
.extras-sec h3 {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 8px;
}
.facts { list-style: none; margin: 0; padding: 0; }
.facts li {
  font-size: 13.5px;
  color: var(--ink-dim);
  padding: 8px 0 8px 24px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
  position: relative;
}
.facts li::before { content: "✦"; position: absolute; left: 2px; top: 8px; color: var(--accent); }
.facts li strong { color: var(--ink); }

.challenges { list-style: none; margin: 0; padding: 0; }
.challenges li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13.5px;
  color: var(--ink-dim);
  padding: 7px 0;
}
.challenge-check {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  display: grid;
  place-items: center;
  font-size: 12px;
  margin-top: 1px;
  transition: all 250ms ease;
}
.challenges li.done .challenge-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #201204;
  content: "✓";
}
.challenges li.done { color: var(--ink); }

/* Quiz */
.quiz-q { font-size: 14.5px; font-weight: 600; margin: 0 0 10px; color: var(--ink); }
.quiz-opts { display: flex; flex-direction: column; gap: 8px; }
.quiz-opt {
  text-align: left;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-dim);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 13.5px;
  cursor: pointer;
  transition: all 150ms ease;
}
.quiz-opt:hover { border-color: rgba(255, 180, 94, 0.5); color: var(--ink); }
.quiz-opt.correct { border-color: #6fe3a0; background: rgba(111, 227, 160, 0.12); color: var(--ink); }
.quiz-opt.wrong { border-color: #ff7b7b; background: rgba(255, 123, 123, 0.1); }
.quiz-feedback { font-size: 13.5px; margin-top: 10px; color: var(--accent-hot); min-height: 20px; }
.quiz-score { font-size: 15px; color: var(--ink); font-weight: 600; }

/* Glossary */
.glossary { margin: 0; }
.glossary dt { color: var(--accent-hot); font-weight: 700; font-size: 14px; margin-top: 10px; }
.glossary dd { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-dim); }

/* Honesty panel */
#honesty-body h3 { font-size: 14px; color: var(--accent); margin: 14px 0 4px; }
#honesty-body p, #honesty-body li { font-size: 13.5px; color: var(--ink-dim); }
#honesty-body ul { padding-left: 18px; margin: 6px 0; }
#honesty-body li { margin-bottom: 6px; }

/* ——— Hotspot card ——— */

.hotcard {
  position: fixed;
  left: 24px;
  top: 110px;
  width: min(330px, calc(100vw - 48px));
  z-index: 30;
  padding: 16px 18px;
  animation: pop-in 220ms cubic-bezier(0.2, 1.2, 0.4, 1);
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.hotcard-kicker { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.hotcard h3 { font-family: var(--font-display); font-size: 19px; margin: 4px 0 8px; }
#hc-body { font-size: 13.5px; color: var(--ink-dim); }
#hc-body p { margin: 0 0 8px; }
.hotcard-close {
  position: absolute;
  top: 8px; right: 10px;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink-dim);
  font-size: 18px;
  cursor: pointer;
}
.hotcard-close:hover { color: var(--ink); }

/* ——— Toast ——— */

.toast {
  position: fixed;
  left: 50%;
  top: 76px;
  transform: translateX(-50%);
  z-index: 40;
  background: rgba(20, 24, 44, 0.92);
  border: 1px solid rgba(255, 180, 94, 0.45);
  color: var(--accent-hot);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  animation: pop-in 220ms cubic-bezier(0.2, 1.2, 0.4, 1);
  pointer-events: none;
  max-width: 86vw;
  text-align: center;
}

/* ——— Failure state ——— */

.glfail {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  text-align: center;
  background: var(--bg);
  padding: 24px;
}
.glfail p { color: var(--ink-dim); max-width: 420px; }

/* ——— Scrollbars (webkit) ——— */

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 4px; }

/* ——— Mobile ——— */

@media (max-width: 720px) {
  .brand { top: 12px; left: 14px; }
  .brand h1 { font-size: 20px; }
  .brand .tagline { display: none; }

  .topbar {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: linear-gradient(transparent, rgba(4, 5, 11, 0.9) 40%);
    scrollbar-width: none;
  }
  .topbar::-webkit-scrollbar { display: none; }
  .tab { flex: none; padding: 9px 13px; }

  .readouts {
    left: 12px;
    right: 12px;
    bottom: auto;
    top: 52px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 5px;
  }
  .ro { font-size: 11.5px; padding: 3px 9px; max-width: none; }

  .journey {
    bottom: 54px;
    width: calc(100vw - 20px);
    padding: 12px 14px 10px;
  }
  #j-title { font-size: 17px; }
  .journey-body { font-size: 13.5px; max-height: 24vh; }

  .panel {
    top: auto;
    right: 0;
    left: 0;
    bottom: 54px;
    width: calc(100vw - 16px);
    margin: 0 auto;
    max-height: 62vh;
    border-radius: 16px;
  }

  .hotcard {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 190px;
    width: auto;
  }

  .toast { top: 178px; bottom: auto; }
}

@media (max-width: 720px) and (max-height: 560px) {
  .readouts { display: none; }
  .journey-body { max-height: 18vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
