:root {
  --bg-deep: #0c0704;
  --sand: #c9a05a;
  --sand-bright: #e8c37a;
  --accent-teal: #2f9e8f;
  --accent-red: #b3402c;
  --accent-green: #35d07f;
  --panel: #1c130a;
  --panel-border: #5a4426;
  --text-light: #f5ead0;
  --text-dim: #c2ab84;
  font-family: Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-deep);
  color: var(--text-light);
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
}

img {
  -webkit-user-drag: none;
  user-select: none;
}

/* ===================== Title screen ===================== */

.title-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 48px;
}
.title-screen[hidden] { display: none; }

.title-logo {
  max-width: 62vw;
  max-height: 55vh;
  opacity: 0;
  transition: opacity 5s ease-in;
}
.title-logo.visible { opacity: 1; }

.title-start-btn {
  background: rgba(10, 5, 2, 0.75);
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  font-size: 1.15rem;
  padding: 14px 42px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 5s ease-in, border-color 0.25s, background 0.25s;
}
.title-start-btn:hover {
  border-color: var(--sand);
  background: rgba(30, 20, 8, 0.85);
}
.title-start-btn.visible { opacity: 1; }

/* ===================== HUD ===================== */

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 18px;
  background: linear-gradient(180deg, #17100a 0%, #0c0704 100%);
  border-bottom: 1px solid var(--panel-border);
  z-index: 20;
}

.hud-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: bold;
  letter-spacing: 0.3px;
  color: var(--sand-bright);
  text-shadow: 0 0 12px rgba(232, 195, 122, 0.4);
}

.hud-logo {
  height: 32px;
  width: auto;
}

.hud-stage {
  color: var(--text-dim);
  font-weight: normal;
  font-size: 0.85em;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hud-timer {
  /* Hidden from players for now - delete this line to bring it back. */
  display: none;
  font-variant-numeric: tabular-nums;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--sand-bright);
}

.hud-progress {
  display: flex;
  gap: 6px;
}

.hud-progress .dot {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  filter: grayscale(1) brightness(0.6);
  font-size: 0.95rem;
  transition: filter 0.4s, box-shadow 0.4s, transform 0.3s;
}

.hud-progress .dot.solved {
  filter: none;
  box-shadow: 0 0 10px rgba(53, 208, 127, 0.7);
  border-color: var(--accent-green);
  transform: scale(1.08);
}

.hud-progress .dot[hidden] {
  display: none;
}

.hud-restart {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  transition: color 0.2s, border-color 0.2s;
}

.hud-restart:hover {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.hud-fullscreen {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  transition: color 0.2s, border-color 0.2s;
}

.hud-fullscreen:hover {
  color: var(--sand-bright);
  border-color: var(--sand);
}

/* ===================== Dev tools ===================== */

/* Hidden from players for now. To bring the dev-skip shortcuts back,
   delete (or comment out) this rule - everything else stays intact. */
.dev-skip-group {
  display: none !important;
  pointer-events: none !important;
}

.dev-skip-group {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dev-skip-btn {
  background: rgba(10, 5, 2, 0.9);
  border: 1px solid var(--sand);
  border-left: none;
  box-shadow: 0 0 14px rgba(232, 195, 122, 0.35);
  color: var(--sand-bright);
  font-size: 0.85rem;
  font-weight: bold;
  padding: 14px 8px;
  border-radius: 0 8px 8px 0;
  writing-mode: vertical-rl;
  letter-spacing: 0.5px;
}

.dev-skip-btn:hover {
  color: var(--sand-bright);
  border-color: var(--sand);
}

.dev-skip-btn[hidden] {
  display: none;
}

/* ===================== Scene ===================== */

.stage-frame {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.scene {
  position: relative;
  width: 100%;
  max-width: 1200px;
  aspect-ratio: 1672 / 941;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  border: 2px solid var(--panel-border);
  box-shadow: 0 0 60px rgba(180, 130, 40, 0.2), inset 0 0 80px rgba(0,0,0,0.6);
}

.scene-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.6s ease;
}

/* ===================== Hotspots ===================== */

.hotspot-box {
  position: absolute;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  z-index: 5;
}

.hotspot-highlight {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  border: 2px solid transparent;
  box-shadow: 0 0 0 rgba(232, 195, 122, 0);
  background: rgba(232, 195, 122, 0);
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
  pointer-events: none;
}

.hotspot-box:hover .hotspot-highlight,
.hotspot-box:focus-visible .hotspot-highlight {
  border-color: var(--sand-bright);
  box-shadow: 0 0 22px 4px rgba(232, 195, 122, 0.55);
  background: rgba(232, 195, 122, 0.08);
}

/* The scorpion is a hidden easter egg - no visible outline, ever */
#hotspot-scorpion:hover .hotspot-highlight,
#hotspot-scorpion:focus-visible .hotspot-highlight {
  border-color: transparent;
  box-shadow: none;
  background: rgba(232, 195, 122, 0);
}

#hotspot-scorpion:hover .hotspot-label,
#hotspot-scorpion:focus-visible .hotspot-label {
  opacity: 0;
}

