/* =====================================================
   CSS: PETA NUSANTARA (level budaya-1) — FINAL
   Pengganti total css/peta-nusantara.css
   Semua selector diawali .peta- / #peta- supaya tidak
   bertabrakan dengan CSS lain yang sudah ada.
   ===================================================== */

#screen-peta {
  overflow-y: auto;
  align-items: center;
  padding: 12px 14px 18px;
  gap: 10px;
  background-color: #bfe3ef;
  background-image: url('../assets/images/backgrounds/bg-peta.webp');
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  background-attachment: scroll !important;
  width: 100%;
  height: 100%;
  min-height: 100%;
  position: relative;
}


/* ---------- Topbar ---------- */
.peta-topbar {
  width: 100%; max-width: 1400px;
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}
.peta-topbar h2 {
  font-family: var(--font-judul);
  font-size: 20px;
  color: var(--coklat);
  margin-right: auto;
}
.peta-btn-quit {
  width: 42px; height: 42px;
  border: 3px solid #fff; border-radius: 50%;
  background: var(--merah); color: #fff;
  font-size: 18px; font-weight: 800; cursor: pointer;
  box-shadow: 0 4px 0 var(--merah-tua);
  flex-shrink: 0;
}
.peta-btn-quit:active { transform: translateY(4px); box-shadow: none; }

.peta-chip {
  background: #fff; border: 2px solid #e6d9c2; border-radius: 999px;
  padding: 6px 15px; font-weight: 800; color: var(--coklat);
  display: flex; align-items: center; gap: 7px;
  box-shadow: 0 3px 0 #e6d9c2;
  white-space: nowrap;
}
.peta-bar-bg {
  flex: 1; min-width: 120px; height: 14px;
  background: #e9ddc6; border-radius: 999px; overflow: hidden;
}
.peta-bar-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--emas), #f57f17);
  transition: width .35s ease;
}

/* ---------- Banner fakta (muncul saat BENAR) ---------- */
.peta-fakta {
  width: 100%; max-width: 1400px;
  background: #e8f5e9;
  border: 2px solid #a5d6a7;
  border-left: 8px solid var(--hijau);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 13.5px; line-height: 1.5;
  color: var(--coklat);
  display: none;
}
.peta-fakta.tampil { display: block; animation: petaMasuk .3s ease; }
.peta-fakta b { color: #1b5e20; }
.peta-poin { opacity: .6; font-weight: 800; }
@keyframes petaMasuk { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Papan peta ----------
   bg-peta.png dipasang di BELAKANG <path>. Kalau filenya belum ada,
   browser diam-diam memakai background-color di bawahnya — tidak error,
   tidak perlu fallback di JS.

   JANGAN membuat .peta-region transparan supaya latar tembus, KECUALI
   gambar latarnya sudah punya bentuk pulau di posisi yang persis sama
   dengan path di peta-data.js. Meleset sedikit, area tabrak dan gambar
   tidak nyambung. Aman: bg-peta.png cukup tekstur laut / kertas tua. */
.peta-papan {
  position: relative;
  width: 100%; max-width: 1400px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
  flex: 1 1 auto;
  z-index: 1;
}
#peta-svg {
  display: block;
  width: 100%;
  max-width: 1200px;
  max-height: 62vh;
  height: auto;
  touch-action: none;
}

.peta-region {
  transition: filter .15s, transform .15s;
  cursor: pointer;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.25));
}
.peta-region.sorot  { filter: drop-shadow(0 8px 16px rgba(255, 220, 100, 0.8)) brightness(1.15); transform: translateY(-2px); }
.peta-region.benar  { filter: sepia(1) hue-rotate(90deg) saturate(2) brightness(0.95); cursor: default; }
.peta-region.dibuka { filter: sepia(1) hue-rotate(-20deg) saturate(2) brightness(0.95); cursor: default; }
.peta-region.salah  { filter: sepia(1) hue-rotate(-50deg) saturate(3) brightness(0.8); }

