/* KodeQuest — fx.css: animasi & komponen efek gamifikasi.
 * Hormati prefers-reduced-motion: semua animasi gerak dimatikan. */

/* Teks melayang (+20 XP, +5 Koin, angka damage). Host-nya (baris HP,
 * kartu battle, chip pemain) harus position:relative — lihat di bawah. */
.fx-float {
  position: absolute;
  z-index: 30;
  font-weight: 800;
  font-size: 1.05rem;
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .6);
  animation: fx-float-up 1.25s ease-out forwards;
}
.fx-float-xp { color: #fbbf24; }
.fx-float-coin { color: #facc15; }
.fx-float-damage { color: #f87171; font-size: 1.25rem; }
.fx-float-flash { color: #22d3ee; }
@keyframes fx-float-up {
  0% { opacity: 0; transform: translateY(6px) scale(.9); }
  15% { opacity: 1; transform: translateY(0) scale(1.05); }
  100% { opacity: 0; transform: translateY(-46px) scale(1); }
}
.hp-row, .battle-card, .player-chip { position: relative; }

/* Getar layar saat jawaban salah; kilat saat monster kena serang. */
@keyframes fx-shake-x {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
.fx-shake { animation: fx-shake-x .4s ease; }
@keyframes fx-hit-wobble {
  0%, 100% { transform: translateX(0); filter: brightness(1); }
  30% { transform: translateX(4px) rotate(1deg); filter: brightness(1.5); }
  60% { transform: translateX(-3px); filter: brightness(1.2); }
}
.fx-hit { animation: fx-hit-wobble .4s ease; }

/* Bilah XP di bawah chip pemain (terisi halus via transition). */
.player-xp-bar {
  flex-basis: 100%;
  height: 8px;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.player-xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b, #facc15);
  transition: width .6s ease;
  border-radius: 999px;
}
.xp-bar-label { font-size: .75rem; color: var(--muted); }

/* Penanda kombo berapi (streak jawaban >= 3). */
.combo-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: #450a0a;
  border: 1px solid #f97316;
  color: #fdba74;
  font-weight: 800;
  border-radius: 999px;
  padding: .3rem .8rem;
  margin: .4rem 0 .2rem;
  animation: fx-combo-pulse 1s ease-in-out infinite;
}
.combo-badge svg { flex: none; }
@keyframes fx-combo-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* Confetti: kanvas layar penuh di atas konten, tidak menangkap klik. */
#fx-confetti {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

/* Modal naik level. */
.fx-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(2, 6, 23, .75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.fx-modal-card {
  background: var(--card);
  border: 2px solid var(--accent);
  border-radius: 18px;
  padding: 1.6rem 2rem;
  text-align: center;
  max-width: 420px;
  width: 100%;
  animation: fx-pop-in .35s ease;
}
.fx-modal-card h2 { color: var(--accent); font-size: 2rem; margin: .4rem 0; }
.fx-modal-card p { line-height: 1.5; margin: .4rem 0 1rem; }
@keyframes fx-pop-in {
  from { opacity: 0; transform: scale(.85); }
  to { opacity: 1; transform: scale(1); }
}

/* Tombol bisu di header (ikon SVG speaker). */
.btn-icon {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  padding: .4rem;
}
.btn-icon:hover { border-color: var(--accent-2); }

/* Avatar di header chip + pemilih avatar. */
.player-avatar { display: inline-flex; flex: none; }
.player-avatar svg { border-radius: 50%; display: block; }
.avatar-fieldset { border: none; padding: 0; margin: 0 0 .4rem; }
.avatar-fieldset legend { font-weight: 700; line-height: 1.5; padding: 0; margin-bottom: .2rem; }
.lb-avatar svg { border-radius: 50%; display: block; }
.lb-avatar { flex: none; }
.pill-streak b { color: #fb923c; }
.pill-streak .flame-ico { vertical-align: -3px; margin-right: .15rem; }
.avatar-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: .6rem 0 1rem; }
.avatar-option {
  background: var(--card-2);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: .6rem .3rem .5rem;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  min-height: 44px;
}
.avatar-option span { font-size: .8rem; font-weight: 700; line-height: 1.3; text-align: center; }
.avatar-option.selected { border-color: var(--accent); background: #451a03; }
.avatar-option:hover { border-color: var(--accent-2); }
.avatar-change { margin-bottom: 1.2rem; }
.avatar-change h3 { margin: 0 0 .2rem; }
.avatar-change p { color: var(--muted); margin: 0 0 .6rem; line-height: 1.5; }

/* Panel misi harian di peta. */
.daily-panel { margin-bottom: 1.2rem; }
.daily-panel h3 { margin: 0 0 .2rem; display: flex; align-items: center; gap: .5rem; }
.daily-panel .daily-reset { color: var(--muted); font-size: .85rem; margin: 0 0 .8rem; line-height: 1.5; }
.daily-list { display: grid; gap: .7rem; }
.daily-item { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: .7rem .9rem; }
.daily-item.done { border-color: var(--good); }
.daily-item .daily-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .3rem .8rem; }
.daily-item .daily-name { font-weight: 800; }
.daily-item .daily-reward { color: var(--accent); font-weight: 800; font-size: .9rem; white-space: nowrap; }
.daily-item p { margin: .25rem 0 .5rem; color: var(--muted); font-size: .92rem; line-height: 1.5; }
.daily-progress { display: flex; align-items: center; gap: .6rem; }
.daily-bar { flex: 1; height: 10px; background: #0b1220; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.daily-fill { height: 100%; width: 0%; background: var(--good); transition: width .5s ease; }
.daily-count { font-weight: 800; font-size: .9rem; white-space: nowrap; }
.daily-item .btn { min-height: 40px; padding: .45rem 1rem; margin-top: .55rem; }
.daily-claimed { color: var(--good); font-weight: 800; margin-top: .55rem; }

/* Timer soal (30 detik) di arena. */
.timer-wrap { display: flex; align-items: center; gap: .6rem; margin: .6rem 0 0; }
.timer-bar { flex: 1; height: 10px; background: #0b1220; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--accent-2); transition: width .2s linear; }
.timer-wrap.low .timer-fill { background: var(--bad); }
.timer-wrap.low .timer-num { color: #fca5a5; animation: fx-combo-pulse .5s ease-in-out infinite; }
.timer-num { font-weight: 800; min-width: 2.2rem; text-align: right; }

/* Bintang per misi di daftar misi + total bintang misi di kartu dunia. */
.mi-stars { color: #facc15; letter-spacing: .1em; font-size: .95rem; white-space: nowrap; }
.mi-stars .star-off { color: #475569; }
.world-mission-stars { color: var(--muted); font-size: .85rem; margin: .35rem 0 0; line-height: 1.5; }
.world-mission-stars b { color: #facc15; }

/* Tombol bantuan "?" kecil + popup penjelasan (penjelasan panjang
   disembunyikan di balik tanda tanya, sesuai kebiasaan pengguna). */
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  border: 1px solid var(--accent-2);
  background: transparent;
  color: var(--accent-2);
  font: inherit;
  font-weight: 800;
  font-size: .9rem;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}
.help-btn:hover { background: #082f49; }
.help-pop {
  background: #082f49;
  border: 1px solid var(--accent-2);
  border-radius: 10px;
  padding: .8rem 1rem;
  margin: .5rem 0 .8rem;
  font-size: .92rem;
  line-height: 1.6;
}
.help-pop p { margin: .3rem 0; }

@media (max-width: 640px) {
  .avatar-picker { grid-template-columns: repeat(2, 1fr); }
}

/* Hormati pengguna yang meminta gerakan minimal: matikan animasi berat. */
@media (prefers-reduced-motion: reduce) {
  .fx-float, .fx-shake, .fx-hit, .combo-badge, .fx-modal-card, .timer-wrap.low .timer-num { animation: none !important; }
  .hp-fill, .player-xp-fill, .daily-fill, .timer-fill, .world-card { transition: none !important; }
}
