/* Jungle Math — Addition One & Subtraction One */

.jm-page {
  width: 100%;
  max-width: 100%;
  min-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
}

.jm-page .back-link {
  align-self: flex-start;
  margin-bottom: 1rem;
}

.jm-header {
  text-align: center;
  margin-bottom: 1rem;
}

.jm-header h2 {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  font-weight: 700;
  color: #fff;
  text-shadow: 2px 2px 0 var(--jungle-dark), 0 3px 10px rgba(0, 0, 0, 0.3);
}

.jm-header p {
  margin-top: 0.35rem;
  font-size: 1rem;
  font-weight: 500;
  color: #d8f3dc;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.jm-score-bar {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.jm-score-pill {
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid var(--sun-yellow);
  border-radius: 999px;
  padding: 0.4rem 1.1rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--jungle-dark);
  box-shadow: 0 3px 0 #c9a000, 0 5px 12px var(--box-shadow);
}

.jm-game-wrap {
  position: relative;
  flex: 1;
  min-height: 420px;
}

.jm-scene {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  height: 100%;
  min-height: 420px;
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(180deg, #87ceeb 0%, #74c69d 55%, #40916c 100%);
  border: 4px solid rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 0 40px rgba(255, 255, 255, 0.12), 0 10px 28px var(--box-shadow);
}

/* Trees */
.jm-tree {
  position: absolute;
  bottom: 0;
  width: 120px;
  height: 55%;
  z-index: 1;
}

.jm-tree-left {
  left: 4%;
}

.jm-tree-right {
  right: 4%;
  transform: scaleX(-1);
}

.jm-tree-trunk {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 45%;
  background: linear-gradient(90deg, #5d4037 0%, #8d6e63 50%, #5d4037 100%);
  border-radius: 8px 8px 4px 4px;
  box-shadow: inset -4px 0 8px rgba(0, 0, 0, 0.2);
}

.jm-tree-foliage {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 110px;
  height: 110px;
  background: radial-gradient(circle at 40% 40%, #95d5b2 0%, #52b788 45%, #2d6a4f 100%);
  border-radius: 50%;
  box-shadow:
    -20px 10px 0 -5px #40916c,
    20px 10px 0 -5px #40916c,
    0 -10px 0 -5px #74c69d;
}

.jm-vine {
  position: absolute;
  top: 18%;
  width: 4px;
  height: 35%;
  background: linear-gradient(180deg, #2d6a4f, #40916c);
  border-radius: 2px;
  z-index: 2;
}

.jm-tree-left .jm-vine {
  left: 58%;
}

.jm-tree-right .jm-vine {
  right: 58%;
}

/* Monkeys */
.jm-monkey {
  position: absolute;
  top: -120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 3;
  transition: top 0.9s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.jm-monkey.swing-in {
  top: 22%;
}

.jm-monkey.swing-up {
  top: -120px;
  transition: top 0.6s ease-in;
}

.jm-monkey-left {
  left: 8%;
}

.jm-monkey-right {
  right: 8%;
}

.jm-monkey-emoji {
  font-size: 3rem;
  filter: drop-shadow(2px 3px 4px rgba(0, 0, 0, 0.25));
  line-height: 1;
}

.jm-monkey.dancing .jm-monkey-emoji {
  animation: jm-monkey-dance 0.6s ease-in-out 3;
}

@keyframes jm-monkey-dance {
  0%, 100% { transform: rotate(0) translateY(0); }
  25% { transform: rotate(-12deg) translateY(-8px); }
  50% { transform: rotate(12deg) translateY(0); }
  75% { transform: rotate(-8deg) translateY(-6px); }
}

.jm-bananas {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  max-width: 72px;
  margin-top: 0.25rem;
  font-size: 1.1rem;
  line-height: 1.1;
}

/* Equation */
.jm-equation-wrap {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translateX(-50%);
  z-index: 4;
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s ease 0.5s;
}

.jm-equation-wrap.visible {
  opacity: 1;
}

.jm-equation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.95);
  border: 4px solid var(--sun-yellow);
  border-radius: 20px;
  padding: 0.75rem 1.5rem;
  box-shadow: 0 6px 0 #c9a000, 0 10px 24px var(--box-shadow);
}

.jm-equation-num,
.jm-equation-op {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  color: var(--jungle-dark);
  line-height: 1;
}

.jm-equation-op {
  color: #e17055;
}

/* Answer choices */
.jm-choices {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  display: flex;
  gap: 1rem;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.jm-choices.visible {
  opacity: 1;
  pointer-events: auto;
}

.jm-choice {
  font-family: inherit;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 700;
  color: var(--jungle-dark);
  width: clamp(64px, 16vw, 88px);
  height: clamp(64px, 16vw, 88px);
  border: 4px solid var(--jungle-bright);
  border-radius: 16px;
  background: linear-gradient(145deg, #fff 0%, #f0fdf4 100%);
  cursor: pointer;
  box-shadow: 0 5px 0 var(--jungle-mid), 0 8px 18px var(--box-shadow);
  transition: transform 0.15s ease;
  touch-action: manipulation;
}

.jm-choice:hover:not(:disabled) {
  transform: translateY(-4px);
}

.jm-choice:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--jungle-mid);
}

.jm-choice:disabled {
  cursor: default;
  opacity: 0.7;
}

.jm-choice.correct {
  background: linear-gradient(145deg, #d8f3dc 0%, #95d5b2 100%);
  border-color: #52b788;
  animation: jm-choice-pop 0.4s ease;
}

.jm-choice.wrong {
  animation: jm-choice-shake 0.45s ease;
  background: #ffcdd2;
  border-color: #e57373;
}

@keyframes jm-choice-pop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

@keyframes jm-choice-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* Start overlay */
.jm-start {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: rgba(26, 77, 46, 0.4);
  backdrop-filter: blur(2px);
  border-radius: 24px;
}

.jm-start.hidden {
  display: none;
}

.jm-start-icon {
  font-size: 3.5rem;
}

.jm-start-text {
  max-width: 300px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.5;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.35);
}

.jm-btn {
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--jungle-dark);
  background: linear-gradient(145deg, #fff 0%, #ffe8a3 100%);
  border: 4px solid var(--sun-yellow);
  border-radius: 16px;
  padding: 0.75rem 1.75rem;
  cursor: pointer;
  box-shadow: 0 5px 0 #e6a800, 0 8px 20px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}

.jm-btn:hover {
  transform: translateY(-3px);
}

.jm-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #e6a800;
}

@media (max-width: 500px) {
  .jm-tree {
    width: 90px;
  }

  .jm-tree-foliage {
    width: 85px;
    height: 85px;
  }

  .jm-monkey-emoji {
    font-size: 2.4rem;
  }

  .jm-choices {
    gap: 0.6rem;
  }
}
