/* ==========================================================================
   GAME EDUKASI ANAK: PINTAR CERIA
   Tema: Bentuk, Angka, Warna, Huruf & Berhitung
   Target Usia: 4 - 7 Tahun
   100% Pure CSS - Tanpa Dependency Eksternal
   ========================================================================== */

:root {
  /* Palet Warna Ramah Anak */
  --bg-primary: #F0F9FF;
  --bg-card: #FFFFFF;
  --text-main: #1E293B;
  --text-muted: #64748B;
  
  /* Warna Aksen Ceria */
  --color-blue: #3B82F6;
  --color-blue-dark: #2563EB;
  --color-yellow: #F59E0B;
  --color-yellow-dark: #D97706;
  --color-green: #10B981;
  --color-green-dark: #059669;
  --color-red: #EF4444;
  --color-red-dark: #DC2626;
  --color-purple: #8B5CF6;
  --color-purple-dark: #7C3AED;
  --color-orange: #F97316;
  --color-orange-dark: #EA580C;
  --color-pink: #EC4899;
  --color-pink-dark: #DB2777;

  /* Bayangan & Radius */
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-pill: 9999px;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-btn: 0 6px 0 rgba(0, 0, 0, 0.18);
}

/* Reset & Dasar */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Nunito', sans-serif;
  background: var(--bg-primary);
  background-image: 
    radial-gradient(#E0F2FE 2px, transparent 2px),
    radial-gradient(#DBEAFE 2px, #F0F9FF 2px);
  background-size: 32px 32px;
  background-position: 0 0, 16px 16px;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  line-height: 1.5;
}

/* Wadah Utama Aplikasi */
.app-container {
  width: 100%;
  max-width: 760px;
  min-height: 640px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 4px solid #E2E8F0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Navigasi Header Atas */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #F8FAFC;
  border-bottom: 3px solid #E2E8F0;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Badge Skor & Level */
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #EFF6FF;
  border: 2px solid #BFDBFE;
  border-radius: var(--radius-pill);
  font-weight: 800;
  font-size: 15px;
  color: var(--color-blue-dark);
}

.stat-icon {
  width: 20px;
  height: 20px;
  fill: var(--color-yellow);
}

/* Tombol Ikon Bundar */
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  background: #FFFFFF;
  border: 2px solid #CBD5E1;
  box-shadow: 0 3px 0 #94A3B8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.icon-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 #94A3B8;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  stroke: #475569;
}

/* Konten Layar (Screen View) */
.screen {
  flex: 1;
  display: none;
  flex-direction: column;
  padding: 24px;
  animation: fadeIn 0.25s ease-out;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   1. LAYAR BERANDA (HOME SCREEN)
   ========================================================================== */
.home-screen {
  text-align: center;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 36px 20px;
}

.game-logo {
  max-width: 320px;
  width: 100%;
  height: auto;
  margin-bottom: 8px;
}

.game-title {
  font-size: 32px;
  font-weight: 900;
  color: var(--color-blue-dark);
  letter-spacing: -0.5px;
}

.game-subtitle {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-muted);
  max-width: 420px;
  margin: 0 auto;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 340px;
  margin-top: 10px;
}

/* Desain Tombol Utama 3D Ramah Anak */
.btn-primary {
  background: var(--color-green);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  padding: 18px 28px;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 6px 0 var(--color-green-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--color-green-dark);
}

.btn-secondary {
  background: #FFFFFF;
  color: var(--color-blue-dark);
  border: 3px solid #BFDBFE;
  border-radius: var(--radius-md);
  padding: 14px 24px;
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 4px 0 #93C5FD;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-secondary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #93C5FD;
}

.btn-tertiary {
  background: #F1F5F9;
  color: #475569;
  border: 2px solid #CBD5E1;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 3px 0 #94A3B8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-tertiary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #94A3B8;
}

/* ==========================================================================
   2. LAYAR PILIH LEVEL
   ========================================================================== */