/* The ceiling sunlight trigger is likewise a hidden spot - no visible outline */
#hotspot-s3ceiling:hover .hotspot-highlight,
#hotspot-s3ceiling:focus-visible .hotspot-highlight {
  border-color: transparent;
  box-shadow: none;
  background: rgba(232, 195, 122, 0);
}

#hotspot-s3ceiling:hover .hotspot-label,
#hotspot-s3ceiling:focus-visible .hotspot-label {
  opacity: 0;
}

/* The rubble passage is a fully hidden trigger - no visible outline or label */
#hotspot-rubble:hover .hotspot-highlight,
#hotspot-rubble:focus-visible .hotspot-highlight {
  border-color: transparent;
  box-shadow: none;
  background: rgba(232, 195, 122, 0);
}

#hotspot-rubble:hover .hotspot-label,
#hotspot-rubble:focus-visible .hotspot-label {
  opacity: 0;
}

/* Room II trap door + torch triggers are hidden spots - no visible outline or label */
#hotspot-trapdoor:hover .hotspot-highlight,
#hotspot-trapdoor:focus-visible .hotspot-highlight,
#hotspot-torch1:hover .hotspot-highlight,
#hotspot-torch1:focus-visible .hotspot-highlight,
#hotspot-torch2:hover .hotspot-highlight,
#hotspot-torch2:focus-visible .hotspot-highlight,
#hotspot-torch3:hover .hotspot-highlight,
#hotspot-torch3:focus-visible .hotspot-highlight {
  border-color: transparent;
  box-shadow: none;
  background: rgba(232, 195, 122, 0);
}

#hotspot-trapdoor:hover .hotspot-label,
#hotspot-trapdoor:focus-visible .hotspot-label,
#hotspot-torch1:hover .hotspot-label,
#hotspot-torch1:focus-visible .hotspot-label,
#hotspot-torch2:hover .hotspot-label,
#hotspot-torch2:focus-visible .hotspot-label,
#hotspot-torch3:hover .hotspot-label,
#hotspot-torch3:focus-visible .hotspot-label {
  opacity: 0;
}

.hotspot-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  white-space: nowrap;
  background: rgba(10, 5, 2, 0.9);
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.hotspot-box:hover .hotspot-label,
.hotspot-box:focus-visible .hotspot-label {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hotspot-check {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  background: var(--accent-green);
  color: #05170d;
  border-radius: 50%;
  font-size: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  z-index: 3;
  box-shadow: 0 0 10px rgba(53, 208, 127, 0.7);
}

.hotspot-box.solved .hotspot-highlight {
  border-color: var(--accent-green);
}

.hotspot-box.solved .hotspot-check {
  display: flex;
}

/* ===================== The Labyrinth: top-down maze ===================== */

.labyrinth-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #000;
  overflow: hidden;
}

.labyrinth-bg {
  position: absolute;
  pointer-events: none;
  user-select: none;
}

