/* Komponen boleh guna semula: butang, kad, cip, suis, modal, toast, belon dialog */

/* ---------- Butang ---------- */
.btn {
  --btn-bg: var(--c-primary);
  --btn-shadow: var(--c-primary-dark);
  --btn-fg: #fff;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 0 var(--sp-5);
  border-radius: var(--radius-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--text-lg);
  font-weight: 900;
  box-shadow: 0 6px 0 var(--btn-shadow);
  transform: translateY(0);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), filter var(--dur-fast);
}
.btn:active, .btn.is-pressed { transform: translateY(5px); box-shadow: 0 1px 0 var(--btn-shadow); }
@media (hover: hover) { .btn:hover { filter: brightness(1.05); } }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--lg { min-height: var(--tap-lg); padding: 0 var(--sp-6); font-size: var(--text-xl); }
.btn--action { --btn-bg: #E0582F; --btn-shadow: #B8431F; } /* lebih gelap sedikit daripada --c-action supaya teks putih cukup kontras (WCAG) */
.btn--accent { --btn-bg: var(--c-accent); --btn-shadow: var(--c-accent-dark); --btn-fg: var(--c-ink); }
.btn--light  { --btn-bg: var(--c-surface); --btn-shadow: var(--c-line); --btn-fg: var(--c-ink); }
.btn--block { width: 100%; }

/* Butang ikon bulat (bar atas) */
.btn-icon {
  display: inline-grid;
  place-items: center;
  width: var(--tap-min);
  height: var(--tap-min);
  border-radius: 50%;
  background: var(--c-surface);
  color: var(--c-ink);
  box-shadow: 0 4px 0 var(--c-line);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast);
}
.btn-icon:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--c-line); }
.btn-icon svg { width: 28px; height: 28px; }
.btn-icon.is-off { color: var(--c-ink-soft); background: var(--c-bg-deep); }

/* ---------- Kad ---------- */
.card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--sp-5);
}

/* Kad pilihan yang boleh ditekan */
.pick {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 150px;
  padding: var(--sp-4);
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  border: 4px solid transparent;
  box-shadow: 0 6px 0 var(--c-line);
  text-align: center;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast), border-color var(--dur-fast);
}
.pick:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--c-line); }
@media (hover: hover) { .pick:hover { border-color: var(--c-primary-soft); } }
.pick.is-selected { border-color: var(--c-primary); }
.pick__name { font-size: var(--text-lg); font-weight: 900; }
.pick__sub { font-size: var(--text-sm); color: var(--c-ink-soft); font-weight: 700; }

