:root {
  --bg: #f4f5ff;
  --card: #ffffff;
  --ink: #1e1b4b;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --accent: #f59e0b;
  --green: #22c55e;
  --red: #ef4444;
  --radius: 18px;
  --shadow: 0 8px 30px rgba(79, 70, 229, 0.12);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: linear-gradient(160deg, #eef2ff 0%, #fdf2f8 50%, #ecfeff 100%);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 700px; margin: 0 auto; padding: 16px 16px 40px; }

.screen { display: none; animation: fade .25s ease; }
.screen.active { display: block; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Hero */
.hero { text-align: center; padding: 22px 8px 14px; }
.hero-badge { font-size: 56px; line-height: 1; margin-bottom: 8px; animation: bounce 2s infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.hero-title { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; }
.hero-sub { color: var(--muted); font-size: 15px; margin-top: 4px; }

/* Player card */
.player-card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin: 8px 0 22px; }
.field-label { font-weight: 700; font-size: 14px; display: block; margin-bottom: 8px; }
input[type="text"] {
  width: 100%; padding: 14px 16px; font-size: 16px; font-family: var(--font);
  border: 2px solid #e5e7eb; border-radius: 12px; outline: none; transition: border .15s;
}
input[type="text"]:focus { border-color: var(--primary); }

/* Buttons */
.btn {
  font-family: var(--font); font-weight: 700; font-size: 16px; cursor: pointer;
  padding: 13px 20px; border: none; border-radius: 14px; transition: transform .1s, box-shadow .15s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.btn-primary:hover { box-shadow: 0 8px 20px rgba(79, 70, 229, 0.35); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-block { width: 100%; margin-top: 12px; }
.btn-ghost { background: #eef2ff; color: var(--primary); padding: 10px 16px; font-size: 14px; }
.btn-green { background: var(--green); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }

.section-title { font-size: 18px; font-weight: 800; margin: 8px 0 12px; }

/* Level grid */
.level-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.level-card {
  background: var(--card); border-radius: var(--radius); padding: 16px; cursor: pointer;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px;
  transition: transform .12s; -webkit-tap-highlight-color: transparent; border: 2px solid transparent;
}
.level-card:active { transform: scale(0.97); }
.level-card .lv-emoji { font-size: 34px; }
.level-card .lv-label { font-weight: 800; font-size: 15px; }
.level-card .lv-umur { color: var(--muted); font-size: 12px; }

/* Category grid */
.category-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.cat-card {
  background: var(--card); border-radius: var(--radius); padding: 20px 14px; cursor: pointer;
  box-shadow: var(--shadow); text-align: center; transition: transform .12s;
  -webkit-tap-highlight-color: transparent; border: 2px solid transparent;
}
.cat-card:active { transform: scale(0.97); }
.cat-card .cat-emoji { font-size: 36px; display: block; margin-bottom: 6px; }
.cat-card .cat-label { font-weight: 800; font-size: 14px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 6px 0 14px;
  position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-weight: 800; font-size: 16px; flex: 1; text-align: center; }
.score-chip {
  background: var(--primary); color: #fff; font-weight: 800; font-size: 14px;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}

/* Progress */
.progress-track { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--green), #84cc16); border-radius: 999px; width: 0%; transition: width .3s; }

/* Quiz body */
.quiz-body { display: flex; flex-direction: column; gap: 16px; }
.q-card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.q-emoji { font-size: 44px; line-height: 1; margin-bottom: 10px; }
.q-text { font-size: 19px; font-weight: 700; line-height: 1.45; }
.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; background: #f8fafc; border: 2px solid #e5e7eb;
  border-radius: 14px; padding: 14px 16px; cursor: pointer; font-size: 16px; font-weight: 600;
  transition: border .12s, background .12s; -webkit-tap-highlight-color: transparent; text-align: left; width: 100%;
}
.opt .opt-key { width: 26px; height: 26px; border-radius: 50%; background: #e5e7eb; font-weight: 800; display: grid; place-items: center; font-size: 13px; flex-shrink: 0; }
.opt.selected { border-color: var(--primary); background: #eef2ff; }
.opt.correct { border-color: var(--green); background: #ecfdf5; }
.opt.wrong { border-color: var(--red); background: #fef2f2; }

/* Result */
.result-body { text-align: center; }
.result-card { background: var(--card); border-radius: 24px; padding: 28px 20px; box-shadow: var(--shadow); }
.result-emoji { font-size: 64px; margin-bottom: 8px; }
.result-score { font-size: 52px; font-weight: 800; letter-spacing: -1px; }
.result-score small { font-size: 20px; color: var(--muted); }
.result-praise { font-size: 17px; font-weight: 700; margin: 8px 0 18px; }
.result-actions { display: flex; flex-direction: column; gap: 10px; }

/* Leaderboard */
.leaderboard-body { display: flex; flex-direction: column; gap: 10px; }
.lb-row {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
}
.lb-rank { font-weight: 800; font-size: 18px; width: 34px; color: var(--muted); text-align: center; }
.lb-rank.top1 { color: #f59e0b; }
.lb-rank.top2 { color: #9ca3af; }
.lb-rank.top3 { color: #b45309; }
.lb-name { flex: 1; font-weight: 700; font-size: 15px; }
.lb-score { font-weight: 800; color: var(--primary); font-size: 16px; }
.lb-empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 28px; }

.hidden { display: none !important; }

@media (min-width: 600px) {
  .level-grid, .category-grid { grid-template-columns: 1fr 1fr 1fr; }
  #app { padding-top: 24px; }
}
