* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05030a;
  font-family: 'Georgia', 'Times New Roman', serif;
  color: #e9ddc4;
}

canvas {
  display: block;
}

#blocker {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(30, 20, 10, 0.85) 0%, rgba(2, 1, 4, 0.97) 100%);
}

/* ---- Main menu (screen router: #screen-main / -single / -multiplayer /
   -settings / -about, all sharing .menu-screen) — replaces the old single
   #instructions block with a proper "pick a mode" landing screen. ---- */
.menu-screen {
  text-align: center;
  max-width: 640px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 40px;
  border: 1px solid rgba(212, 175, 55, 0.4);
  background: rgba(10, 6, 4, 0.55);
  box-shadow: 0 0 60px rgba(212, 175, 55, 0.08), inset 0 0 30px rgba(212, 175, 55, 0.05);
  cursor: default; /* the panel itself isn't the click-to-enter surface anymore */
}

.menu-screen.hidden {
  display: none;
}

.menu-screen h1 {
  font-size: 28px;
  letter-spacing: 1px;
  color: #f1d98b;
  text-shadow: 0 0 20px rgba(241, 217, 139, 0.35);
  margin-bottom: 10px;
  font-weight: 400;
  font-style: italic;
}

.menu-screen h2 {
  font-size: 22px;
  letter-spacing: 1px;
  color: #f1d98b;
  text-shadow: 0 0 16px rgba(241, 217, 139, 0.3);
  margin-bottom: 14px;
  font-weight: 400;
  font-style: italic;
}

.menu-screen .sub {
  color: #cbb98c;
  font-size: 14px;
  margin-bottom: 24px;
  opacity: 0.8;
}

.menu-screen p {
  margin: 8px 0;
  font-size: 15px;
  color: #d8c9a3;
}

.menu-screen .keys {
  margin-top: 20px;
  font-size: 13px;
  color: #a89b7a;
  letter-spacing: 0.5px;
}

.menu-screen .keys span {
  color: #f1d98b;
  border: 1px solid rgba(241, 217, 139, 0.35);
  padding: 2px 8px;
  border-radius: 3px;
  margin: 0 2px;
}

.menu-screen .about-text {
  text-align: left;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 14px;
}

/* Main menu's 4 choices */
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.menu-btn {
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 16px;
  color: #e9ddc4;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 4px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.menu-btn:hover {
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(241, 217, 139, 0.75);
}

.menu-btn-primary {
  color: #f1d98b;
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(241, 217, 139, 0.6);
}

.menu-btn-primary:hover {
  background: rgba(212, 175, 55, 0.28);
}

.menu-back {
  margin-top: 22px;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 13px;
  color: #a89b7a;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.menu-back:hover {
  color: #f1d98b;
}

/* Settings screen rows */
.settings-row {
  text-align: left;
  margin: 16px 0;
}

.settings-row label {
  display: block;
  font-size: 13px;
  color: #cbb98c;
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.settings-row-checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}

.settings-row input[type="range"] {
  width: 100%;
  accent-color: #d4af37;
}

.settings-row select {
  width: 100%;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: 4px;
  color: #f1d98b;
  font-family: 'Georgia', serif;
  font-size: 14px;
}

.settings-note {
  font-size: 11px !important;
  color: #8a7d5e !important;
  opacity: 0.8;
  margin-top: 6px !important;
}

.settings-keys {
  border-top: 1px solid rgba(212, 175, 55, 0.2);
  padding-top: 14px;
}

.keys-title {
  font-size: 12px;
  color: #cbb98c;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px !important;
  opacity: 0.7;
}

#player-name-input {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 4px auto 14px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: 4px;
  color: #f1d98b;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 15px;
  text-align: center;
  outline: none;
}

#player-name-input:focus {
  border-color: rgba(241, 217, 139, 0.9);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.25);
}

.warning {
  color: #e0836c;
  font-size: 13px;
  margin-top: -8px;
  margin-bottom: 14px;
}

.warning.hidden {
  display: none;
}

#online-counter {
  position: absolute;
  top: 12px;
  left: 16px;
  z-index: 10;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 12px;
  color: rgba(241, 217, 139, 0.55);
  pointer-events: none;
}

#online-counter.hidden {
  display: none;
}

#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(241, 217, 139, 0.6);
  font-size: 18px;
  z-index: 10;
  pointer-events: none;
  user-select: none;
  text-shadow: 0 0 6px rgba(0,0,0,0.8);
}

#hint {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: rgba(10, 6, 4, 0.7);
  border: 1px solid rgba(212, 175, 55, 0.3);
  padding: 10px 22px;
  font-size: 14px;
  color: #f1d98b;
  letter-spacing: 0.5px;
  transition: opacity 0.3s ease;
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}

#hint.hidden {
  opacity: 0;
}

