:root {
  --beneath-ink: #f4efe6;
  --beneath-muted: #9ea7a2;
  --beneath-line: rgba(226, 235, 228, 0.18);
  --beneath-accent: #e59258;
  --beneath-bg: #030809;
}

.beneath-ns-document,
.beneath-ns-document body {
  margin: 0;
  overflow: hidden;
  background: var(--beneath-bg);
  color: var(--beneath-ink);
}

.beneath-ns-document #quarto-header,
.beneath-ns-document #title-block-header,
.beneath-ns-document .nav-footer,
.beneath-ns-document #quarto-margin-sidebar,
.beneath-ns-document .quarto-secondary-nav,
.beneath-ns-document #quarto-search-results {
  display: none !important;
}

.beneath-ns-document #quarto-content,
.beneath-ns-document #quarto-document-content,
.beneath-ns-document main.content,
.beneath-ns-document .page-columns,
.beneath-ns-document .column-page,
.beneath-ns-document .column-screen,
.beneath-ns-document .column-body {
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

#beneath-app {
  position: fixed;
  inset: 0;
  display: block !important;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 56% 46%, rgba(31, 54, 49, 0.24), transparent 37%),
    linear-gradient(140deg, #071012 0%, #020607 58%, #050808 100%);
  color: var(--beneath-ink);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

#beneath-stage,
#beneath-stage canvas,
.beneath-vignette,
.beneath-grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#beneath-stage {
  z-index: 0;
}

#beneath-stage canvas {
  display: block;
  touch-action: none;
}

.beneath-vignette {
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(2, 6, 7, 0.92) 0%, rgba(2, 6, 7, 0.35) 27%, transparent 53%),
    radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, 0.62) 100%);
  transition: opacity 1.4s ease;
}

.beneath-grain {
  z-index: 2;
  pointer-events: none;
  opacity: 0.16;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.88' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
}

.beneath-home,
.beneath-intro,
.beneath-hud,
.beneath-legend,
.rotation-toggle,
.beneath-credit,
.beneath-instruction {
  position: absolute;
  z-index: 4;
}

.beneath-home {
  top: 28px;
  left: 34px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(244, 239, 230, 0.72);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-decoration: none;
}

.beneath-home:hover {
  color: var(--beneath-ink);
}

.home-monogram {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(244, 239, 230, 0.4);
  border-radius: 50%;
  color: var(--beneath-ink);
  font-size: 10px;
  letter-spacing: 0;
}

.home-rule {
  width: 34px;
  height: 1px;
  background: rgba(244, 239, 230, 0.34);
}