.peta-label {
  font: 800 13px var(--font-isi), system-ui, sans-serif;
  fill: #5a3a24;
  paint-order: stroke;
  stroke: rgba(255,255,255,.85);
  stroke-width: 3.5px;
  pointer-events: none;
  user-select: none;
}
.peta-label.selesai { fill: #1b5e20; }
.peta-tertanam { pointer-events: none; }

/* ---------- Rak kartu ---------- */
.peta-rak-wrapper {
  width: 100%;
  max-width: 1400px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.peta-scroll-btn {
  display: none;
}
.peta-rak {
  width: 100%; max-width: 1400px;
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  min-height: 0; padding: 10px;
}

.peta-nyawa {
  font-size: 15px;
  letter-spacing: 1px;
  padding: 6px 12px;
}

.peta-kartu {
  position: relative;
  width: 160px;
  background: #fffdf8;
  border: 3px solid #e6d9c2;
  border-radius: 16px;
  padding: 10px 8px 12px;
  text-align: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
  color: var(--coklat);
  box-shadow: 0 4px 0 #e6d9c2;
  transition: transform .12s, box-shadow .12s, opacity .2s;
}
.peta-kartu:hover { transform: translateY(-3px); box-shadow: 0 7px 0 #e6d9c2; }
.peta-kartu.diseret {
  position: fixed; z-index: 999;
  cursor: grabbing;
  transform: scale(1.08) rotate(-2deg);
  box-shadow: 0 14px 24px rgba(0,0,0,.28);
  pointer-events: none;
}
.peta-kartu.dipilih {
  border-color: var(--tosca);
  box-shadow: 0 4px 0 var(--tosca), 0 0 0 4px rgba(15,163,163,.18);
}
.peta-kartu.selesai { opacity: 0; pointer-events: none; }
.peta-kartu.goyang { animation: petaGoyang .4s; }
.peta-kartu.muncul { animation: petaMasuk .3s ease-out; }
@keyframes petaGoyang {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-9px) rotate(-3deg); }
  75% { transform: translateX(9px) rotate(3deg); }
}
@keyframes petaMasuk {
  0% { transform: scale(0.5) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.peta-gambar { height: 80px; display: grid; place-items: center; }
.peta-gambar img,
.peta-gambar svg { max-width: 100%; max-height: 80px; display: block; }
.peta-nama { font-size: 14.5px; font-weight: 800; margin-top: 8px; line-height: 1.25; }
.peta-ciri { font-size: 11.5px; opacity: .6; margin-top: 3px; }

/* Titik percobaan: anak melihat sisa kesempatan tanpa perlu teks */
.peta-coba { position: absolute; top: 6px; right: 8px; display: flex; gap: 3px; }
.peta-coba i { width: 6px; height: 6px; border-radius: 50%; background: #e6d9c2; }
.peta-coba i.pakai { background: var(--merah); }

/* ---------- Toast ---------- */
.peta-toast {
  position: fixed; left: 50%; top: 20%;
  transform: translateX(-50%);
  font-family: var(--font-judul);
  font-size: 42px; font-weight: 900; color: #ffd54f;
  text-shadow: 3px 3px 0 #000, -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000;
  pointer-events: none; z-index: 1000;
  animation: petaNaik .9s cubic-bezier(.17,.89,.32,1.28) forwards;
}
@keyframes petaNaik {
  0%   { opacity: 1; transform: translateX(-50%) scale(.5); }
  45%  { transform: translateX(-50%) translateY(-40px) scale(1.15); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-95px) scale(1.3); }
}

/* ---------- Modal penjelasan (muncul saat SALAH) ---------- */
.peta-modal {
  position: absolute !important; inset: 0; z-index: 1100;
  background: rgba(28,20,10,.72);
  display: none; place-items: center; padding: 20px;
}
.peta-modal.tampil { display: grid; }
.peta-kotak {
  width: 100%; max-width: 580px;
  max-height: 90vh; overflow-y: auto;
  background: var(--krem);
  border: 4px solid #8c5d33;
  border-radius: 20px;
  padding: 26px;
  color: var(--coklat);
  box-shadow: 0 20px 50px rgba(0,0,0,.4);
  animation: petaPop .25s cubic-bezier(.17,.89,.32,1.28);
}
@keyframes petaPop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

.peta-kepala { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.peta-ikon { font-size: 34px; }
.peta-kepala h3 { font-family: var(--font-judul); font-size: 23px; line-height: 1.2; }

.peta-baris {
  background: #fff; border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px;
  font-size: 16px; line-height: 1.55;
  border-left: 6px solid #e6d9c2;
  overflow: hidden;   /* menampung float gambar mini */
}
.peta-baris.koreksi  { border-left-color: var(--merah); }
.peta-baris.petunjuk { border-left-color: var(--tosca); }
.peta-baris.kunci    { border-left-color: var(--emas); }
.peta-baris-judul {
  font-size: 12px; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; opacity: .5; margin-bottom: 4px;
}
.peta-baris b { color: #8c3a3a; }
.peta-baris.petunjuk b { color: #0a6d6d; }

/* Gambar mini di dalam modal.
   .peta-mini        -> rumah yang sedang dipegang (kanan)
   .peta-mini.kiri   -> rumah adat milik pulau yang salah dipilih (kiri) */
.peta-mini {
  float: right;
  width: 80px; height: 64px;
  margin: -4px 0 0 12px;
  object-fit: contain;
}
.peta-mini.kiri { float: left; margin: -4px 12px 0 0; }

.peta-btn-lanjut {
  width: 100%; margin-top: 6px;
  border: 0; border-radius: 12px; padding: 12px 26px;
  font: 800 15px var(--font-isi), system-ui;
  background: var(--emas); color: #3b2a10;
  cursor: pointer;
  box-shadow: 0 5px 0 #b87b12;
}
.peta-btn-lanjut:active { transform: translateY(4px); box-shadow: none; }

/* ---------- Laptop & Tablet Landscape ---------- */
@media (min-width: 768px) and (min-height: 601px) and (orientation: landscape) {
  #screen-peta {
    padding: 10px 20px 14px;
    gap: 8px;
    justify-content: flex-start;
  }
  .peta-topbar {
    margin-bottom: 2px;
  }
  .peta-topbar h2 {
    font-size: clamp(18px, 3vmin, 22px);
  }
  .peta-papan {
    margin-top: 0;
    margin-bottom: 2px;
    flex: 1 1 auto;
    width: 100%;
    max-width: 1250px;
    max-height: 64vh;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #peta-svg {
    width: 100%;
    max-width: 1200px;
    max-height: 64vh;
    height: auto;
  }
  .peta-scroll-btn {
    display: none !important;
  }
  .peta-rak-wrapper {
    width: 100%;
    max-width: 1250px;
    margin-top: 0;
    margin-bottom: 4px;
  }
  .peta-rak {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    overflow: visible !important;
    gap: 12px !important;
    padding: 4px 10px !important;
  }
  .peta-kartu {
    flex: none !important;
    width: clamp(120px, 13vw, 150px) !important;
    height: auto !important;
    padding: 8px 8px 10px !important;
  }
  .peta-gambar {
    height: 60px !important;
  }
  .peta-gambar img, .peta-gambar svg {
    max-height: 60px !important;
  }
  .peta-nama {
    font-size: 13px !important;
    margin-top: 6px !important;
  }

  /* Khusus Alat Musik (10 Kartu) pada Mode Laptop/Tablet: Tampilkan Sejajar Rapi (1 Baris) */
  #screen-peta.peta-mode-alat-musik .peta-rak-wrapper,
  #screen-peta.peta-mode-banyak .peta-rak-wrapper {
    max-width: 1360px;
  }
  #screen-peta.peta-mode-alat-musik .peta-rak,
  #screen-peta.peta-mode-banyak .peta-rak {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    gap: clamp(6px, 0.75vw, 10px) !important;
    padding: 4px 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
  }
  #screen-peta.peta-mode-alat-musik .peta-kartu,
  #screen-peta.peta-mode-banyak .peta-kartu {
    flex: 0 1 clamp(94px, 8.4vw, 116px) !important;
    width: clamp(94px, 8.4vw, 116px) !important;
    min-width: 88px !important;
    max-width: 120px !important;
    height: auto !important;
    padding: 6px 4px 8px !important;
    border-radius: 12px !important;
  }
  #screen-peta.peta-mode-alat-musik .peta-gambar,
  #screen-peta.peta-mode-banyak .peta-gambar {
    height: 48px !important;
  }
  #screen-peta.peta-mode-alat-musik .peta-gambar img,
  #screen-peta.peta-mode-alat-musik .peta-gambar svg,
  #screen-peta.peta-mode-banyak .peta-gambar img,
  #screen-peta.peta-mode-banyak .peta-gambar svg {
    max-height: 48px !important;
  }
  #screen-peta.peta-mode-alat-musik .peta-nama,
  #screen-peta.peta-mode-banyak .peta-nama {
    font-size: 11.5px !important;
    font-weight: 800 !important;
    margin-top: 3px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  #screen-peta.peta-mode-alat-musik .peta-ciri,
  #screen-peta.peta-mode-banyak .peta-ciri {
    display: block !important;
    font-size: 9.5px !important;
    margin-top: 2px !important;
    line-height: 1.15 !important;
    opacity: 0.75 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}

