html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: linear-gradient(to bottom, #AFC8B0 0%, #879E82 52%, #5F735C 100%);
}

a-scene {
  width: 100%;
  height: 100%;
}

#man-dialogue-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 1200px;
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid #444;
  border-radius: 8px;
  padding: 15px 20px;
  color: #fff;
  font-family: Arial, sans-serif;
  z-index: 100;
  display: none;
  max-height: 300px;
  overflow-y: auto;
}

#man-dialogue-container.active {
  display: flex;
  gap: 30px;
}

.dialogue-left {
  flex: 1;
  min-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dialogue-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.dialogue-arrow {
  color: #FFD700;
  font-size: 16px;
  flex-shrink: 0;
}

.dialogue-text {
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.dialogue-text.npc {
  color: #fff;
}

.dialogue-text.player {
  color: #00D9FF;
}

.dialogue-right {
  flex: 0.6;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 1px solid #444;
  padding-left: 15px;
}

.options-label {
  color: #00D9FF;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
}

.dialogue-option {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid #FFD700;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: center;
  transition: all 0.2s ease;
}

.dialogue-option:hover {
  background: rgba(255, 215, 0, 0.2);
  transform: translateX(5px);
}

.dialogue-option-arrow {
  color: #FFD700;
  font-size: 12px;
}

.dialogue-option-text {
  color: #fff;
  font-size: 12px;
  flex: 1;
}

/* Home screen */
#home-screen {
  position: fixed;
  inset: 0;
  z-index: 10000; /* above the game, dialogue, cutscene and the VR button */
  background: #bfe1ea; /* matches the SVG sky if the window isn't 16:9 */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 1s ease;
}

#home-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Keeps the SVG at 16:9 so the click areas stay on top of the drawn buttons */
.home-frame {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
}

.home-frame img {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

/* Positions measured from the SVG at 1920x1080 */
.home-button {
  position: absolute;
  left: 43.1%;   /* 828 / 1920 */
  width: 13.75%; /* 264 / 1920 */
  height: 5.1%;  /* 55 / 1080 */
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.home-button:hover,
.home-button:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6);
  outline: none;
}

/* Button positions in "better home screen.svg" */
#home-start {
  top: 49.5%; /* 535 / 1080 */
}

#home-recap {
  top: 56.9%; /* 615 / 1080 */
}

/* Music volume control (top-right) */
#volume-control {
  position: fixed;
  z-index: 10002; /* above everything, so it works on the home screen, recap and black screens */
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
  gap: 0.5rem;
  font-family: Arial, sans-serif;
}

#volume-button {
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

#volume-button:hover,
#volume-button:focus-visible,
#volume-button[aria-expanded="true"] {
  background: rgba(0, 0, 0, 0.75);
  border-color: #f2c94c;
  outline: none;
}

#volume-panel {
  display: none;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.85rem;
}

#volume-panel.open {
  display: flex;
}

#volume-slider {
  width: 8rem;
  accent-color: #f2c94c;
  cursor: pointer;
}

#volume-value {
  min-width: 2.6rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Quest tracker (top-left) */
#quest-tracker {
  position: fixed;
  z-index: 50; /* under the dialogue, cutscene and home screen */
  top: 1rem;
  left: 0;
  width: min(26rem, calc(100vw - 2rem));
  padding: 0.7rem 1.4rem 0.8rem 1rem;
  color: #fff;
  font-family: Arial, sans-serif;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  background: linear-gradient(to right, rgba(0, 0, 0, 0.55) 60%, rgba(0, 0, 0, 0));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

#quest-tracker.visible {
  opacity: 1;
}

.quest-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: bold;
}

/* The icon is cut out of "quest icon.svg" (the icon sits in the middle of a 1440x810 canvas)
   and painted gold with a mask */