.beneath-intro {
  top: 50%;
  left: clamp(34px, 6vw, 96px);
  width: min(560px, 42vw);
  transform: translateY(-51%);
  transition:
    opacity 1s ease,
    transform 1.2s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.beneath-kicker {
  margin: 0 0 20px;
  color: var(--beneath-accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.32em;
}

.beneath-intro h1 {
  margin: 0;
  color: var(--beneath-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(68px, 8.5vw, 138px);
  font-weight: 400;
  letter-spacing: -0.07em;
  line-height: 0.77;
  text-wrap: balance;
  text-shadow: 0 12px 50px rgba(0, 0, 0, 0.5);
}

.beneath-deck {
  max-width: 390px;
  margin: 34px 0 28px;
  color: rgba(244, 239, 230, 0.72);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(16px, 1.35vw, 21px);
  font-style: italic;
  line-height: 1.5;
}

.beneath-enter {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--beneath-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.beneath-enter svg {
  width: 34px;
  height: 34px;
  padding: 8px;
  border: 1px solid rgba(244, 239, 230, 0.34);
  border-radius: 50%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition:
    transform 0.35s ease,
    border-color 0.35s ease,
    background 0.35s ease;
}

.beneath-enter:hover svg {
  transform: translateY(4px);
  border-color: var(--beneath-accent);
  background: rgba(229, 146, 88, 0.12);
}

.beneath-hud {
  right: 34px;
  bottom: 32px;
  left: 34px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(360px, 1.35fr) minmax(160px, 0.7fr);
  align-items: end;
  gap: 48px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px);
  transition:
    opacity 0.9s ease,
    transform 0.9s ease;
}

.beneath-chapter {
  display: flex;
  align-items: center;
  gap: 18px;
}

.beneath-chapter > span {
  color: var(--beneath-accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-style: italic;
}

.beneath-chapter div {
  padding-left: 18px;
  border-left: 1px solid var(--beneath-line);
}

.beneath-chapter p {
  margin: 0;
}

#chapter-title {
  color: var(--beneath-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
}

#chapter-detail {
  margin-top: 4px;
  color: var(--beneath-muted);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.depth-labels,
.depth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.depth-labels {
  margin-bottom: 8px;
  color: rgba(244, 239, 230, 0.5);
  font-size: 9px;
  letter-spacing: 0.2em;
}

#depth-range {
  width: 100%;
  height: 20px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: ew-resize;
}

#depth-range::-webkit-slider-runnable-track {
  height: 1px;
  background:
    linear-gradient(90deg, var(--beneath-accent) var(--depth, 0%), var(--beneath-line) var(--depth, 0%));
}

#depth-range::-webkit-slider-thumb {
  width: 11px;
  height: 11px;
  margin-top: -5px;
  appearance: none;
  border: 2px solid var(--beneath-bg);
  border-radius: 50%;
  background: var(--beneath-accent);
  box-shadow: 0 0 0 1px var(--beneath-accent), 0 0 18px rgba(229, 146, 88, 0.65);
}

#depth-range::-moz-range-track {
  height: 1px;
  background: var(--beneath-line);
}

#depth-range::-moz-range-progress {
  height: 1px;
  background: var(--beneath-accent);
}

#depth-range::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border: 2px solid var(--beneath-bg);
  border-radius: 50%;
  background: var(--beneath-accent);
}

.depth-actions {
  margin-top: 7px;
}

.depth-actions button,
.beneath-legend button,
.rotation-toggle {
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: rgba(244, 239, 230, 0.42);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.depth-actions button:hover,
.depth-actions button.is-active {
  color: var(--beneath-ink);
}

.beneath-readout {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 12px;
  text-align: right;
}

.readout-value {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 46px;
  font-style: italic;
  line-height: 0.8;
}

.readout-unit,
.readout-label {
  color: var(--beneath-muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.readout-label {
  max-width: 76px;
  padding-bottom: 2px;
  line-height: 1.4;
}

.beneath-legend {
  top: 28px;
  right: 34px;
  width: 260px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.rotation-toggle {
  top: 28px;
  right: 318px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: rgba(244, 239, 230, 0.62);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  opacity: 0;
  pointer-events: none;
  text-transform: uppercase;
  transition:
    color 0.25s ease,
    opacity 0.8s ease;
}

.rotation-toggle:hover {
  color: var(--beneath-ink);
}

.rotation-icon {
  position: relative;
  width: 16px;
  height: 16px;
  border: 1px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}

.rotation-icon::after {
  position: absolute;
  top: -2px;
  right: -1px;
  width: 5px;
  height: 5px;
  border-top: 1px solid currentColor;
  border-right: 1px solid currentColor;
  content: "";
  transform: rotate(16deg);
}

.rotation-toggle.is-paused .rotation-icon {
  border-style: dotted;
}

.beneath-legend button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--beneath-line);
  color: rgba(244, 239, 230, 0.62);
}

.legend-plus {
  color: var(--beneath-accent);
  font-size: 16px;
  transition: transform 0.3s ease;
}

.legend-content {
  display: block;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    max-height 0.45s ease,
    opacity 0.35s ease,
    padding 0.45s ease;
}

.legend-content span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--beneath-muted);
  font-size: 9px;
  line-height: 1.2;
}

