/* base.css — Tema panel slate + aksen emas KORA RPG (lihat DESIGN.md): token, reset, lapisan aksesibilitas
   (fokus, kursor, kurangi-gerak), tombol "bevel pixel", input, login, loader. */
:root {
  --bg-0: #080b12;
  --slate-0: #0e131d;
  --slate-1: #131a27;
  --slate-2: #192233;
  --slate-3: #212d42;
  --slate-4: #2b3a54;
  --line: rgba(242, 204, 96, 0.16);
  --line-2: #2a364c;
  --gold: #f2cc60;
  --gold-hi: #ffe9a3;
  --gold-2: #d9a12a;
  --gold-3: #8a5a10;
  --text: #e9eef6;
  --text-2: #c3cddc;
  --muted: #8796ad;
  --good: #3fb950;
  --good-hi: #7ee787;
  --bad: #f85149;
  --bad-hi: #ff8a80;
  --info: #58a6ff;
  --violet: #b48cff;
  --r-COMMON: #b8c1cc;
  --r-UNCOMMON: #46c35a;
  --r-RARE: #58a6ff;
  --r-EPIC: #bc8cff;
  --r-LEGENDARY: #f2cc60;
  --r-MYTHIC: #ff7b72;
  /* Skala huruf: 11px adalah batas bawah mutlak (label), 12px keterangan, 14px isi */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-title: 20px;
  --radius: 14px;
  --radius-sm: 9px;
  /* Bayangan hanya untuk lapisan di atas dunia game, bukan untuk tiap komponen:
     -lg = jendela & kartu login, -hud = panel/tombol HUD yang melayang di atas seni dunia yang ramai */
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.65);
  --shadow-hud: 0 2px 8px rgba(0, 0, 0, 0.45);
  --font-ui: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-title: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
/* manipulation: cubit-zoom tetap boleh untuk membaca teks, ketuk-ganda tidak memperbesar.
   Kanvas & joystick memakai touch-action: none agar gerakan main tidak memicu zoom. */
html, body {
  width: 100%; height: 100%; overflow: hidden; background: var(--bg-0); color: var(--text);
  font-family: var(--font-ui); font-size: 14px; touch-action: manipulation; user-select: none; position: relative;
  -webkit-font-smoothing: antialiased;
}
#game-container { position: fixed; inset: 0; width: 100vw; height: 100vh; touch-action: none; }
#game-container canvas { display: block; touch-action: none; }
.hidden { display: none !important; }
/* <small> bawaan browser = 0.83em; di baris 12px itu jadi 10px. Batas bawah 11px untuk semua <small>. */
small { font-size: max(var(--fs-xs), 0.85em); }
.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; }
kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  font-family: var(--font-ui); font-size: var(--fs-sm); font-weight: 800; color: var(--text);
  background: #222d42; border: 1px solid #45577a; border-bottom-width: 3px; border-radius: 6px;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #34445f; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Lapisan aksesibilitas ---------- */
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
button:not(:disabled), [role='button'], [role='tab'], a[href], summary, select, label[for], input[type='checkbox'], input[type='radio'] { cursor: pointer; }
button:disabled, [aria-disabled='true'] { cursor: not-allowed; }
@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; }
}

/* ---------- Tombol: isi datar + tepi bawah gelap ("bevel pixel", selaras dengan seni dunia) ----------
   Peran: .btn-gold = aksi utama · .btn (slate) = sekunder · .btn-ghost = tersier · .btn-red = bahaya
   · .btn-green = konfirmasi transaksi (Beli/Terima). Tidak ada tombol ungu/biru: warna itu milik rarity. */
