/* ═══════════════════════════════════════════════════════════════
   GAMES — All Game-Specific Styles
   Matching, Hangman, Fill-in-the-Blank, Mad Libs
   ═══════════════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────────────────
   SHARED GAME LAYOUT
   ─────────────────────────────────────────────────────────────── */
.game-container {
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}

/* ───────────────────────────────────────────────────────────────
   AUDIO DICTATION
   ─────────────────────────────────────────────────────────────── */
.audio-dictation-container {
  max-width: 900px;
  margin: 0 auto;
}

.audio-dictation-container #listenArea {
  margin: 18px 0 8px;
  display: none;
  flex-direction: column;
  align-items: center;
}

.audio-dictation-container .listen-text {
  font-size: 1rem;
}

.audio-dictation-container #progressContainer {
  width: 100%;
  max-width: 400px;
  height: 18px;
  border: 3px solid var(--r-green);
  margin-top: 12px;
  background: var(--r-panel);
  border-radius: 4px;
  overflow: hidden;
}

.audio-dictation-container #progressBar {
  height: 100%;
  width: 0%;
  background: var(--r-green);
  transition: width 0.3s linear;
}

.audio-dictation-container #answerArea {
  margin-top: 14px;
  display: none;
  flex-direction: column;
  align-items: center;
}

.audio-dictation-container #answer {
  padding: 12px 20px;
  border: 3px solid var(--r-green);
  text-align: center;
  font-size: 1.15rem;
  margin-bottom: 15px;
  width: 100%;
  max-width: 350px;
  border-radius: 4px;
  background: var(--r-panel);
  color: var(--r-text);
  font-family: inherit;
}

.audio-dictation-container #answer:focus {
  outline: none;
  border-color: var(--r-gold);
  box-shadow: 0 0 0 0.2rem rgba(252, 191, 73, 0.25);
}

.audio-dictation-container .btn-group-audio {
  display: flex;
  gap: 15px;
  margin: 6px 0 2px;
  justify-content: center;
}

.audio-dictation-container #feedback {
  margin-top: 12px;
  min-height: 30px;
  font-size: 1.15rem;
  font-weight: bold;
}

.audio-dictation-container #attempts {
  margin-top: 6px;
  font-size: 0.95rem;
  color: var(--r-text-mid, #555);
}

.audio-dictation-container .inline-form {
  display: inline-block;
  margin-right: 10px;
}

.audio-dictation-container .inline-button {
  margin-right: 10px;
}

.audio-dictation-container .is-hidden {
  display: none;
}

@media (max-width: 576px) {
  .audio-dictation-container .d-flex {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .audio-dictation-container #progressContainer {
    max-width: 100%;
  }
  .audio-dictation-container #answer {
    max-width: 100%;
  }
  .audio-dictation-container .btn-group-audio {
    width: 100%;
  }
  .audio-dictation-container .btn-group-audio .btn {
    width: 100%;
  }
}

/* ───────────────────────────────────────────────────────────────
   HANGMAN — Listen & Spell
   ─────────────────────────────────────────────────────────────── */
.listen-instructions {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 6px;
  text-align: center;
  margin-bottom: 20px;
}

.listen-instructions p {
  margin-bottom: 12px;
  color: #666;
}

.word-display {
  font-size: 32px;
  letter-spacing: 6px;
  font-weight: 700;
  text-align: center;
}

.hangman-stage {
  font-family: "Courier New", monospace;
  font-size: 14px;
  white-space: pre;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 12px;
}

.wrong-letters {
  letter-spacing: 4px;
  font-weight: 600;
}

.special-chars {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 12px;
  border: 1px solid #e9ecef;
}

.special-chars .special-char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  gap: 8px;
}

.special-chars .special-char {
  font-weight: 600;
  min-height: 36px;
}

/* ───────────────────────────────────────────────────────────────
   MATCHING GAME
   ─────────────────────────────────────────────────────────────── */
.matching-game-container {
  max-width: 900px;
  margin: 0 auto;
}

.matching-status {
  text-align: center;
  font-size: 1.25rem;
  margin: 2rem 0;
  font-weight: 600;
  color: #6366f1;
}

.matching-status .attempts {
  font-size: 0.9rem;
  color: #64748b;
  margin-left: 1rem;
  font-weight: 600;
}