.legend-content p {
  margin: 0;
  color: rgba(244, 239, 230, 0.58);
  font-size: 9px;
  line-height: 1.5;
}

.legend-content p strong {
  color: var(--beneath-ink);
  font-weight: 600;
}

.material-swatches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin: 12px 0 14px;
}

.feature-key {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 12px 0;
  border-top: 1px solid var(--beneath-line);
  border-bottom: 1px solid var(--beneath-line);
}

.feature-key span strong {
  color: rgba(244, 239, 230, 0.78);
  font-weight: 600;
}

.legend-content span::before {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 10px color-mix(in srgb, var(--swatch) 55%, transparent);
  content: "";
}

.beneath-legend.is-open .legend-content {
  max-height: 390px;
  padding-top: 14px;
  opacity: 1;
}

.beneath-legend.is-open .legend-plus {
  transform: rotate(45deg);
}

.beneath-instruction {
  top: 50%;
  right: 24px;
  margin: 0;
  color: rgba(244, 239, 230, 0.32);
  font-size: 8px;
  letter-spacing: 0.18em;
  opacity: 0;
  transform: translateY(-50%) rotate(90deg) translateX(50%);
  transform-origin: right center;
  transition: opacity 0.8s ease;
}

.beneath-credit {
  top: 50%;
  left: 32px;
  display: flex;
  width: 420px;
  flex-direction: column;
  gap: 4px;
  color: rgba(244, 239, 230, 0.32);
  font-size: 8px;
  letter-spacing: 0.1em;
  line-height: 1.5;
  opacity: 0;
  transform: translateX(-50%) rotate(-90deg) translateY(-100%);
  transform-origin: left top;
  transition: opacity 0.8s ease;
}

.beneath-credit a {
  color: rgba(244, 239, 230, 0.55);
}

.mineral-tooltip {
  position: fixed;
  z-index: 6;
  display: grid;
  min-width: 190px;
  max-width: 250px;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid rgba(245, 211, 137, 0.28);
  background: rgba(3, 8, 9, 0.82);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

.mineral-tooltip.is-pinned {
  border-color: rgba(255, 244, 201, 0.62);
  box-shadow:
    0 0 0 1px rgba(255, 244, 201, 0.08),
    0 18px 50px rgba(0, 0, 0, 0.54),
    0 0 28px rgba(245, 211, 137, 0.12);
}

.mineral-tooltip.is-pinned::after {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(244, 239, 230, 0.12);
  color: rgba(244, 239, 230, 0.38);
  content: "SELECTED · TAP ELSEWHERE TO CLOSE";
  font-size: 7px;
  letter-spacing: 0.14em;
}

#tooltip-commodity {
  color: #f5d389;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

#tooltip-name {
  color: var(--beneath-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  font-weight: 400;
}

#tooltip-meta {
  color: var(--beneath-muted);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#beneath-loader {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: var(--beneath-bg);
  color: rgba(244, 239, 230, 0.56);
  font-size: 9px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  transition:
    opacity 1s ease,
    visibility 1s ease;
}

.beneath-ns-document #termsfeed-com---nb {
  position: fixed !important;
  inset: auto 18px 18px auto !important;
  width: min(420px, calc(100vw - 36px)) !important;
  height: auto !important;
  border: 1px solid rgba(244, 239, 230, 0.16) !important;
  background: rgba(3, 8, 9, 0.9) !important;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5) !important;
  backdrop-filter: blur(18px);
}

.beneath-ns-document #termsfeed-com---nb .cc-nb-main-container {
  display: grid !important;
  gap: 8px !important;
  padding: 16px 18px !important;
}

.beneath-ns-document #termsfeed-com---nb .cc-nb-title,
.beneath-ns-document #termsfeed-com---nb .cc-nb-text {
  margin: 0 !important;
  color: rgba(244, 239, 230, 0.78) !important;
}

