/* =====================================================
   GAME — layar permainan
   1. Layar & background
   2. HUD (nyawa, skor, tombol keluar)
   3. Timer bar (khusus boss)
   4. Jalur kejar-kejaran (chase timer)
   5. Area soal & kartu pertanyaan
   6. Opsi jawaban
   7. Feedback melayang
   8. Responsif
   ===================================================== */

/* ============ 1. LAYAR & BACKGROUND ============ */
#screen-game {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  background-attachment: scroll !important;
  /* Background diatur secara dinamis oleh JS via class has-bg bg-* */
}
#screen-game > * { position: relative; z-index: 1; }


/* ============ 2. HUD ============ */
.hud {
  position: relative;              /* jangkar untuk nyawa di tengah */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap-md) var(--gap-lg);
  gap: var(--gap-md);
  flex-wrap: wrap;
}

/* Nyawa: selalu tepat di tengah layar */
.hud-lives {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(1.2rem, 4vmin, 2rem);
  letter-spacing: 4px;
  filter: drop-shadow(0 4px 0 rgba(91, 58, 30, 0.25));
  display: flex;
  gap: 4px;
}

.heart { display: inline-block; animation: bounceHeart 1.5s infinite ease-in-out; transform-origin: bottom center; }
.heart:nth-child(2) { animation-delay: 0.2s; }
.heart:nth-child(3) { animation-delay: 0.4s; }
.heart.empty { animation: none; filter: grayscale(1); opacity: 0.6; }

@keyframes bounceHeart {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.15) translateY(-4px); }
}

.hud-right { display: flex; gap: 8px; align-items: center; }
.chip-combo { background: var(--emas-muda); }

/* Skor bergaya koin */
#hud-score {
  background: linear-gradient(180deg, #C98A3B, #A96F28);
  color: var(--putih);
  border: 0.4vmin solid #7E5220;
  font-family: var(--font-judul);
  font-size: 3vmin;
  box-shadow: 0 0.6vmin 0 #5E3D16;
  padding: 0.5vmin 2vmin;
  border-radius: 2vmin;
}

/* Tombol keluar bulat kayu */
#btn-quit {
  width: 7vmin;
  height: 7vmin;
  border-radius: 50%;
  background: linear-gradient(180deg, #C98A3B, #A96F28);
  color: var(--putih);
  border: 0.4vmin solid #7E5220;
  box-shadow: 0 0.6vmin 0 #5E3D16;
  font-size: 3vmin;
  padding: 0;
}

/* ============ 3. TIMER BAR (khusus boss) ============ */
/* Di level biasa disembunyikan via style di HTML */
.timer-track {
  height: 12px;
  margin: 0 18px;
  background: #EADFCB;
  border-radius: 999px;
  overflow: hidden;
}
.timer-bar {
  height: 100%;
  width: 100%;
  background: var(--tosca);
  border-radius: 999px;
  transition: width 0.1s linear, background 0.3s;
}
.timer-bar.bahaya { background: var(--merah); }

/* ============ 4. JALUR KEJAR-KEJARAN ============ */
.chase-track {
  position: relative;
  height: 56px;
  margin: 0 auto;
  width: min(900px, 92vw);
  /* krem + jejak titik samar */
  background:
    radial-gradient(rgba(169, 111, 40, 0.18) 3px, transparent 3px),
    #F7ECD7;
  background-size: 90px 28px;
  background-position: 30px 14px;
  border: 4px solid #C9A876;
  border-radius: 999px;
  box-shadow: 0 5px 0 rgba(91, 58, 30, 0.25), inset 0 2px 6px rgba(91, 58, 30, 0.12);
  overflow: hidden;                /* karakter tetap di dalam jalur */
}

.chase-pelari,
.chase-pemburu {
  position: absolute;
  top: 50%;
  font-size: 1.9rem;
  transition: left 0.15s linear, transform 0.2s;
  transform: translateY(-50%);
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.2));
}
.chase-pelari { z-index: 2; }
.chase-pemburu { z-index: 1; transform: translateY(-50%) scaleX(-1); }

/* Pemburu panik saat waktu kritis — goyang DI TEMPAT,
   translateY & scaleX ikut dipertahankan agar tidak
   melorot / berbalik arah */
.chase-pemburu.ngamuk { animation: pemburuNgamuk 0.3s ease infinite; }

