/* ==========================================================================
   TEMA VISUAL & PENGATURAN DASAR (AIR & WADUK GAJAH MUNGKUR)
   ========================================================================== */
:root {
  /* Skema Warna Bernuansa Air & Alam Waduk Wonogiri */
  --primary-deep: #0f3e6d;
  --water-main: #1976d2;
  --water-light: #e3f2fd;
  --water-surface: #90caf9;
  --accent-green: #2e7d32;
  --accent-amber: #f57f17;
  --accent-red: #c62828;
  
  /* Warna Latar Belakang & Kartu */
  --bg-gradient: linear-gradient(180deg, #e3f2fd 0%, #bbdefb 60%, #90caf9 100%);
  --surface-white: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.95);
  
  /* Tipografi & Warna Teks */
  --text-dark: #102a43;
  --text-muted: #486581;
  --text-light: #ffffff;
  
  /* Batasan & Radius Desain */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-card: 0 8px 24px rgba(15, 62, 109, 0.12);
  --shadow-btn: 0 4px 10px rgba(15, 62, 109, 0.2);
}

/* Reset CSS Sederhana Tanpa Pustaka Luar */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg-gradient);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   SISTEM VISIBILITAS LAYAR (SINGLE-PAGE APPLICATION MODEL)
   ========================================================================== */
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  padding: 16px;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   ATURAN TOMBOL & TARGET AKSESIBILITAS SENTUH (MINIMAL 44PX)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 48px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease;
  user-select: none;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background-color: var(--primary-deep);
  color: var(--text-light);
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
  background-color: #0a2d50;
}

.btn-secondary {
  background-color: var(--surface-white);
  color: var(--primary-deep);
  border: 2px solid var(--primary-deep);
}

.btn-secondary:hover {
  background-color: var(--water-light);
}

.btn-icon {
  background: transparent;
  color: var(--primary-deep);
  font-size: 1rem;
  font-weight: bold;
  padding: 8px 12px;
}

/* ==========================================================================
   GAYA TAMPILAN 1: HALAMAN SPLASH
   ========================================================================== */
.splash-container {
  max-width: 540px;
  margin: auto;
  background-color: var(--surface-glass);
  padding: 32px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 24px;
  text-align: center;
}

.splash-logos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.brand-logo {
  height: 68px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
}

.splash-hero .main-title {
  color: var(--primary-deep);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 12px;
}

.splash-hero .subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.splash-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.splash-author {
  border-top: 1px solid #d9e2ec;
  padding-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: left;
}

.author-logo {
  height: 44px;
  width: 44px;
  object-fit: contain;
  border-radius: 50%;
  background: #ffffff;
  padding: 2px;
}

.author-info strong {
  display: block;
  font-size: 0.85rem;
  color: var(--primary-deep);
}

.author-info span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   GAYA TAMPILAN 2: HALAMAN EDUKASI
   ========================================================================== */