#fps-counter {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 10;
  font-family: monospace;
  font-size: 11px;
  color: rgba(241, 217, 139, 0.35);
  pointer-events: none;
}

/* ---- Touch controls (phones/tablets) ---------------------------------- */
#touch-ui {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none; /* children opt back in individually */
}

#touch-ui.hidden {
  display: none;
}

#touch-look-zone {
  position: absolute;
  inset: 0;
  right: 0;
  pointer-events: auto;
  touch-action: none;
}

#joystick-base {
  position: absolute;
  left: 32px;
  bottom: 32px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(20, 12, 8, 0.45);
  border: 2px solid rgba(212, 175, 55, 0.45);
  pointer-events: auto;
  touch-action: none;
}

#joystick-thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin-left: -26px;
  margin-top: -26px;
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.55);
  border: 1px solid rgba(241, 217, 139, 0.7);
  pointer-events: none;
}

#run-toggle {
  position: absolute;
  right: 32px;
  bottom: 42px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(20, 12, 8, 0.45);
  border: 2px solid rgba(212, 175, 55, 0.45);
  color: #f1d98b;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 14px;
  pointer-events: auto;
  touch-action: none;
}

#run-toggle.active {
  background: rgba(212, 175, 55, 0.5);
}

#story-button {
  position: absolute;
  right: 32px;
  bottom: 128px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(180, 130, 30, 0.55);
  border: 2px solid rgba(241, 217, 139, 0.7);
  color: #fff6d9;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 12px;
  line-height: 1.25;
  pointer-events: auto;
  touch-action: none;
}

#story-button.hidden {
  display: none;
}

#bench-button {
  position: absolute;
  right: 32px;
  bottom: 218px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(180, 130, 30, 0.55);
  border: 2px solid rgba(241, 217, 139, 0.7);
  color: #fff6d9;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 12px;
  line-height: 1.25;
  pointer-events: auto;
  touch-action: none;
}

#bench-button.hidden {
  display: none;
}

/* ---- Background music toggle ------------------------------------------ */
#mute-toggle {
  position: absolute;
  top: 10px;
  right: 16px;
  z-index: 12;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(20, 12, 8, 0.5);
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: #f1d98b;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

#mute-toggle.hidden {
  display: none;
}

/* ---- "tekan E buat baca" proximity hint --------------------------------- */
#story-hint {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: rgba(10, 6, 4, 0.75);
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 8px 18px;
  font-size: 13px;
  color: #f1d98b;
  letter-spacing: 0.3px;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

#story-hint span {
  border: 1px solid rgba(241, 217, 139, 0.45);
  padding: 1px 7px;
  border-radius: 3px;
  margin: 0 2px;
}

#story-hint.hidden {
  opacity: 0;
}

/* ---- "tekan E buat duduk" proximity hint --------------------------------- */
#bench-hint {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: rgba(10, 6, 4, 0.75);
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 8px 18px;
  font-size: 13px;
  color: #f1d98b;
  letter-spacing: 0.3px;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

#bench-hint span {
  border: 1px solid rgba(241, 217, 139, 0.45);
  padding: 1px 7px;
  border-radius: 3px;
  margin: 0 2px;
}

#bench-hint.hidden {
  opacity: 0;
}

/* ---- "hold Alt to peek the cursor" indicator --------------------------- */
#cursor-peek-hint {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  background: rgba(10, 6, 4, 0.8);
  border: 1px solid rgba(212, 175, 55, 0.5);
  padding: 10px 20px;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 14px;
  color: #f1d98b;
  letter-spacing: 0.3px;
  pointer-events: none;
}

#cursor-peek-hint span {
  border: 1px solid rgba(241, 217, 139, 0.45);
  padding: 1px 7px;
  border-radius: 3px;
  margin: 0 2px;
}

#cursor-peek-hint.hidden {
  display: none;
}

/* ---- Story "old paper" popup ------------------------------------------- */
#story-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 3, 6, 0.72);
  transition: opacity 0.3s ease;
}

#story-overlay.hidden {
  display: none;
}

#story-paper {
  position: relative;
  width: min(90vw, 480px);
  max-height: 80vh;
  overflow-y: auto;
  padding: 38px 34px 30px;
  background:
    radial-gradient(ellipse at top left, rgba(120, 95, 60, 0.15), transparent 60%),
    linear-gradient(#ece0c3, #e2d4ae);
  color: #3a2c18;
  border-radius: 2px;
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(120, 95, 40, 0.25);
  font-family: 'Georgia', serif;
  animation: paper-in 0.25s ease;
}

@keyframes paper-in {
  from { transform: scale(0.94) rotate(-0.6deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}

#story-paper::before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(90, 65, 30, 0.35);
  pointer-events: none;
}

#story-title {
  font-style: italic;
  font-size: 22px;
  margin-bottom: 4px;
  color: #4a3418;
}