.btn {
  --c1: #243149; --bb: #121a29; --bc: #3d4f70; --fc: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px; min-height: 44px;
  font-family: var(--font-ui); font-size: var(--fs-md); font-weight: 800; color: var(--fc);
  background: var(--c1); border: 1px solid var(--bc); border-bottom: 3px solid var(--bb); border-radius: 8px;
  transition: transform 0.1s var(--ease-out), background-color 0.15s, opacity 0.15s; white-space: nowrap;
}
.btn .gi { width: 18px; height: 18px; flex: none; }
.btn:hover:not(:disabled) { background: color-mix(in srgb, var(--c1) 86%, #fff); }
.btn:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 1px; margin-bottom: 2px; }
.btn:disabled, .btn.is-disabled { opacity: 0.45; border-bottom-width: 1px; margin-bottom: 2px; }
.btn-gold { --c1: #e2b54a; --bb: #8a5a10; --bc: #ffe9a3; --fc: #2a1a04; }
.btn-green { --c1: #237a35; --bb: #124a1f; --bc: #46c35a; --fc: #fff; }
.btn-red { --c1: #c4352d; --bb: #6e1515; --bc: #ff8a80; --fc: #fff; }
.btn-ghost { --c1: transparent; --bb: var(--line-2); --bc: var(--line-2); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); }
.btn-sm { padding: 6px 12px; min-height: 36px; font-size: var(--fs-sm); }
.btn-lg { padding: 12px 22px; min-height: 48px; font-size: var(--fs-lg); }
.btn-block { width: 100%; }
/* Layar sentuh: setiap tombol minimal 44px (jempol), termasuk varian kecil */
body.ui-touch .btn-sm { min-height: 44px; }

/* ---------- Input ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > label { font-size: var(--fs-sm); font-weight: 800; color: var(--text-2); }
.field .hint { font-size: var(--fs-sm); color: var(--muted); }
.input, .select, .field input, .field select {
  width: 100%; min-height: 44px; padding: 10px 12px; font-family: var(--font-ui); font-size: var(--fs-md); color: var(--text);
  background: #0b1019; border: 1px solid var(--line-2); border-radius: 8px; outline: none; user-select: text;
  transition: border-color 0.15s, box-shadow 0.15s;
}
/* Pengganti outline: tepi emas + cincin (emas vs panel 11:1) */
.input:focus, .select:focus, .field input:focus, .field select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 204, 96, 0.35); }
/* Zoom tidak lagi dikunci, jadi kolom di HP memakai 16px: iOS tidak memperbesar halaman saat kolom difokus.
   Media query menangkap layar login (sebelum kelas ui-touch dipasang), kelas menangkap laptop layar sentuh.
   !important disengaja: ini batas bawah (seperti batasan browser), harus menang atas aturan ID/komponen. */
body.ui-touch input, body.ui-touch select, body.ui-touch textarea { font-size: 16px !important; }
@media (hover: none) and (pointer: coarse) { input, select, textarea { font-size: 16px !important; } }

/* ---------- Layar putar HP ---------- */
#rotate-warning {
  position: fixed; inset: 0; z-index: 99999; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: #0b0f17; text-align: center; padding: 24px;
}
#rotate-warning .rotate-phone { width: 64px; height: 104px; border: 4px solid var(--gold); border-radius: 14px; animation: rotPhone 1.8s 2 var(--ease-out) forwards; }
#rotate-warning h2 { font-family: var(--font-title); color: var(--gold); font-size: var(--fs-title); max-width: 320px; line-height: 1.5; }
@keyframes rotPhone { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (max-width: 960px) { #rotate-warning { display: flex !important; } }

/* ---------- Login: kartu di atas lukisan kota (seni milik game, bukan gradasi template) ---------- */
#auth-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: flex-start;
  padding: 16px clamp(16px, 8vw, 120px); overflow-y: auto; background: #0b0f17;
}
.auth-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 35%; image-rendering: pixelated; }
/* Peredup kiri kuat → teks di atas kartu selalu kontras; kanan tipis → kota tetap terlihat */
#auth-overlay::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(8, 11, 18, 0.92) 0%, rgba(8, 11, 18, 0.72) 40%, rgba(8, 11, 18, 0.3) 100%); }
.auth-card {
  position: relative; width: 100%; max-width: 380px; padding: 22px 24px 18px; border-radius: 8px;
  background: var(--slate-1); border: 1px solid #3a4a68; border-top: 4px solid var(--gold-2); box-shadow: 0 6px 0 #05070c;
}
.auth-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.auth-emblem { width: 56px; height: 56px; flex: none; }
.auth-card h1 { font-family: var(--font-title); font-size: 28px; line-height: 1.1; color: var(--gold); }
.auth-card .subtitle { color: var(--text-2); font-size: var(--fs-sm); margin-top: 4px; }
.auth-card .btn-row { display: flex; gap: 10px; margin-top: 6px; }
.auth-card .btn-row .btn { flex: 1; }
#auth-message { margin-top: 12px; min-height: 18px; font-size: var(--fs-sm); text-align: center; }
.msg-error { color: var(--bad-hi); }
.msg-success { color: var(--good-hi); }
/* HP landscape (tinggi kecil): judul & form berdampingan agar tidak ada yang terpotong */
@media (max-height: 480px) {
  #auth-overlay { align-items: flex-start; }
  .auth-card { max-width: 640px; display: grid; grid-template-columns: 1fr 1.25fr; gap: 6px 22px; align-items: start; padding: 16px 18px 12px; }
  .auth-head { flex-direction: column; align-items: flex-start; margin: 0; }
  .auth-emblem { width: 40px; height: 40px; }
  .auth-card h1 { font-size: 24px; }
  .auth-card .field { margin-bottom: 8px; }
}

/* ---------- Boot loader ---------- */
#boot-loader { position: fixed; inset: 0; z-index: 98; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: #0b0f17; transition: opacity 0.5s; }
#boot-loader.is-done { opacity: 0; pointer-events: none; }
#boot-loader h2 { font-family: var(--font-title); color: var(--gold); font-size: var(--fs-title); }
.boot-track { width: min(320px, 70vw); height: 10px; border-radius: 10px; background: #0b1019; border: 1px solid var(--line-2); overflow: hidden; }
.boot-fill { height: 100%; width: 0; background: var(--gold-2); transition: width 0.25s; }
#boot-status { font-size: var(--fs-sm); color: var(--text-2); }