.matching-status .attempts.low-lives {
  color: #9c1616; /* retro-theme also overrides to #9c1616 via --r-red-text ✓ */
  animation: pulse-status 1s infinite;
}

@keyframes pulse-status {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.matching-columns {
  display: flex;
  gap: 3rem;
  justify-content: center;
  margin: 2rem 0;
}

.matching-column {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  flex: 1;
  max-width: 350px;
}

.match-card {
  padding: 1.25rem;
  border: 3px solid #6366f1;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  background: white;
  transition: all 0.2s ease;
  font-size: 1rem;
  font-weight: 500;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.1);
}

.match-card:hover {
  background: var(--r-panel2);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.match-card.selected {
  background: var(--r-gold);
  color: var(--r-text);
  border-color: var(--r-gold);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(252, 191, 73, 0.4);
}

.motion-ready .match-card.selected,
.motion-ready .seq-item.selected,
.motion-ready .word-chip.selected,
.motion-ready .placed-chip.selected {
  transform: translateY(-2px) scale(1.01);
}

.match-card.correct {
  background: var(--r-green);
  color: var(--r-text-lt);
  border-color: var(--r-green);
  cursor: default;
  box-shadow: 0 4px 12px rgba(46, 88, 24, 0.3);
}

.match-card.correct:hover {
  transform: none;
}

.match-card.wrong {
  background: var(--r-red);
  color: var(--r-text-lt);
  border-color: var(--r-red);
  animation: shake 0.3s;
}

.motion-ready .option-btn.correct,
.motion-ready .mc-option.mc-correct,
.motion-ready .q-feedback-bar.q-fb-correct,
.motion-ready #feedback.text-success,
.motion-ready #feedbackMsg.alert-success,
.motion-ready #completionMsg,
.motion-ready #completion-panel {
  animation: motion-soft-pop 0.24s var(--motion-ease);
}

.motion-ready .option-btn.wrong,
.motion-ready .mc-option.mc-wrong,
.motion-ready .q-feedback-bar.q-fb-wrong,
.motion-ready #feedback.text-danger,
.motion-ready #feedbackMsg.alert-danger,
.motion-ready #feedbackMsg.alert-warning {
  animation: motion-nudge 0.26s ease-out;
}

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

/* ───────────────────────────────────────────────────────────────
   FILL-IN-THE-BLANK GAME
   ─────────────────────────────────────────────────────────────── */
#sentence-display {
  font-size: 2rem;
  font-weight: bold;
  color: var(--r-text);
  background: var(--r-panel2);
  border: 3px solid var(--r-border);
  border-radius: 6px;
  padding: 24px 32px;
  margin: 20px 0 28px;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

#sentence-display .blank-slot {
  display: inline-block;
  min-width: 100px;
  border-bottom: 4px solid var(--r-green);
  color: var(--r-green);
  font-size: 2rem;
  vertical-align: bottom;
  padding: 0 6px;
  font-style: italic;
}

#sentence-display.correct-flash {
  background: var(--r-panel2);
  border-color: var(--r-green);
  transition: background 0.3s;
}

#sentence-display.wrong-flash {
  background: var(--r-panel2);
  border-color: var(--r-red);
  transition: background 0.3s;
}

/* Fill-in-blank sentence box used inside question.html (mixed mode) */
.fib-sentence-box {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--r-text);
  background: var(--r-panel2);
  border: 3px solid var(--r-border);
  border-radius: 6px;
  padding: 18px 24px;
  line-height: 1.6;
  letter-spacing: 0.02em;
}

.fib-sentence-box .blank-slot.fib-correct {
  color: var(--r-green);
  border-bottom-color: var(--r-green);
  font-style: normal;
}

.fib-sentence-box .blank-slot.fib-wrong {
  color: #9c1616; /* 4.8:1 on panel2 ✓ WCAG AA */
  border-bottom-color: #9c1616;
  font-style: normal;
}

/* ───────────────────────────────────────────────────────────────
   MAD LIBS GAME
   ─────────────────────────────────────────────────────────────── */
#story-display {
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--r-text);
  background: var(--r-panel2);
  border: 3px solid var(--r-border);
  border-radius: 6px;
  padding: 28px 32px;
  margin: 20px 0 10px;
  line-height: 2.2;
  letter-spacing: 0.02em;
}

.blank-slot {
  display: inline-block;
  min-width: 80px;
  border-bottom: 4px solid var(--r-green);
  color: var(--r-green);
  font-size: 1.6rem;
  vertical-align: bottom;
  padding: 0 6px;
  font-style: italic;
}

