:root {
  --zone-accent: #f59e0b;
  --zone-accent-ink: #b45309;
  --zone-accent-soft: rgba(245, 158, 11, 0.14);
  --zone-accent-border: rgba(245, 158, 11, 0.42);
  --zone-accent-fg: #111827;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: #e6e4de; color: #0f172a;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  touch-action: none; user-select: none;
}

#canvas3d { display: block; width: 100%; height: 100%; }

.hidden { display: none !important; }

/* HUD Atas Bright Frosted Glass */
#hud-top {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  right: calc(10px + env(safe-area-inset-right));
  z-index: 10;
  display: flex; flex-direction: column; gap: 7px;
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(15, 23, 42, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
}

.hud-row-main {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

.hud-actions-right {
  display: flex; align-items: center; gap: 6px;
}

.hud-btn, .hud-icon-btn {
  min-height: 35px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 10px;
  background: rgba(241, 245, 249, 0.92);
  color: #0f172a; font-size: 12.5px; font-weight: 700;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.hud-btn { min-width: 52px; padding: 6px 10px; }
.hud-icon-btn {
  width: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.hud-icon-btn.is-muted {
  color: #dc2626;
  border-color: #fca5a5;
  background: #fee2e2;
}
.hud-btn:active, .hud-icon-btn:active { transform: scale(0.95); background: #e2e8f0; }

#zone-meta { flex: 1; min-width: 0; text-align: center; }
#zone-title {
  font-size: 13px; font-weight: 800; color: #0f172a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#zone-progress { font-size: 11px; font-weight: 600; color: #475569; margin-top: 1px; }

#zone-progress-bar {
  width: 100%; height: 4.5px; margin-top: 4px;
  border-radius: 999px; overflow: hidden;
  background: rgba(15, 23, 42, 0.1);
}
#zone-progress-fill {
  height: 100%; width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--zone-accent), #10b981);
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Sakelar Mode Eksplorasi | Patroli | Kasus TWK */
.hud-mode-bar {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  padding: 3px;
  border-radius: 11px;
  background: rgba(226, 232, 240, 0.78);
  border: 1px solid rgba(15, 23, 42, 0.08);
}
.mode-btn {
  padding: 6px 4px; border: none; border-radius: 8px;
  background: transparent; color: #475569;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.mode-btn.active {
  background: var(--zone-accent);
  color: var(--zone-accent-fg);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}
#btn-mode-patrol.active {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #ffffff;
}
#btn-mode-twk.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
}

/* Toast Pencapaian & Feedback */
#toast {
  position: fixed;
  top: calc(114px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(88vw, 340px);
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(236, 253, 245, 0.96);
  border: 1.5px solid #10b981;
  color: #065f46;
  font-size: 13px; font-weight: 700; text-align: center;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: tabFadeIn 0.2s ease;
}
#toast.is-error {
  background: rgba(254, 242, 242, 0.96);
  border-color: #ef4444;
  color: #991b1b;
}

/* Radar Minimap 2D Terang */
#minimap-wrap {
  position: fixed;
  top: calc(114px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  z-index: 9;
  padding: 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(15, 23, 42, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  pointer-events: none;
  transition: top 0.22s ease, opacity 0.18s ease, transform 0.18s ease;
}
body.twk-card-expanded #minimap-wrap {
  opacity: 0;
  transform: translateY(-6px) scale(0.95);
}
body.twk-card-collapsed #minimap-wrap {
  top: calc(162px + env(safe-area-inset-top));
}
.minimap-label {
  font-size: 9px; font-weight: 800; letter-spacing: 0.08em;
  color: #475569; text-align: center; margin-bottom: 4px;
}
#minimap { display: block; width: 84px; height: 104px; border-radius: 8px; }