.labyrinth-fog {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.labyrinth-exit-btn,
.labyrinth-directions-btn {
  position: absolute;
  bottom: 16px;
  background: rgba(10, 5, 2, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  font-size: 0.9rem;
  padding: 8px 18px;
  border-radius: 8px;
  z-index: 20;
}
.labyrinth-exit-btn:hover,
.labyrinth-directions-btn:hover { border-color: var(--sand); }

.labyrinth-exit-btn { left: 16px; }
.labyrinth-directions-btn { right: 16px; }

.labyrinth-fade {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 500;
}

.torch-message {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 501;
  color: var(--sand-bright);
  font-size: 1.4rem;
  text-align: center;
  max-width: 80vw;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.torch-message.visible { opacity: 1; }
.torch-message[hidden] { display: none; }

/* ---- Room II: torn note reward ---- */

.solved-notes {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.solved-note-img {
  width: 160px;
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.6));
}

/* ===================== Directions: torn note clue board ===================== */

.clues-board {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 400;
  overflow: hidden;
}
.clues-board[hidden] { display: none; }

.clues-exit-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(10, 5, 2, 0.85);
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  font-size: 0.9rem;
  padding: 8px 18px;
  border-radius: 8px;
  z-index: 10;
}
.clues-exit-btn:hover { border-color: var(--sand); }

.clue-piece {
  position: absolute;
  cursor: grab;
  touch-action: none;
  user-select: none;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.65));
}
.clue-piece.dragging {
  cursor: grabbing;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.8));
}

.clue-piece img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  -webkit-user-drag: none;
}

.clue-handle {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(10, 5, 2, 0.85);
  border: 1px solid var(--sand);
  color: var(--sand-bright);
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  touch-action: none;
}
.clue-piece:hover .clue-handle,
.clue-piece.rotating .clue-handle,
.clue-piece.scaling .clue-handle {
  opacity: 1;
}

.clue-rotate-handle {
  top: -15px;
  right: -15px;
  cursor: grab;
}
.clue-rotate-handle:active { cursor: grabbing; }

.clue-scale-handle {
  bottom: -15px;
  right: -15px;
  cursor: nwse-resize;
}

/* ===================== Room III ===================== */

.scale-warning-text {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  max-width: 80%;
  text-align: center;
  background: rgba(10, 5, 2, 0.85);
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  font-size: 1rem;
  line-height: 1.5;
  padding: 12px 20px;
  border-radius: 10px;
  pointer-events: none;
}

/* ---- The Scales of Fate minigame ---- */

.scalegame-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #000;
  overflow: hidden;
}

.scalegame-bg {
  position: absolute;
  pointer-events: none;
  user-select: none;
}

.scale-item {
  position: absolute;
  cursor: grab;
  touch-action: none;
  user-select: none;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.65));
}
.scale-item.dragging {
  cursor: grabbing;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.8));
}

.scale-item img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  -webkit-user-drag: none;
}

.scalegame-click-catcher {
  position: absolute;
  inset: 0;
  z-index: 1000;
  cursor: pointer;
}
.scalegame-click-catcher[hidden] { display: none; }

/* ---- Crossword Cross Reference minigame ---- */

.crossword-clues-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(10, 5, 2, 0.75);
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: 6px;
  z-index: 10;
}
.crossword-clues-btn:hover { border-color: var(--sand); }

.crossword-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #000;
  overflow: hidden;
}

.crossword-bg {
  position: absolute;
  pointer-events: none;
  user-select: none;
}

.crossword-cell {
  position: absolute;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f5ead0;
  font-weight: bold;
  font-family: Georgia, 'Times New Roman', serif;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.9), 0 0 4px rgba(0, 0, 0, 0.9);
  border-radius: 3px;
}

.crossword-cell.active {
  background: rgba(232, 195, 122, 0.32);
  box-shadow:
    inset 0 0 0 1px rgba(232, 195, 122, 0.75),
    0 0 10px 2px rgba(232, 195, 122, 0.65),
    0 0 22px 6px rgba(232, 195, 122, 0.35);
}

.crossword-win-overlay {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: rgba(8, 4, 2, 0.85);
  text-align: center;
  padding: 40px;
}
.crossword-win-overlay[hidden] { display: none; }

.crossword-win-text {
  max-width: 640px;
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--sand-bright);
}

