/* ==========================================================================
   Chess Crush - Tema Kerajaan Gelap (Dark Royal)
   Palet, layout potret responsif, bingkai emas, dan tipografi kerajaan
   ========================================================================== */

:root {
  /* Palet Kerajaan Gelap (Bagian 20 SPEC.md) */
  --bg: #0d0b14;           /* Latar utama */
  --bg-2: #161126;         /* Panel & kartu kerajaan */
  --gold: #d4af37;         /* Emas aksen standar */
  --gold-light: #f2d675;   /* Kilau emas & highlight */
  --gold-dark: #8a6d1d;    /* Bayangan emas & border */
  --royal-purple: #4b2a7b; /* Ungu istana */
  --wine: #6e1423;         /* Merah anggur takhta */
  --text: #f3e9d2;         /* Teks krem kontras tinggi */
  --text-dim: #b9ad92;     /* Teks redup */
  --cell-dark: #1b1727;    /* Ubin batu marmer gelap */
  --cell-light: #2a2438;   /* Ubin batu marmer terang */

  /* Font */
  --font-royal: Georgia, "Times New Roman", serif;
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Level Theme Accents (default Level 1) */
  --level-bg-accent: #23123d;
  --level-glow: rgba(212, 175, 55, 0.25);
}

/* Reset & Mobile Viewport Constraints */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: #050408;
  color: var(--text);
  font-family: var(--font-ui);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  color-scheme: dark;
}

/* Bingkai Potret Desktop / Tablet (Maks ~480px, Terpusat di Layar) */
#app {
  width: 100%;
  max-width: 480px;
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 20%, var(--level-bg-accent) 0%, var(--bg) 80%);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9), 0 0 0 1px var(--gold-dark);
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
  touch-action: manipulation;
}

/* Tema Level */
#app.theme-aula-utama {
  --level-bg-accent: #2e124d;
  --level-glow: rgba(212, 175, 55, 0.25);
}
#app.theme-ruang-malam {
  --level-bg-accent: #0f1c3f;
  --level-glow: rgba(180, 205, 240, 0.25);
}
#app.theme-takhta {
  --level-bg-accent: #450c18;
  --level-glow: rgba(242, 214, 117, 0.35);
}

/* --------------------------------------------------------------------------
   1. HUD (Top Bar)
   -------------------------------------------------------------------------- */
#hud {
  flex: 0 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(22, 17, 38, 0.95) 0%, rgba(13, 11, 20, 0.8) 100%);
  border-bottom: 1px solid var(--gold-dark);
  z-index: 10;
}

.hud-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.hud-title {
  font-family: var(--font-royal);
  font-size: 1.15rem;
  font-weight: bold;
  color: var(--gold-light);
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
}
.crown-icon {
  width: 22px;
  height: 22px;
  fill: var(--gold);
}

.hud-stats {
  display: flex;
  gap: 12px;
  align-items: center;
}
.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  background: rgba(13, 11, 20, 0.6);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(212, 175, 55, 0.3);
}
.stat-label {
  font-size: 0.62rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.stat-value.moves {
  color: var(--gold-light);
}

.hud-actions {
  display: flex;
  gap: 6px;
}
.btn-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--gold-dark);
  background: var(--bg-2);
  color: var(--gold-light);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, background-color 0.2s;
}
.btn-icon:hover {
  background: #251d38;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}
.btn-icon:active {
  transform: scale(0.94);
}

/* --------------------------------------------------------------------------
   2. Papan Catur Mini & Progres Target
   -------------------------------------------------------------------------- */
#miniboard-section {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  min-height: 80px;
  max-height: 140px;
  background: rgba(22, 17, 38, 0.4);
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.miniboard-box {
  width: 80px;
  height: 80px;
  min-width: 80px;
  min-height: 80px;
  border: 2px solid var(--gold);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8), 0 0 8px rgba(212, 175, 55, 0.3);
  background: #110e1a;
  position: relative;
  overflow: hidden;
}

.miniboard-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
}
.mini-tile {
  width: 100%;
  height: 100%;
}
.mini-tile.light { background: #d7c49e; }
.mini-tile.dark { background: #4a3424; }

.mini-piece {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  transition: transform 0.35s ease;
  pointer-events: none;
}

.goals-progress-wrap {
  flex: 1;
  margin-left: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.goal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(13, 11, 20, 0.7);
  border: 1px solid rgba(212, 175, 55, 0.3);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
}
.goal-desc {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.goal-target {
  font-weight: 700;
  color: var(--gold-light);
}

/* --------------------------------------------------------------------------
   3. Papan Permainan (Main Board)
   -------------------------------------------------------------------------- */
#board-section {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 8px;
  min-height: 0; /* Penting untuk flex sizing */
}

/* Bingkai Emas Mengikuti Kontur Bentuk Papan */
.board-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none; /* Mencegah scroll dan gesture default */
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.board-inner {
  position: relative;
  background: transparent;
  overflow: visible; /* Biarkan pendaran stroke emas terlihat keluar */
}

.board-contour-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}

.cells-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.gems-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
}