/* Reticle Kontras Ganda (Jelas di atas dinding putih maupun objek warna-warni) */
#reticle {
  position: fixed; top: 50%; left: 50%; z-index: 5;
  width: 11px; height: 11px; border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid #ffffff;
  background: rgba(15, 23, 42, 0.22);
  box-shadow: 0 0 0 1.5px rgba(15, 23, 42, 0.78), 0 2px 6px rgba(15, 23, 42, 0.25);
  pointer-events: none;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
#reticle.active {
  transform: translate(-50%, -50%) scale(1.7);
  border-color: var(--zone-accent);
  background: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.85), 0 4px 10px rgba(15, 23, 42, 0.24);
}
#reticle.active.is-portal {
  border-color: #10b981;
}
#reticle.active.is-mystery {
  border-color: #8b5cf6;
}
#reticle.active.is-twk {
  border-color: #2563eb;
}

#reticle-label {
  position: fixed; top: calc(50% + 24px); left: 50%; z-index: 6;
  transform: translateX(-50%);
  max-width: min(76vw, 290px);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1.5px solid var(--zone-accent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #0f172a; font-size: 12px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
}
#reticle-label.is-portal {
  border-color: #10b981;
  background: rgba(236, 253, 245, 0.95);
  color: #065f46;
}
#reticle-label.is-mystery {
  border-color: #8b5cf6;
  background: rgba(245, 243, 255, 0.95);
  color: #4c1d95;
}
#reticle-label.is-twk {
  border-color: #2563eb;
  background: rgba(239, 246, 255, 0.95);
  color: #1e40af;
}

/* Floating Joystick Terang */
#joy-base {
  position: fixed; z-index: 8; width: 112px; height: 112px;
  border-radius: 50%;
  border: 2px solid rgba(15, 23, 42, 0.24);
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  pointer-events: none;
  transform: translate(-50%, -50%);
}
#joy-knob {
  position: absolute; top: 50%; left: 50%; width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--zone-accent);
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.22);
  transform: translate(-50%, -50%);
}

/* Tombol Aksi Ergonomis Jempol Kanan-Bawah */
#btn-action {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 12;
  min-height: 48px; max-width: 64vw;
  padding: 13px 20px; border: 1.5px solid rgba(15, 23, 42, 0.14);
  border-radius: 16px;
  background: var(--zone-accent);
  color: var(--zone-accent-fg); font-weight: 800; font-size: 14px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
  transition: transform 0.12s ease, filter 0.15s ease;
}
#btn-action:active { transform: scale(0.96); }
#btn-action.is-portal {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
}
#btn-action.is-mystery {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #ffffff;
}
#btn-action.is-twk {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
}