/* ---- Translate Instructions minigame ---- */

.translate-toggle-btn {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 5, 2, 0.75);
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  font-size: 0.95rem;
  padding: 8px 22px;
  border-radius: 6px;
  z-index: 20;
}
.translate-toggle-btn:hover { border-color: var(--sand); }

.translate-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #000;
  overflow: hidden;
}

.translate-bg-img {
  position: absolute;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}

.translate-fade-img {
  transition: opacity 2s linear;
  z-index: 3;
}

.translate-black-box {
  position: absolute;
  background: #000;
  border-radius: 2px;
  z-index: 2;
}

.translate-word-tile {
  position: absolute;
  color: #0a0805;
  background: rgba(232, 213, 168, 0.92);
  border: 1px solid rgba(60, 45, 25, 0.5);
  border-radius: 5px;
  padding: 4px 10px;
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: bold;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: grab;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
  z-index: 30;
}
.translate-word-tile:hover {
  box-shadow: 0 0 8px 2px rgba(232, 195, 122, 0.75), 0 0 16px 4px rgba(232, 195, 122, 0.4);
}
.translate-word-tile.dragging {
  cursor: grabbing;
  transform: scale(1.08);
}

.translate-pretext-message {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  max-width: 70%;
  background: rgba(8, 4, 2, 0.8);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 16px 26px;
  text-align: center;
  color: var(--sand-bright);
  font-size: 1.05rem;
  line-height: 1.5;
  cursor: pointer;
  z-index: 40;
}
.translate-pretext-message[hidden] { display: none; }

.translate-win-overlay {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: rgba(8, 4, 2, 0.85);
  text-align: center;
  padding: 40px;
}
.translate-win-overlay[hidden] { display: none; }

.translate-win-text {
  max-width: 640px;
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--sand-bright);
}

/* ===================== Overlay / Modal ===================== */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 4, 2, 0.92);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.overlay.open { display: flex; }

.modal {
  display: none;
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 28px 24px 24px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 60px rgba(180, 130, 40, 0.3);
}

.modal.puzzle-complete-glow {
  border-color: var(--sand-bright);
  box-shadow:
    inset 0 0 0 2px rgba(232, 195, 122, 0.85),
    0 0 40px 8px rgba(232, 195, 122, 0.7),
    0 0 90px 20px rgba(232, 195, 122, 0.35);
  animation: puzzle-complete-pulse 1.6s ease-in-out infinite;
}

@keyframes puzzle-complete-pulse {
  0%, 100% {
    box-shadow:
      inset 0 0 0 2px rgba(232, 195, 122, 0.85),
      0 0 40px 8px rgba(232, 195, 122, 0.7),
      0 0 90px 20px rgba(232, 195, 122, 0.35);
  }
  50% {
    box-shadow:
      inset 0 0 0 2px rgba(232, 195, 122, 1),
      0 0 55px 14px rgba(232, 195, 122, 0.9),
      0 0 110px 28px rgba(232, 195, 122, 0.5);
  }
}

.modal.modal-huge {
  max-width: 90vw;
  width: 90vw;
  max-height: 88vh;
  height: 88vh;
  display: none;
  flex-direction: column;
}

.modal.modal-fullscreen {
  max-width: 98vw;
  width: 98vw;
  max-height: 95vh;
  height: 95vh;
  padding: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.modal[data-modal="s3rockClues"] {
  background: transparent;
  box-shadow: none;
}

.modal.active { display: block; }
.modal.modal-huge.active { display: flex; }
.modal.modal-fullscreen.active { display: flex; }

.modal h2 {
  margin: 0 0 4px;
  color: var(--sand-bright);
  text-shadow: 0 0 10px rgba(232, 195, 122, 0.35);
  font-size: 1.4rem;
}

.modal-hint {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin: 0 0 16px;
  line-height: 1.5;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.8rem;
  line-height: 1;
  z-index: 10;
}
.modal-close:hover { color: var(--accent-red); }

.modal-back {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(10, 5, 2, 0.75);
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: 6px;
  z-index: 10;
}
.modal-back:hover { border-color: var(--sand); }
.modal-back + h2 { margin-top: 34px; }

/* ---- Standin puzzle (Room II placeholders) ---- */

.standin-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
}

