:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  background: #17150a;
}

* {
  box-sizing: border-box;
}

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

body {
  background: #17150a;
}

#viewport canvas {
  display: block;
  outline: none;
}

.entry {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(18, 17, 10, 0.46);
  backdrop-filter: blur(1.5px);
  transition: opacity 240ms ease;
}

.entry.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.entry__content {
  width: min(90vw, 680px);
  color: #f0ebd0;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .76);
}

.entry__eyebrow {
  margin: 0 0 24px;
  color: rgba(225, 216, 167, .66);
  font-size: 10px;
  letter-spacing: 0;
  text-align: center;
}

.entry__title {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 18px;
  margin-bottom: 28px;
}

.entry__index {
  margin: 0;
  color: #c8bc72;
  font-size: 12px;
}

.entry h1 {
  margin: 0;
  color: #f3edc8;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 48px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
}

.level-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  max-height: 0;
  margin: 0 auto;
  overflow: hidden;
  border-top: 0 solid rgba(234, 222, 145, .28);
  border-bottom: 0 solid rgba(234, 222, 145, .28);
  background: rgba(12, 14, 10, .34);
  opacity: 0;
  pointer-events: none;
  transition: max-height 240ms ease, margin 240ms ease, opacity 180ms ease, border-width 180ms ease;
}

.level-picker.is-open {
  max-height: 120px;
  margin: 0 auto 14px;
  border-top-width: 1px;
  border-bottom-width: 1px;
  opacity: 1;
  pointer-events: auto;
}

.entry .level-picker button {
  position: relative;
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  width: 100%;
  min-width: 0;
  height: 76px;
  padding: 0 22px;
  border: 0;
  border-right: 1px solid rgba(234, 222, 145, .22);
  border-radius: 0;
  background: transparent;
  color: rgba(238, 231, 192, .58);
  cursor: pointer;
  text-align: left;
  text-shadow: inherit;
  transition: background 160ms ease, color 160ms ease;
}

.entry .level-picker button:last-child {
  border-right: 0;
}

.entry .level-picker button span {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10px;
  color: rgba(221, 208, 131, .62);
}

.entry .level-picker button strong {
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry .level-picker button::after {
  position: absolute;
  right: 18px;
  bottom: 0;
  left: 18px;
  height: 2px;
  background: transparent;
  content: "";
}

.entry .level-picker button.is-selected {
  background: rgba(179, 165, 84, .12);
  color: #fff8ce;
}

.entry .level-picker button.is-selected::after {
  background: #c7b968;
}

.entry .level-picker button:hover,
.entry .level-picker button:focus-visible {
  background: rgba(179, 165, 84, .14);
  outline: none;
}

#enter-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 46px;
  padding: 0 18px;
  border: 1px solid rgba(234, 222, 145, .48);
  border-radius: 0;
  background: rgba(25, 23, 10, .58);
  color: #f3ebba;
  cursor: pointer;
  font-size: 12px;
  transition: background 160ms ease, border-color 160ms ease;
}

.entry__actions {
  display: grid;
  grid-template-columns: 1fr 118px 118px;
  gap: 10px;
}

#hub-button,
#music-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 46px;
  padding: 0 16px;
  border: 1px solid rgba(234, 222, 145, .28);
  border-radius: 0;
  background: rgba(15, 17, 13, .42);
  color: rgba(238, 231, 192, .76);
  cursor: pointer;
  font-size: 12px;
  transition: background 160ms ease, border-color 160ms ease;
}

#hub-button b,
#music-button b {
  font-size: 16px;
  font-weight: 400;
  opacity: .72;
}

#hub-button:hover,
#hub-button:focus-visible,
#hub-button[aria-expanded="true"],
#music-button:hover,
#music-button:focus-visible {
  border-color: rgba(241, 229, 154, .58);
  background: rgba(91, 84, 42, .42);
  outline: none;
}

#enter-button b {
  font-size: 20px;
  font-weight: 400;
}

#enter-button:hover,
#enter-button:focus-visible {
  border-color: rgba(241, 229, 154, .82);
  background: rgba(91, 84, 42, .66);
  outline: none;
}

.entry__controls {
  margin: 18px 0 0;
  color: rgba(238, 231, 192, .62);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
}

body.level-37 .entry__index,
body.level-37 .entry .level-picker button span {
  color: rgba(168, 220, 207, .78);
}

body.level-37 .entry .level-picker button.is-selected::after {
  background: #8bc7b8;
}