.fx-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}

/* Ubin Papan Catur Marmer Gelap */
.board-cell-bg {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.35);
}
.board-cell-bg.cell-light {
  background-color: var(--cell-light);
  background-image: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.04) 0%, transparent 80%);
}
.board-cell-bg.cell-dark {
  background-color: var(--cell-dark);
}

/* Layer Permata & Bidak (DOM Persisten) */
.gem-element {
  position: absolute;
  top: 0;
  left: 0;
  cursor: grab;
  will-change: transform, opacity;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
}
.gem-element:active {
  cursor: grabbing;
}

.gem-svg {
  width: 90%;
  height: 90%;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
  transition: filter 0.15s ease;
  pointer-events: none;
}

/* Efek saat Permata Terangkat (Drag / Active) */
.gem-element.lifted {
  z-index: 50;
  cursor: grabbing;
}
.gem-element.lifted .gem-svg {
  transform: scale(1.15);
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 10px var(--gold));
}

/* Efek Sorot Tap Pertama (Tap-Tap Fallback) */
.gem-element.selected-pulse .gem-svg {
  animation: pulse-gold 1s infinite alternate ease-in-out;
}
@keyframes pulse-gold {
  0% { transform: scale(1.0); filter: drop-shadow(0 0 4px var(--gold)); }
  100% { transform: scale(1.12); filter: drop-shadow(0 0 12px var(--gold-light)); }
}

/* Bidak Catur Spesial (Emas Metalik) */
.gem-element.piece .gem-svg {
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 6px rgba(212, 175, 55, 0.6));
}

/* Mode Membidik Palu */
#board-section.targeting-hammer {
  cursor: crosshair;
}
#board-section.targeting-hammer .board-frame {
  box-shadow: 0 0 25px rgba(255, 71, 87, 0.4);
}
#board-section.targeting-hammer .gem-element {
  cursor: crosshair;
}
#board-section.targeting-hammer .gem-element:hover .gem-svg {
  transform: scale(1.14);
  filter: drop-shadow(0 0 8px #ff4757) drop-shadow(0 0 16px var(--gold));
}

/* Sinar Efek Sapuan Bidak */
.piece-beam-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 55;
  overflow: visible;
}

/* Slot Skill & Bottom Bar */
#bottom-bar {
  flex: 0 0 auto;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: linear-gradient(0deg, rgba(22, 17, 38, 0.95) 0%, rgba(13, 11, 20, 0.8) 100%);
  border-top: 1px solid var(--gold-dark);
  z-index: 10;
}

