:root {
  --bg-primary: #05070a;
  --bg-hud: rgba(10, 14, 22, 0.94);
  --border-gold: #ffd700;
  --border-gold-glow: rgba(255, 215, 0, 0.7);
  --border-subtle: rgba(255, 215, 0, 0.4);
  --text-main: #ffffff;
  --text-muted: #ffe57f;
  --text-gold: #ffd700;
  --gold-glow: rgba(255, 215, 0, 0.6);
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'DM Sans', -apple-system, sans-serif;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
}

/* Accessibility & Search Crawler Semantic Layer */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  position: relative;
}

#three-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* Atmospheric vignette */
.vignette {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, transparent 45%, rgba(10, 13, 18, 0.75) 100%);
}

/* ============================================================
   HUD (HEADS UP DISPLAY) - FLOATING OVER 3D CANVAS
   ============================================================ */

/* Top Navigation Bar */
.hud-top {
  position: absolute;
  top: 20px;
  left: 24px;
  right: 24px;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Auto hide top HUD when reading a card so it NEVER blocks the card title */
body.card-reading-mode .hud-top {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(-24px) !important;
}

.brand-capsule {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(12, 16, 24, 0.94);
  border: 2px solid #ffd700;
  backdrop-filter: blur(20px);
  padding: 10px 22px;
  border-radius: 32px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8), 0 0 25px rgba(255, 215, 0, 0.4);
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: linear-gradient(135deg, #fff3b0, #ffd700, #ffb300);
  color: #05070a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  font-style: italic;
  box-shadow: 0 0 14px #ffd700;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
}

/* Phase Progress Indicator (61 Bab Counter) */
.phase-indicator {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(12, 16, 24, 0.94);
  border: 2px solid #ffd700;
  backdrop-filter: blur(20px);
  padding: 10px 22px;
  border-radius: 32px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8), 0 0 25px rgba(255, 215, 0, 0.4);
}

.phase-btn {
  background: transparent;
  border: none;
  font-size: 0.9rem;
  color: #ffe57f;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: var(--font-sans);
}

.phase-btn:hover {
  color: #fff;
  text-shadow: 0 0 8px #ffd700;
}

.phase-btn.active {
  background: rgba(255, 215, 0, 0.2);
  color: #ffd700;
  font-weight: 600;
  border: 1px solid #ffd700;
}

/* Top Right Help / Guide */
.top-actions {
  pointer-events: auto;
  display: flex;
  gap: 10px;
}

.btn-icon {
  background: rgba(12, 16, 24, 0.94);
  border: 2px solid #ffd700;
  color: #ffd700;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(16px);
  transition: all 0.2s ease;
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.35);
}

.btn-icon:hover {
  color: #ffffff;
  border-color: #ffffff;
  background: rgba(255, 215, 0, 0.25);
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.7);
}

/* Bottom Control Deck — Proporsional, Elegan, 1 Baris Seimbang */
.hud-bottom {
  position: absolute;
  bottom: 38px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: auto;
  pointer-events: none;
}

.bottom-deck {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(10, 14, 22, 0.95);
  border: 2px solid #ffd700;
  backdrop-filter: blur(24px);
  padding: 8px 14px;
  border-radius: 36px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.85), 0 0 28px rgba(255, 215, 0, 0.35);
  width: auto;
  flex-wrap: nowrap;
}

.btn-action {
  font-family: var(--font-sans);
  font-size: 0.96rem;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: 26px;
  border: 1.5px solid rgba(255, 215, 0, 0.6);
  background: rgba(22, 28, 42, 0.92);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

.btn-action span {
  font-size: 1.05rem;
  color: #ffd700;
  filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.8));
}

.btn-action:hover {
  background: rgba(255, 215, 0, 0.22);
  border-color: #ffd700;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.45);
}

.btn-action.gold {
  background: linear-gradient(135deg, #fff9c4 0%, #ffd700 45%, #f59e0b 100%);
  color: #06090d;
  font-weight: 700;
  border: 1.5px solid #ffffff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.7), 0 0 25px rgba(255, 215, 0, 0.6);
}

.btn-action.gold span {
  color: #06090d;
  filter: none;
}

.btn-action.gold:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #ffffff 0%, #ffe082 45%, #ffb300 100%);
  box-shadow: 0 8px 25px rgba(255, 220, 100, 0.85);
}

/* Mode "Pecah & Geser Bebas": tombol lepas dari susunan panel, jadi bisa ditaro di mana aja */
.btn-action.menu-scattered-btn {
  position: fixed !important;
  z-index: 999999;
  margin: 0 !important;
  transform-origin: center center;
  transition: left 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
              top 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s ease;
  touch-action: none;
  cursor: grab;
}

.btn-action.menu-scattered-btn:active {
  cursor: grabbing;
  box-shadow: 0 10px 30px rgba(255, 215, 0, 0.55);
}

