/* MilleRace - Game Stages CSS (Stages 1 - 4) */

.stage-screen {
  height: 100vh !important;
  max-height: 100vh !important;
  overflow: hidden !important;
  position: relative;
  width: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.stage-container {
  width: 100%;
  max-width: 1200px;
  height: calc(100vh - 80px);
  margin-top: 80px;
  padding: 10px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 20;
  box-sizing: border-box;
  overflow: hidden;
}

/* Stage Gameplay Area (Hidden during dialogue, revealed smoothly after dialogue ends) */
.stage-gameplay-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.35s ease 0.2s, transform 0.35s ease 0.2s;
  opacity: 1;
  transform: scale(1);
}

.stage-screen.dialogue-active .stage-gameplay-area {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
  transform: scale(0.96);
  transition: opacity 0.15s ease 0s, transform 0.15s ease 0s;
}

/* Question Progress Bar */
.question-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.progress-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: var(--transition-fast);
}

.progress-dot.active {
  background: var(--color-yellow);
  box-shadow: var(--shadow-glow-yellow);
}

.progress-dot.completed {
  background: var(--color-teal);
}

/* Progress Dots Floating Glass Pill attached under Top HUD Bar for Stage 3 & Stage 4 */
.stage3-progress-dots,
.stage4-progress-dots {
  position: fixed;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  margin: 0;
  background: rgba(22, 20, 28, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 5px 16px;
  border-radius: 20px;
  border: 1px solid rgba(243, 205, 80, 0.3);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.stage-screen.dialogue-active .stage3-progress-dots,
.stage-screen.dialogue-active .stage4-progress-dots {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Stage Question Prompt */
.stage-prompt {
  font-family: var(--font-title);
  font-size: clamp(1.15rem, 2vw, 1.4rem);
  font-weight: 700;
  color: var(--color-yellow);
  text-align: center;
  max-width: 860px;
  margin: 0 auto 16px auto;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  line-height: 1.4;
}

/* STAGE 1: Visual AIAS Artwork Cards (Uniform height, dynamic width, 3-card horizontal constraint) */
.stage1-cards-grid {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(14px, 2vw, 28px);
  width: 100%;
  max-width: 1160px;
  margin: 10px auto 10px auto;
  flex-wrap: nowrap;
  /* Prevent wrapping into 2nd row on desktop/laptop/tablet */
}

.art-card {
  height: clamp(300px, 54vh, 480px);
  max-height: 56vh;
  max-width: calc((100% - 2 * clamp(14px, 2vw, 28px)) / 3);
  width: auto;
  background: rgba(22, 20, 28, 0.85);
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition-normal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: var(--shadow-card);
  flex-shrink: 1;
}

.art-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: var(--color-yellow);
  box-shadow: var(--shadow-glow-yellow);
}

.art-card.selected-choice,
.art-card.selected,
.art-card.correct {
  border-color: var(--color-teal) !important;
  box-shadow: 0 0 35px rgba(46, 158, 133, 0.9) !important;
  transform: scale(1.03);
}

.art-card img {
  height: 100%;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  border-radius: 17px;
}

/* STAGE 2: Door Passwords (Fill-in-the-Blank) */
.stage2-header-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: clamp(280px, 36vw, 480px);
  margin-bottom: 12px;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.55));
}

.stage2-banner-img {
  width: 100%;
  height: auto;
  max-height: 64px;
  object-fit: contain;
  display: block;
}

.stage2-puzzle-card {
  background: var(--color-card-bg);
  border: 2px solid var(--color-purple);
  border-radius: 28px;
  padding: 40px;
  width: 100%;
  max-width: 800px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.book-title-display {
  font-family: var(--font-title);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  color: var(--color-text-light);
  margin-bottom: 30px;
  line-height: 1.4;
}

.title-blank {
  display: inline-block;
  min-width: 140px;
  padding: 4px 16px;
  /* border-bottom: 3px dashed var(--color-yellow); */
  color: var(--color-yellow);
  font-weight: bold;
}

.word-options-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}