@keyframes pemburuNgamuk {
  0%, 100% { transform: translateY(-50%) scaleX(-1) rotate(0deg); }
  25%      { transform: translateY(-56%) scaleX(-1) rotate(-8deg); }
  75%      { transform: translateY(-44%) scaleX(-1) rotate(8deg); }
}

/* Reaksi pelari: lolos (benar) / tertangkap (salah) */
.chase-pelari.lolos { animation: lolos 0.6s ease; }
.chase-pelari.tertangkap { animation: tertangkap 0.5s ease; }

@keyframes lolos {
  0%   { transform: translateY(-50%) scale(1); }
  50%  { transform: translateY(-70%) scale(1.3) rotate(-10deg); }
  100% { transform: translateY(-50%) scale(1); }
}
@keyframes tertangkap {
  0%, 100% { transform: translateY(-50%); }
  25%      { transform: translateY(-50%) rotate(-20deg); }
  75%      { transform: translateY(-50%) rotate(20deg); }
}

/* Progress Bar Modern */
.progress-container {
  display: flex;
  align-items: center;
  gap: 2vmin;
  margin-top: -3vmin;
  position: relative;
  z-index: 3;
  justify-content: center;
}

.progress-bar-bg {
  width: 50vw;
  height: 3.5vmin;
  background: rgba(42, 26, 8, 0.4);
  border-radius: 999px;
  border: 0.4vmin solid #7E5220;
  padding: 0.5vmin;
  box-shadow: inset 0 0.4vmin 0.6vmin rgba(0,0,0,0.3), 0 0.6vmin 0 rgba(91, 58, 30, 0.25);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #F5A623, #FFD27A);
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); /* Bouncy smooth width */
  box-shadow: inset 0 -3px 0 rgba(201, 138, 59, 0.5), inset 0 3px 0 rgba(255, 255, 255, 0.4);
}

.progress-text {
  background: linear-gradient(180deg, #A96F28, #8A5A1F);
  color: var(--putih);
  font-family: var(--font-judul);
  font-weight: 700;
  font-size: 2.5vmin;
  padding: 0.8vmin 2.5vmin;
  border-radius: 999px;
  border: 0.4vmin solid #7E5220;
  box-shadow: 0 0.6vmin 0 #5E3D16;
}

/* ============ 5. AREA SOAL & KARTU ============ */
.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(4px, 1vh, 12px) clamp(8px, 1.5vw, 18px) 16px;
  gap: clamp(4px, 1vh, 10px);
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

.soal-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.5vh, 16px);
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto !important;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 168, 118, 0.4) transparent;
  padding-bottom: 20px;
  position: relative;
}

/* Penyeimbang vertikal otomatis: saat ada ruang sisa, soal berada di tengah vertikal yang seimbang */
.soal-area::before,
.soal-area::after {
  content: "";
  display: block;
  margin: auto;
  pointer-events: none;
}

/* Khusus mekanik interaktif layar penuh (Lompat Pilihan, Halal-Haram), matikan scrollbar dan penyeimbang vertikal */
.soal-area.is-lompat,
.soal-area:has(.lompat-container),
.soal-area:has(.hh-container) {
  overflow: hidden !important;
  padding-bottom: 0 !important;
}

.soal-area.is-lompat::before,
.soal-area.is-lompat::after,
.soal-area:has(.lompat-container)::before,
.soal-area:has(.lompat-container)::after,
.soal-area:has(.hh-container)::before,
.soal-area:has(.hh-container)::after {
  display: none !important;
}

.soal-area > * {
  flex-shrink: 0;
}

.question-card {
  position: relative;
  background: #FFFBF0;
  border: 4px solid #E7D9BD;
  border-radius: 24px;
  box-shadow: 0 6px 0 rgba(91, 58, 30, 0.2);
  padding: 30px 28px;
  width: min(760px, 94vw);
  text-align: center;
}

/* Hiasan daun di sudut kartu */
.question-card::before,
.question-card::after {
  position: absolute;
  top: -14px;
  font-size: 1.8rem;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.15));
}
.question-card::before { content: "🌿"; left: 14px; transform: scaleX(-1) rotate(15deg); }
.question-card::after  { content: "🌿"; right: 14px; transform: rotate(15deg); }

.question-card .q-label {
  display: inline-block;
  background: var(--merah);
  color: var(--putih);
  font-family: var(--font-judul);
  font-size: 0.9rem;
  padding: 5px 18px;
  border-radius: 999px;
  margin-bottom: 12px;
  box-shadow: 0 3px 0 var(--merah-tua);
}
.question-card h3 {
  font-family: var(--font-judul);
  font-size: 1.7rem;
  line-height: 1.3;
}