#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 250, 218, 0.48);
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity 160ms ease;
}

#interaction-ring {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 250, 218, 0.28);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(239, 228, 173, 0.08);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: border-color 120ms ease, box-shadow 120ms ease, opacity 160ms ease;
}

body.is-playing #interaction-ring {
  opacity: 0.58;
}

#interaction-ring.has-target {
  border-color: rgba(255, 245, 190, 0.92);
  box-shadow: 0 0 16px rgba(239, 228, 173, 0.26), inset 0 0 7px rgba(255,255,255,.1);
  opacity: 1;
}

body.is-playing #crosshair {
  opacity: 1;
}

body.is-playing #viewport canvas {
  cursor: none;
}

.fall-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: #030303;
  color: rgba(231, 226, 205, 0.78);
  opacity: 0;
  pointer-events: none;
  transition: opacity 700ms ease;
}

.fall-overlay p {
  margin: 0;
  font-family: "Songti SC", Georgia, serif;
  font-size: 17px;
  letter-spacing: 0;
}

.fall-overlay.is-visible {
  opacity: 1;
}

.transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 29;
  display: grid;
  place-items: center;
  background: #d9e7dd;
  color: rgba(35, 63, 57, .72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 420ms ease;
}

.transition-overlay p {
  margin: 0;
  font-family: "Songti SC", Georgia, serif;
  font-size: 17px;
}

.transition-overlay.is-visible {
  opacity: 1;
}

body.level-37 .vignette {
  background: radial-gradient(circle, transparent 64%, rgba(29, 62, 57, .22) 100%);
}

body.level-37 .grain {
  opacity: .018;
}

.recording-overlay {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: none;
  overflow: hidden;
  border: 10px solid rgba(5, 9, 7, 0.3);
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.72), inset 2px 0 rgba(255, 30, 20, 0.13), inset -2px 0 rgba(20, 100, 255, 0.13);
  color: rgba(225, 238, 218, 0.78);
  font-family: "Courier New", monospace;
  pointer-events: none;
  text-shadow: 1px 0 rgba(255, 48, 35, 0.5), -1px 0 rgba(42, 126, 255, 0.45), 0 1px 4px #000;
}

.recording-overlay::before,
.recording-overlay::after {
  position: absolute;
  inset: 0;
  content: "";
}

.recording-overlay::before {
  background: repeating-linear-gradient(0deg, rgba(4, 8, 6, 0.12) 0, rgba(4, 8, 6, 0.12) 1px, transparent 1px, transparent 4px);
  animation: scan-drift 6s linear infinite;
}

.recording-overlay::after {
  opacity: 0.14;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 220 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='4' seed='8'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"), linear-gradient(95deg, transparent 18%, rgba(255,255,255,.14) 18.1%, transparent 18.35%, transparent 68%, rgba(255,255,255,.09) 68.08%, transparent 68.2%);
  mix-blend-mode: screen;
  animation: camera-noise 140ms steps(2) infinite;
}

body.is-recording .recording-overlay {
  display: block;
}

body.is-recording #viewport canvas {
  filter: sepia(0.22) saturate(0.68) contrast(1.14) brightness(0.9);
}

.recording-overlay__top,
.recording-overlay__stamp {
  position: absolute;
  z-index: 1;
  font-size: 13px;
  line-height: 1.55;
}

.recording-overlay__top { top: 28px; left: 32px; }
.recording-overlay__stamp { right: 30px; bottom: 26px; text-align: right; }
.recording-overlay__stamp span { opacity: 0.62; font-size: 11px; }

.recording-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 50%;
  background: #e84231;
  box-shadow: 0 0 8px #e84231;
  animation: rec-blink 1s steps(1) infinite;
}

.recording-overlay__focus {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 34px;
  border: 1px solid rgba(225, 238, 218, 0.34);
  transform: translate(-50%, -50%);
}

.vignette,
.grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.vignette {
  background: radial-gradient(circle, transparent 56%, rgba(23, 19, 5, 0.34) 100%);
}

.grain {
  opacity: 0.036;
  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='.92' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.65'/%3E%3C/svg%3E");
  animation: grain 180ms steps(2) infinite;
}

.location-label {
  position: fixed;
  left: 24px;
  bottom: 22px;
  z-index: 4;
  color: rgba(245, 237, 188, 0.76);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease;
}

.location-label.is-visible {
  opacity: 1;
}