/* ---------- Cip / label kecil ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--c-primary-soft);
  color: var(--c-primary-dark);
  font-size: var(--text-sm);
  font-weight: 800;
  white-space: nowrap;
}
.chip--accent { background: #FFF1C7; color: #7A5A00; }
.chip--muted { background: var(--c-bg-deep); color: var(--c-ink-soft); }

/* ---------- Suis hidup/mati (tetapan) ---------- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  min-height: var(--tap-lg);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 0 var(--c-line);
  width: 100%;
  text-align: left;
}
.switch-row__label { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--text-lg); font-weight: 800; }
.switch-row__label svg { width: 32px; height: 32px; color: var(--c-primary); flex: 0 0 auto; }
.switch-row__hint { display: block; font-size: var(--text-sm); color: var(--c-ink-soft); font-weight: 700; }
.switch {
  position: relative;
  flex: 0 0 auto;
  width: 72px;
  height: 42px;
  border-radius: var(--radius-pill);
  background: var(--c-line);
  transition: background var(--dur-base);
}
.switch::after {
  content: "";
  position: absolute;
  top: 5px; left: 5px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform var(--dur-base) var(--ease-bounce);
}
[aria-checked="true"] .switch { background: var(--c-success); }
[aria-checked="true"] .switch::after { transform: translateX(30px); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  padding-bottom: calc(var(--sp-4) + var(--safe-b));
  background: rgba(43, 43, 58, 0.45);
  animation: fade-in var(--dur-base) both;
}
.modal {
  width: min(100%, 560px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--c-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  padding: var(--sp-5);
  animation: pop-in var(--dur-slow) var(--ease-bounce) both;
}
.modal__title { font-size: var(--text-xl); margin-bottom: var(--sp-4); text-align: center; }
.modal__actions { display: flex; gap: var(--sp-3); justify-content: center; flex-wrap: wrap; margin-top: var(--sp-5); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: none; } }

/* ---------- Medan teks ---------- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.field__label { font-size: var(--text-base); font-weight: 900; }
.input {
  min-height: var(--tap-min);
  padding: 0 var(--sp-4);
  border-radius: var(--radius-md);
  border: 3px solid var(--c-line);
  background: var(--c-surface);
  font: inherit;
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--c-ink);
}
.input:focus { border-color: var(--c-primary); outline: none; }

/* ---------- Toast ---------- */
.toast {
  pointer-events: none;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-pill);
  background: var(--c-ink);
  color: #fff;
  font-weight: 800;
  text-align: center;
  box-shadow: var(--shadow-float);
  animation: toast-in var(--dur-slow) var(--ease-bounce) both;
}
.toast.is-leaving { animation: toast-out var(--dur-base) ease-in both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(20px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* ---------- Belon dialog Lulu ---------- */
.speech {
  position: relative;
  background: var(--c-surface);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-card);
  font-size: var(--text-lg);
  font-weight: 800;
  line-height: 1.35;
  animation: pop-in var(--dur-slow) var(--ease-bounce) both;
}
.speech::before {
  content: "";
  position: absolute;
  left: -12px;
  bottom: 18px;
  border: 12px solid transparent;
  border-right-color: var(--c-surface);
  border-left: 0;
}
.speech .ar { font-size: var(--text-ar-label); display: block; }

/* Watak Lulu dan avatar */
.lulu { width: 100%; height: auto; overflow: visible; }
.lulu--bob { animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.avatar {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--c-bg-deep);
  flex: 0 0 auto;
}
.avatar svg { width: 76%; height: 76%; }
.avatar--sm { width: 48px; height: 48px; }

/* ---------- Peringkat 7: bar kemas kini, status offline ---------- */
.update-bar { position: fixed; left: 50%; bottom: calc(var(--safe-b, 0px) + 14px); transform: translateX(-50%); z-index: 80; display: flex; align-items: center; gap: 10px; background: var(--c-ink); color: #fff; padding: 8px 8px 8px 18px; border-radius: 99px; box-shadow: var(--shadow-float); font-weight: 700; max-width: calc(100vw - 24px); animation: toast-in var(--dur-base) var(--ease-bounce); }
.update-bar__x { width: 44px; height: 44px; border-radius: 50%; color: #fff; font-size: 24px; }
body.in-game .update-bar { display: none; }
.mini-bar { display: block; height: 8px; background: var(--c-line); border-radius: 99px; margin-top: 6px; overflow: hidden; width: min(260px, 60vw); }
.mini-bar span { display: block; height: 100%; background: var(--c-primary); transition: width var(--dur-base); }
.ios-steps { margin: 0 0 8px; padding-left: 1.3em; line-height: 1.6; font-weight: 700; }

/* ---------- Mod ringan (telefon kos rendah) ----------
   Dihidupkan automatik jika RAM ≤ 2 GB atau Penjimat Data. Buang animasi berterusan & bayang berat. */
body.lite .lulu--bob, body.lite .splash__start, body.lite .house:not(.is-locked) .house__art { animation: none !important; }
body.lite .house__art { filter: none; }
body.lite .burst { display: none; }
body.lite .screen { animation: none !important; }
body.lite .hills { filter: none !important; }
body.lite .gcard, body.lite .pick, body.lite .bs__tile { transition-duration: 0ms !important; }