.word-chip {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(243, 205, 80, 0.5);
  color: var(--color-text-light);
  font-family: var(--font-mono);
  font-size: 1.2rem;
  padding: 12px 28px;
  border-radius: 30px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.word-chip:hover {
  background: var(--color-yellow);
  color: var(--color-dark-bg);
  transform: scale(1.05);
}

.word-chip.selected-choice {
  background: var(--color-teal) !important;
  border-color: var(--color-teal) !important;
  color: #FFFFFF !important;
  box-shadow: 0 0 20px rgba(46, 158, 133, 0.8) !important;
}

/* STAGE 3: Textual AIAS Evaluation (Ink Night Background & stage3-paper.svg Container) */
.stage3-gameplay-wrap {
  width: 100%;
  max-width: 1000px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: absolute;
  top: 16px;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  height: calc(100vh - 16px);
  padding-bottom: 0;
  z-index: 20;
}

.stage3-paper-card {
  background-image: url('../assets/images/ui/questions/stage3-paper.svg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center bottom;
  width: min(880px, 94vw);
  max-width: 920px;
  flex: 1;
  height: 100%;
  min-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(60px, 9vh, 95px) clamp(100px, 12vw, 170px) calc(15vh + 110px) clamp(100px, 9vw, 160px);
  box-sizing: border-box;
  filter: drop-shadow(0 15px 35px rgba(0, 0, 0, 0.75));
  margin: 10px auto 0 auto;
  pointer-events: none;
}

.passage-text {
  font-family: var(--font-body), 'Bona Nova', serif;
  font-size: clamp(1.15rem, 1.4vw, 1.4rem);
  line-height: 1.65;
  color: #0E0D12;
  text-align: center;
  max-width: 100%;
  width: 100%;
  font-weight: 500 !important;
  user-select: text;
  pointer-events: auto;
  transform: rotateZ(-6deg);
}

/* Stage 3 Rating Strip: Delayed entrance until dialogue avatar finishes exiting */
.stage3-rating-strip {
  position: fixed;
  bottom: 15vh;
  /* Located at 3/4 of screen, leaving 4/4 space below */
  left: 0;
  width: 100vw;
  height: 100px;
  background: #8A38F5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3.5vw, 44px);
  padding: 0 clamp(20px, 4vw, 60px);
  box-sizing: border-box;
  z-index: 70;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1) 0.22s, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1) 0.22s;
}

.stage-screen.dialogue-active .stage3-rating-strip {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
  transform: translateY(35px);
  transition: opacity 0.15s ease 0s, transform 0.15s ease 0s;
}

/* Stage 3 Corner Character: Visible during dialogue, quick snappy exit before options appear */
#stage3-corner-char {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease-out, transform 0.18s ease-out, visibility 0.18s ease-out;
  transform: translateY(16px);
}

#screen-stage3.dialogue-active #stage3-corner-char {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(0);
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

/* Avatars stick to bottom-left and bottom-right corners covering the empty 4/4 space (Identical size to dialogue avatar) */
.stage3-strip-avatar {
  position: fixed;
  bottom: 0;
  width: clamp(250px, 22vw, 400px);
  height: clamp(250px, 22vw, 400px);
  z-index: 80;
  flex-shrink: 0;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1) 0.65s, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1) 0.65s;
}

.stage-screen.dialogue-active .stage3-strip-avatar {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(28px);
  transition: opacity 0.15s ease 0s, transform 0.15s ease 0s;
}

.stage3-left-avatar {
  left: 0;
}

.stage3-right-avatar {
  right: 0;
}

.stage3-strip-avatar .strip-char-img {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.7));
}

.stage3-left-avatar .strip-char-img {
  left: 0;
  object-position: bottom left;
}

.stage3-right-avatar .strip-char-img {
  right: 0;
  object-position: bottom right;
}

.rating-scale-label {
  font-family: var(--font-body), 'Bona Nova', serif;
  font-size: clamp(1.05rem, 1.2vw, 1.25rem);
  font-weight: 400 !important;
  /* Regular font weight, not bold */
  color: #FFFFFF;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.rating-buttons-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 2.5vw, 36px);
  flex-wrap: nowrap;
}

/* Empty Circles with Bold Yellow Stroke */
.rating-circle-btn {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(22, 20, 28, 0.4);
  border: 5.5px solid #F3CD50;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  outline: none;
  padding: 0;
}

/* "Somewhat Human" and "Barely Human" are 6px smaller than Human/Not Human */
.rating-circle-btn[data-rating="Somewhat Human"],
.rating-circle-btn[data-rating="Barely Human"] {
  width: 48px;
  height: 48px;
}

.rating-circle-btn:hover {
  background: rgba(243, 205, 80, 0.2);
  border-color: #FFFFFF;
  transform: translateY(-3px) scale(1.12);
  box-shadow: 0 0 20px rgba(243, 205, 80, 0.85);
}

/* Tooltip overlay above the circle */
.rating-tooltip {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: #16141C;
  color: #F3CD50;
  border: 1.5px solid #F3CD50;
  border-radius: 20px;
  padding: 6px 14px;
  font-family: var(--font-body), 'Bona Nova', serif;
  font-size: 0.95rem;
  font-weight: 400 !important;
  /* Regular font weight */
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
  z-index: 100;
}

.rating-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #F3CD50;
}