.subtitle {
  position: fixed;
  left: 50%;
  bottom: 8.5%;
  z-index: 8;
  width: min(820px, calc(100vw - 48px));
  color: #f4f0dc;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 2px 5px #000, 0 0 18px rgba(0,0,0,.9);
  transform: translate(-50%, 7px);
  transition: opacity 460ms ease, transform 460ms ease;
}

.subtitle.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

#subtitle-speaker {
  display: block;
  margin-bottom: 6px;
  color: #c5bd91;
  font-size: 11px;
}

#subtitle-text {
  margin: 0;
  font-family: "Songti SC", Georgia, serif;
  font-size: 18px;
  line-height: 1.55;
  letter-spacing: 0;
}

.interaction-prompt {
  position: fixed;
  left: 50%;
  bottom: 54px;
  z-index: 5;
  min-height: 22px;
  padding: 5px 9px;
  border: 1px solid rgba(217, 211, 174, 0.28);
  background: rgba(24, 23, 16, 0.62);
  color: rgba(245, 241, 213, 0.9);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 140ms ease;
}

.interaction-prompt.is-visible {
  opacity: 1;
}

.settings-button {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 15;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(229, 222, 181, 0.4);
  border-radius: 50%;
  background: rgba(27, 26, 18, 0.58);
  color: #e7dfb7;
  cursor: pointer;
  font-size: 18px;
}

.panel,
.music-panel,
.book-panel {
  position: fixed;
  z-index: 20;
  border: 1px solid rgba(216, 206, 158, 0.32);
  border-radius: 6px;
  background: rgba(27, 26, 20, 0.94);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  color: #e8e2c7;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.panel.is-open,
.music-panel.is-open,
.book-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.panel {
  top: 68px;
  right: 18px;
  width: min(330px, calc(100vw - 36px));
  padding: 18px;
  transform: translateY(-8px);
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel__header h2,
.book-panel h2,
.panel__header p {
  margin: 0;
  letter-spacing: 0;
}

.panel__header h2 {
  font-size: 17px;
  font-weight: 500;
}

.panel__close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: #e8e2c7;
  cursor: pointer;
  font-size: 19px;
}

.panel label {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 14px;
  margin: 16px 0;
  color: #d7d1b7;
  font-size: 13px;
}

.panel input[type="range"],
.panel select {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: #b8ae72;
}

.panel select {
  height: 34px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 4px;
  background: #343229;
  color: #eee9d3;
  padding: 0 8px;
}

.panel .toggle-row {
  grid-template-columns: 1fr auto;
}

.panel .toggle-row input {
  grid-column: 2;
}

.music-panel {
  top: 50%;
  left: 50%;
  display: grid;
  grid-template-columns: minmax(250px, .82fr) minmax(300px, 1.18fr);
  grid-template-rows: auto auto 1fr;
  gap: 0 28px;
  width: min(820px, calc(100vw - 36px));
  max-height: min(82vh, 760px);
  padding: 24px;
  overflow: hidden;
  transform: translate(-50%, calc(-50% + 8px));
}

.music-panel.is-open {
  transform: translate(-50%, -50%);
}

.music-panel .panel__header {
  grid-column: 1 / -1;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(218, 208, 166, .16);
}

.music-panel .panel__header p {
  margin: 0 0 5px;
  color: #9f9879;
  font-size: 9px;
}

.music-panel .panel__header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 400;
}

.music-now {
  align-self: start;
  min-height: 132px;
  padding: 18px 0 20px;
  border-top: 1px solid rgba(218, 208, 166, .2);
  border-bottom: 1px solid rgba(218, 208, 166, .2);
}

.music-now span,
.music-now small {
  display: block;
  color: #9f9879;
  font-size: 9px;
  line-height: 1.5;
}

.music-now strong {
  display: block;
  margin: 10px 0 7px;
  color: #f0ead0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-weight: 400;
  line-height: 1.25;
}

.music-progress {
  margin: 16px 0 2px;
}

.music-progress input {
  width: 100%;
  accent-color: #c2b875;
  cursor: pointer;
}

.music-progress input:disabled {
  cursor: default;
  opacity: .38;
}

.music-progress__time {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  color: #8f886e;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.music-controls {
  display: grid;
  grid-template-columns: 42px 58px 42px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 20px 0 14px;
}

.music-controls button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(218, 208, 166, .24);
  border-radius: 50%;
  background: rgba(255,255,255,.04);
  color: #ddd6bb;
  cursor: pointer;
}