.quest-icon {
  --s: 1.4rem;
  flex-shrink: 0;
  width: var(--s);
  height: var(--s);
  background: #f2c94c;
  -webkit-mask: url("images/quest icon.svg") no-repeat;
  mask: url("images/quest icon.svg") no-repeat;
  -webkit-mask-size: calc(var(--s) * 2.7507) calc(var(--s) * 1.5473);
  mask-size: calc(var(--s) * 2.7507) calc(var(--s) * 1.5473);
  -webkit-mask-position: calc(var(--s) * -0.8552) calc(var(--s) * -0.2450);
  mask-position: calc(var(--s) * -0.8552) calc(var(--s) * -0.2450);
  filter: drop-shadow(0 0 3px rgba(242, 201, 76, 0.6));
}

#quest-objectives {
  margin: 0.45rem 0 0;
  padding-left: 2.4rem;
  font-size: 0.95rem;
  line-height: 1.4;
}

#quest-objectives li {
  margin-bottom: 0.3rem;
}

#quest-objectives li.optional {
  color: #d8d8d8;
}

/* Briefly highlight the tracker when the objective changes */
#quest-tracker.updated .quest-title span:last-child {
  animation: quest-flash 1.2s ease;
}

@keyframes quest-flash {
  0%, 100% { color: #fff; }
  30% { color: #f2c94c; }
}

/* Story recap: full-screen image with subtitles at the bottom */
#recap {
  position: fixed;
  inset: 0;
  z-index: 10001; /* above the home screen */
  background: #bfe1ea; /* same as the home screen around the 16:9 frame */
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.8s ease;
}

#recap.active {
  display: flex;
}

/* Same size as the home screen frame (.home-frame) */
.recap-frame {
  position: relative;
  overflow: hidden;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  background: #000;
}

#recap.visible {
  opacity: 1;
}

#recap-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.6s ease;
}

/* Dark fade at the bottom so the subtitles are readable on any image */
.recap-frame::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
  pointer-events: none;
}

#recap-text {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 4.5rem;
  transform: translateX(-50%);
  width: min(1300px, calc(100% - 2rem));
  color: #fff;
  /* scales with the frame width (frame is never wider than 100vw or 177.8vh) */
  font: clamp(0.8rem, min(1.6vw, 2.85vh), 1.4rem)/1.5 Arial, sans-serif;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  transition: opacity 0.6s ease;
}

#recap-hint {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  bottom: 1.5rem;
  color: rgba(255, 255, 255, 0.6);
  font: 0.8rem Arial, sans-serif;
  letter-spacing: 0.08em;
  text-align: center;
}

#recap .fading {
  opacity: 0;
}

/* Black screen cutscene */
#cutscene {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 10%;
  opacity: 0;
  transition: opacity 1.5s ease;
  cursor: pointer;
}

#cutscene.active {
  display: flex;
}

#cutscene.visible {
  opacity: 1;
}

#cutscene-text {
  max-width: 900px;
  color: #eee;
  font: 1.5rem/1.7 Georgia, 'Times New Roman', serif;
  text-align: center;
  white-space: pre-line; /* allow line breaks (\n) in cutscene text */
  opacity: 0;
  transition: opacity 1.2s ease;
}

#cutscene-text.visible {
  opacity: 1;
}

#cutscene-hint {
  position: absolute;
  bottom: 2.5rem;
  color: #777;
  font: 0.85rem Arial, sans-serif;
  letter-spacing: 0.1em;
  opacity: 0;
  transition: opacity 0.8s ease;
}

#cutscene-hint.visible {
  opacity: 1;
}

#keyboard-help {
  position: fixed;
  z-index: 10;
  top: 0.5rem;
  left: 0.5rem;
  width: min(28rem, calc(100vw - 1rem));
  color: #1b1b1b;
  font: 0.85rem Arial, sans-serif;
  pointer-events: none;
}

#keyboard-help div {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0.8rem;
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid rgba(255, 255, 255, 0.45);
}

#keyboard-help strong {
  min-width: 1.5rem;
  text-align: center;
}