/* === Variables - Natural warm earthy greens === */
:root {
  --forest: #2d5a3d;
  --sage: #4a7c59;
  --moss: #6b8e6b;
  --olive: #8b9a5c;
  --cream: #f5f0e8;
  --warm-white: #faf7f2;
  --bark: #3d2e1f;
  --earth: #5c4a3a;
  --leaf-light: #7fa876;
  --clay-red: #e05548;
}

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

body {
  font-family: 'Hanken Grotesk', sans-serif;
  background: #ffffff;
  color: var(--bark);
  min-height: 100vh;
  overflow-x: hidden;
}

/* === Typography === */
.roboto-slab {
  font-family: 'Roboto Slab', serif;
}

.hanken {
  font-family: 'Hanken Grotesk', sans-serif;
}

h1, h2 {
  font-family: 'Roboto Slab', serif;
  font-weight: 600;
  color: var(--forest);
}

/* === Screen Management === */
.screen {
  display: none;
  min-height: 100vh;
  padding: 2rem;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* === Intro Overlay === */
.intro-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.intro-overlay.hidden {
  display: none;
}

/* === Correct answer overlay === */
.correct-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  cursor: pointer;
}

.correct-overlay.hidden {
  display: none;
}

.correct-popup {
  background: var(--warm-white);
  border-radius: 20px;
  padding: 2rem 2rem 1.5rem;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(45, 90, 61, 0.35);
  border: 2px solid var(--sage);
}

.correct-popup h2 {
  font-size: 1.75rem;
  margin-bottom: 1rem;
  color: var(--forest);
}

#correct-explanation {
  font-size: 1.1rem;
  line-height: 1.65;
  color: var(--bark);
  margin-bottom: 1.25rem;
}

#correct-explanation em {
  font-style: italic;
  font-weight: 600;
  color: var(--sage);
}

.correct-continue {
  font-size: 0.95rem;
  color: var(--moss);
  font-weight: 500;
  margin: 0;
}

.intro-popup {
  background: var(--warm-white);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(45, 90, 61, 0.3);
}

.intro-popup h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--forest);
}

.intro-popup p {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--bark);
  margin-bottom: 1rem;
}

.intro-popup strong {
  font-weight: 600;
  color: var(--forest);
}

#start-btn {
  font-family: 'Roboto Slab', serif;
  font-size: 1.25rem;
  font-weight: 600;
  padding: 1rem 2.5rem;
  margin-top: 0.5rem;
  background: var(--forest);
  color: var(--warm-white);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(45, 90, 61, 0.3);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

#start-btn:hover {
  background: var(--sage);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(45, 90, 61, 0.4);
}

/* === Game Screen === */
#game-screen {
  padding: 1rem;
  gap: 1rem;
  transition: transform 0.1s ease-out;
}

#game-screen.shake {
  animation: boardShake 0.5s ease-in-out;
}

@keyframes boardShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
  20%, 40%, 60%, 80% { transform: translateX(6px); }
}

/* Heartbreak emoji flash */
.heartbreak-emoji {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 80;
  pointer-events: none;
  animation: heartbreakPop 1s ease-out forwards;
}

.heartbreak-icon {
  width: 5rem;
  height: 5rem;
  display: block;
}

.heartbreak-path {
  fill: var(--clay-red);
  stroke: var(--warm-white);
  stroke-width: 2;
  stroke-linejoin: round;
}

.heartbreak-emoji.hidden {
  display: none;
}

.heartbreak-emoji.visible {
  display: block;
}

@keyframes heartbreakPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
  }
  30% {
    transform: translate(-50%, -50%) scale(1);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 900px;
  padding: 0.75rem 1rem;
  background: var(--sage);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(45, 90, 61, 0.2);
}

.lives-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lives-label {
  font-weight: 600;
  color: var(--warm-white);
}

.heart {
  display: inline-flex;
  transition: opacity 0.3s;
}

.heart-icon {
  width: 1.4rem;
  height: 1.4rem;
  display: block;
}

.heart-path {
  fill: var(--clay-red);
  stroke: var(--warm-white);
  stroke-width: 1.2;
  stroke-linejoin: round;
}