.rating-circle-btn:hover .rating-tooltip,
.rating-circle-btn:focus .rating-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.rating-check-icon {
  color: #FFFFFF;
  font-size: 1.6rem;
  font-weight: 900;
  opacity: 0;
  transform: scale(0.2);
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.rating-circle-btn.selected-choice,
.rating-circle-btn.selected {
  background: var(--color-teal) !important;
  border-color: #FFFFFF !important;
  transform: scale(1.15);
  box-shadow: 0 0 25px rgba(46, 158, 133, 0.95) !important;
}

.rating-circle-btn.selected-choice .rating-check-icon,
.rating-circle-btn.selected .rating-check-icon {
  opacity: 1;
  transform: scale(1);
}

/* STAGE 4: PISA Inferential Comprehension (Ink Night Background & Horizontal Paper Container) */
.stage4-gameplay-wrap {
  width: 96vw;
  max-width: 1400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
}

.stage4-paper-card {
  background-image: url('../assets/images/ui/questions/stage4-paper.svg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  width: 100%;
  max-width: min(96vw, 1380px);
  /* Wide as the screen width dimension */
  min-height: 320px;
  height: clamp(320px, 48vh, 480px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px clamp(80px, 12vw, 200px);
  box-sizing: border-box;
  filter: drop-shadow(0 15px 35px rgba(0, 0, 0, 0.7));
  transform: rotate(0.5deg);
}

.passage-box {
  color: #0E0D12;
  font-family: var(--font-body), 'Bona Nova', serif;
  font-size: clamp(1.2rem, 1.45vw, 1.45rem);
  line-height: 1.7;
  text-align: center;
  max-width: min(50vw, 620px);
  font-weight: 400 !important;
  /* Regular font weight, not bold */
  user-select: text;
}

/* Stage 4 Floating Multiple-Choice Options at Bottom-Right (No Dialog Box Behind) */
.stage4-floating-options-list {
  position: fixed;
  bottom: 28px;
  right: 48px;
  width: min(520px, 48vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 70;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.stage-screen.dialogue-active .stage4-floating-options-list {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
  transform: translateY(20px);
}

.stage4-floating-options-list .option-item {
  background: #8A38F5;
  border: 2px solid transparent;
  border-radius: 32px;
  padding: 12px 24px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--font-body), 'Bona Nova', serif;
  font-size: clamp(1.15rem, 1.4vw, 1.35rem);
  font-weight: 400 !important;
  /* Regular font weight, not bold */
  color: #FFFFFF;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.stage4-floating-options-list .option-item:hover {
  background: rgba(138, 56, 245, 0.9);
  border-color: var(--color-yellow);
  transform: translateX(-6px) scale(1.02);
  box-shadow: var(--shadow-glow-yellow);
}

.stage4-floating-options-list .option-item.selected-choice,
.stage4-floating-options-list .option-item.selected {
  border-color: #FFFFFF !important;
  background: var(--color-teal) !important;
  box-shadow: 0 0 25px rgba(46, 158, 133, 0.95) !important;
  color: #FFFFFF !important;
  transform: scale(1.04);
}

.stage4-floating-options-list .option-letter {
  background: rgba(22, 20, 28, 0.6);
  border: 2px solid var(--color-yellow);
  color: var(--color-yellow);
  font-family: var(--font-title), 'Cinzel', serif;
  font-size: 1.15rem;
  font-weight: 700;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stage4-floating-options-list .option-item.selected .option-letter,
.stage4-floating-options-list .option-item.selected-choice .option-letter {
  background: #FFFFFF;
  color: var(--color-dark-bg);
  border-color: #FFFFFF;
}

/* Responsive Breakpoints for Stage Layouts */
@media (max-width: 900px) {

  .stage-corner-character,
  .stage3-strip-avatar {
    width: clamp(200px, 25vw, 280px);
    height: clamp(200px, 25vw, 280px);
    opacity: 0.85;
  }

  .stage3-paper-card {
    width: 96vw;
    padding: clamp(50px, 8vh, 80px) clamp(50px, 8vw, 90px) calc(15vh + 90px) clamp(50px, 8vw, 90px);
  }

  .passage-text {
    font-size: clamp(1rem, 3.2vw, 1.25rem);
    line-height: 1.55;
  }

  .stage-container {
    margin-top: 70px;
    padding: 0 16px;
  }

  .stage1-cards-grid {
    gap: 12px;
  }

  .art-card {
    height: 240px;
    max-width: calc((100% - 24px) / 3);
  }

  .stage-dialog-bottom {
    left: 16px;
    bottom: 16px;
    width: calc(100vw - 32px);
    max-width: 100vw;
  }

  .dialog-box {
    padding: 18px 22px;
  }
}

@media (max-width: 600px) {

  .stage-corner-character,
  .stage3-strip-avatar {
    opacity: 0.35;
    width: 160px;
    height: 160px;
  }

  .stage3-paper-card {
    width: 98vw;
    padding: clamp(70px, 12vh, 100px) clamp(40px, 8vw, 60px) calc(15vh + 80px) clamp(40px, 8vw, 60px);
  }

  .passage-text {
    font-size: clamp(0.85rem, 3vw, 1rem);
    line-height: 1.5;
  }

  .stage1-cards-grid {
    flex-wrap: wrap;
    gap: 10px;
  }

  .art-card {
    height: 180px;
    max-width: 48%;
  }

  .dialog-text {
    font-size: 1.05rem;
  }

  .hud-stage-subtitle {
    display: none;
  }
}