.standin-text {
  color: var(--text-dim);
  font-size: 1rem;
  max-width: 420px;
}

.standin-actions {
  display: flex;
  gap: 14px;
}

/* ---- Jars ---- */

.letter-toggle {
  display: block;
  margin: 0 auto 14px;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
}
.letter-toggle:hover { border-color: var(--sand); }
.letter-toggle.hidden { display: none; }

.jars-layout {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.jars-scene {
  position: relative;
  width: auto;
  height: 100%;
  max-width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
}

.jars-scene > img {
  height: 100%;
  width: auto;
  max-width: 100%;
  display: block;
}

.jar-hotspot {
  position: absolute;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.jar-hotspot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  border: 2px solid transparent;
  box-shadow: 0 0 0 rgba(232, 195, 122, 0);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.jar-hotspot:hover::after {
  border-color: var(--sand-bright);
  box-shadow: 0 0 18px 3px rgba(232, 195, 122, 0.5);
  background: rgba(232, 195, 122, 0.08);
}

.jar-hotspot.lit::after {
  border-color: var(--accent-green);
  box-shadow: 0 0 18px 3px rgba(53, 208, 127, 0.6);
  background: rgba(53, 208, 127, 0.12);
}

.jar-hotspot.wrong::after {
  border-color: var(--accent-red);
  animation: shake 0.4s;
}

.jar-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%) translateY(4px);
  white-space: nowrap;
  background: rgba(10, 5, 2, 0.92);
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  font-size: 0.78rem;
  padding: 4px 9px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.jar-hotspot:hover .jar-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.jars-feedback {
  text-align: center;
  min-height: 1.4em;
  color: var(--accent-red);
  font-size: 0.85rem;
  margin-top: 10px;
}

/* ---- Sliding blocks ---- */

.modal[data-modal="blocks"] {
  max-width: 97vw;
  width: 97vw;
  max-height: 95vh;
  height: 95vh;
}

.modal[data-modal="blocks"] h2 {
  margin: 34px 0 2px;
}

.modal[data-modal="blocks"] .modal-hint {
  margin: 0 0 4px;
}

.blocks-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.blocks-frame {
  position: relative;
  height: 100%;
  max-width: 100%;
  min-height: 0;
  aspect-ratio: 1672 / 941;
}

.blocks-frame-art {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.blocks-board {
  position: absolute;
  top: 15%;
  left: 13.5%;
  width: 73%;
  height: 70%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
  z-index: 2;
}

.block-tile {
  background-size: cover;
  cursor: pointer;
  border: 2px solid transparent;
  padding: 0;
  transition: filter 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.block-tile:hover { filter: brightness(1.15); }
.block-tile.selected {
  border-color: var(--sand-bright);
  box-shadow: 0 0 16px 3px rgba(232, 195, 122, 0.7);
  transform: scale(0.94);
  z-index: 1;
}

.blocks-reset {
  position: absolute;
  top: 14px;
  right: 14px;
  margin: 0;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  padding: 6px 14px;
  border-radius: 6px;
  z-index: 10;
  font-size: 0.85rem;
}
.blocks-reset:hover { border-color: var(--sand); }

/* ---- Constellation (full-screen drag-and-place) ---- */

.modal[data-modal="constellation"] {
  max-width: 98.5vw;
  width: 98.5vw;
  max-height: 97vh;
  height: 97vh;
}

.modal[data-modal="constellation"] h2 {
  margin: 34px 0 2px;
}

.modal[data-modal="constellation"] .modal-hint {
  margin: 0 0 4px;
}

#calibrateToggle {
  position: absolute;
  top: 14px;
  left: 14px;
  margin: 0;
  z-index: 10;
}

#calibrateReadout {
  position: absolute;
  top: 54px;
  left: 14px;
  margin: 0;
  max-width: 220px;
  min-height: 0;
  z-index: 10;
}

.constellation-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

.constellation-dome {
  position: relative;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 1672 / 941;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  background: #05070f;
}

.dome-bg {
  position: absolute;
  transition: opacity 0.4s ease;
}

.dome-placed {
  position: absolute;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.5));
}