.music-controls .music-play {
  width: 58px;
  height: 58px;
  border-color: rgba(229, 217, 147, .52);
  color: #f2e9b7;
  font-size: 18px;
}

.music-volume {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  align-self: end;
  color: #bdb69b;
  font-size: 11px;
}

.music-volume input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: #b8ae72;
}

.music-track-list {
  grid-column: 2;
  grid-row: 2 / 6;
  min-height: 0;
  margin: 0;
  padding: 0 4px 0 0;
  overflow: auto;
  border-top: 1px solid rgba(218, 208, 166, .16);
  list-style: none;
}

.music-track-list li {
  border-bottom: 1px solid rgba(218, 208, 166, .11);
}

.music-track-list button {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  padding: 11px 8px;
  border: 0;
  background: transparent;
  color: #c8c1a8;
  cursor: pointer;
  text-align: left;
}

.music-track-list button:hover,
.music-track-list button:focus-visible,
.music-track-list button.is-current {
  background: rgba(184, 174, 114, .12);
  color: #f1e9c9;
  outline: none;
}

.music-track-list em {
  color: #8f886e;
  font-size: 10px;
  font-style: normal;
}

.music-track-list span,
.music-track-list small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-track-list span {
  font-size: 12px;
}

.music-track-list small {
  margin-top: 3px;
  color: #8f886e;
  font-size: 9px;
}

.book-panel {
  top: 50%;
  left: 50%;
  width: min(680px, calc(100vw - 32px));
  max-height: min(76vh, 720px);
  overflow: auto;
  padding: 28px 32px 34px;
  transform: translate(-50%, calc(-50% + 8px));
}

.book-panel.is-open {
  transform: translate(-50%, -50%);
}

.book-panel .panel__header {
  margin-bottom: 8px;
  color: #aaa27d;
  font-size: 11px;
}

.book-panel h2 {
  margin-bottom: 20px;
  color: #f0ead0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 400;
}

.book-content {
  min-height: 240px;
  color: #d4cfb8;
  font-family: Georgia, "Songti SC", serif;
  font-size: 15px;
  line-height: 1.85;
  white-space: pre-line;
}

.book-pagination {
  display: grid;
  grid-template-columns: 88px 1fr 88px;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid rgba(218, 208, 166, 0.16);
  text-align: center;
}

.book-pagination button {
  min-height: 34px;
  border: 1px solid rgba(218, 208, 166, 0.24);
  border-radius: 4px;
  background: rgba(255,255,255,.04);
  color: #ddd6bb;
  cursor: pointer;
}

.book-pagination button:disabled {
  opacity: 0.32;
  cursor: default;
}

#book-page {
  color: #9f9879;
  font-size: 12px;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-1%, 1%); }
  50% { transform: translate(1%, -1%); }
  75% { transform: translate(1%, 1%); }
}

@keyframes camera-noise {
  0% { transform: translate(0, 0) scale(1.02); }
  25% { transform: translate(-0.6%, 0.35%) scale(1.02); }
  50% { transform: translate(0.4%, -0.45%) scale(1.02); }
  75% { transform: translate(0.25%, 0.5%) scale(1.02); }
}

@keyframes scan-drift {
  from { transform: translateY(-8px); }
  to { transform: translateY(8px); }
}

@keyframes rec-blink {
  50% { opacity: 0.22; }
}

@media (max-width: 600px) {
  .entry__content { width: min(92vw, 420px); }
  .entry__title { display: block; margin-bottom: 22px; text-align: center; }
  .entry__index { margin-bottom: 7px; }
  .entry h1 { font-size: 34px; }
  .level-picker { grid-template-columns: 1fr; }
  .level-picker.is-open { max-height: 180px; }
  .entry .level-picker button { height: 66px; border-right: 0; border-bottom: 1px solid rgba(234, 222, 145, .16); }
  .entry .level-picker button:last-child { border-bottom: 0; }
  .entry__actions { grid-template-columns: 1fr 90px 90px; }
  .entry__controls { max-width: 270px; margin-inline: auto; }
  .book-panel { padding: 22px 20px 28px; }
  .book-content { min-height: 280px; }
  .music-panel { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto auto minmax(180px, 1fr); gap: 0; padding: 20px; }
  .music-track-list { grid-column: 1; grid-row: 6; margin-top: 18px; }
  #subtitle-text { font-size: 15px; }
}

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