/* ==========================================
   1. RESET & SETUP SPA (SINGLE PAGE APP)
========================================== */
html {
  scroll-behavior: smooth;
} /* Animasi scroll halus untuk navbar */

body {
  margin: 0;
  background-color: #222;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden; /* Kembalikan overflow hidden ini agar kanvas tidak bisa di-scroll */
}

/* ==========================================
   2. BUNGKUSAN AJAIB (ANTI-STRETCH 16:9 HD)
========================================== */
#game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  /* Ganti rumusnya menjadi 1280 / 720 */
  max-width: calc(100vh * (1280 / 720));
  max-height: calc(100vw * (720 / 1280));
  margin: auto;
  top: 50%;
  transform: translateY(-50%);
}

#game-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ==========================================
   3. LAYAR OVERLAY (START, MENANG, HELP, DLL)
========================================== */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-family: sans-serif;
  text-align: center;
  color: white;
}

#start-screen {
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
}
#instruction-screen {
  background: rgba(0, 0, 0, 0.7);
  z-index: 95;
  display: none;
}
#victory-screen {
  background: rgba(0, 0, 0, 0.9);
  z-index: 100;
  display: none;
}
#credits-screen {
  background: #111;
  z-index: 105;
  display: none;
}
#help-screen {
  background: rgba(0, 0, 0, 0.8);
  z-index: 110;
  display: none;
}

/* Modal Box di dalam Overlay */
.modal-box {
  background: rgba(30, 30, 30, 0.95);
  border: 4px solid #f1c40f;
  border-radius: 10px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
  box-sizing: border-box;
}
/* Tombol Utama (Besar) */
.primary-btn {
  padding: 15px 40px;
  font-size: 20px;
  color: white;
  border: 2px solid #fff;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}
.btn-green {
  background: #27ae60;
}
.btn-blue {
  background: #3498db;
}
.btn-red {
  background: #e74c3c;
  padding: 12px 35px;
  font-size: 18px;
}
.btn-gold {
  background: #f1c40f;
  color: #000;
  padding: 12px 35px;
  font-size: 18px;
  border: none;
}

/* Menu Pilih Karakter */
.character-select-container {
  display: flex;
  gap: 30px;
  margin-bottom: 30px;
}
.character-card {
  padding: 15px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 140px;
}
.character-card .preview-box {
  width: 100px;
  height: 120px;
  background-color: rgba(0, 0, 0, 0.6);
  border: 2px dashed #aaa;
  border-radius: 5px;
  margin-bottom: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
}
#select-cowo {
  border: 3px solid #f1c40f;
  background: rgba(255, 255, 255, 0.2);
}
#select-cewe {
  border: 3px solid transparent;
  background: rgba(0, 0, 0, 0.5);
}

/* ==========================================
   4. DESAIN UI DALAM GAME (HUD & KONTROL)
========================================== */
#hud-ui {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.7);
  color: gold;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 16px;
  z-index: 10;
  border: 2px solid gold;
}

#top-controls {
  position: absolute;
  top: 20px;
  right: 2.1%;
  z-index: 90;
  display: flex;
  gap: 15px;
}

.icon-btn {
  padding: 5px 10px;
  font-size: 24px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: 2px solid #f1c40f;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ==========================================
   5. MINIMAP
========================================== */
#minimap-container {
  width: max-content !important; /* Paksa lebar menyesuaikan teks */
  height: auto !important; /* Paksa tinggi menyesuaikan teks */
}

.minimap-label {
  /* (Baris ini boleh dihapus saja karena sudah tidak dipakai) */
}

#btn-close-map {
  display: none;
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 10px 20px;
  font-size: 18px;
  background: #e74c3c;
  color: white;
  border: 2px solid #fff;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  z-index: 60;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

/* ==========================================
   6. INFO CARD & DIALOG
========================================== */
#info-card-ui {
  display: none;
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 350px;
  max-width: 90%;
  background: rgba(255, 255, 255, 0.95);
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  font-family: sans-serif;
  z-index: 30;
  box-sizing: border-box;
  max-height: 80vh;
  overflow-y: auto;
}
#close-btn {
  background: red;
  color: white;
  border: none;
  padding: 5px 10px;
  cursor: pointer;
  float: right;
  border-radius: 5px;
}
.action-buttons {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}
.action-btn {
  flex: 1;
  padding: 10px;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
#btn-maps {
  background: #4285f4;
}
#btn-quiz {
  background: #0f9d58;
}

#dialog-ui {
  display: none;
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 700px;
  background: rgba(0, 0, 0, 0.85);
  border: 3px solid #cda434;
  border-radius: 10px;
  padding: 15px;
  color: white;
  font-family: sans-serif;
  z-index: 20;
  box-sizing: border-box;
  gap: 15px;
  align-items: flex-start;
}
#npc-avatar {
  width: 80px;
  height: 80px;
  background: #555;
  border-radius: 5px;
  border: 2px solid #fff;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #aaa;
}
#npc-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5px;
}

