/* =============================================
   KAEDAH MEMPERBAIKI TANAH - animated quiz
   Unique game namespace: kmt-
   ============================================= */

html:has(body.kmt-game-body),
body.kmt-game-body {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

body.kmt-game-body {
  background: #eaf4df;
}

.kmt-page {
  width: min(100vw, 390px);
  height: min(100dvh, 844px);
  min-height: 0;
  max-width: 390px;
  max-height: 844px;
  margin: 0 auto;
  overflow: hidden;
}

.kmt-page .bg-img,
.kmt-page .bg-overlay {
  position: fixed;
  height: 100vh;
}

.kmt-page nav {
  padding: 6px 12px;
}

.kmt-page .nav-logo {
  width: 36px;
  height: 36px;
  gap: 6px;
}

.kmt-page .nav-logo-img {
  width: 100%;
  height: 100%;
  border-radius: 5px;
}

.kmt-page .nav-logo-text,
.kmt-page .nav-links {
  display: none;
}

.kmt-page .nav-cta {
  padding: 8px 22px;
  font-size: 0.88rem;
}

.kmt-page .nav-toggle {
  display: block;
  color: #173d2a;
}

.kmt-shell {
  position: relative;
  z-index: 5;
  width: 100%;
  height: min(calc(100dvh - 52px), 792px);
  min-height: 0;
  margin: 0 auto;
  padding: 6px 7px 7px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}

.kmt-topbar {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(240, 250, 252, 0.88);
  border: 1.5px solid rgba(160, 200, 100, 0.3);
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(14px);
}

.kmt-back-btn {
  padding: 6px 8px;
  border: 1.5px solid rgba(46, 125, 50, 0.3);
  border-radius: 9px;
  background: rgba(46, 125, 50, 0.12);
  color: #1b5e2f;
  font-family: 'Nunito', sans-serif;
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.kmt-progress-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.kmt-progress-track {
  flex: 1;
  min-width: 58px;
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.1);
}

.kmt-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #2e7d32, #66bb6a);
  transition: width 0.35s ease;
}

.kmt-step-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.kmt-score-pill {
  min-width: 46px;
  padding: 6px 9px;
  border-radius: 99px;
  background: linear-gradient(135deg, #ff9500, #ffb74d);
  box-shadow: 0 2px 10px rgba(255, 149, 0, 0.3);
  color: #fff;
  font-family: 'Fredoka One', cursive;
  font-size: 0.68rem;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.kmt-game-card {
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1.5px solid rgba(160, 200, 100, 0.35);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 255, 245, 0.96));
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(8px);
  opacity: 1;
  transform: none;
  animation: none;
}

.kmt-station-head {
  flex: 0 0 auto;
  margin-bottom: 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
}