.skills-wrapper {
  display: flex;
  gap: 12px;
  align-items: center;
}
.skill-slot {
  width: 54px;
  height: 54px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  border: 2px dashed var(--gold-dark);
  background: rgba(13, 11, 20, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
}
.skill-slot.has-skill {
  border-style: solid;
  border-color: var(--gold);
  background: radial-gradient(circle, #2a1f42 0%, #161126 100%);
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}
.skill-slot.has-skill:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 14px var(--gold-light);
}
.skill-slot.active-targeting {
  border-color: #ff4757;
  animation: pulse-red 0.8s infinite alternate;
}
@keyframes pulse-red {
  0% { box-shadow: 0 0 4px #ff4757; }
  100% { box-shadow: 0 0 14px #ff4757; }
}

.skill-icon {
  width: 32px;
  height: 32px;
  fill: var(--gold-light);
}

.bottom-actions {
  display: flex;
  gap: 10px;
}
.btn-royal {
  height: 44px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, #241c38 0%, #161126 100%);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-royal:hover {
  background: linear-gradient(180deg, #32274d 0%, #201836 100%);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}
.btn-royal:active {
  transform: scale(0.96);
}

/* --------------------------------------------------------------------------
   5. Banner Kombo & Skor Melayang
   -------------------------------------------------------------------------- */
.combo-banner {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-family: var(--font-royal);
  font-size: 2rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 10px var(--gold), 0 0 20px var(--gold-dark);
  background: rgba(22, 17, 38, 0.9);
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 6px 18px;
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.combo-banner.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.floating-score {
  position: absolute;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--gold-light);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  z-index: 60;
  transition: transform 0.6s ease-out, opacity 0.6s ease-out;
}

/* Toast */
.toast-msg {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(22, 17, 38, 0.95);
  border: 1px solid var(--gold);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 120;
  opacity: 0;
  transition: opacity 0.2s;
}
.toast-msg.show {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   6. Layar-Layar UI (Menu, Level Select, Game, Achievements)
   -------------------------------------------------------------------------- */
.screen-view {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
}

/* Menu Utama */
#screen-menu {
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #2b1347 0%, #0d0b14 85%);
  overflow: hidden;
  z-index: 10;
}
.embers-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}
.gold-ember {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #f2d675;
  border-radius: 50%;
  box-shadow: 0 0 8px #d4af37, 0 0 16px #f2d675;
  opacity: 0;
  animation: ember-float 4s infinite linear;
}
@keyframes ember-float {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  20% { opacity: 0.8; }
  80% { opacity: 0.6; }
  100% { transform: translateY(-300px) scale(1.2); opacity: 0; }
}

.menu-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 85%;
  max-width: 360px;
  text-align: center;
}
.menu-crown-wrap {
  margin-bottom: 8px;
  animation: gentle-bob 3s infinite ease-in-out;
}
@keyframes gentle-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.royal-large-crown {
  width: 80px;
  height: 56px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.8));
}
.menu-title {
  font-family: var(--font-royal);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 1px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9), 0 0 15px rgba(212, 175, 55, 0.4);
  margin-bottom: 4px;
}
.menu-subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 28px;
}
.menu-buttons-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.menu-btn {
  width: 100%;
  height: 48px;
  min-height: 48px;
  font-size: 1rem;
  justify-content: center;
  gap: 10px;
}
.menu-btn.primary-btn {
  background: linear-gradient(180deg, #44206b 0%, #220d3b 100%);
  border-color: var(--gold-light);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
}
.menu-footer {
  margin-top: 24px;
}

/* Header Sub-layar (Level Select & Achievements) */
.subscreen-header {
  flex: 0 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 14px;
  background: rgba(22, 17, 38, 0.95);
  border-bottom: 1px solid var(--gold-dark);
}
.subscreen-title {
  font-family: var(--font-royal);
  font-size: 1.2rem;
  color: var(--gold-light);
}
.back-btn {
  width: 44px;
  height: 44px;
}

/* Kartu Level */
.level-cards-scroll-wrap {
  flex: 1 1 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.level-card {
  background: linear-gradient(135deg, rgba(22, 17, 38, 0.9) 0%, rgba(13, 11, 20, 0.95) 100%);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.7);
  transition: transform 0.2s;
}
.level-card.locked {
  opacity: 0.6;
  border-color: #4a3c20;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-badge {
  font-size: 0.75rem;
  color: var(--gold);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.card-status {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.card-title {
  font-family: var(--font-royal);
  font-size: 1.25rem;
  color: var(--text);
}
.card-goal {
  font-size: 0.85rem;
  color: var(--gold-light);
}
.card-score-box {
  display: flex;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
}
.score-label { color: var(--text-dim); }
.score-value { font-weight: 700; color: #fff; }
.card-play-btn {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

/* Kartu Achievements */
.achievements-scroll-wrap {
  flex: 1 1 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.achievement-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(22, 17, 38, 0.85);
  border: 1px solid var(--gold-dark);
  border-radius: 10px;
  padding: 12px;
}
.achievement-item.unlocked {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.25);
}
.ach-medal-icon {
  font-size: 1.8rem;
}
.ach-details {
  flex: 1;
}
.ach-title-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
}
.ach-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gold-light);
}
.ach-progress-num {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.ach-desc {
  font-size: 0.78rem;
  color: var(--text);
  margin-bottom: 6px;
}
.ach-progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 3px;
  overflow: hidden;
}
.ach-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark) 0%, var(--gold-light) 100%);
  border-radius: 3px;
}