/* Panel induknya "melebur"/transparan begitu isinya pecah nyebar, biar gak nyisain kotak kosong */
.bottom-deck.menu-dissolved {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

/* ============================================================
   CARD INSPECTION MODAL (READING GLASS)
   ============================================================ */
.reading-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  background: rgba(8, 11, 15, 0.85);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.reading-modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.reading-modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  background: linear-gradient(145deg, #131922 0%, #0d1117 100%);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  padding: 42px 36px 36px;
  position: relative;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 50px rgba(255, 215, 0, 0.2);
  transform: translateY(20px) scale(0.96);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.reading-modal-backdrop.active .reading-modal-card {
  transform: translateY(0) scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close-btn:hover {
  color: #fff;
}

.card-tag {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-gold);
  margin-bottom: 12px;
  display: block;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  line-height: 1.2;
  color: #fff;
  margin-bottom: 16px;
  font-weight: 400;
}

.card-lead {
  font-size: 1.1rem;
  color: #d1d5db;
  line-height: 1.6;
  margin-bottom: 24px;
}

.card-quote-box {
  padding: 20px 24px;
  background: rgba(212, 175, 55, 0.08);
  border-left: 3px solid var(--text-gold);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 24px 0;
}

.card-quote-box p {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-style: italic;
  line-height: 1.45;
  color: #f5eed8;
}

.card-body-text {
  font-size: 1rem;
  color: #9aa2ac;
  line-height: 1.7;
  white-space: pre-line;
  margin-bottom: 24px;
}

.card-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 20px 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  margin: 24px 0;
  text-align: center;
}

.card-metrics-row strong {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  color: var(--text-gold);
  line-height: 1;
  display: block;
}

.card-metrics-row span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Modal Bottom Navigation */
.modal-bottom-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

/* ============================================================
   INTRO MENU MODAL (4 KATA PENGANTAR)
   ============================================================ */
.intro-modal-custom {
  max-width: 720px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.intro-tabs-header {
  margin-bottom: 16px;
  padding-right: 36px;
}

.intro-modal-headline {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 600;
  color: #ffd700;
  margin-bottom: 4px;
}

.intro-modal-subline {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.intro-nav-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 215, 0, 0.25);
  scrollbar-width: none;
}

.intro-nav-tabs::-webkit-scrollbar {
  display: none;
}

.intro-tab-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 215, 0, 0.3);
  background: rgba(255, 255, 255, 0.04);
  color: #d1d5db;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.intro-tab-btn:hover {
  background: rgba(255, 215, 0, 0.12);
  color: #fff;
  border-color: #ffd700;
}

.intro-tab-btn.active {
  background: linear-gradient(135deg, #ffd700, #ffb300);
  color: #05070a;
  border-color: #ffd700;
  box-shadow: 0 0 14px rgba(255, 215, 0, 0.5);
}

.intro-card-display {
  overflow-y: auto;
  padding-right: 8px;
  margin-top: 4px;
}

/* ============================================================
   LEVEL SELECTOR DRAWER (FOR CHAPTERS 1-60)
   ============================================================ */
.level-selector-drawer {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 25;
  background: var(--bg-hud);
  border: 1px solid var(--border-gold);
  backdrop-filter: blur(20px);
  padding: 14px 20px;
  border-radius: 30px;
  display: flex;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.level-selector-drawer.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.lvl-chip {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 0.84rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.lvl-chip:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.lvl-chip.active {
  background: var(--text-gold);
  color: #0d1116;
  font-weight: 600;
  border-color: var(--text-gold);
}

/* Mobile Responsiveness & High Performance Touch Experience */
@media (max-width: 768px) {
  .hud-top {
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .brand-capsule {
    padding: 5px 12px;
    gap: 7px;
    border-radius: 20px;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
  }
  .brand-mark {
    width: 22px;
    height: 22px;
    min-width: 22px;
    font-size: 0.85rem;
  }
  .brand-title {
    font-size: 0.80rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .phase-indicator {
    padding: 5px 12px;
    border-radius: 20px;
    flex-shrink: 0;
    white-space: nowrap;
  }
  #deck-status-text {
    font-size: 0.78rem !important;
    white-space: nowrap;
  }
  .hud-bottom {
    bottom: 16px;
  }
  .bottom-deck {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    border-radius: 18px;
    padding: 7px 8px;
    gap: 6px 8px;
    max-width: 78vw;
    border-width: 1.5px;
  }
  .btn-action {
    font-size: 0.72rem;
    padding: 7px 9px;
    border-radius: 16px;
    gap: 4px;
    white-space: nowrap;
  }
  .reading-modal-backdrop {
    padding: 16px 12px;
  }
  .reading-modal-card {
    padding: 24px 16px 32px;
    max-height: 86vh;
    border-radius: 18px;
    overflow-x: hidden;
  }
  .modal-bottom-nav {
    display: flex;
    flex-direction: column-reverse;
    gap: 14px;
    align-items: center;
    margin-top: 26px;
    padding-top: 18px;
    padding-bottom: 8px;
    width: 100%;
    box-sizing: border-box;
  }
  .modal-bottom-nav .btn-action {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    justify-content: center;
    padding: 12px 18px;
    font-size: 0.92rem;
    border-radius: 24px;
    box-shadow: 0 4px 18px rgba(255, 215, 0, 0.28);
  }
  .modal-bottom-nav span {
    font-size: 0.78rem !important;
    text-align: center;
    color: var(--text-muted);
    opacity: 0.85;
  }
  .card-title {
    font-size: 1.55rem;
    line-height: 1.25;
  }
  .card-lead {
    font-size: 0.95rem;
  }
  .card-quote-box {
    padding: 14px 16px;
    margin: 16px 0;
  }
  .card-quote-box p {
    font-size: 1.12rem;
  }
  .intro-modal-custom {
    padding: 22px 16px 18px;
    max-height: 88vh;
  }
  .intro-modal-headline {
    font-size: 1.4rem;
  }
  .intro-nav-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    overflow-x: visible;
    padding-bottom: 12px;
    margin-bottom: 16px;
  }
  .intro-tab-btn {
    width: 100%;
    padding: 8px 6px;
    font-size: 0.78rem;
    text-align: center;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 380px) {
  .brand-title {
    display: none;
  }
  .btn-action {
    font-size: 0.68rem;
    padding: 6px 8px;
  }
  .bottom-deck {
    max-width: 84vw;
  }
}