.blank-slot.current-blank {
  border-bottom-color: var(--r-gold);
  color: var(
    --r-green,
    #2e5818
  ); /* gold was 1.1:1 on panel2 FAIL; green = 4.5:1 ✓ */
  animation: pulse-blank 1s infinite;
}

.blank-slot.future-blank {
  border-bottom-color: var(--r-border);
  color: var(--r-text-mid);
}

.filled-slot {
  display: inline-block;
  padding: 0 6px;
  color: var(--r-green);
  font-weight: bold;
  font-style: normal;
  border-bottom: 3px solid transparent;
}

.filled-slot.just-answered {
  color: var(
    --r-green,
    #2e5818
  ); /* gold was 1.1:1 on panel2 FAIL; green = 4.5:1 ✓ */
}

@keyframes pulse-blank {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

#completed-story {
  font-size: 1.7rem;
  font-weight: bold;
  color: var(--r-text);
  background: var(--r-panel2);
  border: 3px solid var(--r-green);
  border-radius: 6px;
  padding: 28px 32px;
  margin: 16px 0 20px;
  line-height: 2.2;
  animation: pop-in 0.4s ease;
}

@keyframes pop-in {
  0% {
    transform: scale(0.9);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.answer-highlight {
  color: var(
    --r-green,
    #2e5818
  ); /* gold was 1.1:1 on panel2 FAIL; green = 4.5:1 ✓ */
  font-style: italic;
  border-bottom: 3px solid var(--r-gold);
  padding: 0 4px;
}

#blank-area {
  transition: opacity 0.2s;
}

/* ───────────────────────────────────────────────────────────────
   SHARED GAME OPTIONS & FEEDBACK
   ─────────────────────────────────────────────────────────────── */
#options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 0 auto 24px;
  max-width: 640px;
}

.option-btn {
  padding: 18px 22px;
  background: var(--r-panel);
  color: var(--r-text);
  border: 3px solid var(--r-border);
  font-size: 1.1rem;
  font-family: inherit;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.option-btn:hover:not(:disabled) {
  background: var(--r-panel2);
  border-color: var(--r-gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.option-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.option-btn.correct {
  background: var(--r-panel2) !important;
  border-color: var(--r-green) !important;
  color: var(--r-green) !important;
  font-weight: bold;
}

.option-btn.wrong {
  background: var(--r-panel2) !important;
  border-color: var(--r-red) !important;
  color: #9c1616 !important; /* darkened red = 4.8:1 on panel2 ✓ WCAG AA */
}

#english-hint {
  font-size: 1rem;
  margin-bottom: 10px;
}

@keyframes motion-soft-pop {
  0% {
    transform: scale(0.985);
  }
  55% {
    transform: scale(1.025);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes motion-nudge {
  0%,
  100% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(-6px);
  }
  65% {
    transform: translateX(5px);
  }
}

.game-interaction-hint,
.bubble-translate-hint {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--r-text, #160a02);
  background: rgba(255, 253, 245, 0.94);
  border: 1px solid rgba(22, 10, 2, 0.24);
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  padding: 4px 10px;
  font-style: normal;
  line-height: 1.2;
  text-transform: uppercase;
}

.game-interaction-hint.centered {
  display: flex;
  justify-content: center;
  width: max-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.game-interaction-hint.block {
  display: flex;
  justify-content: center;
  width: 100%;
  border-radius: 6px;
  text-align: center;
}

.game-interaction-hint.secondary {
  font-size: 0.66rem;
  padding: 3px 8px;
  background: rgba(255, 253, 245, 0.84);
}

#blank-prompt {
  font-size: 1rem;
  color: var(--r-text-mid);
  margin-bottom: 14px;
}

#feedback {
  min-height: 30px;
  font-size: 1.05rem;
  font-weight: bold;
  margin-bottom: 8px;
  color: var(--r-green);
}

#feedback.wrong-msg {
  color: #9c1616; /* darkened red = 6.7:1 on parchment ✓ WCAG AA */
}

#game-over-panel,
#completion-panel,
#story-done-panel {
  display: none;
  margin-top: 20px;
}

