:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f8fafc;
  background: #050506;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #050506;
}

button,
a,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #050506;
}

.app-shell::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 30%, transparent 0%, rgba(0, 0, 0, 0.05) 42%, rgba(0, 0, 0, 0.36) 100%),
    linear-gradient(180deg, rgba(5, 5, 6, 0.28), transparent 28%, rgba(5, 5, 6, 0.34));
}

.app-mode-read::after {
  background:
    radial-gradient(circle at 50% 30%, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.54) 66%, rgba(0, 0, 0, 0.84) 100%),
    linear-gradient(180deg, rgba(5, 5, 6, 0.52), transparent 38%, rgba(5, 5, 6, 0.72));
}

.app-mode-map::after {
  background: rgba(0, 0, 0, 0.58);
}

.story-hud {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: start;
  gap: 16px;
  max-width: min(880px, calc(100vw - 32px));
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 22px;
  padding: 14px;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(6, 6, 8, 0.48);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.story-hud-copy {
  min-width: 0;
}

.story-hud h2,
.story-hud p {
  margin: 0;
}

.story-hud h2 {
  margin-top: 3px;
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.story-hud p:not(.story-hud-kicker) {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 0.78rem;
}

.story-hud-kicker {
  color: rgba(255, 255, 255, 0.52);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.story-mode-switch,
.story-hud-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.story-mode-switch {
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
}

.story-mode-switch button,
.story-hud-actions button,
.reader-footer button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 8px 11px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition:
    transform 160ms ease,
    color 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    opacity 160ms ease;
}

.story-mode-switch button {
  border-color: transparent;
  padding: 7px 11px;
  font-size: 0.76rem;
  font-weight: 760;
}

.story-mode-switch button.is-active {
  color: #fff;
  background: rgba(216, 208, 186, 0.16);
  border-color: rgba(216, 208, 186, 0.2);
}

.story-mode-switch button:hover,
.story-hud-actions button:hover:not(:disabled),
.story-hud-actions button:focus-visible,
.reader-footer button:hover:not(:disabled),
.reader-footer button:focus-visible {
  outline: none;
  transform: translateY(-1px);
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
}

.story-hud-actions button:disabled,
.reader-footer button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.story-hud-stats {
  margin-top: 6px !important;
  color: rgba(216, 208, 186, 0.68) !important;
  font-size: 0.7rem !important;
  font-weight: 720;
}

.story-instructions {
  position: fixed;
  right: 18px;
  bottom: 112px;
  z-index: 20;
  max-width: min(390px, calc(100vw - 36px));
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  padding: 9px 13px;
  color: rgba(255, 255, 255, 0.62);
  background: rgba(6, 6, 8, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 0.76rem;
  font-weight: 650;
}

.scene-transition {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 0%, rgba(0, 0, 0, 0.08) 35%, rgba(0, 0, 0, 0.72) 100%),
    rgba(0, 0, 0, 0.18);
  opacity: 0;
  transition: opacity 260ms ease;
}

.scene-transition.is-active {
  opacity: 1;
}

.reader-panel {
  position: fixed;
  inset: 0;
  z-index: 24;
  display: grid;
  place-items: center;
  pointer-events: none;
  padding: 112px 20px 36px;
}

.reader-panel-inner {
  width: min(820px, 100%);
  max-height: calc(100vh - 156px);
  overflow: auto;
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 28px;
  padding: clamp(24px, 4vw, 46px);
  color: rgba(255, 255, 255, 0.86);
  background:
    radial-gradient(circle at top right, rgba(216, 208, 186, 0.1), transparent 36%),
    rgba(6, 6, 8, 0.68);
  box-shadow: 0 26px 100px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px) saturate(120%);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
}

.reader-panel-inner::-webkit-scrollbar {
  width: 8px;
}

.reader-panel-inner::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.reader-kicker {
  margin: 0 0 12px;
  color: rgba(216, 208, 186, 0.72);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.reader-panel h1 {
  margin: 0 0 22px;
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 7vw, 5.35rem);
  font-weight: 500;
  line-height: 0.94;
  letter-spacing: -0.055em;
}

.reader-body {
  display: grid;
  gap: 17px;
}

.reader-body p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(1.04rem, 1.7vw, 1.22rem);
  line-height: 1.78;
}