/* ==========================================
   7. KUIS UI
========================================== */
#quiz-ui {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 400px;
  background: white;
  padding: 20px;
  border-radius: 10px;
  z-index: 40;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  font-family: sans-serif;
  box-sizing: border-box;
}

/* ==========================================
   8. ROTATE SCREEN WARNING
========================================== */
#rotate-screen {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #111;
  color: #fff;
  z-index: 9999;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-family: sans-serif;
}
@media screen and (max-width: 768px) and (orientation: portrait) {
  #rotate-screen {
    display: flex;
  }
  #game-wrapper {
    display: none !important;
  }
}

/* ==========================================
   9. DESAIN LANDING PAGE
========================================== */
#landing-page {
  width: 100%;
  min-height: 100vh;
}

/* NAVBAR */
.navbar {
  position: fixed;
  top: 0;
  width: 100%;
  background: rgba(20, 20, 20, 0.95);
  padding: 15px 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  z-index: 1000;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}
.navbar .logo {
  font-size: 24px;
  font-weight: bold;
  color: #f1c40f;
}
.nav-links {
  list-style: none;
  display: flex;
  gap: 30px;
  margin: 0;
  padding: 0;
}
.nav-links a {
  color: white;
  text-decoration: none;
  font-size: 16px;
  transition: 0.3s;
}
.nav-links a:hover {
  color: #f1c40f;
}

/* SECTIONS */
.content-section {
  padding: 100px 10%; /* Padding besar agar rapi */
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.dark-bg {
  background-color: #111;
  border-top: 2px solid #333;
}

/* HERO / BERANDA */
#home {
  height: 100vh;
  text-align: center;
  background:
    linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.8)),
    url("assets/tileset_surakarta.png") center/cover;
  align-items: center;
  padding-top: 0;
}
.hero-content h1 {
  font-size: 55px;
  color: #f1c40f;
  margin-bottom: 20px;
  text-shadow: 2px 4px 6px rgba(0, 0, 0, 0.8);
}
.hero-content p {
  font-size: 20px;
  max-width: 600px;
  margin: 0 auto 40px auto;
  line-height: 1.6;
}

/* PANDUAN GRID */
.guide-grid {
  display: flex;
  gap: 30px;
  margin-top: 40px;
  flex-wrap: wrap;
  justify-content: center;
}
.guide-card {
  background: #222;
  padding: 30px;
  border-radius: 10px;
  flex: 1;
  min-width: 250px;
  border: 2px solid #333;
  text-align: center;
  transition: 0.3s;
}
.guide-card:hover {
  border-color: #f1c40f;
  transform: translateY(-10px);
}
.guide-card .icon {
  font-size: 50px;
  margin-bottom: 15px;
}
.guide-card h3 {
  color: #f1c40f;
  margin-bottom: 15px;
}

/* TENTANG & KREDIT */
.about-container {
  display: flex;
  gap: 50px;
  margin-top: 30px;
  flex-wrap: wrap;
}
.about-text,
.about-credits {
  flex: 1;
  min-width: 300px;
  line-height: 1.8;
  font-size: 18px;
}
.about-text h3 {
  color: #3498db;
  margin-top: 30px;
}
.about-credits h3 {
  color: #27ae60;
}
.about-credits ul {
  padding-left: 20px;
}
.about-credits li {
  margin-bottom: 10px;
}

footer {
  text-align: center;
  padding: 30px;
  background: #050505;
  color: #666;
  font-size: 14px;
}