#story-date {
  font-size: 12px;
  color: #8a7248;
  margin-bottom: 16px;
  min-height: 1em;
}

#story-text {
  font-size: 15px;
  line-height: 1.7;
}

#story-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 22px;
  color: #6b5530;
  cursor: pointer;
  line-height: 1;
}

#story-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid rgba(90, 65, 30, 0.25);
  font-family: 'Georgia', serif;
}

#story-nav button {
  background: none;
  border: none;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 13px;
  color: #6b5530;
  cursor: pointer;
  padding: 4px 6px;
}

#story-nav button:hover {
  color: #3a2c18;
  text-decoration: underline;
}

#story-progress {
  font-size: 11px;
  color: #8a7248;
  letter-spacing: 0.5px;
}

/* ---- "kenangan terbaca X/Y" progress badge ----------------------------- */
#kenangan-counter {
  position: absolute;
  top: 12px;
  right: 56px;
  z-index: 10;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 12px;
  color: rgba(241, 217, 139, 0.55);
  pointer-events: none;
}

#kenangan-counter.hidden {
  display: none;
}

/* ---- Loading screen ------------------------------------------------------
   Sits above literally everything else (z-index higher than #story-overlay's
   25) since it needs to hide the menu too, not just the 3D scene behind it.
   Faded out (not display:none'd immediately) via a CSS transition triggered
   from main.js's LoadingManager.onLoad, so it doesn't just pop off abruptly. */
#loading-screen {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05030a;
  transition: opacity 0.5s ease;
}

#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

#loading-inner {
  width: min(86vw, 380px);
  text-align: center;
}

#loading-title {
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 18px;
  color: #f1d98b;
  text-shadow: 0 0 20px rgba(241, 217, 139, 0.35);
  margin-bottom: 22px;
}

#loading-bar-track {
  width: 100%;
  height: 4px;
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 2px;
  overflow: hidden;
}

#loading-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #a3852f, #f1d98b);
  transition: width 0.2s ease;
}

#loading-pct {
  margin-top: 12px;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: #a89b7a;
}

/* ---- Rotate-device prompt (mobile portrait gate) ------------------------- */
#rotate-overlay {
  position: absolute;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(5, 3, 6, 0.94);
  text-align: center;
  padding: 0 30px;
}

#rotate-overlay.hidden {
  display: none;
}

#rotate-icon {
  font-size: 44px;
  animation: rotate-nudge 1.6s ease-in-out infinite;
}

@keyframes rotate-nudge {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-90deg); }
}

#rotate-overlay p {
  font-size: 14px;
  color: #d8c9a3;
  line-height: 1.6;
}

/* ---- "Kembali ke menu" button, visible while inside the gallery --------- */
#exit-to-menu-btn {
  position: absolute;
  top: 10px;
  left: 16px;
  z-index: 13;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 12px;
  color: #f1d98b;
  background: rgba(20, 12, 8, 0.5);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
}

#exit-to-menu-btn:hover {
  background: rgba(212, 175, 55, 0.18);
}

#exit-to-menu-btn.hidden {
  display: none;
}

/* ---- "Terapkan & Reload" button for the quality setting ------------------ */
#btn-apply-quality {
  margin-top: 10px;
  font-size: 13px;
  padding: 8px 16px;
}

#btn-apply-quality.hidden {
  display: none;
}

/* ---- Galeri Foto — plain 2D grid + lightbox ------------------------------
   Alternative to the 3D corridor for anyone who just wants to see the photos
   without dealing with WASD/pointer-lock. Grid itself is populated by
   populatePhotoGrid() in main.js; markup here is just the container + the
   per-thumbnail .photo-grid-item class it generates. */
#photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
  margin-bottom: 6px;
}

.photo-grid-item {
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 3px;
  cursor: pointer;
  background: rgba(212, 175, 55, 0.06);
  transition: border-color 0.15s, transform 0.15s;
}

.photo-grid-item:hover {
  border-color: rgba(241, 217, 139, 0.8);
  transform: scale(1.03);
}

.photo-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#photo-grid-empty {
  grid-column: 1 / -1;
  font-size: 13px;
  color: #a89b7a;
  padding: 20px 0;
}

#photo-lightbox {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 3, 6, 0.92);
}

#photo-lightbox.hidden {
  display: none;
}

#lightbox-img {
  max-width: min(88vw, 900px);
  max-height: 80vh;
  border: 1px solid rgba(212, 175, 55, 0.4);
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.6);
}

#lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  font-size: 28px;
  color: #f1d98b;
  cursor: pointer;
  line-height: 1;
}

#lightbox-prev, #lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(20, 12, 8, 0.5);
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: #f1d98b;
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
}

#lightbox-prev { left: 16px; }
#lightbox-next { right: 16px; }

#lightbox-progress {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #a89b7a;
  letter-spacing: 0.5px;
}