.reader-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.map-workspace {
  position: fixed;
  inset: 104px 16px 18px;
  z-index: 24;
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(420px, 1.05fr);
  gap: 16px;
  pointer-events: none;
}

.map-workspace .constellation-panel,
.map-workspace .archive-index {
  position: relative;
  inset: auto;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  width: 100%;
  max-width: none;
  height: 100%;
  pointer-events: auto;
}

.map-workspace .constellation-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.map-workspace .constellation-map {
  height: 100%;
  min-height: 0;
}

.map-workspace .archive-index {
  max-height: none;
}

.scene-quicknav {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 24;
  width: min(460px, calc(100vw - 32px));
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 22px;
  padding: 12px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(6, 6, 8, 0.48);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.scene-quicknav-title {
  margin: 0 0 8px;
  color: rgba(255, 255, 255, 0.52);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.scene-quicknav-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scene-quicknav-list button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 8px 11px 8px 8px;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  font-size: 0.76rem;
}

.scene-quicknav-list button.is-entry {
  border-color: rgba(216, 208, 186, 0.22);
}

.scene-quicknav-list button.is-tag {
  border-color: rgba(159, 182, 173, 0.22);
}

.scene-quicknav-list button.is-chapter {
  border-color: rgba(184, 200, 216, 0.24);
}

.scene-quicknav-list button:hover:not(:disabled),
.scene-quicknav-list button:focus-visible {
  outline: none;
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
}

.scene-quicknav-list button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.scene-quicknav-list button span {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(216, 208, 186, 0.18);
  font-size: 0.65rem;
  font-weight: 800;
}

.chapter-progress {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 22;
  display: grid;
  gap: 7px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.chapter-progress-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 7px 10px;
  color: rgba(255, 255, 255, 0.64);
  background: rgba(6, 6, 8, 0.38);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 0.68rem;
  font-weight: 750;
}

.chapter-progress-row span,
.chapter-progress-row strong {
  position: relative;
  z-index: 1;
}

.chapter-progress-row strong {
  color: rgba(255, 255, 255, 0.82);
}

.chapter-progress-row i {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(216, 208, 186, 0.16), rgba(184, 200, 216, 0.08));
}

.content-diagnostics {
  position: fixed;
  left: 16px;
  top: 106px;
  z-index: 31;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: min(560px, calc(100vw - 32px));
  border: 1px solid rgba(248, 113, 113, 0.24);
  border-radius: 18px;
  padding: 10px 12px;
  color: rgba(255, 255, 255, 0.76);
  background: rgba(69, 10, 10, 0.36);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 0.72rem;
}

.content-diagnostics strong {
  color: #fff;
}

.content-diagnostics span {
  color: rgba(255, 255, 255, 0.72);
}