.level-screen {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.screen-header-title {
  font-size: 24px;
  font-weight: 900;
  color: var(--text-main);
  text-align: center;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.level-card {
  background: #FFFFFF;
  border: 3px solid #E2E8F0;
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 5px 0 #CBD5E1;
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
}

.level-card:hover:not(.locked) {
  border-color: var(--color-blue);
}

.level-card:active:not(.locked) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #CBD5E1;
}

.level-card.locked {
  background: #F1F5F9;
  opacity: 0.75;
  cursor: not-allowed;
}

.level-badge {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  color: #FFFFFF;
}

.level-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.level-desc {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.level-stars {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.star-icon-small {
  width: 20px;
  height: 20px;
  fill: #CBD5E1; /* Warna abu-abu saat belum tercapai */
}

.star-icon-small.earned {
  fill: var(--color-yellow);
}

/* ==========================================================================
   3. LAYAR PERMAINAN (PLAY SCREEN)
   ========================================================================== */
.play-screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.progress-bar-container {
  width: 100%;
  height: 12px;
  background: #E2E8F0;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 20%;
  background: linear-gradient(90deg, var(--color-blue), var(--color-green));
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

.question-card {
  background: #F8FAFC;
  border: 3px solid #E2E8F0;
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.question-number-badge {
  font-size: 14px;
  font-weight: 800;
  color: var(--color-blue-dark);
  background: #DBEAFE;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
}

.question-text {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-main);
  max-width: 540px;
}

/* Area Visual Soal (Bentuk, Balok, Berhitung, Pola) */
.visual-stage {
  min-height: 120px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px;
}

/* Balok & Geometri Non-Living */
.toy-block {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 900;
  color: #FFFFFF;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.toy-block.shape-circle {
  border-radius: 50%;
}

.toy-block.shape-triangle {
  width: 0;
  height: 0;
  border-left: 32px solid transparent;
  border-right: 32px solid transparent;
  border-bottom: 64px solid var(--block-color, #3B82F6);
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.toy-block.shape-star {
  background: transparent;
  box-shadow: none;
}

.math-symbol {
  font-size: 36px;
  font-weight: 900;
  color: var(--text-main);
  padding: 0 8px;
}

/* Kotak Jawaban Interaktif */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 4px;
}

.option-btn {
  background: #FFFFFF;
  border: 3px solid #CBD5E1;
  border-radius: var(--radius-md);
  padding: 18px 14px;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-size: 19px;
  font-weight: 900;
  color: var(--text-main);
  box-shadow: 0 5px 0 #94A3B8;
  transition: transform 0.1s, box-shadow 0.1s, border-color 0.1s, background-color 0.1s;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--color-blue);
}

.option-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #94A3B8;
}

/* Feedback Status Pilihan */
.option-btn.correct {
  background: #ECFDF5;
  border-color: var(--color-green);
  color: var(--color-green-dark);
  box-shadow: 0 5px 0 var(--color-green-dark);
  animation: bounceCorrect 0.4s ease;
}

.option-btn.wrong {
  background: #FEF2F2;
  border-color: var(--color-red);
  color: var(--color-red-dark);
  box-shadow: 0 5px 0 var(--color-red-dark);
  animation: shakeWrong 0.4s ease;
}

@keyframes bounceCorrect {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.05); }
}

@keyframes shakeWrong {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Banner Feedback Jawaban */
.feedback-banner {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  text-align: center;
  transition: all 0.2s ease;
  opacity: 0;
  visibility: hidden;
}

.feedback-banner.show-correct {
  opacity: 1;
  visibility: visible;
  background: #D1FAE5;
  color: var(--color-green-dark);
  border: 2px solid #6EE7B7;
}

.feedback-banner.show-wrong {
  opacity: 1;
  visibility: visible;
  background: #FEE2E2;
  color: var(--color-red-dark);
  border: 2px solid #FCA5A5;
}

/* ==========================================================================
   4. LAYAR SELESAI LEVEL (WIN / SUMMARY SCREEN)
   ========================================================================== */
.summary-screen {
  text-align: center;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 30px 20px;
}

.summary-stars-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 10px 0;
}

.summary-star {
  width: 56px;
  height: 56px;
  fill: #E2E8F0;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.summary-star.active {
  fill: var(--color-yellow);
  transform: scale(1.15);
}

.summary-title {
  font-size: 28px;
  font-weight: 900;
  color: var(--color-green-dark);
}

.summary-score-card {
  background: #F8FAFC;
  border: 3px solid #E2E8F0;
  border-radius: var(--radius-md);
  padding: 16px 28px;
  display: flex;
  gap: 24px;
}

.score-item {
  display: flex;
  flex-direction: column;
}

.score-item-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.score-item-value {
  font-size: 24px;
  font-weight: 900;
  color: var(--color-blue-dark);
}

/* ==========================================================================
   5. MODAL / DIALOG CARA BERMAIN & PENGATURAN
   ========================================================================== */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fadeIn 0.15s ease-out;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  border: 4px solid #E2E8F0;
  box-shadow: var(--shadow-card);
  max-width: 520px;
  width: 100%;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #E2E8F0;
  padding-bottom: 12px;
}

.modal-title {
  font-size: 20px;
  font-weight: 900;
  color: var(--text-main);
}

.instruction-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.instruction-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.instruction-badge {
  min-width: 32px;
  height: 32px;
  background: #EFF6FF;
  border: 2px solid #BFDBFE;
  color: var(--color-blue-dark);
  font-weight: 900;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pengaturan Toggles */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: #F8FAFC;
  border-radius: var(--radius-sm);
  border: 2px solid #E2E8F0;
}

.setting-info {
  display: flex;
  flex-direction: column;
}

.setting-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.setting-desc {
  font-size: 13px;
  color: var(--text-muted);
}

/* Switch Toggle Sederhana */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #CBD5E1;
  transition: 0.2s;
  border-radius: 34px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
  background-color: var(--color-green);
}

input:checked + .toggle-slider:before {
  transform: translateX(22px);
}

/* ==========================================================================
   RESPONSIVE DESIGN (HP & TABLET)
   ========================================================================== */
@media (max-width: 640px) {
  body {
    padding: 8px;
  }

  .app-container {
    min-height: calc(100vh - 16px);
    border-radius: var(--radius-md);
  }

  .header-bar {
    padding: 10px 14px;
  }

  .stat-pill {
    padding: 4px 10px;
    font-size: 13px;
  }

  .game-title {
    font-size: 26px;
  }

  .game-subtitle {
    font-size: 15px;
  }

  .question-text {
    font-size: 19px;
  }

  .options-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .option-btn {
    min-height: 64px;
    font-size: 18px;
    padding: 14px;
  }

  .level-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-score-card {
    flex-direction: column;
    gap: 12px;
    padding: 14px 20px;
  }
}