.heart.lost .heart-path {
  fill: #8a7a75;
}
.heart.lost {
  opacity: 0.4;
  filter: grayscale(0.6);
}

.timer-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.timer-bar {
  width: 120px;
  height: 12px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  width: 100%;
  background: var(--cream);
  border-radius: 6px;
  transition: width 0.1s linear;
}

.timer-fill.warning {
  background: var(--olive);
}

.timer-fill.danger {
  background: #c45c4a;
}

.timer-text {
  font-weight: 700;
  font-size: 1rem;
  color: var(--warm-white);
  min-width: 1.5rem;
}

/* === Scene === */
.scene-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  height: 360px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(45, 90, 61, 0.25);
}

.background {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

#scenario-title {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--forest);
  margin: 0;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  z-index: 3;
  text-align: center;
}

.speech-bubble {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 75%;
  max-width: 520px;
  background: var(--warm-white);
  padding: 1rem 1.25rem 1.25rem;
  border-radius: 24px 24px 24px 6px;
  box-shadow: 0 4px 16px rgba(61, 46, 31, 0.2);
  border: 3px solid var(--bark);
  z-index: 3;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}
.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -14px;
  left: 24px;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 14px solid var(--bark);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.08));
}
.speech-bubble::before {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 28px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid var(--warm-white);
  z-index: 1;
}

#speech-text {
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--bark);
  white-space: pre-line;
}

/* === Scenario Section === */
.scenario-section {
  background: var(--warm-white);
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  border-left: 4px solid var(--forest);
  max-width: 900px;
  width: 100%;
}

#scenario-dialogue {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--forest);
  text-align: center;
}

#scenario-dialogue em {
  font-style: italic;
  font-weight: 600;
  color: var(--sage);
}

/* Emphasised words in body text - Hanken Grotesk weight variants */
strong, .emphasis {
  font-weight: 600;
}

.subtle {
  font-weight: 300;
}

/* === Choices === */
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  max-width: 900px;
  width: 100%;
}

.choice-btn {
  font-family: 'Roboto Slab', serif;
  font-size: 1rem;
  font-weight: 500;
  padding: 1rem 1.25rem;
  background: var(--cream);
  color: var(--forest);
  border: 2px solid var(--moss);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.choice-btn:hover {
  background: var(--moss);
  color: var(--warm-white);
  border-color: var(--sage);
  transform: translateX(4px);
}

.choice-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.choice-btn.correct {
  background: var(--sage);
  color: var(--warm-white);
  border-color: var(--forest);
}

.choice-btn.wrong {
  background: #c45c4a;
  color: var(--warm-white);
  border-color: #a04a3a;
}

/* === Game Over / Victory overlays (popup over blurred game) === */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 95;
}

.result-overlay.hidden {
  display: none;
}

.result-popup {
  background: var(--warm-white);
  border-radius: 20px;
  padding: 2rem 2rem 1.5rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(45, 90, 61, 0.35);
}

.result-popup h1 {
  font-size: 2.25rem;
  margin-bottom: 1rem;
}

.result-popup p {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.result-popup strong {
  font-weight: 600;
}

.result-popup-gameover h1 {
  color: #c45c4a;
}

.result-popup-victory h1 {
  color: var(--forest);
}

#retry-btn,
#playagain-btn {
  font-family: 'Roboto Slab', serif;
  font-size: 1.15rem;
  font-weight: 600;
  padding: 1rem 2rem;
  background: var(--forest);
  color: var(--warm-white);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.btn-english {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.92;
}

#retry-btn:hover,
#playagain-btn:hover {
  background: var(--sage);
  transform: translateY(-2px);
}

/* === Responsive === */
@media (max-width: 600px) {
  .scene-container {
    height: 320px;
  }

  .speech-bubble {
    width: 88%;
  }

  #speech-text {
    font-size: 1.15rem;
  }

  .choices {
    grid-template-columns: 1fr;
  }

  .game-header {
    flex-direction: column;
    gap: 0.75rem;
  }
}

.result-overlay .result-popup {
  border: 2px solid var(--sage);
}