@media (max-width: 1120px) {
  .story-hud {
    grid-template-columns: 1fr;
    width: min(640px, calc(100vw - 32px));
  }

  .map-workspace {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .map-workspace .constellation-panel,
  .map-workspace .archive-index {
    min-height: 480px;
  }
}

@media (max-width: 920px) {
  .scene-quicknav {
    left: 10px;
    bottom: 10px;
    max-width: calc(100vw - 20px);
    border-radius: 18px;
  }

  .chapter-progress,
  .story-instructions {
    display: none;
  }

  .map-workspace {
    inset: 184px 10px 10px;
  }
}

@media (max-width: 720px) {
  .story-hud {
    top: 10px;
    left: 10px;
    max-width: calc(100vw - 20px);
    padding: 12px;
    border-radius: 18px;
  }

  .story-mode-switch,
  .story-hud-actions,
  .reader-footer {
    width: 100%;
  }

  .story-mode-switch button,
  .story-hud-actions button,
  .reader-footer button {
    flex: 1 1 auto;
  }

  .reader-panel {
    padding: 196px 10px 14px;
  }

  .reader-panel-inner {
    max-height: calc(100vh - 212px);
    border-radius: 22px;
  }
}

@media (max-width: 640px) {
  .scene-quicknav {
    display: none;
  }

  .map-workspace {
    inset: 214px 10px 10px;
  }

  .map-workspace .constellation-panel,
  .map-workspace .archive-index {
    min-height: 420px;
  }
}

/* Phase 6: navigation and visual clarity upgrades */
.journey-trail {
  position: fixed;
  top: 116px;
  left: 16px;
  z-index: 26;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: min(720px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  padding: 7px;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(6, 6, 8, 0.4);
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.journey-trail-label {
  padding: 0 5px 0 8px;
  color: rgba(216, 208, 186, 0.62);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.journey-trail button,
.journey-trail strong {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 7px 10px;
  color: rgba(255, 255, 255, 0.68);
  background: rgba(255, 255, 255, 0.055);
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 740;
}

.journey-trail button {
  cursor: pointer;
}

.journey-trail button::after {
  content: "›";
  margin-left: 7px;
  color: rgba(255, 255, 255, 0.28);
}

.journey-trail button:hover,
.journey-trail button:focus-visible {
  outline: none;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.journey-trail strong {
  color: #fff;
  background: rgba(216, 208, 186, 0.12);
  border-color: rgba(216, 208, 186, 0.22);
}

.portal-dock {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 25;
  width: min(520px, calc(100vw - 32px));
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 24px;
  padding: 12px;
  color: rgba(255, 255, 255, 0.78);
  background:
    radial-gradient(circle at top left, rgba(216, 208, 186, 0.1), transparent 36%),
    rgba(6, 6, 8, 0.52);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(16px) saturate(118%);
  -webkit-backdrop-filter: blur(16px) saturate(118%);
}

.portal-dock-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.portal-dock-header p,
.portal-dock-header strong,
.portal-dock-header span {
  margin: 0;
}

.portal-dock-header p {
  color: rgba(255, 255, 255, 0.52);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.portal-dock-header strong {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.84);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 500;
}

.portal-dock-header span {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 6px 9px;
  color: rgba(255, 255, 255, 0.58);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.68rem;
  font-weight: 760;
  text-transform: uppercase;
}

.portal-dock-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.portal-dock-card {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 9px;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 10px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  text-align: left;
  transition:
    transform 170ms ease,
    border-color 170ms ease,
    background 170ms ease;
}

.portal-dock-card:hover,
.portal-dock-card:focus-visible {
  outline: none;
  transform: translateY(-2px);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.105);
}

.portal-dock-card.is-entry {
  border-color: rgba(216, 208, 186, 0.24);
}

.portal-dock-card.is-tag {
  border-color: rgba(159, 182, 173, 0.24);
}

.portal-dock-card.is-chapter {
  border-color: rgba(184, 200, 216, 0.26);
}

.portal-dock-card.is-visual {
  border-color: rgba(232, 212, 154, 0.24);
}

.portal-dock-card.is-visited:not(:hover) {
  opacity: 0.72;
}

.portal-dock-card:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.portal-dock-shortcut {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: rgba(216, 208, 186, 0.16);
  box-shadow: inset 0 0 0 1px rgba(216, 208, 186, 0.18);
  font-size: 0.7rem;
  font-weight: 850;
}

.portal-dock-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.portal-dock-copy small {
  color: rgba(255, 255, 255, 0.48);
  font-size: 0.58rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.portal-dock-copy strong {
  overflow: hidden;
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.02;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-dock-copy em {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.68rem;
  font-style: normal;
  line-height: 1.32;
}

.chapter-path {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 24;
  width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 8px 10px;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(6, 6, 8, 0.43);
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.chapter-path-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 4px 7px;
}

.chapter-path-header span,
.chapter-path-header strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.64rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.chapter-path-header span {
  color: rgba(255, 255, 255, 0.48);
}

.chapter-path-header strong {
  color: rgba(216, 208, 186, 0.76);
}

.chapter-path-nodes {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 1px;
  scrollbar-width: none;
}

.chapter-path-nodes::-webkit-scrollbar {
  display: none;
}

.chapter-path-nodes button {
  flex: 0 0 auto;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 850;
}

.chapter-path-nodes button.is-visited {
  color: rgba(255, 255, 255, 0.82);
  border-color: rgba(159, 182, 173, 0.24);
  background: rgba(159, 182, 173, 0.08);
}

.chapter-path-nodes button.is-active {
  color: #050506;
  border-color: rgba(216, 208, 186, 0.72);
  background: rgba(216, 208, 186, 0.9);
}

.chapter-path-nodes button:hover,
.chapter-path-nodes button:focus-visible {
  outline: none;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.36);
  background: rgba(255, 255, 255, 0.13);
}

.chapter-path-nodes button.is-active:hover,
.chapter-path-nodes button.is-active:focus-visible {
  color: #050506;
  background: rgba(216, 208, 186, 1);
}

.scene-compass {
  position: fixed;
  right: 16px;
  top: 16px;
  z-index: 25;
  display: grid;
  gap: 4px;
  min-width: 188px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 11px 12px;
  color: rgba(255, 255, 255, 0.76);
  background: rgba(6, 6, 8, 0.42);
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  text-align: right;
}

.scene-compass span {
  color: rgba(216, 208, 186, 0.72);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.scene-compass strong {
  color: #fff;
  font-size: 0.9rem;
  font-weight: 760;
}

.scene-compass em {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.68rem;
  font-style: normal;
}

.scene-transition {
  display: grid;
  place-items: center;
}

.scene-transition span {
  transform: translateY(12px);
  color: rgba(216, 208, 186, 0.82);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.22em;
  opacity: 0;
  text-transform: uppercase;
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.scene-transition.is-active span {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1180px) {
  .portal-dock-list {
    grid-template-columns: 1fr;
  }

  .portal-dock {
    width: min(360px, calc(100vw - 32px));
  }

  .chapter-path {
    left: auto;
    right: 16px;
    bottom: 16px;
    width: min(360px, calc(100vw - 32px));
    transform: none;
  }
}

@media (max-width: 920px) {
  .journey-trail {
    top: 190px;
    left: 10px;
    max-width: calc(100vw - 20px);
  }

  .portal-dock {
    left: 10px;
    bottom: 10px;
    width: min(390px, calc(100vw - 20px));
    border-radius: 20px;
  }

  .chapter-path,
  .scene-compass {
    display: none;
  }
}

@media (max-width: 720px) {
  .journey-trail {
    display: none;
  }

  .portal-dock {
    max-height: 32vh;
    overflow: auto;
  }

  .portal-dock-header span {
    display: none;
  }
}

@media (max-width: 640px) {
  .portal-dock {
    display: none;
  }
}

/* Phase 2: narrative guidance layer */
.narrative-veil {
  position: fixed;
  top: 118px;
  right: 16px;
  z-index: 26;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  width: min(420px, calc(100vw - 32px));
  border: 1px solid rgba(216, 208, 186, 0.16);
  border-radius: 24px;
  padding: 13px;
  color: rgba(255, 255, 255, 0.78);
  background:
    radial-gradient(circle at top left, rgba(216, 208, 186, 0.13), transparent 36%),
    radial-gradient(circle at bottom right, rgba(159, 182, 173, 0.08), transparent 42%),
    rgba(6, 6, 8, 0.42);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  pointer-events: none;
}

.narrative-veil-orb {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.72), rgba(216, 208, 186, 0.2) 34%, transparent 62%),
    rgba(216, 208, 186, 0.08);
  box-shadow:
    0 0 0 1px rgba(216, 208, 186, 0.16),
    0 0 34px rgba(216, 208, 186, 0.16);
}

.narrative-veil-orb::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: inherit;
}

.narrative-veil-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.narrative-veil-copy p,
.narrative-veil-copy h3,
.narrative-veil-copy span,
.narrative-veil-copy em {
  margin: 0;
}

.narrative-veil-copy p {
  color: rgba(216, 208, 186, 0.68);
  font-size: 0.6rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.narrative-veil-copy h3 {
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.28rem;
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.narrative-veil-copy span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.76rem;
  line-height: 1.45;
}

.narrative-veil-copy em {
  color: rgba(159, 182, 173, 0.76);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 680;
  line-height: 1.38;
}

.narrative-veil-meter {
  grid-column: 1 / -1;
  position: relative;
  overflow: hidden;
  min-height: 25px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
}

.narrative-veil-meter strong {
  position: relative;
  z-index: 1;
  display: block;
  padding: 6px 10px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.narrative-veil-meter i {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(216, 208, 186, 0.22), rgba(159, 182, 173, 0.12));
}

@media (max-width: 1180px) {
  .narrative-veil {
    top: 190px;
    width: min(360px, calc(100vw - 32px));
  }
}

@media (max-width: 920px) {
  .narrative-veil {
    display: none;
  }
}

/* Phase 7 navigation pass: one lightweight prompt replaces stacked explore HUDs in walk mode. */
.contextual-nav-prompt {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 24;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "state title"
    "state copy";
  gap: 3px 10px;
  width: min(520px, calc(100vw - 32px));
  padding: 11px 14px;
  border: 1px solid rgba(255, 245, 206, 0.16);
  border-radius: 18px;
  color: #f6efe2;
  background:
    radial-gradient(circle at left, rgba(255, 245, 206, 0.1), transparent 36%),
    rgba(6, 7, 9, 0.62);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  pointer-events: none;
  transform: translateX(-50%);
}

.contextual-nav-prompt span {
  grid-area: state;
  align-self: center;
  padding: 5px 8px;
  border: 1px solid rgba(255, 245, 206, 0.16);
  border-radius: 999px;
  color: rgba(255, 245, 206, 0.74);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.contextual-nav-prompt strong {
  grid-area: title;
  min-width: 0;
  overflow: hidden;
  color: #fff;
  font-size: 0.84rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contextual-nav-prompt em {
  grid-area: copy;
  color: rgba(246, 239, 226, 0.58);
  font-size: 0.72rem;
  font-style: normal;
  line-height: 1.28;
}

.contextual-nav-prompt.is-lost {
  border-color: rgba(255, 190, 130, 0.24);
  background:
    radial-gradient(circle at left, rgba(255, 128, 80, 0.14), transparent 38%),
    rgba(7, 6, 6, 0.68);
}

.contextual-nav-prompt.is-inside-clearing {
  border-color: rgba(255, 245, 206, 0.26);
  background:
    radial-gradient(circle at left, rgba(255, 245, 206, 0.18), transparent 42%),
    rgba(6, 7, 9, 0.64);
}

@media (max-width: 720px) {
  .contextual-nav-prompt {
    bottom: 18px;
    width: min(440px, calc(100vw - 24px));
    grid-template-columns: 1fr;
    grid-template-areas:
      "state"
      "title"
      "copy";
  }

  .contextual-nav-prompt span {
    justify-self: start;
  }
}

.cloud-journey-card {
  position: absolute;
  top: 20px;
  right: 22px;
  z-index: 36;
  width: min(300px, calc(100vw - 44px));
  color: #f6efe2;
  pointer-events: auto;
}

.cloud-journey-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 245, 206, 0.16);
  border-radius: 999px;
  color: inherit;
  background: rgba(6, 7, 9, 0.58);
  box-shadow: 0 16px 54px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  cursor: pointer;
}

.cloud-journey-summary span {
  align-self: center;
  padding: 3px 7px;
  border-radius: 999px;
  color: rgba(255, 245, 206, 0.78);
  background: rgba(255, 245, 206, 0.08);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cloud-journey-summary strong {
  align-self: center;
  overflow: hidden;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cloud-journey-card-saving .cloud-journey-summary,
.cloud-journey-card-loading .cloud-journey-summary {
  border-color: rgba(255, 245, 206, 0.28);
}

.cloud-journey-card-error .cloud-journey-summary {
  border-color: rgba(255, 142, 104, 0.32);
}

.cloud-journey-panel {
  margin-top: 9px;
  padding: 13px;
  border: 1px solid rgba(255, 245, 206, 0.16);
  border-radius: 18px;
  background:
    radial-gradient(circle at top right, rgba(255, 245, 206, 0.12), transparent 38%),
    rgba(6, 7, 9, 0.76);
  box-shadow: 0 20px 68px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.cloud-journey-panel p,
.cloud-journey-panel small {
  display: block;
  margin: 0 0 10px;
  color: rgba(246, 239, 226, 0.68);
  font-size: 0.72rem;
  line-height: 1.42;
}

.cloud-journey-panel form {
  display: grid;
  gap: 9px;
}

.cloud-journey-panel label {
  display: grid;
  gap: 6px;
  color: rgba(255, 245, 206, 0.72);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.cloud-journey-panel input {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid rgba(255, 245, 206, 0.16);
  border-radius: 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  outline: none;
}

.cloud-journey-panel input:focus {
  border-color: rgba(255, 245, 206, 0.36);
}

.cloud-journey-panel button {
  padding: 9px 11px;
  border: 1px solid rgba(255, 245, 206, 0.18);
  border-radius: 999px;
  color: #0d0d0d;
  background: rgba(255, 245, 206, 0.88);
  cursor: pointer;
}

.cloud-journey-panel button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.cloud-journey-disconnect {
  width: 100%;
  color: #f6efe2 !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

.cloud-journey-message {
  margin-top: 10px !important;
  word-break: break-word;
}

@media (max-width: 720px) {
  .cloud-journey-card {
    top: 12px;
    right: 12px;
    width: min(280px, calc(100vw - 24px));
  }
}

.letting-go-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 190, 115, 0.16), transparent 36%),
    rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.letting-go-card {
  width: min(520px, 100%);
  padding: 28px;
  border-radius: 28px;
  color: #fff5df;
  background: linear-gradient(180deg, rgba(15, 12, 9, 0.92), rgba(5, 6, 7, 0.86));
  border: 1px solid rgba(255, 245, 206, 0.18);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.52);
}

.letting-go-kicker {
  margin: 0 0 8px;
  color: rgba(255, 245, 206, 0.58);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.letting-go-card h2 {
  margin: 0 0 12px;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 0.95;
}

.letting-go-card p {
  color: rgba(255, 245, 206, 0.72);
  line-height: 1.6;
}

.letting-go-card input {
  width: 100%;
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  color: #fff8e8;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 245, 206, 0.18);
  outline: none;
  font-size: 18px;
}

.letting-go-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.letting-go-actions button {
  border: 1px solid rgba(255, 245, 206, 0.16);
  border-radius: 999px;
  padding: 10px 16px;
  color: #fff5df;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.letting-go-actions button:last-child {
  background: linear-gradient(135deg, rgba(255, 154, 95, 0.88), rgba(255, 216, 145, 0.72));
  color: #160b05;
}

.letting-go-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.audio-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(100%, 248px);
}

.audio-control > button {
  min-width: 108px;
  border: 1px solid rgba(255, 245, 206, 0.18);
  background: rgba(255, 255, 255, 0.055);
}

.audio-control > button.is-active {
  color: #1a1108;
  background: linear-gradient(135deg, rgba(255, 216, 145, 0.92), rgba(159, 216, 255, 0.74));
  border-color: rgba(255, 245, 206, 0.34);
}

.audio-control-volume {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 245, 206, 0.12);
  background: rgba(5, 6, 8, 0.42);
  color: rgba(246, 239, 226, 0.72);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.audio-control-volume input {
  width: 76px;
  accent-color: #ffd891;
}

@media (max-width: 760px) {
  .audio-control {
    width: 100%;
    justify-content: space-between;
  }

  .audio-control-volume input {
    width: 88px;
  }
}

.runtime-crash-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  color: #fff5df;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 216, 145, 0.12), transparent 34%),
    linear-gradient(180deg, #050506, #090807 52%, #030304);
}

.runtime-crash-card {
  width: min(620px, 100%);
  padding: clamp(24px, 5vw, 42px);
  border: 1px solid rgba(255, 245, 206, 0.18);
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(15, 12, 9, 0.92), rgba(5, 6, 7, 0.86));
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.54);
}

.runtime-crash-kicker {
  margin: 0 0 10px;
  color: rgba(255, 245, 206, 0.58);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.runtime-crash-card h1 {
  margin: 0 0 12px;
  font-size: clamp(34px, 7vw, 60px);
  line-height: 0.92;
}

.runtime-crash-card p {
  margin: 0;
  color: rgba(255, 245, 206, 0.74);
  line-height: 1.7;
}

.runtime-crash-card code {
  display: block;
  margin-top: 18px;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid rgba(255, 245, 206, 0.16);
  border-radius: 14px;
  color: #ffd891;
  background: rgba(0, 0, 0, 0.28);
  white-space: pre-wrap;
}
