/* ============================================================
   Belajar Sempoa — style.css
   Tema: cerah & ramah anak, responsif untuk HP dan tablet.
   ============================================================ */

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

body {
  font-family: "Comic Sans MS", "Chalkboard SE", "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(160deg, #fff3b0 0%, #ffd6e0 50%, #bde0fe 100%);
  min-height: 100vh;
  color: #4a3b2a;
  padding-bottom: 40px;
}

/* ---------- Kepala & tab ---------- */
header {
  text-align: center;
  padding: 20px 12px 12px;
}

h1 {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  color: #d62828;
  text-shadow: 2px 2px 0 #fff;
}

.subjudul {
  margin: 6px 0 14px;
  font-size: clamp(0.95rem, 2.5vw, 1.15rem);
  color: #6b4f2a;
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tab-btn {
  font-family: inherit;
  font-size: clamp(1rem, 2.6vw, 1.2rem);
  font-weight: bold;
  padding: 12px 20px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: #ffd166;
  color: #5a3b00;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.1s, background 0.2s;
}

.tab-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

.tab-btn.aktif {
  background: #06d6a0;
  color: #fff;
  border-color: #fff;
}

.tab-ikon {
  margin-right: 6px;
}

/* ---------- Panel & kartu ---------- */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 12px;
}

.tab-panel {
  display: none;
}

.tab-panel.aktif {
  display: block;
}

.tersembunyi {
  display: none !important;
}

