:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #5b6a7a;
  --line: #dde4ec;
  --accent: #1f5fa8;
  --accent-ink: #ffffff;
  --good: #1e7d46;
  --bad: #b3392f;
  --warn-bg: #fff7e6;
  --warn-line: #e8c877;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
}

body { -webkit-user-select: none; user-select: none; }
input, textarea { -webkit-user-select: text; user-select: text; }

#app {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 32px;
  box-shadow: 0 1px 3px rgba(20, 35, 60, 0.06);
}

h1 { font-size: 1.6rem; margin: 0 0 12px; }
h2 { font-size: 1.25rem; margin: 0 0 10px; }
p.muted, .muted { color: var(--muted); }
.small { font-size: 0.9rem; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 12px 28px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.secondary {
  background: #e8eef6;
  color: var(--accent);
}
.btn-row { margin-top: 24px; display: flex; gap: 12px; justify-content: flex-end; }
.btn-row.center { justify-content: center; }

/* ---------- top bar during test ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.topbar .section-name { font-weight: 700; }
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.15rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 14px;
  min-width: 92px;
  text-align: center;
}
.timer.low { color: var(--bad); border-color: var(--bad); }

.progress-outer {
  flex: 1;
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.progress-inner {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.25s;
}

/* ---------- questions ---------- */
.qnum { color: var(--muted); font-size: 0.95rem; margin-bottom: 6px; }
.qtext { font-size: 1.2rem; font-weight: 600; margin-bottom: 20px; }

.options { display: flex; flex-direction: column; gap: 10px; }
.options.grid {
  display: grid;
  /* min 120px: svg skala penuh (100) + padding (16) + garis tepi (4).
   * Huruf opsi diletakkan DI ATAS gambar (bukan di samping) supaya kelima
   * opsi muat satu baris tanpa memampatkan svg — skala bentuk pada opsi
   * harus selalu sama dengan sel matriks. */
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.opt {
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--card);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.05rem;
  text-align: left;
  width: 100%;
}
.opt:hover { border-color: var(--accent); }
.opt.selected { border-color: var(--accent); background: #eaf2fb; }
.opt.correct-flash { border-color: var(--good); background: #e9f7ee; }
.opt.wrong-flash { border-color: var(--bad); background: #fbeeec; }
.opt .letter {
  font-weight: 700;
  color: var(--muted);
  min-width: 22px;
}
.opt.svg-opt {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  padding: 6px 8px 8px;
}
.opt.svg-opt .letter { align-self: flex-start; }

/* ---------- matrix ---------- */
.matrix-grid {
  display: grid;
  grid-template-columns: repeat(3, 110px);
  gap: 6px;
  justify-content: center;
  margin: 0 auto 24px;
}
.matrix-cell {
  width: 110px;
  height: 110px;
  border: 1.5px solid var(--ink);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.matrix-cell.missing {
  background: repeating-linear-gradient(45deg, #f2f2f2, #f2f2f2 8px, #e4e4e4 8px, #e4e4e4 16px);
  font-size: 2rem;
  font-weight: 700;
  color: var(--muted);
}
.matrix-cell svg { width: 100px; height: 100px; }
/* Opsi jawaban matriks harus berskala SAMA dengan sel matriks (viewBox
 * identik + ukuran render identik) — pada soal progresi ukuran, opsi yang
 * tampak lebih kecil menyesatkan. */
.opt svg { width: 100px; height: 100px; flex-shrink: 0; }

/* ---------- symbol search ---------- */
.sym-wrap { text-align: center; }
.sym-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
}
.sym-box {
  width: 64px; height: 64px;
  border: 1.5px solid var(--ink);
  background: #fff;
  display: flex; align-items: center; justify-content: center;
}
.sym-box svg { width: 52px; height: 52px; }
.sym-label { font-weight: 700; color: var(--muted); margin: 4px 0; font-size: 0.95rem; letter-spacing: 0.06em; }
.sym-divider { width: 2px; height: 64px; background: var(--ink); margin: 0 16px; }
.sym-buttons { display: flex; justify-content: center; gap: 16px; margin-top: 22px; }
.sym-buttons .btn { min-width: 150px; font-size: 1.15rem; padding: 14px 20px; }
.btn.yes { background: var(--good); }
.btn.no { background: var(--bad); }

/* ---------- feedback / notices ---------- */
.feedback { margin-top: 16px; font-weight: 600; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

.notice {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 16px 0;
}

ul.rules { padding-left: 22px; }
ul.rules li { margin-bottom: 8px; }

/* ---------- form ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 11px 14px;
  font-size: 1.05rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
}
.field input:focus { outline: none; border-color: var(--accent); }

.example-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  margin: 16px 0;
  background: #fafbfd;
}

.done-icon { font-size: 3rem; text-align: center; margin-bottom: 8px; }
.center { text-align: center; }

/* ---------- admin ---------- */
table.results {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.results th, table.results td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}
table.results th { background: #eef2f7; position: sticky; top: 0; }
table.results tr:nth-child(even) td { background: #f8fafc; }
.table-scroll { overflow-x: auto; max-height: 70vh; overflow-y: auto; }
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 700;
  background: #eaf2fb;
  color: var(--accent);
}
.badge.warn { background: #fdeeec; color: var(--bad); }

/* ---------- tab admin ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.invite-link {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}
.invite-link input {
  flex: 1;
  padding: 10px 12px;
  font-size: 0.95rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-family: ui-monospace, monospace;
}
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1; min-width: 180px; margin-bottom: 0; }