/* ───────────────────────────────────────────────────────────────
   RESPONSIVE — Games Mobile
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 576px) {
  .game-container {
    text-align: center;
  }

  .d-flex.justify-content-between {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Hangman */
  .word-display {
    font-size: 24px;
    letter-spacing: 4px;
  }

  .hangman-stage {
    font-size: 12px;
  }

  /* Matching */
  .matching-columns {
    gap: 1rem;
    flex-wrap: wrap;
  }

  .matching-column {
    flex: 1;
    min-width: 150px;
    max-width: 200px;
  }

  /* Fill-in-blank */
  #sentence-display {
    font-size: 1.2rem;
    padding: 16px 12px;
    margin: 12px 0 18px;
  }

  #sentence-display .blank-slot {
    font-size: 1.2rem;
    min-width: 60px;
  }

  /* Mad Libs */
  #story-display {
    font-size: 1rem;
    padding: 16px 12px;
    margin: 12px 0 8px;
    line-height: 2;
  }

  .blank-slot {
    font-size: 1rem;
    min-width: 50px;
  }

  .filled-slot {
    font-size: 1rem;
  }

  #completed-story {
    font-size: 1.1rem;
    padding: 16px 12px;
    line-height: 2;
  }

  /* All games */
  #options-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    max-width: 100%;
  }

  .option-btn {
    padding: 14px 12px;
    font-size: 1rem;
  }

  #feedback {
    font-size: 1rem;
    min-height: 28px;
  }

  #english-hint,
  #blank-prompt {
    font-size: 0.9rem;
  }
}

/* ───────────────────────────────────────────────────────────────
   I-SPY GAME
   ─────────────────────────────────────────────────────────────── */
.ispy-wrapper {
  max-width: 900px;
  margin: 0 auto;
}

/* Stage: fixed 16:10 aspect ratio so background image fills it */
.ispy-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #c8dff5;
  border-radius: 8px;
  overflow: hidden;
  border: 3px solid #555;
}

/* Inner container fills the stage exactly */
.ispy-stage-inner {
  position: absolute;
  inset: 0;
}

/* Each hotspot object */
.ispy-obj {
  position: absolute;
  cursor: pointer;
  border-radius: 4px;
  transition:
    background 0.15s,
    outline 0.15s;
  box-sizing: border-box;
}

/* In bg-image mode hotspots are invisible by default */
.has-bg-image .ispy-obj {
  background: transparent;
  outline: 2px solid transparent;
}

/* Hover: show a faint blue ring so the area is discoverable */
.has-bg-image .ispy-obj:hover {
  background: rgba(100, 160, 255, 0.18);
  outline: 2px solid rgba(100, 160, 255, 0.5);
}

/* Correct hit — flash green */
.ispy-obj.correct {
  background: rgba(50, 200, 80, 0.45) !important;
  outline: 3px solid #22bb44 !important;
}

/* Wrong hit — flash red */
.ispy-obj.wrong {
  background: rgba(220, 50, 50, 0.35) !important;
  outline: 3px solid #cc2222 !important;
}