.kartu {
  background: #fffdf5;
  border: 3px solid #fff;
  border-radius: 20px;
  padding: 18px;
  margin: 14px 0;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

.kartu h2 {
  color: #ef476f;
  margin-bottom: 10px;
  font-size: clamp(1.15rem, 3vw, 1.5rem);
}

.instruksi,
.catatan {
  color: #6b4f2a;
  line-height: 1.5;
}

/* ---------- Tab Rumus ---------- */
.pengenalan-manik {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.info-manik {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff8e1;
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 1.05rem;
}

.contoh-manik {
  display: inline-block;
  width: 44px;
  height: 30px;
  border-radius: 50%;
  flex: none;
}

.manik-atas-contoh {
  background: radial-gradient(circle at 35% 30%, #ffd166, #f4a261 60%, #e76f51);
  border: 2px solid #b3541e;
}

.manik-bawah-contoh {
  background: radial-gradient(circle at 35% 30%, #a0e7ff, #48cae4 60%, #0096c7);
  border: 2px solid #0077b6;
}

.grup-rumus h3 {
  color: #3a7d44;
  margin: 16px 0 8px;
  font-size: 1.15rem;
}

.subgrup-rumus {
  margin: 10px 0;
}

.subgrup-rumus h4 {
  color: #7b5ea7;
  margin-bottom: 8px;
}

.kumpulan-chip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-rumus {
  background: #e8f5e9;
  border: 2px solid #a5d6a7;
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 1.05rem;
  font-weight: bold;
  color: #2e6b34;
  white-space: nowrap;
}

.grup-rumus[data-jenis="besar"] .chip-rumus {
  background: #e3f2fd;
  border-color: #90caf9;
  color: #1565c0;
}

.grup-rumus[data-jenis="kombinasi"] .chip-rumus {
  background: #f3e5f5;
  border-color: #ce93d8;
  color: #6a1b9a;
}

/* ---------- Sempoa ---------- */
.wadah-sempoa {
  margin: 14px 0;
}

.sempoa {
  max-width: 640px;
  margin: 0 auto;
}

.baris-label {
  display: grid;
  gap: 6px;
  margin-bottom: 6px;
  text-align: center;
}

.baris-label span {
  font-weight: bold;
  color: #6b4f2a;
  font-size: clamp(0.8rem, 2.4vw, 1.05rem);
}

.bingkai {
  display: grid;
  gap: 6px;
  grid-template-rows: auto 16px auto;
  background: linear-gradient(180deg, #c98d4b, #a66a2c);
  border: 4px solid #8d5524;
  border-radius: 18px;
  padding: 14px 12px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.3), 0 8px 16px rgba(0, 0, 0, 0.2);
}

.dek {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Gandar (batang) di belakang manik */
.dek::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 6px;
  transform: translateX(-50%);
  background: #5d3a1a;
  border-radius: 3px;
}

.dek-atas {
  height: clamp(56px, 10vw, 76px);
  /* Manik aktif = turun mendekati palang (bawah dek) */
  justify-content: flex-end;
}

.dek-atas.tidak-aktif {
  /* Manik nonaktif = naik menjauhi palang */
  justify-content: flex-start;
}

.dek-bawah {
  height: clamp(160px, 28vw, 210px);
  gap: 4px;
  padding-top: 4px;
}

/* Celah antara manik aktif (dekat palang) dan nonaktif */
.manik-bawah.jarak {
  margin-top: clamp(14px, 3vw, 22px);
}

.palang {
  background: #4e2e0e;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.manik {
  position: relative;
  z-index: 1;
  width: clamp(38px, 9vw, 56px);
  height: clamp(28px, 6vw, 36px);
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s;
}

.manik:active {
  transform: scale(0.92);
}

.manik-atas {
  background: radial-gradient(circle at 35% 30%, #ffd166, #f4a261 60%, #e76f51);
  border: 2px solid #b3541e;
}

.manik-bawah {
  background: radial-gradient(circle at 35% 30%, #a0e7ff, #48cae4 60%, #0096c7);
  border: 2px solid #0077b6;
}

/* Manik aktif sedikit lebih terang supaya jelas terhitung */
.manik.aktif {
  filter: brightness(1.12) saturate(1.2);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
}

/* ---------- Tampilan nilai & tombol ---------- */
.kartu-nilai {
  text-align: center;
}

.label-nilai {
  font-size: 1.05rem;
  color: #6b4f2a;
  margin-bottom: 8px;
}

.tampilan-nilai {
  display: inline-block;
  min-width: 200px;
  font-family: "Courier New", monospace;
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: bold;
  color: #06d6a0;
  background: #1d3557;
  border-radius: 14px;
  padding: 8px 24px;
  letter-spacing: 4px;
  margin-bottom: 14px;
}

.btn-besar {
  font-family: inherit;
  font-size: clamp(1rem, 2.6vw, 1.2rem);
  font-weight: bold;
  padding: 14px 26px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.1s;
  touch-action: manipulation;
}

.btn-besar:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.btn-reset {
  background: #ff8fa3;
  color: #6b0f1f;
}

.btn-periksa {
  background: #06d6a0;
  color: #fff;
}

.btn-berikutnya {
  background: #118ab2;
  color: #fff;
}

/* ---------- Tab Latihan ---------- */
.grup-level-judul {
  color: #3a7d44;
  margin: 14px 0 10px;
  font-size: 1.1rem;
}

.level-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.btn-level {
  font-family: inherit;
  font-size: clamp(1rem, 2.6vw, 1.15rem);
  font-weight: bold;
  padding: 18px 14px;
  border: 3px solid #fff;
  border-radius: 16px;
  background: #bde0fe;
  color: #1d3557;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.1s, background 0.2s;
}

.btn-level:active {
  transform: translateY(3px);
}

.btn-level.aktif {
  background: #ef476f;
  color: #fff;
}

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

.skor {
  font-size: 1.05rem;
  font-weight: bold;
  color: #7b5ea7;
  margin-bottom: 8px;
}

.teks-soal {
  font-family: "Courier New", monospace;
  font-size: clamp(2.2rem, 8vw, 3.4rem);
  font-weight: bold;
  color: #d62828;
  margin: 8px 0;
}

.tombol-kuis {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.umpan-balik {
  font-size: clamp(1.05rem, 3vw, 1.3rem);
  font-weight: bold;
  min-height: 1.6em;
  line-height: 1.5;
  border-radius: 14px;
  padding: 10px;
}

.umpan-balik:empty {
  padding: 0;
}

.umpan-balik.benar {
  background: #d8f3dc;
  color: #2d6a4f;
}

.umpan-balik.salah {
  background: #ffe5e5;
  color: #b23a48;
}

/* ---------- Layar kecil (HP portrait, layar sentuh) ---------- */
@media (max-width: 480px) {
  body {
    /* Sisakan ruang untuk bottom tab bar + area aman notch */
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }

  header {
    padding: 14px 10px 6px;
  }

  /* Tab navigasi menjadi bottom tab bar ala aplikasi native */
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    gap: 0;
    background: rgba(255, 253, 245, 0.97);
    border-top: 2px solid #ffd166;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }

  .tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    border-width: 2px;
    border-radius: 14px;
    box-shadow: none;
    min-height: 56px;
  }

  .tab-ikon {
    margin-right: 0;
    font-size: 1.5rem;
    line-height: 1.1;
  }

  .tab-teks {
    font-size: 0.8rem;
  }

  /* Kartu dan teks tetap nyaman dibaca di layar sempit */
  .kartu {
    padding: 14px;
    border-radius: 16px;
  }

  .bingkai {
    padding: 10px 8px;
  }

  /* Manik minimal ~44px supaya mudah disentuh jari anak */
  .manik {
    width: clamp(44px, 12vw, 56px);
    height: 44px;
  }

  .dek-atas {
    height: 58px;
  }

  .dek-bawah {
    height: 224px;
    gap: 6px;
    padding-top: 6px;
  }

  .manik-bawah.jarak {
    margin-top: 18px;
  }

  /* Tombol latihan besar, penuh lebar, mudah disentuh */
  .btn-besar {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    min-height: 52px;
  }

  .tombol-kuis {
    flex-direction: column;
    gap: 10px;
  }

  .btn-level {
    padding: 18px 14px;
    min-height: 56px;
  }
}

/* ---------- Tab Latihan Soal (backend) ---------- */
.form-param {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.label-param {
  font-weight: bold;
  color: #6b4f2a;
  font-size: 1.05rem;
}

/* font-size >= 16px supaya iOS tidak auto-zoom saat fokus */
.input-param {
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: bold;
  padding: 12px 14px;
  border: 3px solid #ffd166;
  border-radius: 14px;
  background: #fffdf5;
  color: #4a3b2a;
  width: 100%;
}

.input-param:focus {
  outline: 3px solid #06d6a0;
  border-color: #06d6a0;
}

.param-dua-kolom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.param-dua-kolom > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.param-operator {
  border: 3px solid #ffd166;
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.pilih-operator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: bold;
  color: #4a3b2a;
  padding: 6px 0;
}

.pilih-operator input {
  width: 24px;
  height: 24px;
  accent-color: #06d6a0;
}

.latihan-error {
  color: #b23a48;
  font-weight: bold;
  min-height: 1.2em;
}

.latihan-error:empty {
  display: none;
}

.banner-adaptif {
  background: #d8f3dc;
  border: 2px solid #a5d6a7;
  color: #2d6a4f;
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: bold;
  margin: 14px 0 0;
  text-align: center;
}

/* Soal ditulis vertikal rata kanan seperti latihan di buku */
.tampilan-soal {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: max-content;
  margin: 12px auto 0;
  font-family: "Courier New", monospace;
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: bold;
  color: #1d3557;
  border-bottom: 4px solid #4a3b2a;
  padding: 4px 8px;
}

.baris-hitung {
  display: flex;
  gap: 12px;
  line-height: 1.25;
}

.op-hitung {
  width: 1ch;
  text-align: left;
  color: #d62828;
}

.angka-hitung {
  min-width: 4ch;
  text-align: right;
}

.baris-jawab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 14px 0;
  font-family: "Courier New", monospace;
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: bold;
  color: #d62828;
}

.input-jawaban {
  font-family: "Courier New", monospace;
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: bold;
  width: 6ch;
  text-align: right;
  padding: 4px 10px;
  border: 3px solid #ffd166;
  border-radius: 14px;
  background: #fffdf5;
  color: #06d6a0;
}

.input-jawaban:focus {
  outline: 3px solid #06d6a0;
  border-color: #06d6a0;
}

.ringkasan-eval {
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  font-weight: bold;
  color: #d62828;
  margin: 10px 0;
}

.analisis-eval {
  color: #6b4f2a;
  font-size: 1.05rem;
  line-height: 1.6;
  text-align: left;
}

.item-salah {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #ffe5e5;
  border-radius: 14px;
  padding: 10px 14px;
  margin: 8px 0;
  flex-wrap: wrap;
}

.item-salah .tampilan-soal {
  font-size: 1.3rem;
  margin: 0;
  border-bottom-width: 2px;
  padding: 2px 6px;
}

.item-salah .jawaban-salah {
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 1.1rem;
  color: #b23a48;
}

.item-salah .jawaban-benar {
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 1.1rem;
  color: #2d6a4f;
}

/* ---------- Tab Riwayat ---------- */
.kartu-set {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
  transition: transform 0.1s;
}

.kartu-set:active {
  transform: scale(0.98);
}

.kartu-set .meta-set {
  color: #6b4f2a;
  font-size: 0.95rem;
  line-height: 1.5;
}

.kartu-set .tanggal-set {
  font-weight: bold;
  color: #4a3b2a;
  font-size: 1.05rem;
}

.badge-skor {
  font-weight: bold;
  font-size: 1.05rem;
  border-radius: 999px;
  padding: 8px 14px;
  white-space: nowrap;
}

.badge-skor.hijau {
  background: #d8f3dc;
  color: #2d6a4f;
}

.badge-skor.kuning {
  background: #fff3b0;
  color: #856a00;
}

.badge-skor.merah {
  background: #ffe5e5;
  color: #b23a48;
}

.badge-skor.abu {
  background: #e9ecef;
  color: #6c757d;
}

.status-set {
  font-size: 0.9rem;
  font-weight: bold;
  color: #b23a48;
}

/* Detail per soal di layar riwayat */
.item-soal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-radius: 14px;
  padding: 10px 14px;
  margin: 8px 0;
  background: #d8f3dc;
  border: 3px solid transparent;
}

.item-soal.salah {
  background: #ffe5e5;
  border-color: #ef476f;
}

.item-soal.belum {
  background: #e9ecef;
}

.item-soal .tampilan-soal {
  font-size: 1.3rem;
  margin: 0;
  border-bottom-width: 2px;
  padding: 2px 6px;
}

.item-soal .info-jawaban {
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 1.1rem;
  text-align: right;
}

.jawaban-coret {
  text-decoration: line-through;
  color: #b23a48;
}

.jawaban-tepat {
  color: #2d6a4f;
}

.jawaban-belum {
  color: #6c757d;
}