.dome-drop-target {
  position: absolute;
  border-radius: 8px;
  outline: 2px dashed transparent;
  transition: outline-color 0.15s, background 0.15s;
}

/* The tray pieces sit directly on top of the dome image, docked into the
   dark unused margins on its left and right sides, rather than in a
   separate side column - so the dome itself can use the full width. */
.constellation-tray {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
}

.constellation-piece {
  position: absolute;
  width: 9%;
  transform: translateY(-50%);
  cursor: grab;
  touch-action: none;
  user-select: none;
  pointer-events: auto;
  transition: filter 0.15s ease;
}

.constellation-piece:hover {
  filter: drop-shadow(0 0 8px rgba(232, 195, 122, 0.85));
}

.constellation-piece img {
  width: 100%;
  display: block;
  pointer-events: none;
}

.constellation-piece.dragging {
  position: fixed;
  z-index: 200;
  cursor: grabbing;
  opacity: 0.55;
  pointer-events: none;
  transform: none;
}

/* ---- Letter ---- */

.letter-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}

.modal-huge .letter-img {
  flex: 1;
  min-height: 0;
}

/* ---- Golden Heart reveal ---- */

.modal.modal-heart {
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

@keyframes heart-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.heart-reveal-img {
  max-width: 70%;
  max-height: 80%;
  object-fit: contain;
  filter: drop-shadow(0 0 40px rgba(255, 200, 90, 0.85)) drop-shadow(0 0 90px rgba(255, 170, 50, 0.55));
  animation: heart-fade-in 2s ease forwards;
  pointer-events: none;
}

/* ---- Scorpion warning ---- */

.modal.modal-scorpion {
  max-width: 480px;
  width: 88vw;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
}

.modal.modal-scorpion.active {
  display: flex;
}

.scorpion-text {
  margin: 0;
  color: var(--text-light);
  font-size: 1.1rem;
  line-height: 1.6;
}

/* ---- Door: keyhole assembly minigame ---- */

.keyhole-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.keyhole-bg {
  position: absolute;
  pointer-events: none;
}

.keyhole-piece {
  position: absolute;
  border: none;
  background: transparent;
  padding: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6));
  transition: filter 0.2s;
}

.keyhole-piece img {
  width: 100%;
  display: block;
  pointer-events: none;
}

.keyhole-piece.locked {
  display: none;
}

.keyhole-piece:hover {
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 10px rgba(232, 195, 122, 0.6));
}

.keyhole-piece.dragging {
  position: fixed;
  z-index: 200;
  cursor: grabbing;
  opacity: 0.55;
  pointer-events: none;
  filter: none;
}

.keyhole-piece.placed {
  cursor: default;
  filter: drop-shadow(0 0 12px rgba(255, 210, 100, 0.8));
}

/* ---- The Wall: hole-plugging minigame ---- */

.firewall-stage {
  flex: 1;
  min-height: 0;
  position: relative;
}

.firewall-bg {
  position: absolute;
  pointer-events: none;
}

.firewall-hole {
  position: absolute;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.firewall-hole img {
  position: absolute;
  left: 50%;
  top: calc(50% + 35%);
  width: 150%;
  height: 150%;
  transform: translate(-50%, -50%);
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.1s;
  pointer-events: none;
}

.firewall-hole.plugged img {
  opacity: 1;
}

.firewall-hole.wrong img {
  filter: drop-shadow(0 0 10px rgba(179, 64, 44, 0.9));
}

.firewall-hole.deactivated {
  cursor: default;
  pointer-events: none;
}

.firewall-hole-mark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-red);
  font-weight: bold;
  font-size: 1.3rem;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.85);
  opacity: 0;
  pointer-events: none;
}

.firewall-hole.deactivated .firewall-hole-mark {
  opacity: 1;
}

.firewall-hint-zone {
  position: absolute;
}

.firewall-hint-glyph {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  height: 65%;
  width: auto;
  max-width: 90%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.75));
}

.firewall-hint-zone:hover .firewall-hint-glyph {
  opacity: 1;
}