/* Bottom Sheet Terang dengan Drag Handle & Transisi Halus */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-height: 68vh; display: flex; flex-direction: column;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 -10px 32px rgba(15, 23, 42, 0.14);
  transform: translateY(105%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease, visibility 0.28s ease;
}
.sheet.is-open {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.sheet-panel {
  display: flex; flex-direction: column; flex: 1; min-height: 0;
}

.sheet-handle {
  display: flex; justify-content: center; padding: 4px 0 10px;
  cursor: grab;
}
.sheet-handle span {
  width: 42px; height: 4px; border-radius: 999px;
  background: rgba(148, 163, 184, 0.6);
}

.sheet-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  margin-bottom: 10px;
}
.sheet-header h2 { font-size: 16.5px; line-height: 1.3; margin-top: 4px; color: #0f172a; }
.sheet-header h3 { font-size: 17px; margin-top: 3px; color: #0f172a; }
.sheet-header button {
  padding: 7px 12px; border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #f1f5f9; color: #334155;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}

.badge {
  display: inline-block;
  padding: 2px 9px; border-radius: 999px;
  background: var(--zone-accent-soft);
  border: 1px solid var(--zone-accent-border);
  font-size: 11px; color: var(--zone-accent-ink); font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.04em;
}

.sheet-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab-btn {
  flex: 1; padding: 9px 6px;
  border: 1px solid #e2e8f0; border-radius: 10px;
  background: #f1f5f9; color: #475569;
  font-size: 12px; font-weight: 700;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.tab-btn.active {
  background: var(--zone-accent); color: var(--zone-accent-fg); border-color: var(--zone-accent);
}

.sheet-body {
  overflow-y: auto; touch-action: pan-y; flex: 1;
  font-size: 14px; line-height: 1.6; color: #1e293b;
  padding-right: 2px;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: tabFadeIn 0.18s ease; }
.tab-pane p { margin-bottom: 10px; color: #1e293b; }

.keyword-chip {
  padding: 9px 12px; margin-bottom: 10px; border-radius: 10px;
  background: var(--zone-accent-soft);
  border: 1px solid var(--zone-accent-border);
  color: #0f172a; font-size: 13.5px;
}

/* Tab pemilih Ayat pada Pasal multi-ayat */
.verse-tabs {
  display: flex; gap: 5px; overflow-x: auto;
  padding-bottom: 4px; margin-bottom: 8px;
  scrollbar-width: none; touch-action: pan-x;
}
.verse-tabs::-webkit-scrollbar { display: none; }
.verse-tab-btn {
  flex-shrink: 0; padding: 5px 10px; border-radius: 999px;
  border: 1px solid #cbd5e1; background: #ffffff; color: #475569;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.verse-tab-btn.active {
  background: var(--zone-accent-soft);
  border-color: var(--zone-accent-border);
  color: var(--zone-accent-ink);
}
.verse-block + .verse-block {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed #cbd5e1;
}
.verse-block-label {
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--zone-accent-ink); margin-bottom: 4px;
}

/* Cloze Preview di Mode Eksplorasi */
.cloze-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
  margin-bottom: 8px;
}
.cloze-toolbar-label {
  font-size: 11.5px; color: #475569; font-weight: 700; margin-right: 2px;
}
.cloze-mode-btn {
  padding: 5px 9px; border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f1f5f9; color: #334155;
  font-size: 11.5px; font-weight: 700;
}
.cloze-mode-btn.active {
  background: var(--zone-accent); color: var(--zone-accent-fg); border-color: var(--zone-accent);
}

.verbatim-box {
  padding: 12px; border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3.5px solid var(--zone-accent);
  font-size: 13.5px; line-height: 1.75; color: #0f172a;
}

.cloze-reveal-chip {
  display: inline-block;
  padding: 1px 6px; margin: 1px 1px;
  border-radius: 6px;
  border: 1.5px dashed #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
  font: inherit; font-weight: 700; font-size: 13px;
  line-height: 1.4;
}
.cloze-reveal-chip.is-revealed {
  border-style: solid;
  border-color: #10b981;
  background: #ecfdf5;
  color: #047857;
}

.sheet-footer { margin-top: 10px; }
#btn-mark-done {
  width: 100%; padding: 12px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff; font-weight: 800; font-size: 14px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  transition: transform 0.12s ease, opacity 0.15s ease;
}
#btn-mark-done:active { transform: scale(0.98); }
#btn-mark-done.is-done {
  background: #ecfdf5;
  border: 1.5px solid #10b981;
  color: #047857;
  box-shadow: none;
}

/* Mode Patroli Kuis 2 Langkah */
.patrol-step-pill {
  display: inline-block; align-self: flex-start;
  margin-bottom: 8px; padding: 4px 10px; border-radius: 999px;
  background: #f3e8ff;
  border: 1px solid #c4b5fd;
  color: #6d28d9; font-size: 11.5px; font-weight: 800;
}
.patrol-prompt {
  font-size: 13.5px; color: #334155; font-weight: 500; margin-bottom: 10px;
}

.quiz-options {
  display: flex; flex-direction: column; gap: 8px;
}
.quiz-option-btn {
  width: 100%; text-align: left; padding: 11px 12px; border-radius: 12px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc; color: #0f172a;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}
.quiz-option-btn:active { transform: scale(0.98); }
.quiz-option-btn.is-wrong {
  border-color: #fb7185;
  background: #fff1f2;
  color: #be123c;
  opacity: 0.78;
}
.quiz-opt-code { display: block; font-size: 13px; font-weight: 800; color: var(--zone-accent-ink); }
.quiz-opt-key { display: block; font-size: 12.5px; color: #475569; margin-top: 2px; }

.patrol-blank {
  display: inline-block;
  padding: 1px 7px; margin: 2px 1px;
  border-radius: 7px;
  border: 1.5px dashed #94a3b8;
  background: #f1f5f9;
  color: #334155;
  font: inherit; font-weight: 700; font-size: 13px; line-height: 1.45;
}
.patrol-blank.is-active {
  border-color: #d97706;
  background: #fef3c7;
  color: #92400e;
}
.patrol-blank.is-filled {
  border-style: solid;
  border-color: #0284c7;
  background: #e0f2fe;
  color: #0369a1;
}
.patrol-blank.is-wrong {
  border-style: solid;
  border-color: #e11d48;
  background: #ffe4e6;
  color: #be123c;
}
.patrol-blank.is-correct {
  border-style: solid;
  border-color: #10b981;
  background: #d1fae5;
  color: #047857;
}

.word-bank {
  display: flex; flex-wrap: wrap; gap: 7px;
  margin-top: 12px;
}
.bank-chip {
  padding: 8px 12px; border-radius: 10px;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a; font-size: 13px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.bank-chip:active { transform: scale(0.95); background: #f1f5f9; }
.bank-chip.is-used {
  opacity: 0.3; pointer-events: none;
}

.patrol-feedback {
  margin-top: 8px; padding: 8px 10px; border-radius: 9px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #b91c1c; font-size: 12.5px; font-weight: 600; line-height: 1.4;
}
.patrol-feedback.is-success {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #065f46;
}

.patrol-footer {
  display: flex; gap: 8px; margin-top: 10px;
}
.patrol-btn-secondary {
  padding: 11px 14px; border-radius: 11px;
  border: 1px solid #cbd5e1;
  background: #f1f5f9; color: #334155;
  font-size: 13px; font-weight: 700;
}
.patrol-btn-primary {
  flex: 1; padding: 11px 14px; border: none; border-radius: 11px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff; font-size: 13.5px; font-weight: 800;
}
.patrol-btn-primary:disabled {
  opacity: 0.45;
}

/* Modal Pilih Ruangan Istana & Backup */
.modal {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(15, 23, 42, 0.36);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}
.modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.modal-card {
  width: 100%; max-width: 390px; max-height: 86vh; overflow-y: auto;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.18);
  transform: translateY(14px) scale(0.97);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal.is-open .modal-card { transform: translateY(0) scale(1); }

#zone-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 8px; max-height: 44vh; overflow-y: auto;
  padding-right: 4px; touch-action: pan-y; overscroll-behavior: contain;
}
.zone-modal-card {
  display: flex; flex-direction: column;
  max-height: 88dvh;
}
.zone-header-badges {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.zone-online-badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 999px;
  background: #ecfdf5; border: 1px solid #6ee7b7;
  color: #047857; font-size: 10.5px; font-weight: 800;
}
.zone-online-badge.is-offline {
  background: #fffbeb; border-color: #fcd34d; color: #b45309;
}

.zone-global-summary {
  padding: 10px 11px; border-radius: 13px;
  background: #f8fafc; border: 1px solid #e2e8f0;
  margin-bottom: 9px;
}
.zone-global-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.zone-global-title { font-size: 12px; font-weight: 800; color: #0f172a; }
.zone-global-fraction { font-size: 11.5px; font-weight: 700; color: #047857; }
.zone-mastery-badge {
  margin-bottom: 6px; padding: 5px 10px; border-radius: 999px;
  background: linear-gradient(135deg, #f59e0b, #10b981);
  color: #ffffff; font-size: 11.5px; font-weight: 800; text-align: center;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.22);
}
.zone-global-bar { height: 6px; margin-bottom: 8px; }
.zone-global-metrics {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.zone-global-metric {
  padding: 5px 4px; border-radius: 9px; text-align: center;
  background: #ffffff; border: 1px solid #e2e8f0;
}
.zone-global-metric strong { display: block; font-size: 13.5px; font-weight: 800; color: #0f172a; }
.zone-global-metric span { display: block; font-size: 10px; font-weight: 700; color: #64748b; }

.zone-search-wrap {
  position: relative; display: flex; align-items: center;
  margin-bottom: 8px;
}
.zone-search-input {
  width: 100%; padding: 9px 32px 9px 11px;
  border-radius: 11px; border: 1.5px solid #cbd5e1;
  background: #f8fafc; color: #0f172a;
  font-size: 13px; font-weight: 600;
  user-select: text; -webkit-user-select: text;
}
.zone-search-input:focus {
  outline: none; border-color: var(--zone-accent); background: #ffffff;
}
.zone-search-clear {
  position: absolute; right: 7px;
  width: 24px; height: 24px; border: none; border-radius: 999px;
  background: #e2e8f0; color: #334155; font-size: 11px; font-weight: 800;
}

.zone-filter-bar {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px;
  margin-bottom: 4px;
}
.zone-filter-btn {
  padding: 6px 4px; border-radius: 9px;
  border: 1px solid #cbd5e1; background: #f8fafc;
  color: #475569; font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.zone-filter-btn.active {
  background: var(--zone-accent); color: var(--zone-accent-fg); border-color: var(--zone-accent);
}

.zone-entry-wrap { display: flex; flex-direction: column; gap: 5px; }
.zone-match-chips {
  display: flex; flex-wrap: wrap; gap: 5px; padding-left: 4px;
}
.zone-match-chip {
  padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--zone-accent-border);
  background: var(--zone-accent-soft);
  color: var(--zone-accent-ink);
  font-size: 11px; font-weight: 700; text-align: left;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.zone-empty-msg {
  padding: 16px 10px; text-align: center;
  font-size: 12.5px; font-weight: 600; color: #64748b;
  background: #f8fafc; border-radius: 12px; border: 1px dashed #cbd5e1;
}

.install-pwa-btn {
  width: 100%; margin-top: 10px; padding: 10px 12px;
  border: none; border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff; font-size: 13px; font-weight: 800;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.24);
}
.install-pwa-btn:active { transform: scale(0.98); }
.zone-group-label {
  margin-top: 6px; padding: 2px 2px 0;
  font-size: 11px; font-weight: 800; letter-spacing: 0.05em;
  text-transform: uppercase; color: #64748b;
}
.zone-group-label:first-child { margin-top: 0; }
.zone-item {
  width: 100%; text-align: left; padding: 12px 13px; border-radius: 13px;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc; color: #0f172a;
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.zone-item:active { transform: scale(0.98); }
.zone-item.is-active {
  border-color: var(--zone-accent);
  background: var(--zone-accent-soft);
}

.zone-item-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.zone-item-badges { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.zone-item-title { font-size: 14px; font-weight: 800; color: #0f172a; }
.zone-item-sub { font-size: 12px; color: #475569; margin-top: 2px; }
.zone-item-stats {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
}
.zone-mini-bar {
  flex: 1; height: 5px; border-radius: 999px; overflow: hidden;
  background: rgba(15, 23, 42, 0.1);
}
.zone-mini-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--zone-accent), #10b981);
}
.zone-count-pill {
  padding: 2px 8px; border-radius: 999px;
  background: #ecfdf5; border: 1px solid #a7f3d0;
  font-size: 11px; font-weight: 700; color: #047857; white-space: nowrap;
}
.zone-active-tag {
  padding: 2px 7px; border-radius: 999px;
  background: var(--zone-accent-soft);
  border: 1px solid var(--zone-accent-border);
  color: var(--zone-accent-ink);
  font-size: 10px; font-weight: 800; text-transform: uppercase;
}
.zone-due-tag {
  padding: 2px 7px; border-radius: 999px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #c2410c;
  font-size: 10px; font-weight: 800;
}

.modal-backup-bar {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}
.backup-btn {
  padding: 10px 8px; border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #f1f5f9; color: #0f172a;
  font-size: 12.5px; font-weight: 700;
}
.backup-btn:active { transform: scale(0.97); background: #e2e8f0; }

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   MODE KASUS TWK (Kartu Skenario, Konfirmasi, Setup & Ringkasan)
   ========================================================= */
.twk-card {
  position: fixed;
  top: calc(114px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  right: calc(10px + env(safe-area-inset-right));
  z-index: 11;
  padding: 9px 11px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(37, 99, 235, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.14);
}
.twk-card.is-collapsed {
  padding: 7px 10px;
  border-radius: 13px;
}
.twk-card.is-collapsed .twk-card-body {
  display: none;
}

.twk-card-top {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.twk-card-meta {
  display: flex; align-items: center; gap: 5px;
  flex: 1; min-width: 0; overflow: hidden;
}
.twk-chip-num, .twk-chip-score, .twk-chip-scope {
  padding: 3px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 800; white-space: nowrap;
}
.twk-chip-num {
  background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; flex-shrink: 0;
}
.twk-chip-score {
  background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; flex-shrink: 0;
}
.twk-chip-scope {
  background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1;
  overflow: hidden; text-overflow: ellipsis;
}
.twk-toggle-btn {
  flex-shrink: 0;
  padding: 4px 9px; border-radius: 9px;
  border: 1px solid #cbd5e1; background: #f8fafc;
  color: #1e293b; font-size: 11px; font-weight: 800;
}
.twk-toggle-btn:active { transform: scale(0.96); }

.twk-card-body {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}
.twk-scenario {
  font-size: 13px; line-height: 1.52; color: #0f172a; font-weight: 500;
  max-height: 24vh; overflow-y: auto; touch-action: pan-y;
  padding-right: 2px;
}
.twk-hint {
  margin-top: 7px; padding: 6px 9px; border-radius: 9px;
  background: #fffbeb; border: 1px solid #fcd34d;
  color: #92400e; font-size: 12px; font-weight: 600; line-height: 1.4;
}
.twk-card-actions {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
}
.twk-mini-btn {
  padding: 6px 10px; border-radius: 9px;
  border: 1px solid #cbd5e1; background: #f8fafc;
  color: #334155; font-size: 11.5px; font-weight: 700;
}
.twk-mini-btn:disabled { opacity: 0.55; }
.twk-mini-btn.twk-mini-primary {
  margin-left: auto; border: none;
  background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #ffffff;
}
#btn-twk-config { margin-left: auto; }
.twk-mini-primary:not(.hidden) + #btn-twk-config { margin-left: 0; }

/* Bar Konfirmasi Pilihan Bawah Layar */
.twk-confirm-bar {
  position: fixed;
  left: calc(14px + env(safe-area-inset-left));
  right: calc(14px + env(safe-area-inset-right));
  bottom: calc(22px + env(safe-area-inset-bottom));
  max-width: 400px; margin: 0 auto; z-index: 16;
  padding: 12px 14px; border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1.5px solid #2563eb;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: tabFadeIn 0.16s ease;
}
.twk-confirm-text {
  font-size: 13.5px; font-weight: 800; color: #0f172a;
  text-align: center; margin-bottom: 10px;
}
.twk-confirm-actions {
  display: flex; gap: 8px;
}

/* Modal Pengaturan TWK */
.twk-setup-history {
  margin-bottom: 12px; padding: 8px 10px; border-radius: 10px;
  background: #eff6ff; border: 1px solid #bfdbfe;
  font-size: 12px; font-weight: 600; color: #1e40af;
}
.twk-setup-section { margin-bottom: 12px; }
.twk-setup-label {
  font-size: 12px; font-weight: 800; color: #334155;
  margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center;
}
.twk-pool-note { font-size: 11px; font-weight: 700; color: #2563eb; }
.twk-scope-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.twk-opt-card {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 10px 11px; border-radius: 12px;
  border: 1.5px solid #cbd5e1; background: #f8fafc; color: #0f172a;
}
.twk-opt-card strong { font-size: 12.5px; font-weight: 800; line-height: 1.25; }
.twk-opt-card span { font-size: 11px; color: #475569; font-weight: 600; }
.twk-opt-card.active {
  border-color: #2563eb; background: rgba(37, 99, 235, 0.1); color: #1e3a8a;
}
.twk-count-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.twk-count-btn {
  padding: 9px 6px; border-radius: 10px;
  border: 1.5px solid #cbd5e1; background: #f8fafc;
  color: #334155; font-size: 12.5px; font-weight: 700;
}
.twk-count-btn.active {
  border-color: #2563eb; background: #2563eb; color: #ffffff;
}
.twk-count-btn:disabled { opacity: 0.4; }
.twk-missed-toggle {
  width: 100%; padding: 10px 12px; border-radius: 11px; text-align: left;
  border: 1.5px solid #fdba74; background: #fff7ed;
  color: #c2410c; font-size: 12.5px; font-weight: 800;
}
.twk-missed-toggle.active {
  border-color: #ea580c; background: #ea580c; color: #ffffff;
}

/* Hasil, Kunci Pembahasan & Ringkasan Sesi TWK di Bottom Sheet */
.patrol-step-pill.is-correct {
  background: #ecfdf5; border-color: #6ee7b7; color: #047857;
}
.patrol-step-pill.is-wrong {
  background: #fff1f2; border-color: #fda4af; color: #be123c;
}
.twk-result-box {
  padding: 11px 12px; border-radius: 12px; margin-bottom: 10px;
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-left: 3.5px solid #2563eb;
  font-size: 13px; line-height: 1.55; color: #0f172a;
}
.twk-result-box.is-correct { border-left-color: #10b981; background: #f0fdf4; border-color: #bbf7d0; }
.twk-result-box.is-wrong { border-left-color: #e11d48; background: #fff1f2; border-color: #fecdd3; }
.twk-box-title {
  font-size: 11.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.04em; color: #1d4ed8; margin-bottom: 4px;
}
.twk-result-box.is-correct .twk-box-title { color: #047857; }
.twk-result-box.is-wrong .twk-box-title { color: #be123c; }

.twk-metrics-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px;
  margin-bottom: 12px;
}
.twk-metric-card {
  padding: 9px 6px; border-radius: 12px; text-align: center;
  background: #f8fafc; border: 1px solid #e2e8f0;
}
.twk-metric-val { display: block; font-size: 16px; font-weight: 800; color: #0f172a; }
.twk-metric-lbl { display: block; font-size: 10.5px; font-weight: 700; color: #64748b; margin-top: 2px; }

.twk-missed-list { display: flex; flex-direction: column; gap: 8px; }
.twk-missed-item {
  padding: 10px 11px; border-radius: 12px;
  background: #fff7ed; border: 1px solid #fed7aa;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.twk-missed-item-info { flex: 1; min-width: 0; }
.twk-missed-item-title { font-size: 12.5px; font-weight: 800; color: #9a3412; }
.twk-missed-item-sub {
  font-size: 11.5px; color: #475569; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.twk-study-btn {
  flex-shrink: 0; padding: 7px 11px; border: none; border-radius: 9px;
  background: #2563eb; color: #ffffff; font-size: 12px; font-weight: 800;
}
.patrol-btn-info {
  flex: 1; padding: 11px 12px; border: none; border-radius: 11px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff; font-size: 13px; font-weight: 800;
}