/* ============ 6. OPSI JAWABAN ============ */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: min(760px, 94vw);
}

.option-btn {
  font-family: var(--font-isi);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--coklat);
  background: #FFF3D6;
  border: 3px solid #E8B95C;
  box-shadow: 0 5px 0 #D9A63F;
  border-radius: 999px;
  padding: 18px 22px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.15s;
}
.option-btn:hover:not(:disabled) { transform: translateY(-3px) scale(1.02); filter: brightness(1.04); }
.option-btn:disabled { cursor: default; }

.option-btn.benar {
  background: var(--hijau);
  border-color: #3B8A3F;
  box-shadow: 0 5px 0 #2E6C31;
  color: var(--putih);
  animation: pop 0.35s ease;
}
.option-btn.salah {
  background: var(--merah);
  border-color: var(--merah-tua);
  box-shadow: 0 5px 0 #701818;
  color: var(--putih);
  animation: goyang 0.4s ease;
}

/* ============ 7. FEEDBACK MELAYANG ============ */
.feedback-float {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-judul);
  font-weight: 800;
  font-size: clamp(1.6rem, 3vmin, 2.2rem);
  animation: naik 0.8s ease forwards;
  pointer-events: none;
  z-index: 20;
  text-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
}
.feedback-float.benar { color: var(--hijau); }
.feedback-float.salah { color: var(--merah); }

/* ============ 8. RESPONSIF ============ */

/* --- HP Landscape (Layar pendek <= 540px) --- */
@media (max-height: 540px) {
  .hud {
    padding: clamp(4px, 1vh, 8px) clamp(12px, 3vw, 24px);
    flex-wrap: nowrap;
    min-height: 42px;
  }
  .hud-lives {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(1.1rem, 3vmin, 1.6rem);
    letter-spacing: 4px;
    margin-top: 0;
    order: unset;
    width: auto;
  }
  .game-area {
    padding: 2px 8px 8px;
    gap: clamp(4px, 1vh, 8px);
    justify-content: flex-start;
  }
  .soal-area {
    gap: clamp(4px, 1vh, 8px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0 16px 0;
    justify-content: flex-start;
  }
  .soal-area::before,
  .soal-area::after {
    display: none;
  }
  .soal-area::-webkit-scrollbar {
    width: 0px;
    background: transparent;
  }
  .question-card {
    padding: clamp(6px, 1.2vh, 10px) clamp(12px, 2vw, 20px);
    border-radius: 14px;
    border-width: 2px;
    width: min(720px, 96vw);
  }
  .question-card::before,
  .question-card::after {
    display: none;
  }
  .question-card .q-label {
    display: none;
  }
  .question-card h3 {
    font-size: clamp(0.85rem, 2.2vh, 1.05rem);
    line-height: 1.2;
    margin: 0;
  }
  .options-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(6px, 1.2vmin, 10px);
    width: min(720px, 94vw);
  }
  .option-btn {
    padding: clamp(8px, 1.4vh, 12px) clamp(10px, 1.5vw, 16px);
    font-size: clamp(0.82rem, 1.9vmin, 1rem);
    border-radius: 12px;
  }
  #btn-quit {
    width: clamp(34px, 7vmin, 44px);
    height: clamp(34px, 7vmin, 44px);
    font-size: clamp(1rem, 2.2vmin, 1.3rem);
  }
  #hud-score {
    font-size: clamp(0.85rem, 2vmin, 1.05rem);
    padding: 4px 12px;
    border-radius: 999px;
  }
  .chase-track {
    height: clamp(34px, 7vh, 46px);
  }
  .chase-pelari, .chase-pemburu {
    font-size: clamp(1.2rem, 3vmin, 1.6rem);
  }
  .dd-chip {
    padding: clamp(6px, 1.2vh, 10px) clamp(10px, 2vw, 16px);
    font-size: clamp(0.85rem, 2vmin, 1rem);
  }
  .dd-vertical .dd-chip {
    padding: clamp(6px, 1.2vh, 10px) clamp(12px, 2vw, 16px);
    font-size: clamp(0.82rem, 1.8vmin, 0.95rem);
  }
  .dd-jawaban.dd-vertical, .dd-bank.dd-vertical {
    gap: clamp(4px, 1vh, 6px);
  }
}