.kmt-station-badge {
  padding: 3px 14px;
  border-radius: 99px;
  background: linear-gradient(135deg, #1b5e2f, #2e7d32);
  box-shadow: 0 2px 10px rgba(27, 94, 47, 0.25);
  color: #fff;
  font-family: 'Fredoka One', cursive;
  font-size: 0.64rem;
  line-height: 1.1;
}

.kmt-station-title {
  margin: 0;
  color: #1b5e2f;
  font-family: 'Fredoka One', cursive;
  font-size: 1rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.kmt-station-desc {
  margin: 0;
  color: #315a34;
  font-size: 0.64rem;
  font-weight: 800;
  line-height: 1.1;
}

.kmt-soil-panel {
  flex: 0 0 auto;
  height: 218px;
  min-height: 0;
  margin-bottom: 7px;
  border-radius: 14px;
  overflow: hidden;
  border: 1.5px solid rgba(111, 152, 78, 0.24);
  background: rgba(231, 246, 221, 0.98);
}

.kmt-soil-scene {
  --kmt-health-ratio: 0;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 13px;
  background:
    linear-gradient(180deg, #b7e2f2 0%, #dff1db 48%, #b7d985 49%, #78984e 100%);
  transition: filter 0.35s ease;
}

.kmt-sky-shine {
  position: absolute;
  top: -36px;
  right: -28px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 117, 0.62), rgba(255, 214, 117, 0));
  opacity: calc(0.25 + var(--kmt-health-ratio) * 0.65);
}

.kmt-health-badge,
.kmt-ph-chip {
  position: absolute;
  top: 8px;
  z-index: 3;
  border-radius: 12px;
  font-size: 0.52rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.kmt-health-badge {
  left: 8px;
  min-width: 72px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.86);
  color: #1b5e2f;
}

.kmt-health-badge span,
.kmt-health-badge strong {
  display: block;
}

.kmt-health-badge strong {
  margin-top: 2px;
  font-family: 'Fredoka One', cursive;
  font-size: 0.74rem;
}

.kmt-ph-chip {
  right: 8px;
  max-width: 130px;
  padding: 7px 9px;
  overflow: hidden;
  background: linear-gradient(135deg, #ff9500, #ffb74d);
  color: #fff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kmt-field {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 63%;
  overflow: hidden;
}

.kmt-soil-layer {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  overflow: hidden;
  transition: filter 0.45s ease;
}

.kmt-soil-top {
  top: 0;
  height: 34%;
  background:
    radial-gradient(circle at 20% 34%, rgba(92, 53, 30, 0.36) 0 4px, transparent 5px),
    linear-gradient(90deg, #88633f, #6d4b2e);
  filter: saturate(calc(0.65 + var(--kmt-health-ratio) * 0.55));
}

.kmt-soil-top::before,
.kmt-soil-top::after,
.kmt-soil-mid::after,
.kmt-soil-low::after {
  content: "";
  position: absolute;
  left: 0;
  pointer-events: none;
  transition: width 0.5s ease, opacity 0.45s ease;
}

.kmt-soil-top::before {
  top: 0;
  width: calc(var(--kmt-health-ratio) * 100%);
  height: 8px;
  background:
    repeating-linear-gradient(90deg, rgba(40, 120, 46, 0.9) 0 2px, transparent 2px 9px),
    linear-gradient(90deg, rgba(96, 181, 73, 0.88), rgba(160, 213, 86, 0.78));
  opacity: calc(0.08 + var(--kmt-health-ratio) * 0.88);
}

.kmt-soil-top::after {
  top: 8px;
  bottom: 0;
  width: calc(var(--kmt-health-ratio) * 100%);
  background:
    radial-gradient(circle at 18% 42%, rgba(255, 230, 128, 0.34) 0 3px, transparent 4px),
    radial-gradient(circle at 67% 58%, rgba(123, 201, 78, 0.35) 0 4px, transparent 5px),
    linear-gradient(90deg, rgba(79, 139, 55, 0.46), rgba(105, 163, 66, 0.26));
  mix-blend-mode: soft-light;
  opacity: calc(0.12 + var(--kmt-health-ratio) * 0.72);
}

.kmt-soil-mid {
  top: 34%;
  height: 32%;
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.08) 0 4px, transparent 4px 10px),
    linear-gradient(90deg, #8b5f37, #76512e);
  filter: saturate(calc(0.65 + var(--kmt-health-ratio) * 0.45));
}

.kmt-soil-mid::after {
  top: 0;
  bottom: 0;
  width: calc(var(--kmt-health-ratio) * 100%);
  background:
    radial-gradient(circle at 28% 40%, rgba(255, 194, 86, 0.35) 0 3px, transparent 4px),
    radial-gradient(circle at 72% 53%, rgba(121, 199, 82, 0.25) 0 4px, transparent 5px),
    linear-gradient(90deg, rgba(116, 80, 43, 0.1), rgba(183, 128, 64, 0.22));
  opacity: calc(0.1 + var(--kmt-health-ratio) * 0.64);
}

.kmt-soil-low {
  bottom: 0;
  height: 34%;
  background:
    radial-gradient(circle at 16% 48%, rgba(55, 42, 30, 0.36) 0 5px, transparent 6px),
    radial-gradient(circle at 72% 58%, rgba(55, 42, 30, 0.34) 0 4px, transparent 5px),
    linear-gradient(90deg, #5a4b35, #4a4031);
}

.kmt-soil-low::after {
  top: 0;
  bottom: 0;
  width: calc(var(--kmt-health-ratio) * 100%);
  background:
    radial-gradient(circle at 25% 50%, rgba(194, 214, 156, 0.24) 0 5px, transparent 6px),
    radial-gradient(circle at 70% 46%, rgba(194, 214, 156, 0.18) 0 4px, transparent 5px),
    linear-gradient(90deg, rgba(74, 103, 60, 0.16), rgba(101, 124, 76, 0.08));
  opacity: calc(0.08 + var(--kmt-health-ratio) * 0.58);
}

.kmt-crack {
  position: absolute;
  z-index: 2;
  width: 3px;
  border-radius: 99px;
  background: rgba(45, 29, 21, 0.55);
  transform-origin: top;
  opacity: calc(0.86 - var(--kmt-health-ratio) * 0.78);
}

.kmt-crack::before,
.kmt-crack::after {
  content: "";
  position: absolute;
  top: 36%;
  width: 28px;
  height: 3px;
  border-radius: 99px;
  background: inherit;
}

.kmt-crack::before {
  right: 0;
  transform: rotate(-36deg);
  transform-origin: right center;
}

.kmt-crack::after {
  left: 0;
  transform: rotate(34deg);
  transform-origin: left center;
}

.kmt-crack-one {
  left: 21%;
  top: 18%;
  height: 84px;
  transform: rotate(7deg);
}

.kmt-crack-two {
  left: 50%;
  top: 12%;
  height: 98px;
  transform: rotate(-5deg);
}

.kmt-crack-three {
  left: 76%;
  top: 24%;
  height: 70px;
  transform: rotate(10deg);
}

.kmt-water-puddle {
  position: absolute;
  right: 22px;
  bottom: 18px;
  width: 76px;
  height: 22px;
  border-radius: 50%;
  background: rgba(85, 168, 210, 0.38);
  opacity: calc(0.44 - var(--kmt-health-ratio) * 0.34);
  transform: scaleX(calc(1 - var(--kmt-health-ratio) * 0.35));
}

.kmt-plant {
  position: absolute;
  z-index: 4;
  bottom: 98px;
  width: 9px;
  height: 54px;
  border-radius: 99px 99px 0 0;
  background: #2f8f43;
  opacity: calc(0.18 + var(--kmt-health-ratio) * 0.82);
  transform: scaleY(calc(0.2 + var(--kmt-health-ratio) * 0.8));
  transform-origin: bottom;
  transition: transform 0.5s ease, opacity 0.45s ease;
}

.kmt-plant span,
.kmt-plant::before,
.kmt-plant::after {
  content: "";
  position: absolute;
  border-radius: 50% 50% 50% 0;
  background: #43a047;
}

.kmt-plant span {
  left: 6px;
  top: 14px;
  width: 23px;
  height: 13px;
  transform: rotate(-26deg);
}

.kmt-plant::before {
  right: 5px;
  top: 23px;
  width: 21px;
  height: 12px;
  transform: scaleX(-1) rotate(-28deg);
}

.kmt-plant::after {
  left: 4px;
  top: 32px;
  width: 18px;
  height: 10px;
  transform: rotate(-18deg);
}

.kmt-plant-one {
  left: 24%;
}

.kmt-plant-two {
  left: 49%;
  height: 66px;
}

.kmt-plant-three {
  left: 72%;
  height: 49px;
}

.kmt-particles {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.kmt-particle {
  position: absolute;
  top: 24px;
  left: var(--kmt-x);
  width: var(--kmt-size);
  height: var(--kmt-size);
  border-radius: 50%;
  background: var(--kmt-color);
  opacity: 0;
  animation: kmtParticleDrop 0.95s ease-out forwards;
}

.kmt-cloud-water,
.kmt-lime-dust,
.kmt-plow-line {
  position: absolute;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
}

.kmt-cloud-water {
  top: 34px;
  left: 42%;
  width: 94px;
  height: 38px;
  border-radius: 50px;
  background:
    radial-gradient(circle at 18% 50%, #fff 0 17px, transparent 18px),
    radial-gradient(circle at 49% 38%, #fff 0 23px, transparent 24px),
    radial-gradient(circle at 78% 55%, #fff 0 16px, transparent 17px);
  filter: drop-shadow(0 5px 10px rgba(48, 95, 120, 0.18));
}

.kmt-lime-dust {
  left: 12%;
  right: 12%;
  top: 82px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.9) 0 2px, transparent 3px);
  background-size: 18px 12px;
}

.kmt-plow-line {
  left: -80px;
  top: 116px;
  width: 90px;
  height: 23px;
  border-radius: 4px 18px 18px 4px;
  background: linear-gradient(90deg, #7a4f2f, #c47f3c);
  box-shadow: 0 12px 0 rgba(82, 52, 30, 0.28);
}

.kmt-soil-scene.kmt-effect-water .kmt-cloud-water,
.kmt-soil-scene.kmt-effect-drain .kmt-cloud-water {
  animation: kmtCloudRain 0.9s ease-out;
}

.kmt-soil-scene.kmt-effect-lime .kmt-lime-dust,
.kmt-soil-scene.kmt-effect-fertilizer .kmt-lime-dust {
  animation: kmtDustSweep 0.95s ease-out;
}

.kmt-soil-scene.kmt-effect-plow .kmt-plow-line {
  animation: kmtPlowSweep 0.95s ease-out;
}

.kmt-soil-scene.kmt-effect-drain .kmt-water-puddle {
  animation: kmtDrainPuddle 0.8s ease-out;
}

.kmt-soil-scene.kmt-wrong {
  animation: kmtWrongShake 0.28s ease;
}

.kmt-soil-scene.kmt-improved .kmt-field {
  animation: kmtFieldRecover 0.72s ease;
}

.kmt-soil-scene.kmt-improved .kmt-plant {
  animation: kmtPlantNod 0.72s ease;
}

.kmt-quiz-panel {
  flex: 1 1 auto;
  min-height: 0;
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1.5px solid rgba(46, 125, 50, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
}

.kmt-question-meta {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kmt-method-label,
.kmt-question-count {
  min-width: 0;
  border-radius: 99px;
  font-size: 0.53rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.kmt-method-label {
  max-width: 230px;
  padding: 5px 8px;
  overflow: hidden;
  background: rgba(46, 125, 50, 0.16);
  color: #1b5e2f;
  text-overflow: ellipsis;
}

.kmt-question-count {
  padding: 5px 7px;
  background: rgba(255, 149, 0, 0.16);
  color: #b25d00;
  font-family: 'Fredoka One', cursive;
}

.kmt-question-text {
  flex: 0 0 auto;
  min-height: 38px;
  margin: 0;
  color: #173d22;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.17;
}

.kmt-option-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-content: stretch;
}

.kmt-option-btn {
  min-width: 0;
  min-height: 39px;
  padding: 7px 6px;
  border: 1.5px solid rgba(46, 125, 50, 0.28);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.98);
  color: #1b5e2f;
  font-family: 'Nunito', sans-serif;
  font-size: 0.61rem;
  font-weight: 900;
  line-height: 1.08;
  text-align: center;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
  touch-action: manipulation;
}

.kmt-option-btn:active {
  transform: scale(0.97);
}

.kmt-option-btn.kmt-selected {
  border-color: rgba(255, 149, 0, 0.72);
  background: rgba(255, 183, 77, 0.25);
}

.kmt-option-btn.kmt-correct {
  border-color: rgba(46, 125, 50, 0.68);
  background: rgba(76, 175, 80, 0.2);
  color: #1b5e2f;
}

.kmt-option-btn.kmt-wrong {
  border-color: rgba(198, 63, 55, 0.5);
  background: rgba(229, 115, 115, 0.16);
  color: #7b241f;
}

.kmt-feedback {
  flex: 0 0 auto;
  min-height: 15px;
  margin: 0;
  color: #b25d00;
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1.08;
  text-align: center;
}

.kmt-feedback.kmt-good {
  color: #1b5e2f;
}

.kmt-submit-btn {
  flex: 0 0 auto;
  width: min(190px, 80%);
  min-height: 34px;
  margin: 0 auto;
  padding: 8px 18px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(135deg, #1b5e2f, #2e7d32);
  box-shadow: 0 5px 14px rgba(46, 125, 50, 0.25);
  color: #fff;
  font-family: 'Fredoka One', cursive;
  font-size: 0.7rem;
  line-height: 1;
}

.kmt-submit-btn:disabled {
  opacity: 0.72;
}

@keyframes kmtParticleDrop {
  0% {
    opacity: 0;
    transform: translate3d(0, -10px, 0) scale(0.7);
  }
  16% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--kmt-drift), 116px, 0) scale(1);
  }
}

@keyframes kmtCloudRain {
  0% {
    opacity: 0;
    transform: translateY(-18px);
  }
  20%,
  70% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translateY(4px);
  }
}

@keyframes kmtDustSweep {
  0% {
    opacity: 0;
    transform: translateY(-20px) scale(0.85);
  }
  30%,
  70% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translateY(34px) scale(1.1);
  }
}

@keyframes kmtPlowSweep {
  0% {
    opacity: 0;
    transform: translateX(0) rotate(0deg);
  }
  15%,
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(430px) rotate(3deg);
  }
}

@keyframes kmtDrainPuddle {
  0% {
    opacity: 0.52;
    transform: scaleX(1.1);
  }
  100% {
    opacity: 0.08;
    transform: scaleX(0.3);
  }
}

@keyframes kmtWrongShake {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-4px);
  }
  70% {
    transform: translateX(4px);
  }
}

@keyframes kmtFieldRecover {
  0% {
    filter: brightness(0.95) saturate(0.9);
  }
  45% {
    filter: brightness(1.12) saturate(1.22);
  }
  100% {
    filter: brightness(1) saturate(1);
  }
}

@keyframes kmtPlantNod {
  0% {
    filter: brightness(0.96);
  }
  45% {
    filter: brightness(1.18);
  }
  100% {
    filter: brightness(1);
  }
}

@media (max-height: 760px) {
  .kmt-soil-panel {
    height: 178px;
    margin-bottom: 6px;
  }

  .kmt-station-head {
    margin-bottom: 5px;
  }

  .kmt-station-desc {
    display: none;
  }

  .kmt-quiz-panel {
    gap: 5px;
    padding: 8px;
  }

  .kmt-question-text {
    min-height: 32px;
    font-size: 0.61rem;
  }

  .kmt-option-grid {
    gap: 5px;
  }

  .kmt-option-btn {
    min-height: 33px;
    padding: 5px;
    font-size: 0.51rem;
  }

  .kmt-submit-btn {
    min-height: 31px;
    padding: 7px 16px;
    font-size: 0.64rem;
  }
}
