/* modal.css — Jendela RPG: header kontekstual, sumber daya, kartu item stack, filter, detail, dialog.
   Jendela = satu-satunya lapisan dengan bayangan besar (--shadow-lg); isi di dalamnya datar. */
#inventory-modal { position: fixed; inset: 0; z-index: 85; display: flex; align-items: center; justify-content: center; padding: max(8px, env(safe-area-inset-top)) 10px 8px; background: rgba(4, 6, 10, 0.72); animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity: 0; } }
.gm-window {
  position: relative; width: 100%; max-width: 1020px; height: min(680px, 94vh); display: flex; flex-direction: column; overflow: hidden;
  border-radius: 10px; background: var(--slate-1); border: 1px solid #3a4a68; border-top: 4px solid var(--gold-2); box-shadow: var(--shadow-lg);
  animation: winIn 0.24s var(--ease-out);
}
/* Jendela menerima fokus saat dibuka (tabindex -1) sebagai titik awal Tab; wadahnya sendiri tidak diberi cincin */
.gm-window:focus { outline: none; }
/* Tampilan daftar tanpa panel detail (misi, panduan, surat): jendela menyempit mengikuti isi */
.gm-window.is-narrow { max-width: 760px; }
@keyframes winIn { from { opacity: 0; transform: translateY(12px); } }
.gm-header { position: relative; z-index: 1; display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 12px 66px 12px 16px; border-bottom: 1px solid var(--line-2); background: var(--slate-2); }
/* Judul mengambil sisa ruang; bila tab tidak muat, tab turun ke baris sendiri (subjudul tidak terpotong) */
.gm-title { display: flex; align-items: center; gap: 11px; flex: 1 1 280px; min-width: 0; }
.gm-title-icon { width: 44px; height: 44px; flex: 0 0 44px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--slate-0); border: 1px solid rgba(242, 204, 96, 0.4); }
.gm-title-icon .gi { width: 32px; height: 32px; }
.gm-title h2 { font-family: var(--font-title); font-size: var(--fs-title); font-weight: 700; color: var(--gold-hi); line-height: 1.15; white-space: nowrap; }
.gm-title p { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; line-height: 1.35; }
.gm-tabs { display: flex; gap: 4px; padding: 3px; border-radius: 8px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line-2); }
/* flex: none = tab tidak menyusut di bawah lebar labelnya (label tidak saling menimpa); barisnya yang bergeser */
.gm-tab {
  flex: none; min-height: 36px; padding: 0 14px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); white-space: nowrap;
  font-family: var(--font-ui); font-weight: 800; font-size: var(--fs-md); display: inline-flex; gap: 6px; align-items: center; transition: background-color 0.15s, color 0.15s;
}
.gm-tab .gi { width: 20px; height: 20px; flex: none; }
.gm-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.gm-tab.active { color: #2a1a04; background: #e2b54a; box-shadow: inset 0 -2px 0 #8a5a10; }
.gm-tab .count { font-size: var(--fs-xs); padding: 0 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.25); }
body.ui-touch .gm-tab { min-height: 44px; min-width: 44px; justify-content: center; }
.gm-resources { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.res-pill { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px 0 6px; border-radius: 16px; font-weight: 900; font-size: var(--fs-md); background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line-2); white-space: nowrap; }
.res-pill .gi { width: 22px; height: 22px; }
.res-pill small { color: var(--muted); font-weight: 800; font-size: var(--fs-xs); }
.res-pill.is-bump { animation: bump 0.4s; }
@keyframes bump { 40% { transform: scale(1.12); border-color: var(--gold); } }
.gm-close { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.04); color: var(--text-2); font-size: 1.15rem; font-weight: 900; transition: background-color 0.15s, color 0.15s, border-color 0.15s; }
.gm-close:hover { color: #fff; background: rgba(196, 53, 45, 0.3); border-color: var(--bad); }
/* Pita koneksi terputus (modalDialogs.js) */
.gm-offline { display: flex; align-items: center; gap: 8px; padding: 8px 16px; font-size: var(--fs-sm); font-weight: 800; color: #ffd8d3; background: #4a1717; border-bottom: 1px solid rgba(248, 81, 73, 0.5); }
.gm-body { position: relative; z-index: 1; flex: 1; min-height: 0; padding: 14px 16px 16px; overflow: hidden; display: flex; flex-direction: column; }
.gm-scroll { overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; }

/* ---------- Panel umum ---------- */
.panel { background: rgba(9, 13, 21, 0.45); border: 1px solid var(--line-2); border-radius: 8px; padding: 12px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 900; font-size: var(--fs-md); color: var(--gold); margin-bottom: 10px; }
.panel-title small { font-weight: 700; color: var(--muted); font-size: var(--fs-sm); }
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, 1fr); gap: 14px; flex: 1; min-height: 0; }
.split > * { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.empty { padding: 28px 14px; text-align: center; color: var(--muted); font-size: var(--fs-md); line-height: 1.45; }
.empty .gi { width: 54px; height: 54px; opacity: 0.45; display: block; margin: 0 auto 8px; }
/* Gagal memuat (modalDialogs.js loadState): penjelasan dulu, lalu jalan keluar */
.empty.is-error { color: var(--text-2); }
.empty.is-error b { display: block; color: var(--bad-hi); margin-bottom: 4px; }
.empty.is-error .btn { margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 6px; font-size: var(--fs-xs); font-weight: 900; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; }
.chip.r-COMMON { color: var(--r-COMMON); border-color: rgba(184, 193, 204, 0.35); }
.chip.r-UNCOMMON { color: var(--r-UNCOMMON); border-color: rgba(70, 195, 90, 0.4); }
.chip.r-RARE { color: var(--r-RARE); border-color: rgba(88, 166, 255, 0.45); }
.chip.r-EPIC { color: var(--r-EPIC); border-color: rgba(188, 140, 255, 0.45); }
.chip.r-LEGENDARY { color: var(--r-LEGENDARY); border-color: rgba(242, 204, 96, 0.5); }
.chip.r-MYTHIC { color: var(--r-MYTHIC); border-color: rgba(255, 123, 114, 0.5); }
.chip.passive { color: #8cd4ff; border-color: rgba(88, 166, 255, 0.35); background: rgba(88, 166, 255, 0.08); }
.chip.gold { color: var(--gold-hi); border-color: rgba(242, 204, 96, 0.4); background: rgba(242, 204, 96, 0.08); }

/* ---------- Bar filter & pencarian ----------
   PC: filter membungkus ke baris baru (tak ada label terpotong). Layar pendek: satu baris yang bisa digeser,
   tepi memudar sebagai petunjuk masih ada isi (kelas fade-l / fade-r dipasang modalDialogs.js). */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; max-width: 100%; }
.filter-btn {
  position: relative; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 8px; white-space: nowrap;
  border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.03); color: var(--text-2); font-family: var(--font-ui); font-weight: 800; font-size: var(--fs-sm);
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.filter-btn .gi { width: 18px; height: 18px; }
.filter-btn:hover { color: var(--text); border-color: #45577a; }
.filter-btn.active { color: var(--gold-hi); border-color: rgba(242, 204, 96, 0.7); background: rgba(242, 204, 96, 0.12); }
.filter-btn .n { font-size: var(--fs-xs); color: var(--muted); }
body.ui-touch .filter-btn { min-height: 44px; }
.search-box { position: relative; flex: 1; min-width: 150px; max-width: 260px; }
.search-box input { width: 100%; height: 36px; padding: 0 10px 0 30px; border-radius: 8px; border: 1px solid var(--line-2); background: #0b1019; color: var(--text); font-family: var(--font-ui); font-size: var(--fs-md); outline: none; user-select: text; }
.search-box input:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(242, 204, 96, 0.35); }
.search-box::before { content: '⌕'; position: absolute; left: 10px; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 1rem; pointer-events: none; }
body.ui-touch .search-box input { height: 44px; }
.fade-r { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent); }
.fade-l { -webkit-mask-image: linear-gradient(90deg, transparent, #000 36px); mask-image: linear-gradient(90deg, transparent, #000 36px); }
.fade-l.fade-r { -webkit-mask-image: linear-gradient(90deg, transparent, #000 36px, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(90deg, transparent, #000 36px, #000 calc(100% - 36px), transparent); }

/* ---------- Grid & kartu item (stack xN) ----------
   Kartu yang bisa dipilih dirender sebagai <button> (keyboard & pembaca layar). Isi datar diwarnai
   tipis oleh rarity; tanpa bayangan, tanpa pendar (pendar khusus Legendary/Mythic ada di economy.css). */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 9px; align-content: start; padding: 4px 4px 8px 2px; }
.item-grid.compact { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 7px; }
.icard {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px 8px; border-radius: 8px; text-align: center;
  font-family: var(--font-ui); font-size: var(--fs-sm); line-height: 1.2; color: var(--text);
  background: color-mix(in srgb, var(--rc, #3a4760) 12%, #151d2b); border: 1.5px solid var(--rc, #3a4760); transition: background-color 0.15s, border-color 0.15s;
}
button.icard { width: 100%; -webkit-appearance: none; appearance: none; cursor: pointer; }
button.icard:hover { background: color-mix(in srgb, var(--rc, #3a4760) 24%, #151d2b); }
.icard.is-sel { box-shadow: 0 0 0 2px #fff; }
.icard .art { width: 54px; height: 54px; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.35)); }
.icard .art .gi { width: 100%; height: 100%; }
.icard .nm { font-size: var(--fs-sm); font-weight: 800; line-height: 1.2; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.4em; }
.icard .sub { font-size: var(--fs-xs); font-weight: 800; color: var(--text-2); }
.icard .qty { position: absolute; top: -6px; right: -6px; min-width: 28px; height: 20px; padding: 0 6px; display: flex; align-items: center; justify-content: center; border-radius: 6px; font-size: var(--fs-xs); font-weight: 900; color: #2a1a04; background: #e2b54a; border: 2px solid #0e131d; z-index: 2; }
.icard .qty.is-bump { animation: bump 0.45s; }
.icard .lv { position: absolute; top: 6px; left: 6px; padding: 0 5px; height: 18px; display: flex; align-items: center; border-radius: 4px; font-size: var(--fs-xs); font-weight: 900; color: #fff; background: #c4352d; }
.icard .eq { position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%); padding: 0 8px; border-radius: 4px; font-size: var(--fs-xs); font-weight: 900; color: #2a1a04; background: #e2b54a; border: 1.5px solid #0e131d; white-space: nowrap; }
/* Dipakai: bingkai emas + label "Dipakai". Tanpa pendar dan tanpa animasi. */
.icard.is-eq { --rc: var(--gold) !important; border-width: 2px; background: #252214; }
.icard.locked { filter: grayscale(1) brightness(0.55); }
.r-COMMON { --rc: #56606e; --rg: rgba(184, 193, 204, 0.16); }
.r-UNCOMMON { --rc: #2e8a3e; --rg: rgba(70, 195, 90, 0.2); }
.r-RARE { --rc: #2f6fd6; --rg: rgba(88, 166, 255, 0.24); }
.r-EPIC { --rc: #8957e5; --rg: rgba(188, 140, 255, 0.28); }
.r-LEGENDARY { --rc: #d9a12a; --rg: rgba(242, 204, 96, 0.32); }
.r-MYTHIC { --rc: #e5534b; --rg: rgba(255, 123, 114, 0.32); }

/* ---------- Panel detail item ---------- */
.detail { display: flex; flex-direction: column; gap: 10px; }
.detail-hero { display: flex; gap: 12px; align-items: center; }
.detail-art { position: relative; width: 92px; height: 92px; flex: 0 0 92px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--rc, #3a4760) 16%, #121927); border: 2px solid var(--rc, #3a4760); }
.detail-art .gi { width: 70px; height: 70px; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.35)); }
.detail-name { font-size: var(--fs-lg); font-weight: 900; line-height: 1.25; color: var(--text); }
.detail-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.stat-rows { display: grid; gap: 6px; }
.stat-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; background: rgba(0, 0, 0, 0.25); font-size: var(--fs-md); font-weight: 700; color: var(--text-2); }
.stat-row b { color: var(--text); font-weight: 900; }
.dur-bar { height: 6px; border-radius: 3px; background: #070a10; overflow: hidden; margin-top: 4px; }
.dur-bar > i { display: block; height: 100%; background: var(--good); }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: auto; }

/* ---------- Dialog konfirmasi & inspect ---------- */
#gm-confirm, #item-inspect-popup { position: fixed; inset: 0; z-index: 130; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(4, 6, 10, 0.6); animation: fadeIn 0.15s; }
.dialog {
  width: 100%; max-width: 380px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px; border-radius: 10px;
  background: var(--slate-1); border: 1px solid #3a4a68; border-top: 4px solid var(--gold-2); box-shadow: var(--shadow-lg); animation: winIn 0.2s var(--ease-out);
}
.dialog h3 { font-family: var(--font-title); color: var(--gold-hi); font-size: var(--fs-title); line-height: 1.2; margin-bottom: 8px; }
.dialog p { color: var(--text-2); font-size: var(--fs-md); line-height: 1.45; margin-bottom: 14px; }
.dialog .btn-row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- HP / layar sempit ---------- */
@media (max-width: 760px), (max-height: 520px) {
  .gm-window { height: 96vh; height: 96dvh; border-radius: 8px; border-top-width: 3px; }
  .gm-header { padding: 4px 58px 4px 10px; gap: 8px; }
  .gm-close { top: 4px; right: 6px; }
  .gm-title { gap: 8px; }
  .gm-title-icon { width: 34px; height: 34px; flex-basis: 34px; }
  .gm-title-icon .gi { width: 26px; height: 26px; }
  .gm-title h2 { font-size: 18px; }
  .gm-title p { display: none; }
  .res-pill { height: 30px; font-size: var(--fs-sm); }
  .gm-body { padding: 10px; }
  .split { grid-template-columns: minmax(0, 1fr) minmax(240px, 0.9fr); gap: 10px; }
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .icard .art { width: 44px; height: 44px; }
  .stat-row { font-size: var(--fs-sm); padding: 6px 8px; }
  .detail-art { width: 72px; height: 72px; flex-basis: 72px; }
  .detail-art .gi { width: 54px; height: 54px; }
}
/* HP landscape (tinggi pendek): header 1 baris tipis. Judul tidak pernah terpotong; tab & sumber daya
   menyusut lalu bisa digeser. Isi kolom kiri bergulir utuh. */
@media (max-height: 520px) {
  .gm-header { flex-wrap: nowrap; }
  .gm-title { flex: none; }
  .gm-tabs { flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .gm-tabs::-webkit-scrollbar { display: none; }
  .gm-tab { padding: 0 10px; font-size: var(--fs-sm); }
  .gm-resources { flex: 1 1 0; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
  .gm-resources > :first-child { margin-left: auto; }
  .gm-resources::-webkit-scrollbar { display: none; }
  .res-pill { flex: 0 0 auto; }
  .split > * { overflow-y: auto; overscroll-behavior: contain; }
  .split .item-grid.gm-scroll { flex: none; overflow: visible; }
  .toolbar { gap: 6px; margin-bottom: 8px; }
  /* Satu baris yang bisa digeser. Di dalam .toolbar (baris) ia mengambil satu baris penuh; di dalam kolom
     (mis. Pasar .mk-left) ia tidak boleh ikut memanjang ke bawah. */
  .filter-bar { flex: none; min-width: 0; align-items: center; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
  .toolbar > .filter-bar { flex: 1 1 100%; }
  .filter-bar::-webkit-scrollbar { display: none; }
  .search-box { min-width: 110px; }
  .lbl-long { display: none; }
}
.lbl-short { display: none; }
@media (max-height: 520px) { .lbl-short { display: inline; } }
@media (max-width: 560px) {
  .split { grid-template-columns: 1fr; overflow-y: auto; }
}