/* ---------- Layar HP Landscape (Mobile Landscape) ---------- */
@media (max-width: 1024px) and (max-height: 600px) and (orientation: landscape) {
  #screen-peta {
    padding: 4px 8px 12px;
    gap: 2px;
    justify-content: space-between;
    overflow-x: hidden;
  }
  .peta-topbar {
    padding: 2px 6px;
    gap: 6px;
  }
  .peta-topbar h2 {
    font-size: clamp(14px, 3.5vmin, 18px);
  }
  .peta-chip {
    padding: 2px 8px;
    font-size: 11px;
    gap: 4px;
  }
  .peta-nyawa {
    font-size: 13px;
    padding: 2px 8px;
  }
  .peta-papan {
    margin-top: -2vh;
    max-height: 52vh;
    z-index: 1;
  }
  #peta-svg {
    max-height: 52vh;
  }
  .peta-rak-wrapper {
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: auto;
    margin-bottom: clamp(10px, 3vh, 18px);
    z-index: 10;
  }
  .peta-scroll-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #5a3a24;
    color: #ffd54f;
    border: 2px solid #e6d9c2;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.45);
    font-size: 13px;
    cursor: pointer;
    z-index: 20;
    transition: transform 0.1s, background 0.15s;
    padding: 0;
    user-select: none;
  }
  .peta-scroll-btn:active {
    transform: translateY(-50%) scale(0.9);
    background: #3b200b;
  }
  .peta-scroll-prev {
    left: 2px;
  }
  .peta-scroll-next {
    right: 2px;
  }
  .peta-rak {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 4px 38px 6px 38px !important;
    width: 100% !important;
    margin: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    box-sizing: border-box !important;
    scroll-snap-type: x proximity;
    touch-action: pan-x;
  }
  .peta-rak::-webkit-scrollbar {
    display: none !important;
  }
  .peta-kartu {
    flex: 0 0 112px !important;
    width: 112px !important;
    min-width: 112px !important;
    max-width: 112px !important;
    height: 82px !important;
    padding: 5px 6px 4px !important;
    border-radius: 12px !important;
    border: 2.5px solid #e6d9c2 !important;
    box-shadow: 0 3px 0 #e6d9c2 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    scroll-snap-align: center;
    background: #fffdf8 !important;
    overflow: hidden;
  }
  .peta-kartu:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 #e6d9c2;
  }
  .peta-kartu:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #e6d9c2;
  }
  .peta-gambar {
    height: 42px !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
  }
  .peta-gambar img,
  .peta-gambar svg {
    max-height: 42px !important;
    max-width: 100% !important;
    object-fit: contain !important;
    pointer-events: none;
  }
  .peta-nama {
    font-size: 11px !important;
    font-weight: 800 !important;
    margin-top: 3px !important;
    line-height: 1.15 !important;
    text-align: center !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    color: var(--coklat) !important;
  }
  .peta-ciri {
    display: none !important;
  }
  .peta-coba {
    top: 4px !important;
    right: 5px !important;
    gap: 2px !important;
  }
  .peta-coba i {
    width: 5px !important;
    height: 5px !important;
  }
}

/* ---------- Layar HP Portrait / Sangat Sempit (< 560px) ---------- */
@media (max-width: 560px) {
  .peta-rak-wrapper {
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .peta-scroll-btn {
    display: flex !important;
    width: 28px;
    height: 28px;
    font-size: 11px;
  }
  .peta-scroll-prev {
    left: 2px;
  }
  .peta-scroll-next {
    right: 2px;
  }
  .peta-rak {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 4px 32px !important;
    gap: 6px !important;
    scrollbar-width: none !important;
  }
  .peta-rak::-webkit-scrollbar {
    display: none !important;
  }
  .peta-kartu {
    flex: 0 0 100px !important;
    width: 100px !important;
    min-width: 100px !important;
    height: 76px !important;
    padding: 4px 5px !important;
  }
  .peta-gambar {
    height: 38px !important;
  }
  .peta-gambar img, .peta-gambar svg {
    max-height: 38px !important;
  }
  .peta-nama {
    font-size: 10.5px !important;
  }
  .peta-ciri {
    display: none !important;
  }
  .peta-topbar h2 {
    font-size: 14px !important;
  }
  .peta-mini {
    width: 50px;
    height: 42px;
  }
}