/* ==========================================
   10. FIX RESPONSIVE UNTUK LAYAR PENDEK (LANDSCAPE HP)
========================================== */
@media screen and (max-height: 450px) {
  /* 1. Turunkan judul dan kecilkan font agar tidak menabrak tombol */
  #start-screen h1 {
    font-size: 28px !important;
    margin-top: 35px !important;
    margin-bottom: 5px !important;
  }

  /* 2. Perkecil teks sub-judul */
  #start-screen p {
    font-size: 14px !important;
    margin-bottom: 10px !important;
  }

  /* 3. Rapatkan jarak antar kotak karakter */
  .character-select-container {
    gap: 15px !important;
    margin-bottom: 15px !important;
  }

  /* 4. Perkecil kotak kartu karakter */
  .character-card {
    padding: 10px !important;
    width: 110px !important;
  }
  .character-card .preview-box {
    height: 80px !important;
    margin-bottom: 5px !important;
  }
  .character-card h3 {
    font-size: 16px !important;
  }

  /* 5. Perkecil tombol Mulai Petualangan */
  .primary-btn {
    padding: 10px 25px !important;
    font-size: 16px !important;
  }

  /* 6. Geser & kecilkan sedikit tombol "Kembali ke Beranda" */
  #start-screen a[href="index.html"] {
    top: 10px !important;
    left: 10px !important;
    font-size: 12px !important;
    padding: 5px 8px !important;
  }
  /* ==========================================
       TAMBAHAN FIX UNTUK HUD, KONTROL & MODAL
    ========================================== */

  /* 1. Perkecil dan geser HUD Fragmen Ingatan */
  #hud-ui {
    top: 10px !important;
    left: 10px !important;
    padding: 5px 10px !important;
    font-size: 14px !important;
  }

  /* 2. Perkecil dan geser Tombol Kontrol Kanan Atas (Home, Help, Mute) */
  #top-controls {
    top: 10px !important;
  }
  .icon-btn {
    padding: 3px 8px !important;
    font-size: 18px !important; /* Ukuran ikon diperkecil */
    border-width: 2px !important;
  }

  /* 3. Sesuaikan Kotak Petunjuk Misi (Modal Box) agar tidak nabrak layar */
  .modal-box {
    padding: 15px 20px !important;
    max-height: 90vh !important; /* Jika masih kurang muat, otomatis bisa di-scroll */
    overflow-y: auto !important;
  }
  .modal-box h2 {
    font-size: 22px !important;
    margin-bottom: 10px !important;
  }
  .modal-box p,
  .modal-box ul {
    font-size: 14px !important;
    line-height: 1.4 !important;
    margin-bottom: 15px !important;
  }

  /* 4. Perkecil tombol 'Saya Mengerti!' dll di dalam modal */
  .modal-box .primary-btn,
  #btn-understand {
    padding: 8px 25px !important;
    font-size: 14px !important;
  }
  /* ==========================================
       TAMBAHAN FIX UNTUK DIALOG UI & INFO CARD
    ========================================== */

  /* --- 1. PENYESUAIAN DIALOG BOX NPC (#dialog-ui) --- */
  #dialog-ui {
    bottom: 10px !important; /* Geser lebih rapat ke bawah */
    padding: 10px !important; /* Kurangi padding dalam */
    gap: 10px !important; /* Rapatkan jarak avatar ke teks */
    width: 95% !important; /* Lebarkan sedikit agar teks muat banyak */
    border-width: 2px !important; /* Tipiskan garis pinggir emas */
  }

  /* Kecilkan Avatar NPC agar tidak makan tempat vertikal */
  #npc-avatar {
    width: 50px !important;
    height: 50px !important;
    font-size: 10px !important; /* Kecilkan teks placeholder jika gambar loading */
    border-width: 1px !important;
  }

  /* Kecilkan teks di dalam dialog */
  #npc-name {
    font-size: 16px !important;
    margin-bottom: 5px !important;
  }
  #npc-text {
    font-size: 13px !important;
    margin-bottom: 10px !important;
    line-height: 1.3 !important; /* Rapatkan jarak antar baris */
  }

  /* Kecilkan tombol 'Lanjut' */
  #dialog-next-btn {
    padding: 6px 12px !important;
    font-size: 13px !important;
  }

  /* --- 2. PENYESUAIAN INFO CARD LANDMARK (#info-card-ui) --- */
  #info-card-ui {
    bottom: 10px !important; /* Geser lebih rapat ke bawah */
    right: 10px !important; /* Geser lebih rapat ke kanan (biar tidak nabrak minimap) */
    width: 280px !important; /* Kecilkan lebar agar pemandangan game masih terlihat */
    padding: 10px !important;
    max-height: 95vh !important; /* Biarkan hampir full tinggi jika teks sangat panjang */
  }

  /* Tombol 'X' tutup kecilkan */
  #info-card-ui #close-btn {
    padding: 3px 8px !important;
    font-size: 12px !important;
  }

  /* Kecilkan Judul Tempat */
  #info-card-ui #landmark-name {
    font-size: 18px !important;
    margin: 0 0 5px 0 !important;
  }

  /* PENTING: Kecilkan Ukuran Video YouTube agar tidak nabrak layar */
  #info-card-ui #youtube-video {
    height: 120px !important; /* Paksa tingginya menjadi pendek (override HTML) */
  }

  /* Kecilkan Teks Deskripsi Sejarah */
  #info-card-ui #landmark-desc {
    font-size: 13px !important;
    margin: 5px 0 !important;
    line-height: 1.3 !important;
    max-height: 60px; /* Batasi tinggi teks agar tidak full, pemain bisa scroll */
    overflow-y: auto;
  }

  /* Kecilkan tombol 'Lihat Maps' dan 'Mulai Kuis' */
  #info-card-ui .action-buttons {
    margin-top: 10px !important;
    gap: 5px !important;
  }
  #info-card-ui .action-btn {
    padding: 8px !important;
    font-size: 13px !important;
  }
}