/* Emoji / sprite mode label */
.obj-emoji {
  font-size: clamp(1.2rem, 4vw, 2.4rem);
  display: block;
  text-align: center;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.obj-label {
  font-size: 0.65rem;
  text-align: center;
  display: block;
  pointer-events: none;
  user-select: none;
  word-break: break-word;
}

/* Prompt bar */
.ispy-prompt {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #2d4a1e;
  color: #e8d87a;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 1.1rem;
  font-weight: 600;
  border: 2px solid #5a7a3a;
}

.speak-btn {
  background: #3d6b25;
  border: 2px solid #6a9a45;
  color: #e8d87a;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background 0.15s;
}

.speak-btn:hover {
  background: #4e8530;
}

/* Phase badge */
.phase-badge {
  background: #5a3e00;
  color: #f0c040;
  border: 1px solid #8a6010;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Gender colours on articles */
/* Colours for gender-coded article spans inside .ispy-prompt (dark bg #2d4a1e).
	Original #4488ff / #ee6699 gave 2.8:1 / 3.1:1 — FAIL.
	#80c4ff = 4.9:1 on #2d4a1e ✓  |  #ffb3d1 = 5.3:1 on #2d4a1e ✓ */
.gm {
  color: #80c4ff;
}
.gf {
  color: #ffb3d1;
}

@media (max-width: 600px) {
  .ispy-stage {
    aspect-ratio: 4 / 3;
    border-width: 2px;
  }
  .ispy-prompt {
    font-size: 0.9rem;
    padding: 6px 10px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   SCENARIO GAME — shared by scenario.html and scenario-typing.html
   ═══════════════════════════════════════════════════════════════ */

.scenario-wrapper {
  max-width: 1200px;
  margin: 0 auto;
}

.mobile-container {
  max-width: 440px;
  margin: 1.5rem auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  border: 3px solid var(--r-border, #7a5c2e);
  border-radius: 8px;
  overflow: hidden;
  background: var(--r-surface, #181008);
}

.scenario-container {
  width: 100%;
  height: 90vh;
  max-height: 820px;
  display: flex;
  flex-direction: column;
  position: relative;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.scene-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.45) 0%,
    rgba(0, 0, 0, 0.65) 100%
  );
  z-index: 1;
}

/* Scope .progress-bar to avoid Bootstrap conflict */
.scenario-container .progress-bar {
  background: var(--r-surface, #181008);
  color: var(--r-gold, #fcbf49);
  padding: 10px 14px;
  text-align: center;
  font-size: 0.75rem;
  font-family: "Press Start 2P", monospace;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--r-border, #7a5c2e);
  position: relative;
  z-index: 2;
  height: auto; /* override Bootstrap */
  border-radius: 0;
}

.chat-layer {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 2;
}

.scenario-container .bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 0.88rem;
  animation: scenario-fadeIn 0.3s ease;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.scenario-container .bubble.left {
  align-self: flex-start;
  background: var(--r-panel, #eae2b7);
  color: var(--r-text, #160a02);
  border: 2px solid var(--r-border, #7a5c2e);
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

.scenario-container .bubble.right {
  align-self: flex-end;
  background: var(--r-green, #2e5818);
  color: var(--r-text-lt, #f0e4b0);
  border: 2px solid rgba(0, 0, 0, 0.3);
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.bubble-english {
  font-size: 0.7rem;
  opacity: 0.75;
  margin-top: 6px;
  font-style: italic;
  line-height: 1.3;
  display: none;
}
.bubble-english.revealed {
  display: block;
}
.bubble-translate-hint {
  margin-top: 7px;
  font-size: 0.62rem;
}

.scenario-container .controls {
  padding: 14px;
  background: var(--r-panel, #eae2b7);
  border-top: 3px solid var(--r-border, #7a5c2e);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 2;
}

.scenario-container .hint-card {
  background: #fffdf5;
  border-left: 4px solid var(--r-gold, #fcbf49);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--r-text, #160a02);
}

/* Scope input-group to avoid Bootstrap override */
.scenario-container .input-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
}

.scenario-container .user-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--r-green, #2e5818);
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
  background: white;
  color: var(--r-text, #160a02);
  outline: none;
  transition: border-color 0.2s;
}

.scenario-container .user-input:focus {
  border-color: var(--r-gold, #fcbf49);
  box-shadow: 0 0 0 2px rgba(252, 191, 73, 0.25);
}

.scenario-container .submit-btn {
  background: var(--r-green, #2e5818);
  color: var(--r-text-lt, #f0e4b0);
  border: 2px solid rgba(0, 0, 0, 0.25);
  padding: 10px 18px;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s;
}

.scenario-container .submit-btn:hover {
  background: #3d7020;
}
.scenario-container .submit-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.scenario-container .choice-btn {
  background: var(--r-green, #2e5818);
  color: var(--r-text-lt, #f0e4b0);
  border: 2px solid rgba(0, 0, 0, 0.2);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
  position: relative;
}

.scenario-container .choice-btn:hover {
  background: #3d7020;
}

.choice-number {
  display: inline-block;
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 8px;
  border-radius: 3px;
  margin-right: 8px;
  font-weight: bold;
  font-size: 0.85rem;
}

.scenario-container .done-btn {
  background: var(--r-gold, #fcbf49);
  color: var(--r-text, #160a02);
  border: 2px solid var(--r-border, #7a5c2e);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s;
}

.scenario-container .done-btn:hover {
  background: #e8ac30;
}

.scenario-container .restart-btn {
  background: transparent;
  color: var(--r-text, #160a02);
  border: 2px solid var(--r-border, #7a5c2e);
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
}

.scenario-container .restart-btn:hover {
  background: var(--r-panel2, #f5efd0);
}

.scenario-container .feedback-serious {
  background: var(--r-panel2, #f5efd0);
  border-left: 4px solid var(--r-blue, #003049);
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 0.83rem;
  color: var(--r-text, #160a02);
}

.scenario-container .exit-section {
  text-align: center;
  padding-top: 6px;
}

.scenario-container .exit-link {
  color: var(--r-text, #160a02);
  text-decoration: none;
  font-size: 0.82rem;
  opacity: 0.6;
  transition:
    color 0.2s,
    opacity 0.2s;
}

.scenario-container .exit-link:hover {
  color: var(--r-red, #d62828) !important;
  opacity: 1;
}

@keyframes scenario-fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.scenario-container .bubble[data-speak-text] {
  cursor: pointer;
}
.scenario-container .bubble[data-speak-text]:hover {
  filter: brightness(1.12);
}
.scenario-container .bubble[data-speak-text]::after {
  content: " 🔊";
  font-size: 0.7em;
  opacity: 0.55;
}
.scenario-container .bubble[data-speak-text].speaking::after {
  content: " 🔊";
  opacity: 1;
  animation: scenario-pulse-speaker 0.6s ease-in-out infinite alternate;
}

@keyframes scenario-pulse-speaker {
  from {
    opacity: 0.5;
  }
  to {
    opacity: 1;
  }
}

/* ── Scenario-typing additions ─────────────────────────────── */

.typing-badge {
  display: inline-block;
  background: var(--r-blue, #003049);
  color: var(--r-text-lt, #f0e4b0);
  font-size: 0.55rem;
  padding: 2px 7px;
  border-radius: 3px;
  margin-left: 8px;
  vertical-align: middle;
  letter-spacing: 0.5px;
}

.tap-mode-badge {
  display: inline-block;
  background: var(--r-blue, #003049);
  color: var(--r-text-lt, #f0e4b0);
  font-size: 0.6rem;
  padding: 3px 8px;
  border-radius: 4px;
  margin-top: 8px;
  letter-spacing: 0.5px;
}

.reply-hint {
  background: var(--r-panel2, #f5efd0);
  border-left: 4px solid var(--r-blue, #003049);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--r-text, #160a02);
}
.reply-hint em {
  font-style: normal;
  color: #160a02 !important;
  font-weight: 700;
}

.feedback-try-again {
  background: #fff8e0;
  border-left: 4px solid var(--r-gold, #fcbf49);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--r-text, #160a02);
}

.feedback-answer {
  background: #fff0f0;
  border-left: 4px solid var(--r-red, #d62828);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--r-text, #160a02);
}

.scenario-container .user-input.correct {
  border-color: var(--r-green, #2e5818);
  background: #f0fff0;
}

.scenario-container .user-input.wrong {
  border-color: var(--r-red, #d62828);
  background: #fff5f5;
}

@media (max-width: 460px) {
  .mobile-container {
    margin: 0;
    border-radius: 0;
    max-width: 100%;
  }
  .scenario-container {
    height: 100vh;
  }
}

/* ───────────────────────────────────────────────────────────────
   AI CHAT
   ─────────────────────────────────────────────────────────────── */
.ai-chat-bg {
  background-image: linear-gradient(
    160deg,
    #1a0a00 0%,
    #2b1806 45%,
    #0d1f05 100%
  );
}

/* Stage selection cards inside the tap-to-begin overlay */
.stage-select-grid {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 52vh;
  overflow-y: auto;
  gap: 0.35rem;
  padding: 0.25rem 0;
}
.stage-card {
  cursor: pointer;
  padding: 0.6rem 0.9rem;
  border: 2px solid var(--r-border);
  background: var(--r-panel);
  border-radius: 4px;
  text-align: left;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.stage-card:hover {
  border-color: var(--r-gold);
  background: var(--r-panel2);
}
.stage-card-title {
  font-weight: bold;
  font-size: 0.82rem;
  color: var(--r-text);
}
.stage-card-desc {
  font-size: 0.72rem;
  color: var(--r-text-mid);
  margin-top: 0.15rem;
}

/* Top bar inside scenario container repurposed for AI chat */
.ai-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-top-bar-title {
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.new-chat-btn {
  font-size: 0.68rem;
  padding: 2px 9px;
  background: var(--r-orange);
  color: var(--r-text, #160a02); /* dark text on orange = 7.75:1 ✓ WCAG AA */
  border: none;
  cursor: pointer;
  border-radius: 3px;
  flex-shrink: 0;
  margin-left: 8px;
  font-family: inherit;
}
.new-chat-btn:hover {
  opacity: 0.85;
}

/* Special French character bar (ai-chat variant) */
.special-char-btn {
  font-size: 0.88rem;
  padding: 2px 7px;
  background: var(--r-panel2);
  border: 1px solid var(--r-border);
  cursor: pointer;
  border-radius: 3px;
  font-family: inherit;
  color: var(--r-text);
}
.special-char-btn:hover {
  background: var(--r-gold);
}

/* AI bubble click-to-replay affordance */
.bubble.ai-bubble {
  cursor: pointer;
}
.bubble.ai-bubble:hover {
  opacity: 0.92;
}
.bubble.speaking {
  outline: 2px solid var(--r-gold);
}

/* Typing indicator (3 bouncing dots) */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 2px;
}
.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8a7040;
  animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) {
  animation-delay: 0.22s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.44s;
}
@keyframes typingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-7px);
  }
}

/* API-not-configured warning bar */
.api-warning {
  background: var(--r-red);
  color: #fff;
  padding: 8px 12px;
  font-size: 0.75rem;
  text-align: center;
  border-radius: 4px;
  margin: 4px 0 6px;
  line-height: 1.5;
}
.api-warning a {
  color: #ffd;
}
.api-warning code {
  background: rgba(0, 0, 0, 0.25);
  padding: 0 3px;
  border-radius: 2px;
}

/* Hint (suggest a reply) button */
.hint-btn {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 7px 10px;
  background: rgba(252, 191, 73, 0.13);
  border: 1px dashed var(--r-gold);
  color: var(
    --r-text,
    #160a02
  ); /* dark text on hint bg ✓ WCAG AA; gold was 1.2:1 on parchment – FAIL */
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 3px;
  text-align: center;
}
.hint-btn:hover:not(:disabled) {
  background: rgba(252, 191, 73, 0.25);
}
.hint-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Conversation completion card */
.completion-card {
  text-align: center;
  padding: 18px 12px 14px;
}
.completion-emoji {
  font-size: 2.2rem;
  margin-bottom: 6px;
}
.completion-msg {
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--r-gold);
}
.completion-msg-en {
  font-size: 0.78rem;
  color: var(
    --r-text-lt,
    #f0e4b0
  ); /* dark chat overlay bg: --r-text (near-black) was ~1.3:1 FAIL; light cream ✓ */
  margin-bottom: 14px;
}

/* Sophie avatar canvas */
#sophieCanvas {
  position: absolute;
  top: 44px;
  right: 10px;
  z-index: 10;
  border-radius: 50%;
  pointer-events: none;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
  display: none;
  opacity: 0.92;
}

/* Password gate overlay */
.password-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 5, 0, 0.92);
}
.password-box {
  background: var(--r-panel);
  border: 2px solid var(--r-gold);
  border-radius: 6px;
  padding: 1.6rem 1.4rem 1.4rem;
  width: 260px;
  text-align: center;
}
.password-box .pw-icon {
  font-size: 2rem;
  margin-bottom: 0.35rem;
}
.password-box .pw-title {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--r-border, #7a5418);
  margin-bottom: 0.2rem;
}
.password-box .pw-hint {
  font-size: 0.72rem;
  color: var(--r-text-mid);
  margin-bottom: 0.8rem;
}
.password-box input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--r-border);
  background: var(--r-panel2);
  color: var(--r-text);
  font-family: inherit;
  font-size: 0.88rem;
  border-radius: 3px;
  margin-bottom: 0.55rem;
  text-align: center;
  letter-spacing: 0.1em;
}
.password-box .pw-error {
  font-size: 0.75rem;
  color: #9c1616; /* #9c1616 = 6.7:1 on parchment ✓ WCAG AA */
  min-height: 1.1rem;
  margin-bottom: 0.4rem;
}

/* ═══════════════════════════════════════════════════════════════
   NEW GAMES — Shared touch / tap helpers
   ═══════════════════════════════════════════════════════════════ */
.q-option-btn,
.word-chip,
.placed-chip {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Ensure passage containers never overflow their horizontal space */
.passage-box {
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

/* Responsive: matching-game-container padding tightened on small phones */
@media (max-width: 480px) {
  .matching-game-container {
    padding: 0 4px;
  }
}
