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

@font-face {
  font-family: 'Patrick Hand';
  src: url('../fonts/patrick-hand.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
.hand { font-family: 'Patrick Hand', 'Segoe Script', 'Bradley Hand', 'Comic Sans MS', cursive; }

:root {
  --bg: #0f172a;
  --card: #1e293b;
  --ink: #f1f5f9;
  --dim: #94a3b8;
  --acc: #38bdf8;
  --good: #22c55e;
  --bad: #ef4444;
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  height: 100%;
  overscroll-behavior: none;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(14px, env(safe-area-inset-left));
  height: 100dvh;
}

.screen { display: none; }
.screen.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }

h1 { font-size: clamp(1.7rem, 6vw, 2.4rem); text-align: center; }
h2 { font-size: clamp(1.1rem, 4vw, 1.4rem); }
.sub { color: var(--dim); text-align: center; margin: 4px 0 0; }

/* ---- Home ---- */
#home { align-items: center; justify-content: center; gap: 18px; text-align: center; }
#home .btncol { width: min(420px, 100%); margin-top: 4px; }

/* ---- Profile ---- */
#profile { gap: 10px; }
#profile h2 { text-align: center; }
#profile form { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; overflow-y: auto; padding: 4px; }
#profileMsg { color: var(--dim); font-size: .9rem; text-align: center; }

/* ---- Modules ---- */
#modules { gap: 10px; }
#modules h2 { text-align: center; }
.cardcol { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; overflow-y: auto; padding: 2px 2px 6px; }

/* ---- Play ---- */
#play { gap: 10px; }
.playHeader { display: flex; align-items: center; gap: 10px; }
.playHeader h2 { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quit {
  background: rgba(30, 41, 59, .9);
  color: var(--ink);
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: .9rem;
  cursor: pointer;
  flex-shrink: 0;
}
.quit:active { transform: scale(.97); }

.videoWrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  overflow: hidden;
}
video { width: 100%; height: 100%; object-fit: contain; }

/* ---- Result ---- */
#result { align-items: center; justify-content: center; gap: 14px; text-align: center; }
.big { font-size: clamp(2.2rem, 10vw, 3.4rem); font-weight: 800; color: var(--acc); }
#rDetail { width: 100%; overflow-y: auto; max-height: 40%; }

/* ---- Shared ---- */
.btncol { display: flex; flex-direction: column; gap: 10px; }
.btn {
  background: var(--card);
  color: var(--ink);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 1.05rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.btn:active { transform: scale(.99); }
.btn.primary { background: var(--acc); color: #082f49; border-color: var(--acc); font-weight: 700; text-align: center; }

.card { background: var(--card); border: 1px solid #334155; border-radius: 12px; padding: 14px; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .mod-title { font-weight: 700; }
.card .mod-meta { color: var(--dim); font-size: .85rem; }
.card .mod-score { font-weight: 700; color: var(--acc); white-space: nowrap; }
.card .subrows { margin-top: 10px; border-top: 1px dashed #334155; padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.card .subrows .row { padding: 4px 0; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
input {
  background: var(--card);
  color: var(--ink);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
}
input:focus { outline: 2px solid var(--acc); }
small { color: var(--dim); font-weight: 400; }

.overlay {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .92);
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
}
.quizCard {
  background:
    repeating-linear-gradient(transparent 0 28px, rgba(0, 60, 136, .16) 28px 30px),
    linear-gradient(#fdf8e7, #faf1d8);
  border: 1px solid #e6d9b0;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
  padding: 12px 14px 14px;
  max-height: 100%; overflow-y: auto;
  width: 100%;
  color: #2b2b2b;
}
#qScore {
  color: #b45309;
  font-weight: 700;
  margin-bottom: 6px;
  font-family: 'Patrick Hand', cursive;
  font-size: .95rem;
}
#qText {
  font-weight: 600;
  margin-bottom: 10px;
  font-family: 'Patrick Hand', 'Segoe Script', 'Bradley Hand', 'Comic Sans MS', cursive;
  font-size: 1.15rem;
  line-height: 1.3;
}
#qAnswers { display: flex; flex-direction: column; gap: 6px; }
.ans {
  background: rgba(255, 255, 255, .55);
  border: 1px solid #cfc4a0;
  border-radius: 10px;
  padding: 8px 12px;
  text-align: left;
  color: #2b2b2b;
  font-size: 1.02rem;
  cursor: pointer;
  font-family: 'Patrick Hand', 'Segoe Script', 'Bradley Hand', 'Comic Sans MS', cursive;
}
.ans:hover:not(:disabled) { background: #fff8e1; }
.ans.right { background: #d1fae5; border-color: #34d399; color: #064e3b; }
.ans.wrong { background: #fee2e2; border-color: #f87171; color: #7f1d1d; }
.ans:disabled { cursor: default; }

/* Modal hasil jawaban: menutupi soal & pilihan, tengah, tanpa scroll */
.resultModal {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background:
    repeating-linear-gradient(transparent 0 28px, rgba(0, 60, 136, .16) 28px 30px),
    linear-gradient(#fdf8e7, #faf1d8);
  border: 1px solid #e6d9b0;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
  padding: 20px;
  text-align: center;
  z-index: 3;
}
.rm-verdict { font-size: 2rem; font-weight: 800; font-family: 'Patrick Hand', cursive; }
.rm-verdict.good { color: #15803d; }
.rm-verdict.bad { color: #b91c1c; }
#rmScore { font-size: 1.1rem; font-weight: 700; color: #b45309; font-family: 'Patrick Hand', cursive; }
#rmExplain { color: #5b4a26; font-family: 'Patrick Hand', cursive; font-size: 1.05rem; line-height: 1.35; max-height: 38%; overflow-y: auto; }
#rmNext { min-width: 160px; }

.hidden { display: none !important; }