.edu-container {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.edu-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.edu-header h2 {
  color: var(--primary-deep);
  font-size: 1.4rem;
}

.edu-card {
  background: var(--surface-glass);
  padding: 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.edu-card h3 {
  color: var(--primary-deep);
  font-size: 1.15rem;
  margin-bottom: 10px;
}

.edu-badge {
  display: inline-block;
  background-color: var(--water-light);
  color: var(--water-main);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.curriculum-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--text-dark);
}

.curriculum-list li {
  position: relative;
  padding-left: 20px;
  line-height: 1.4;
}

.curriculum-list li::before {
  content: "✔";
  position: absolute;
  left: 0;
  color: var(--accent-green);
  font-size: 0.85rem;
}

.step-guide {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.step-guide li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.step-num {
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--water-main);
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ==========================================================================
   GRID PILIHAN LEVEL
   ========================================================================== */
.level-group {
  margin-top: 14px;
}

.group-header {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.group-easy {
  background-color: #e8f5e9;
  color: var(--accent-green);
  border-left: 4px solid var(--accent-green);
}

.group-medium {
  background-color: #fff8e1;
  color: #b78103;
  border-left: 4px solid var(--accent-amber);
}

.group-hard {
  background-color: #ffebee;
  color: var(--accent-red);
  border-left: 4px solid var(--accent-red);
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.btn-level {
  background-color: var(--surface-white);
  border: 1px solid #c5d7e5;
  color: var(--primary-deep);
  font-size: 0.95rem;
}

.btn-level:hover {
  background-color: var(--water-light);
  border-color: var(--water-main);
}

/* ==========================================================================
   PENYESUAIAN RESPONSIF (HP 360PX DAN LAPTOP)
   ========================================================================== */
@media (min-width: 600px) {
  .splash-actions {
    flex-direction: row;
  }
  .splash-actions .btn {
    flex: 1;
  }
}

@media (max-width: 380px) {
  .splash-container {
    padding: 20px 16px;
  }
  .brand-logo {
    height: 52px;
  }
  .splash-hero .main-title {
    font-size: 1.4rem;
  }
  .level-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   TAMPILAN 3: GAMEPLAY HUD & TATA LETAK RESPONSIF (TAHAP B1)
   ========================================================================== */
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--surface-glass);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  gap: 10px;
}

.hud-left, .hud-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-badge {
  background: var(--water-light);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary-deep);
}

.hud-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.hud-val {
  color: var(--primary-deep);
}

.hud-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-hud {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  background: var(--surface-white);
  border: 1px solid #d9e2ec;
  border-radius: var(--radius-sm);
  color: var(--primary-deep);
}

.btn-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Tata Letak Dua Kolom: Kolom Misi & Kolom Algoritma */
.game-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

@media (min-width: 900px) {
  .game-layout {
    display: grid;
    grid-template-columns: 1.05fr 1.15fr;
    gap: 20px;
    align-items: start;
  }
}

.game-panel-left, .game-panel-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Kartu Informasi Misi & Parameter Fisis */
.level-info-card {
  background: var(--surface-glass);
  padding: 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.level-info-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.level-info-head h3 {
  font-size: 1.15rem;
  color: var(--primary-deep);
}

.level-description {
  font-size: 0.9rem;
  color: var(--text-dark);
  line-height: 1.45;
  margin-bottom: 14px;
}

.params-table {
  background: #f0f4f8;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
}

.param-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.param-key {
  color: var(--text-muted);
}

.param-val {
  font-weight: 700;
  color: var(--primary-deep);
}

/* Referensi Debit Pintu */
.gate-ref-table {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #d9e2ec;
}

.gate-ref-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.gate-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-gate {
  background: var(--water-light);
  color: var(--water-main);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

/* Placeholder Waduk Simulasi */
.sim-placeholder-container {
  background: var(--surface-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.sim-placeholder-badge {
  background: #e2e8f0;
  color: var(--primary-deep);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 14px;
}

.sim-placeholder-body {
  height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  border: 2px dashed #cbd5e1;
  margin: 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  gap: 6px;
}

.sim-water-icon {
  font-size: 2rem;
}

.sim-placeholder-body p {
  color: var(--primary-deep);
}

.sim-placeholder-body span {
  font-size: 0.8rem;
  max-width: 320px;
}

/* Area Kerja & Palet Blok */
.block-card {
  background: var(--surface-glass);
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.block-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.block-card-header h4 {
  font-size: 1.05rem;
  color: var(--primary-deep);
}

.card-caption {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.workspace-btn-group {
  display: flex;
  gap: 6px;
}

.btn-action-tool {
  min-height: 44px;
  padding: 6px 12px;
  font-size: 0.8rem;
  background: var(--surface-white);
  border: 1px solid #c5d7e5;
  color: var(--primary-deep);
  border-radius: var(--radius-sm);
}

.btn-action-danger {
  color: var(--accent-red);
  border-color: #ffcdd2;
}

.btn-action-danger:hover {
  background: #ffebee;
}

/* Grid Palet Blok */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.btn-palette-block {
  min-height: 46px;
  padding: 8px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Pewarnaan Kategori Blok */
.block-gate {
  background: #e3f2fd;
  color: #0d47a1;
  border-color: #90caf9;
}

.block-gate:hover {
  background: #bbdefb;
}

.block-wait {
  background: #fff8e1;
  color: #b78103;
  border-color: #ffe082;
}

.block-wait:hover {
  background: #ffecb3;
}

/* Susunan Blok di Workspace */
.workspace-dropzone {
  min-height: 200px;
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.workspace-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
}

.workspace-empty span {
  font-size: 0.8rem;
  display: block;
  margin-top: 4px;
}

.workspace-item {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #d9e2ec;
  background: var(--surface-white);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  gap: 8px;
}

.item-seq {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 20px;
}

.item-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

.stepper-box {
  display: flex;
  align-items: center;
  background: var(--surface-white);
  border: 1px solid #d9e2ec;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.btn-step {
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: #f0f4f8;
  color: var(--primary-deep);
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-step:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stepper-val {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
  color: var(--primary-deep);
}

.item-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-tool {
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: 1px solid #d9e2ec;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.btn-tool:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.btn-tool-delete {
  color: var(--accent-red);
  border-color: #ffcdd2;
}

.btn-tool-delete:hover {
  background: #ffebee;
}

/* Tombol Eksekusi */
.execute-area {
  display: flex;
  width: 100%;
}

.btn-run {
  width: 100%;
  min-height: 52px;
  font-size: 1.1rem;
  background-color: var(--accent-green);
  gap: 10px;
}

.btn-run:hover {
  background-color: #256628;
}

.btn-run-icon {
  font-size: 1rem;
}

/* Penyesuaian Responsif Layar Kecil (360px) */
@media (max-width: 400px) {
  .game-hud {
    flex-wrap: wrap;
    padding: 8px;
  }
  .hud-stats {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }
  .palette-grid {
    grid-template-columns: 1fr;
  }
  .workspace-item {
    flex-wrap: wrap;
    padding: 8px;
  }
  .item-tools {
    width: 100%;
    justify-content: flex-end;
    margin-top: 6px;
    border-top: 1px dashed #e2e8f0;
    padding-top: 4px;
  }
}

/* ==========================================================================
   TAMPILAN SIMULASI SVG & MODAL EVALUASI (TAHAP B2)
   ========================================================================== */

/* Wadah & Kanvas SVG Simulasi Waduk */
.simulation-card {
  background: var(--surface-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.simulation-header {
  padding: 10px 16px;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
}

.simulation-header h4 {
  font-size: 0.95rem;
  color: var(--primary-deep);
}

.svg-container {
  width: 100%;
  padding: 8px;
  background: #ffffff;
}

.sim-svg-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
}

/* Transisi Halus Elemen SVG */
#svg-water, #svg-water-surface {
  transition: y 0.5s ease, height 0.5s ease;
}

.gate-door {
  transition: y 0.3s ease, fill 0.3s ease;
}

#svg-water-stream {
  transition: stroke-width 0.4s ease;
}

/* ==========================================================================
   PANEL MODAL EVALUASI SIMULASI (HASIL SUKSES / GAGAL)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  background: var(--surface-white);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalPop 0.25s ease-out;
}

@keyframes modalPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.result-badge {
  display: inline-block;
  padding: 6px 18px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

.badge-success {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.badge-danger {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.modal-header h3 {
  font-size: 1.35rem;
  color: var(--primary-deep);
}

.modal-reason-text {
  font-size: 0.9rem;
  color: var(--text-dark);
  line-height: 1.4;
}

/* Tabel Catatan Histori Ketinggian Air */
.modal-log-section h4 {
  font-size: 0.9rem;
  color: var(--primary-deep);
  margin-bottom: 8px;
}

.table-scroll-wrapper {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: center;
}

.log-table th {
  background: #f1f5f9;
  padding: 8px;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  border-bottom: 1px solid #cbd5e1;
}

.log-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f1f5f9;
}

.log-tag-safe {
  color: #16a34a;
  font-weight: bold;
}

.log-tag-fail {
  color: #dc2626;
  font-weight: bold;
  text-transform: capitalize;
}

/* Kotak Refleksi Pedagogi & Petunjuk */
.modal-pedagogy-card {
  background: #eff6ff;
  border-left: 4px solid var(--water-main);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
}

.modal-pedagogy-card h4 {
  font-size: 0.85rem;
  color: var(--primary-deep);
  margin-bottom: 4px;
}

.modal-pedagogy-card p {
  font-size: 0.82rem;
  color: #1e3a8a;
  line-height: 1.45;
}

.modal-hint-card {
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
}

.modal-hint-card.hidden {
  display: none;
}

.modal-hint-card h4 {
  font-size: 0.85rem;
  color: #92400e;
  margin-bottom: 4px;
}

.modal-hint-card p {
  font-size: 0.82rem;
  color: #78350f;
  line-height: 1.45;
}

.modal-footer {
  display: flex;
  margin-top: 6px;
}

.btn-modal-close {
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
}

/* ==========================================================================
   PANEL PEMANTAU LIVE SIMULASI (METRIK & STATUS HTML BERSIFAT RESPONTIF)
   ========================================================================== */
.sim-monitor-panel {
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Baris 1: Detik, T, Qkeluar */
.sim-metrics-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--primary-deep);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  gap: 8px;
}

.metric-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.metric-label {
  color: #90caf9;
  font-size: 0.8rem;
}

/* Baris 2: Elemen HTML Status Tersendiri */
.sim-status-box {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: normal;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Kondisi Aman / Sukses: Hijau */
.sim-status-box.status-safe {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

/* Kondisi Gagal: Merah */
.sim-status-box.status-fail {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

/* Penyesuaian Khusus Layar Kecil (360px) */
@media (max-width: 400px) {
  .sim-metrics-row {
    padding: 6px 8px;
    font-size: 0.78rem;
  }
  .sim-status-box {
    font-size: 0.8rem;
    padding: 6px 10px;
  }
}

/* ==========================================================================
   TAMPILAN STRUKTUR POHON BERSARANG & SLOT KONTROL (TAHAP C1)
   ========================================================================== */

/* Pewarnaan Kategori Blok Logika Baru */
.block-control-if {
  background: #f3e8ff;
  color: #6b21a8;
  border-color: #d8b4fe;
}

.block-control-if:hover {
  background: #e9d5ff;
}

.block-control-loop {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.block-control-loop:hover {
  background: #fde68a;
}

/* Lencana Penghitung Kuota Blok (Blok: n/maks) */
.block-counter-badge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: #e2e8f0;
  color: var(--primary-deep);
  border: 1px solid #cbd5e1;
}

.block-counter-badge.counter-full {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

/* Penanda Slot Induk Utama */
.root-slot-indicator {
  padding: 6px 12px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 8px;
  user-select: none;
  transition: all 0.2s ease;
}

.root-slot-indicator:hover {
  background: #e2e8f0;
}

/* Penataan Fleksibel Simpul Blok */
.workspace-item .item-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.item-inline-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.item-bold {
  font-weight: 700;
  color: var(--primary-deep);
}

.block-nest-header {
  padding-bottom: 4px;
}

.block-nest-divider {
  font-size: 0.82rem;
  padding: 4px 6px;
  color: #6b21a8;
}

/* Kontainer Wadah Anak (Slot Bersarang) */
.slot-container {
  border: 2px dashed #cbd5e1;
  background: #ffffff;
  border-radius: var(--radius-sm);
  padding: 6px;
  margin-top: 4px;
  transition: all 0.2s ease;
}

.slot-header {
  padding: 4px 8px;
  background: #f8fafc;
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slot-header:hover {
  background: #f1f5f9;
  color: var(--primary-deep);
}

.slot-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slot-empty-hint {
  font-size: 0.78rem;
  color: #94a3b8;
  font-style: italic;
  padding: 6px 8px;
  text-align: center;
}

/* Efek Sorot Slot Aktif */
.slot-container.slot-active,
.root-slot-indicator.slot-active {
  border: 2px solid var(--water-main) !important;
  background-color: #f0f7ff !important;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.18);
}

.slot-container.slot-active .slot-header {
  background-color: #e0f2fe;
  color: var(--water-main);
  font-weight: 700;
}

/* ==========================================================================
   LABEL SKENARIO AKTIF & RINGKASAN EVALUASI MULTI-SKENARIO (TAHAP C2)
   ========================================================================== */

/* Lencana Skenario Berjalan di Atas Panel Metrik */
.sim-scenario-tag {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  transition: all 0.2s ease;
}

.sim-scenario-tag.hidden {
  display: none;
}

/* Bagian Ringkasan Kasus Uji di Modal Evaluasi */
.modal-scenario-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 12px;
}

.modal-scenario-section.hidden {
  display: none;
}

.modal-scenario-section h4 {
  font-size: 0.88rem;
  color: var(--primary-deep);
  margin-bottom: 8px;
}

.scenario-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scenario-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  gap: 8px;
}

.scenario-card-item.scenario-pass {
  border-left: 4px solid var(--accent-green);
}

.scenario-card-item.scenario-fail {
  border-left: 4px solid var(--accent-red);
  background-color: #fef2f2;
}

.scenario-info-title {
  font-weight: 700;
  color: var(--text-dark);
}

.scenario-info-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.scenario-status-pill {
  font-weight: 800;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 12px;
  flex-shrink: 0;
}

.pill-pass {
  background: #dcfce7;
  color: #15803d;
}

.pill-fail {
  background: #fee2e2;
  color: #b91c1c;
}

/* ==========================================================================
   TAMPILAN TAHAP D: SKOR, ANIMASI NYAWA, PAUSE, DAN GAME OVER
   ========================================================================== */

/* Animasi Guncangan Saat Nyawa Berkurang */
.heart-hit {
  animation: heartShake 0.45s ease-in-out;
  display: inline-block;
}

@keyframes heartShake {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 red); }
  25% { transform: scale(1.3) rotate(-8deg); filter: drop-shadow(0 0 6px rgba(220, 38, 38, 0.8)); }
  50% { transform: scale(0.9) rotate(8deg); filter: drop-shadow(0 0 4px rgba(220, 38, 38, 0.6)); }
  75% { transform: scale(1.15) rotate(-4deg); }
  100% { transform: scale(1) rotate(0deg); filter: none; }
}

/* Penanda Tombol Level Selesai di Halaman Edukasi */
.btn-level.completed {
  background-color: #ecfdf5;
  border-color: #10b981;
  color: #065f46;
  font-weight: 700;
  position: relative;
}

.btn-level.completed::after {
  content: " ✔";
  color: #10b981;
  font-size: 0.95rem;
}

/* Penataan Kartu Modal Sederhana (Pause & Game Over) */
.modal-compact {
  max-width: 420px;
  text-align: center;
  gap: 16px;
}

.modal-pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.modal-actions-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.modal-actions-group .btn {
  flex: 1;
  min-width: 140px;
}

.gameover-score-box {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 12px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.gameover-score-box span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.gameover-score-box strong {
  font-size: 1.8rem;
  color: var(--primary-deep);
}

.text-center {
  text-align: center;
}

/* Tombol pada modal ringkas (Game Over) di tengah */
.modal-compact .modal-footer {
  justify-content: center;
}

/* ==========================================================================
   TAMPILAN TAHAP F: HALAMAN HASIL & REKAPITULASI MISI
   ========================================================================== */
.result-container {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.result-logos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.result-logo-img {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.result-header h2 {
  color: var(--primary-deep);
  font-size: 1.45rem;
}

.result-summary-card {
  background: var(--surface-glass);
  padding: 24px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.result-score-banner {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.result-score-val {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--primary-deep);
  display: block;
}

.result-star-hero {
  font-size: 2.8rem;
  line-height: 1;
  color: #f59e0b;
  letter-spacing: 6px;
  user-select: none;
}

.result-title {
  font-size: 1.25rem;
  color: var(--primary-deep);
  font-weight: 700;
}

.result-meta-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid #d9e2ec;
  width: 100%;
  font-size: 0.9rem;
  color: var(--text-dark);
}

.result-level-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-level-row {
  background: var(--surface-white);
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: 0 2px 4px rgba(15, 62, 109, 0.05);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.level-row-done {
  border-left: 5px solid var(--accent-green);
}

.level-row-pending {
  border-left: 5px solid #94a3b8;
  opacity: 0.85;
}

.result-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.result-row-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-row-title {
  font-weight: 700;
  color: var(--primary-deep);
  font-size: 0.95rem;
}

.result-row-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.result-row-score-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.result-row-stars {
  font-size: 1.2rem;
  color: #f59e0b;
  letter-spacing: 2px;
  user-select: none;
}

.result-row-status {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
}

.result-details {
  background: #f8fafc;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  border: 1px dashed #cbd5e1;
}

.result-details-summary {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--water-main);
  cursor: pointer;
  user-select: none;
}

.result-details-text {
  font-size: 0.8rem;
  color: var(--text-dark);
  line-height: 1.45;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #e2e8f0;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.result-actions .btn {
  flex: 1;
  min-width: 180px;
}

.result-author-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 12px 0 20px 0;
}

/* Responsif Layar Kecil (360px) */
@media (max-width: 480px) {
  .result-actions {
    flex-direction: column;
  }
  .result-actions .btn {
    width: 100%;  
  }
  .result-row-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .result-row-score-box {
    width: 100%;
    justify-content: space-between;
    margin-top: 4px;
    border-top: 1px dashed #e2e8f0;
    padding-top: 4px;
  }
}