@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Pixelify+Sans:wght@500;700&display=swap");

/* Token warna dan komponen dasar (artboard 0.2 Komponen). Tanpa ungu; biru khusus kerajaanmu dan aksi utama. */
:root {
  --bg: #f6f5f1; --panel: #ffffff; --text: #1c1c1a; --muted: #65655f; --line: #dcdad3; --soft: #efeee9;
  --dataran: #e4ebc8; --hutan: #a9c79a; --bukit: #dcc8a6;
  --outline-ink: #1d2230; --ink: #1d2230; --me: #1d4ed8; --danger: #b91c1c; --bandit: #3f3f46; --wild: #854d0e;
  --focus: #d97706; --ok: #15803d; --gold: #f0b43c; --gold-ink: #7c4a03; --gold-bg: #fdf2d8;
  --me-soft: #e6edfd; --me-ink: #1e3a8a; --cream: #f4f1e4;
  --shadow: 4px 4px 0 rgba(29, 34, 48, 0.22);
  /* Dua font untuk seluruh game: Pixelify Sans (judul, kelas .display) dan Nunito (semua teks lain),
     dimuat dari Google Fonts supaya sama di semua perangkat. Jangan menulis keluarga font langsung:
     pakai var(--font) atau var(--display). */
  --display: "Pixelify Sans", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
h3 { font-size: 14px; margin: 16px 0 6px; color: var(--muted); }
a { color: var(--me); }
.muted { color: var(--muted); font-size: 13px; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 16px; }
.display { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0; color: var(--text); }
.eyebrow { margin: 0; font: 600 12px/1.2 var(--font); letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Logo, lambang, dan potongan peta (art/logo.png, art/emblem.png, art/map_demo.png); skala bulat saja. */
.logo, .emblem, .mapshot { display: inline-block; background-repeat: no-repeat; image-rendering: pixelated; flex: none; }
.logo { width: 166px; height: 54px; background-image: url(assets/logo.png); background-size: 100% 100%; }
.emblem { width: 48px; height: 48px; background-image: url(assets/emblem.png); background-size: 100% 100%; }
.mapshot { background-image: url(assets/mapshot.png); background-size: max(1792px, 100%) auto; background-position: center; }

/* Navigasi atas: semua tujuan berupa tombol 44px, bukan tautan teks. */
nav.top { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--panel); border-bottom: 2px solid var(--ink); flex-wrap: wrap; }
nav.top .logo { width: 120px; height: 39px; margin-right: 8px; }
nav.top .btn[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--cream); }
nav.top .who { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.lvl { display: inline-flex; align-items: center; gap: 10px; }
nav.top .lvl { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.spacer { flex: 1; }
@media (max-width: 600px) {
  nav.top { gap: 10px 6px; padding: 8px; }
  nav.top .who, nav.top .chip.gold { display: none; }
  nav.top .lvl .xp { width: 48px !important; }
}

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.panel { background: var(--panel); border: 2px solid var(--ink); border-radius: 8px; box-shadow: var(--shadow); }
.inset { background: var(--soft); border-radius: 6px; }
.backdrop { background: rgba(29, 34, 48, 0.6); }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* Tombol: peran menentukan warna. Utama = menyimpan data, lembut = membuka/melihat, sekunder = netral, bahaya = hapus. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 6px; border: 2px solid var(--line); background: var(--soft); color: var(--text); font: inherit; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(0.96); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--me); border-color: var(--me); color: #fff; }
.btn.subtle { background: var(--me-soft); border-color: #bccdf5; color: var(--me-ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { display: flex; width: 100%; margin-top: 6px; }
.btn.sm { padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; filter: none; }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]::before { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 2px; animation: spin 0.8s steps(4) infinite; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, [tabindex]:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.conn { color: var(--danger); font-weight: 600; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }

label { display: block; font-size: 14px; margin-top: 10px; }
input, select, textarea { display: block; width: 100%; min-height: 44px; padding: 0 10px; margin-top: 4px; font: inherit; border: 2px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); }
input[aria-invalid="true"] { border-color: var(--danger); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .label { margin: 0; font-size: 14px; font-weight: 600; }
.field input, .field select { margin: 0; }
.help { font-size: 13px; color: var(--muted); }
.err { color: var(--danger); font-size: 13px; }
.msg { min-height: 1.5em; margin: 8px 0 0; color: var(--danger); }
.msg.ok { color: var(--ok); }
.check { display: flex; gap: 8px; align-items: center; min-height: 44px; margin: 0; }
.check input { width: 20px; min-height: 20px; margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; }
.table-scroll { overflow-x: auto; }

/* Label status. */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; line-height: 1.6; background: var(--soft); border: 1px solid var(--line); color: var(--text); white-space: nowrap; }
.chip.ok { background: #e5f3e9; border-color: var(--ok); color: #14532d; }
.chip.me { background: var(--me); border-color: var(--me); color: #fff; }
.chip.gold { background: var(--gold-bg); border-color: #c98a12; color: var(--gold-ink); }
.chip.danger { background: #fde8e8; border-color: var(--danger); color: var(--danger); }
.chip.ink { background: var(--ink); border-color: var(--ink); color: var(--cream); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; flex: none; }

/* Bar XP (emas), darah, dan memuat. */
.xp { position: relative; height: 10px; border: 2px solid var(--ink); border-radius: 3px; background: #fff; overflow: hidden; }
.xp i { display: block; height: 100%; background: var(--gold); }
.hp { height: 6px; border-radius: 3px; background: rgba(29, 34, 48, 0.15); overflow: hidden; }
.hp i { display: block; height: 100%; }
.loadbar { height: 12px; border: 2px solid var(--ink); border-radius: 3px; background: #fff; overflow: hidden; }
.loadbar i { display: block; width: 30%; height: 100%; background: repeating-linear-gradient(90deg, var(--me) 0 8px, #3b6cf0 8px 16px); animation: load 1.2s steps(10) infinite; }
.spin { display: inline-block; width: 14px; height: 14px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 2px; animation: spin 0.8s steps(4) infinite; flex: none; }
.skel-box { display: grid; gap: 8px; padding: 4px 0; }
.skel-line { height: 12px; }
.skel-inline { display: inline-block; height: 0.85em; vertical-align: middle; }
.skel-report { display: grid; gap: 12px; }
.skel { border-radius: 4px; background: linear-gradient(90deg, #e8e5dc 25%, #f1efe8 50%, #e8e5dc 75%); background-size: 200% 100%; animation: skel 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@keyframes skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* Pesan singkat. */
.toast { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; box-shadow: 3px 3px 0 rgba(29, 34, 48, 0.2); font-weight: 600; font-size: 14px; }
.toast.ok { border-color: var(--ok); background: #e5f3e9; color: #14532d; }
.toast.danger { border-color: var(--danger); background: #fde8e8; color: #7f1d1d; }
.toast.gold { border-color: #c98a12; background: var(--gold-bg); color: var(--gold-ink); }

/* Keadaan kosong / galat. */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 32px; text-align: center; }
.empty .muted { max-width: 360px; font-size: 14px; }

/* Sumber daya dengan ikon sprite. */
.res { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Foto profil dari bagian avatar (fase 6). */
.face { position: relative; display: inline-block; flex: none; overflow: hidden; border-radius: 4px; background: #5aa64f; vertical-align: middle; }
.face i { position: absolute; inset: 0; background: url(assets/avatar.png) no-repeat; background-size: 1200% 700%; image-rendering: pixelated; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Pilihan bahasa "ID | EN" (i18n.js → langToggle): dua segmen, target 44px, aria-pressed. */
.lang-toggle { display: inline-flex; flex: none; border: 2px solid var(--sel-bg, var(--ink)); border-radius: 6px; overflow: hidden; background: var(--panel); }
.lang-toggle button { min-width: 44px; min-height: 40px; padding: 0 10px; border: 0; background: var(--panel); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.lang-toggle button + button { border-left: 2px solid var(--sel-bg, var(--ink)); }
.lang-toggle button[aria-pressed="true"] { background: var(--sel-bg, var(--ink)); color: var(--sel-ink, var(--cream)); }
.lang-toggle button:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }

/* Layar memuat (fase 12, boot.js): menutup halaman sampai aset siap. */
.boot { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; background: var(--ink); }
.boot.closing { animation: fade-out 150ms ease-in forwards; }
.boot-card { width: min(420px, 100%); padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.boot-txt { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.boot-bar { width: 100%; }
.boot-bar i { width: 0; animation: none; background: var(--me); transition: width 120ms linear; }
.boot-err { margin: 0; color: var(--danger); font-size: 14px; }
/* Toast versi baru: tetap tampil sampai pemain memuat ulang. */
.bol-new { position: fixed; z-index: 900; left: 50%; top: 140px; transform: translateX(-50%); max-width: calc(100vw - 32px); flex-wrap: wrap; justify-content: center; }

/* Pop-up (fase 12): masuk skala 0,96 → 1 + pudar 180 ms, keluar kebalikannya 130 ms (api.js
   menambah .closing sebelum menutup). Lapisan belakang memudar. Kurangi gerakan: hanya pudar singkat. */
@keyframes pop-in { from { opacity: 0; transform: scale(0.96); } }
@keyframes pop-out { to { opacity: 0; transform: scale(0.96); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
dialog[open] { animation: pop-in 180ms ease-out; }
dialog[open]::backdrop { animation: fade-in 180ms ease-out; }
dialog.closing { animation: pop-out 130ms ease-in forwards; }
dialog.closing::backdrop { animation: fade-out 130ms ease-in forwards; }
.pop { animation: pop-in 180ms ease-out; }
.pop.closing { animation: pop-out 130ms ease-in forwards; pointer-events: none; }
.over:not([hidden]) { animation: fade-in 180ms ease-out; }
.over:not([hidden]) > * { animation: pop-in 180ms ease-out; }
/* Layar sempit: dialog jadi bottom sheet yang naik dari bawah. */
@media (max-width: 600px) {
  dialog[open] { margin: auto 0 0; width: 100vw !important; max-width: 100vw !important; max-height: 90dvh !important; border-radius: 12px 12px 0 0; border-bottom: 0; animation-name: sheet-in; animation-duration: 200ms; }
  dialog.closing { animation-name: sheet-out; }
}
@media (prefers-reduced-motion: reduce) {
  dialog[open], dialog.closing, .pop, .pop.closing, .over:not([hidden]) > * { animation-name: fade-in !important; animation-duration: 90ms !important; }
  dialog.closing, .pop.closing { animation-name: fade-out !important; }
}
/* Tombol Tutup di pojok kanan atas setiap pop-up: ✕ + teks, sekunder abu-abu, ≥ 44 px. */
.x-close { flex: none; margin-left: auto; }
.x-close .x { font-size: 16px; line-height: 1; }
.x-form { margin: 0 0 0 auto; flex: none; }
.overlay > .panel { animation: pop-in 180ms ease-out; }