/* Modals (Pause, Win, Lose) */
.royal-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(13, 11, 20, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250;
  padding: 20px;
}
.royal-modal-box {
  position: relative;
  width: 100%;
  max-width: 330px;
  background: linear-gradient(180deg, #1f1733 0%, #120e1e 100%);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.95), 0 0 20px rgba(212, 175, 55, 0.3);
}
.modal-title {
  font-family: var(--font-royal);
  font-size: 1.5rem;
  color: var(--gold-light);
  margin-bottom: 6px;
}
.modal-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 18px;
}
.victory-crown-icon { font-size: 2.8rem; margin-bottom: 4px; }
.defeat-icon { font-size: 2.5rem; margin-bottom: 4px; }
.final-score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 20px;
}
.score-caption { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; }
.score-number { font-size: 1.8rem; font-weight: 800; color: #fff; }
.new-record-pill {
  background: linear-gradient(90deg, #d4af37, #f2d675);
  color: #1b1727;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 12px;
  margin-top: 4px;
  box-shadow: 0 0 10px rgba(242, 214, 117, 0.6);
}
.missing-goals-box {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.missing-goal-item {
  font-size: 0.8rem;
  color: #ff6b81;
}
.modal-buttons-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-action-btn {
  width: 100%;
  justify-content: center;
}

/* Skakmat Getar Merah pada Raja Hitam */
.checkmate-shake-red {
  animation: shake-red-anim 0.5s infinite;
  filter: drop-shadow(0 0 12px #ff4757) drop-shadow(0 0 24px #e6193c) !important;
}
@keyframes shake-red-anim {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); }
  25% { transform: translate3d(-3px, 2px, 0) rotate(-4deg); }
  50% { transform: translate3d(3px, -2px, 0) rotate(4deg); }
  75% { transform: translate3d(-2px, -3px, 0) rotate(-3deg); }
  100% { transform: translate3d(2px, 2px, 0) rotate(3deg); }
}

/* Sinematik Backdrop & Stage */
.cinematic-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #08050e;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.cinematic-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
/* Obor Api */
.torch {
  position: absolute;
  top: 25%;
  width: 24px;
  height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.torch.left-torch { left: 16px; }
.torch.right-torch { right: 16px; }
.torch-flame {
  width: 18px;
  height: 28px;
  background: radial-gradient(circle at 50% 60%, #fff 0%, #ffbe1a 40%, #e63900 85%, transparent 100%);
  border-radius: 50% 50% 20% 20%;
  filter: drop-shadow(0 0 12px #ff9900);
  animation: flicker 0.2s infinite alternate ease-in-out;
}
@keyframes flicker {
  0% { transform: scale(1) rotate(-2deg); }
  100% { transform: scale(1.15) rotate(2deg); }
}
.torch-handle {
  width: 6px;
  height: 36px;
  background: #4a2810;
  border-radius: 2px;
}

.king-duel-wrapper {
  position: relative;
  width: 280px;
  height: 160px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
}
.white-king-cinema {
  width: 90px;
  height: 110px;
  animation: white-king-advance 2.8s forwards ease-out;
}
@keyframes white-king-advance {
  0% { transform: translateX(0); }
  60% { transform: translateX(50px); }
  100% { transform: translateX(65px); }
}
.black-king-cinema {
  width: 90px;
  height: 110px;
  position: relative;
  animation: black-king-topple 3s forwards ease-in-out;
}
@keyframes black-king-topple {
  0%, 45% { transform: rotate(0deg); opacity: 1; }
  75% { transform: rotate(65deg) translateY(20px); }
  100% { transform: rotate(88deg) translateY(38px); opacity: 0.85; }
}
.falling-crown {
  position: absolute;
  top: 10px;
  left: 30px;
  animation: crown-drop 2.5s forwards ease-in;
}
@keyframes crown-drop {
  0%, 45% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  75% { transform: translate(25px, 60px) rotate(120deg); opacity: 1; }
  100% { transform: translate(35px, 95px) rotate(190deg); opacity: 0.9; }
}

.gold-confetti {
  position: absolute;
  top: -10px;
  width: 7px;
  height: 7px;
  background: var(--gold-light);
  box-shadow: 0 0 6px var(--gold);
  border-radius: 1px;
  animation: confetti-fall 3s infinite linear;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(500px) rotate(720deg); opacity: 0; }
}

.cinematic-ending-banner {
  position: absolute;
  bottom: 100px;
  width: 90%;
  text-align: center;
  font-family: var(--font-royal);
  font-size: 1.15rem;
  color: var(--gold-light);
  line-height: 1.5;
  text-shadow: 0 0 14px rgba(212, 175, 55, 0.7);
  animation: fade-in 1.5s ease-out;
}
@keyframes fade-in {
  0% { opacity: 0; transform: translateY(15px); }
  100% { opacity: 1; transform: translateY(0); }
}
.skip-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 310;
  font-size: 0.85rem;
  padding: 0 14px;
}

/* --------------------------------------------------------------------------
   7. Overlay Lanskap ("Putar perangkat ke potret")
   -------------------------------------------------------------------------- */
#landscape-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(13, 11, 20, 0.98);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--gold-light);
  text-align: center;
  padding: 20px;
}
#landscape-overlay .rotate-phone-icon {
  width: 56px;
  height: 56px;
  fill: var(--gold);
  margin-bottom: 16px;
  animation: rotate-anim 2s infinite ease-in-out;
}
@keyframes rotate-anim {
  0% { transform: rotate(90deg); }
  50% { transform: rotate(0deg); }
  100% { transform: rotate(90deg); }
}

@media (orientation: landscape) and (pointer: coarse) {
  #landscape-overlay {
    display: flex;
  }
}

/* Hormati prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