.firewall-tabs {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 10px 14px;
  flex-shrink: 0;
  border-top: 1px solid var(--panel-border);
}

.firewall-tab {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 0.9rem;
}

.firewall-tab:hover {
  border-color: var(--sand);
}

.firewall-full-img {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---- Watch your step!: trap-tile crossing minigame ---- */

.modal[data-modal="floortile"] {
  height: 92vh;
  max-height: 92vh;
}

.floortile-stage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
}

.floortile-stage {
  position: relative;
  height: 66vh;
  max-height: 66vh;
  width: 94vw;
  max-width: 94vw;
  min-height: 0;
}

.floortile-bg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.floortile-tile {
  position: absolute;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.floortile-tile.active-col {
  box-shadow: inset 0 0 0 3px rgba(232, 195, 122, 0.85);
}

.floortile-tile.safe {
  box-shadow: inset 0 0 0 3px rgba(53, 208, 127, 0.85);
  cursor: default;
}

.floortile-tile.trap-flash {
  animation: shake 0.4s;
  box-shadow: inset 0 0 0 3px rgba(179, 64, 44, 0.9);
}

.floortile-tile.resolved {
  cursor: default;
}

.floortile-label-mark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  font-weight: 900;
  color: var(--accent-red);
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.9));
}

.floortile-tile.labeled .floortile-label-mark {
  opacity: 1;
}

.floortile-message {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  max-width: 70%;
  text-align: center;
  background: rgba(10, 5, 2, 0.92);
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  font-size: 1.15rem;
  line-height: 1.5;
  padding: 18px 26px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 20;
}

.floortile-message.visible {
  opacity: 1;
}

.floortile-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 14px 14px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--panel-border);
}

.floortile-lives {
  color: var(--sand-bright);
  font-size: 1.7rem;
  letter-spacing: 2px;
  font-weight: bold;
  text-shadow: 0 0 12px rgba(232, 195, 122, 0.45);
}

.floortile-label-btn {
  border-color: var(--accent-red);
  color: var(--sand-bright);
  font-weight: bold;
  font-size: 1rem;
  padding: 10px 22px;
  box-shadow: 0 0 14px rgba(179, 64, 44, 0.45);
}

.floortile-label-btn:hover {
  border-color: var(--accent-red);
  box-shadow: 0 0 20px rgba(179, 64, 44, 0.7);
}

.floortile-label-btn.active {
  border-color: var(--accent-green);
  background: rgba(53, 208, 127, 0.25);
  box-shadow: 0 0 26px rgba(53, 208, 127, 0.9);
}

.floortile-label-btn.active:hover {
  border-color: var(--accent-green);
  box-shadow: 0 0 32px rgba(53, 208, 127, 1);
}

.floortile-heart-pop {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 6rem;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  z-index: 25;
  filter: drop-shadow(0 0 24px rgba(0, 0, 0, 0.85));
}

.floortile-tip-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
}

.floortile-tip-overlay[hidden] { display: none; }

.floortile-tip-img {
  height: 94%;
  max-height: 94%;
  width: auto;
  max-width: 94%;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6);
}

/* ---- The Divine Code: Simon-says pinpad minigame ---- */

.modal.modal-pinpad {
  max-width: 640px;
  width: 92vw;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 18px 20px 16px;
}

.modal.modal-pinpad.active {
  display: flex;
}

.pinpad-tip-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 12px;
  background: rgba(10, 5, 2, 0.75);
  border: 1px solid var(--panel-border);
  border-radius: 17px;
  color: var(--text-light);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  line-height: 1;
  z-index: 10;
}

.pinpad-tip-btn:hover {
  border-color: var(--sand);
}

.modal.modal-pinpad h2 {
  margin-bottom: 2px;
}

.pinpad-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 580px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.pinpad-progress-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pinpad-progress {
  display: flex;
  gap: 5px;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: rgba(10, 5, 2, 0.5);
}