.beneath-ns-document #termsfeed-com---nb .cc-nb-title {
  color: var(--beneath-ink) !important;
  font-family: Georgia, "Times New Roman", serif !important;
  font-size: 15px !important;
  font-weight: 400 !important;
}

.beneath-ns-document #termsfeed-com---nb .cc-nb-text {
  font-size: 9px !important;
  line-height: 1.45 !important;
}

.beneath-ns-document #termsfeed-com---nb .cc-nb-buttons-container {
  display: flex !important;
  gap: 8px !important;
}

.beneath-ns-document #termsfeed-com---nb .cc-nb-buttons-container button {
  width: auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 8px 12px !important;
  border: 1px solid rgba(244, 239, 230, 0.2) !important;
  border-radius: 999px !important;
  background: transparent !important;
  color: var(--beneath-ink) !important;
  font-size: 8px !important;
  font-weight: 700 !important;
  letter-spacing: 0.1em !important;
  text-transform: uppercase !important;
}

.beneath-ns-document #termsfeed-com---nb .cc-nb-okagree {
  border-color: var(--beneath-accent) !important;
  background: var(--beneath-accent) !important;
  color: #17100c !important;
}

.loader-mark {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(244, 239, 230, 0.16);
  border-top-color: var(--beneath-accent);
  border-radius: 50%;
  animation: beneath-spin 1.1s linear infinite;
}

@keyframes beneath-spin {
  to { transform: rotate(360deg); }
}

#beneath-app.is-ready #beneath-loader {
  visibility: hidden;
  opacity: 0;
}

#beneath-app.has-entered .beneath-intro {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-55%) translateX(-24px);
}

#beneath-app.has-entered .beneath-vignette {
  opacity: 0.44;
}

#beneath-app.has-entered .beneath-hud,
#beneath-app.has-entered .beneath-legend,
#beneath-app.has-entered .rotation-toggle,
#beneath-app.has-entered .beneath-instruction,
#beneath-app.has-entered .beneath-credit {
  opacity: 1;
  pointer-events: auto;
}

#beneath-app.has-entered .beneath-hud {
  transform: translateY(0);
}

@media (max-width: 900px) {
  .beneath-home {
    top: 18px;
    left: 18px;
  }

  .beneath-home > span:last-child,
  .home-rule {
    display: none;
  }

  .beneath-intro {
    top: auto;
    bottom: 68px;
    left: 24px;
    width: calc(100% - 48px);
    transform: none;
  }

  .beneath-intro h1 {
    font-size: clamp(60px, 18vw, 94px);
  }

  .beneath-deck {
    max-width: 310px;
    margin: 24px 0 20px;
    font-size: 16px;
  }

  .beneath-hud {
    right: 20px;
    bottom: 20px;
    left: 20px;
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .beneath-chapter,
  .beneath-readout {
    display: none;
  }

  .beneath-legend {
    top: 18px;
    right: 18px;
    width: 220px;
  }

  .rotation-toggle {
    top: 64px;
    right: 18px;
    font-size: 8px;
  }

  .beneath-credit,
  .beneath-instruction {
    display: none;
  }

  .depth-actions button {
    font-size: 8px;
  }

  .mineral-tooltip.is-pinned {
    top: auto !important;
    right: 14px;
    bottom: 112px;
    left: 14px !important;
    width: auto;
    max-width: none;
  }

  .beneath-ns-document #termsfeed-com---nb {
    inset: 72px 12px auto 12px !important;
    width: auto !important;
  }

  .beneath-ns-document #termsfeed-com---nb .cc-nb-main-container {
    gap: 6px !important;
    padding: 12px 14px !important;
  }

  .beneath-ns-document #termsfeed-com---nb .cc-nb-text {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .loader-mark {
    animation: none;
  }

  #beneath-app *,
  #beneath-app *::before,
  #beneath-app *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