/* --- TABLET & LAPTOP / LAYAR LUAS (Tinggi >= 600px & Lebar >= 768px) --- */
@media (min-width: 768px) and (min-height: 600px) {
  .hud {
    padding: clamp(8px, 1.5vh, 16px) clamp(18px, 2.5vw, 32px);
  }
  .hud-lives {
    font-size: clamp(1.4rem, 2.8vw, 2.2rem);
    letter-spacing: 6px;
  }
  #btn-quit {
    width: clamp(46px, 5vmin, 58px);
    height: clamp(46px, 5vmin, 58px);
  }
  #hud-score {
    font-size: clamp(1.1rem, 1.8vmin, 1.35rem);
    padding: 6px 18px;
    border-radius: 999px;
  }
  .chase-track {
    width: min(960px, 88vw);
    height: clamp(54px, 6.2vh, 64px);
    border-width: 4px;
    margin-bottom: 4px;
  }
  .chase-pelari, .chase-pemburu {
    font-size: clamp(2rem, 2.4vw, 2.4rem);
  }
  .progress-container {
    margin-top: clamp(-20px, -2vh, -14px);
    gap: 14px;
  }
  .progress-bar-bg {
    width: min(560px, 50vw);
    height: clamp(20px, 2.4vh, 26px);
    border-width: 3.5px;
  }
  .progress-text {
    font-size: clamp(1rem, 1.3vw, 1.25rem);
    padding: 5px 20px;
  }
  .game-area {
    padding: clamp(6px, 1.2vh, 14px) clamp(16px, 2.5vw, 32px) clamp(16px, 2.5vh, 32px);
    gap: clamp(10px, 1.8vh, 18px);
  }
  .soal-area {
    gap: clamp(16px, 2.5vh, 28px);
    max-width: 1040px;
  }
  .question-card {
    width: min(920px, 88vw);
    padding: clamp(26px, 3.5vh, 42px) clamp(28px, 3.2vw, 46px);
    border: 4.5px solid #E7D9BD;
    border-radius: 28px;
    box-shadow: 0 8px 0 rgba(91, 58, 30, 0.2), 0 16px 36px rgba(91, 58, 30, 0.12);
    background: #FFFDF7;
  }
  .question-card::before,
  .question-card::after {
    font-size: clamp(2rem, 2.4vw, 2.5rem);
    top: -16px;
  }
  .question-card::before { left: 20px; }
  .question-card::after  { right: 20px; }
  .question-card .q-label {
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    padding: 6px 22px;
    margin-bottom: clamp(10px, 1.5vh, 16px);
    box-shadow: 0 4px 0 var(--merah-tua);
  }
  .question-card h3 {
    font-size: clamp(1.6rem, 2.3vw, 2.2rem);
    line-height: 1.35;
    color: #3D2714;
    font-weight: 800;
  }
  .options-grid {
    width: min(920px, 88vw);
    gap: clamp(14px, 1.8vh, 20px) clamp(16px, 2vw, 24px);
  }
  .option-btn {
    padding: clamp(18px, 2.5vh, 26px) clamp(22px, 2vw, 32px);
    font-size: clamp(1.15rem, 1.6vw, 1.35rem);
    border-radius: 999px;
    border-width: 3.5px;
    background: #FFF5DD;
    box-shadow: 0 6px 0 #D9A63F, 0 8px 18px rgba(91, 58, 30, 0.1);
  }
}

/* --- TALL TABLETS (iPad / iPad Pro min-height: 750px) --- */
@media (min-width: 768px) and (min-height: 750px) {
  .game-area {
    padding: clamp(10px, 1.8vh, 20px) clamp(20px, 3vw, 40px) clamp(24px, 3.5vh, 48px);
    gap: clamp(14px, 2.2vh, 24px);
  }
  .soal-area {
    gap: clamp(20px, 3vh, 36px);
  }
  .question-card {
    width: min(960px, 88vw);
    padding: clamp(32px, 4.2vh, 50px) clamp(32px, 3.6vw, 56px);
  }
  .question-card h3 {
    font-size: clamp(1.75rem, 2.5vw, 2.35rem);
  }
  .options-grid {
    width: min(960px, 88vw);
    gap: clamp(16px, 2.2vh, 24px) clamp(18px, 2.2vw, 28px);
  }
  .option-btn {
    padding: clamp(20px, 2.8vh, 30px) clamp(24px, 2.2vw, 36px);
    font-size: clamp(1.2rem, 1.7vw, 1.45rem);
  }
}