.pinpad-progress-seg {
  width: 16px;
  height: 10px;
  border-radius: 3px;
  background: rgba(232, 195, 122, 0.12);
  border: 1px solid var(--panel-border);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.pinpad-progress-seg.filled {
  background: var(--sand-bright);
  box-shadow: 0 0 8px 2px rgba(232, 195, 122, 0.85);
}

.pinpad-play-btn {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--sand-bright);
  padding: 6px 18px;
  border-radius: 6px;
  font-size: 0.9rem;
}

.pinpad-play-btn:hover {
  border-color: var(--sand);
}

.pinpad-play-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.pinpad-stage {
  position: relative;
  width: min(100%, 580px, calc(54vh * 824 / 860));
  aspect-ratio: 824 / 860;
}

.pinpad-bg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.pinpad-btn {
  position: absolute;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  border-radius: 14%;
  transition: background 0.1s, box-shadow 0.1s;
}

.pinpad-stage.playing .pinpad-btn {
  pointer-events: none;
}

.pinpad-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.pinpad-btn:active {
  background: rgba(0, 0, 0, 0.4);
}

.pinpad-btn.lit {
  background: rgba(232, 195, 122, 0.55);
  box-shadow: inset 0 0 22px 8px rgba(255, 220, 140, 0.85);
}

.pinpad-btn.solved-glow {
  background: rgba(53, 208, 127, 0.25);
  box-shadow: inset 0 0 16px 4px rgba(53, 208, 127, 0.5);
}

.pinpad-btn.stage-glow {
  background: rgba(232, 195, 122, 0.55);
  box-shadow: inset 0 0 22px 8px rgba(255, 220, 140, 0.85), 0 0 18px 4px rgba(255, 220, 140, 0.6);
  animation: pinpad-stage-glow-pulse 1.4s ease-in-out infinite;
}

@keyframes pinpad-stage-glow-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}

.pinpad-bigx {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5.5rem;
  font-weight: bold;
  color: var(--accent-red);
  text-shadow: 0 0 24px rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 30;
}

.pinpad-bigx.visible {
  opacity: 1;
}

.pinpad-message {
  min-height: 1.4em;
  color: var(--sand-bright);
  font-size: 0.95rem;
}

.pinpad-stage-message {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 90%;
  text-align: center;
  background: rgba(10, 5, 2, 0.92);
  border: 1px solid var(--sand-bright);
  color: var(--sand-bright);
  font-size: 1.1rem;
  line-height: 1.5;
  padding: 16px 22px;
  border-radius: 10px;
  z-index: 40;
  cursor: pointer;
  box-shadow: 0 0 30px 6px rgba(232, 195, 122, 0.4);
}

.pinpad-stage-message[hidden] { display: none; }

/* ---- Solved / complete screens ---- */

.solved-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 8px 4px 4px;
}

.solved-reward-img {
  width: 90px;
  height: auto;
  filter: drop-shadow(0 0 12px rgba(255, 210, 100, 0.7));
}

.solved-text {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-light);
}

.continue-btn {
  margin-top: 8px;
  background: var(--sand);
  color: #241703;
  border: none;
  padding: 10px 22px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 0.95rem;
  transition: background 0.2s;
}
.continue-btn:hover { background: var(--sand-bright); }

.modal.modal-complete {
  background: none;
  border: none;
  box-shadow: none;
}

.complete-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.complete-dim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 2s ease;
}

.complete-dim.visible { opacity: 1; }
.complete-dim[hidden] { display: none; }

.complete-text {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 80%;
  text-align: center;
  color: var(--sand-bright);
  font-size: 1.8rem;
  font-weight: bold;
  line-height: 1.4;
  text-shadow: 0 0 24px rgba(232, 195, 122, 0.85), 0 2px 10px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 2s ease;
  z-index: 5;
}

.complete-text.visible { opacity: 1; }
.complete-text[hidden] { display: none; }

@media (max-width: 600px) {
  .scene { aspect-ratio: 3 / 4; }
}

@media (max-width: 480px) {
  .hud { padding: 8px 10px; }
  .hud-title { font-size: 0.85rem; }
  .hud-logo { height: 24px; }
  .modal { padding: 22px 16px 18px; }
  .modal.modal-huge { padding: 18px 14px 14px; }
}
