:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1e2635;
  --muted: #5a6577;
  --line: #dfe4ee;
  --accent: #2563eb;
  --accent-dark: #1a4bc4;
  --good: #12854f;
  --bad: #c0392b;
  --code-bg: #0f1830;
  --code-ink: #e6ecff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

code { font-family: Consolas, "Courier New", monospace; background: #eef1f8; padding: 1px 5px; border-radius: 4px; }

.q-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  background: #0f1420;
  color: #fff;
}
.q-header .brand { color: #fff; text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.q-header .brand .dot { width: 12px; height: 12px; border-radius: 50%; background: #22d3a6; display: inline-block; }
.q-header .tagline { color: #9fb0cf; font-size: 14px; }

.q-wrap { max-width: 880px; margin: 0 auto; padding: 26px 18px 60px; }

.q-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.q-card.narrow { max-width: 460px; margin: 40px auto; }
.q-card h1 { margin: 0 0 8px; font-size: 22px; }
.lead { color: var(--muted); margin: 0 0 14px; }
.hint { color: var(--muted); font-size: 13px; }
.who { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.err { background: #fdecea; color: #b42318; border: 1px solid #f5c2bd; padding: 10px 12px; border-radius: 8px; }
.ok-msg { background: #e7f7ee; color: #12854f; border: 1px solid #b7e6c9; padding: 10px 12px; border-radius: 8px; }
.reg-form textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  resize: vertical;
}
.q-card h2.group-title { border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.q-card ol, .q-card ul { padding-left: 20px; }
.q-card li { margin: 4px 0; }

/* registration / login */
.reg-form { display: grid; gap: 12px; max-width: 420px; }
.reg-form label { display: grid; gap: 5px; font-size: 14px; font-weight: 600; color: #333c4d; }
.reg-form input, .reg-form select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

/* buttons */
.btn {
  display: inline-block;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}
.btn:hover { background: var(--accent-dark); }
.btn.ghost { background: #eef1f8; color: var(--ink); }
.btn.ghost:hover { background: #e2e7f2; }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #a5301f; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.inline-form { margin: 0; }
.limit-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 14px; }
.limit-form label { display: grid; gap: 5px; font-size: 14px; font-weight: 600; color: #333c4d; }
.limit-form input { font: inherit; width: 110px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* questions */
.intro-card { position: sticky; top: 10px; }
.q-timer {
  float: right;
  margin-left: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  background: #eef3ff;
  color: var(--accent-dark);
  font-size: 14px;
  white-space: nowrap;
}
.q-timer strong { font-family: Consolas, "Courier New", monospace; font-size: 18px; margin-left: 4px; }
.q-timer.low { background: #fdecea; color: var(--bad); }
.q {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.q-no {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.q-topic { font-weight: 700; }
.q-week { margin-left: auto; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }

.q-code {
  margin: 0;
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 16px 18px;
  border-radius: 10px;
  overflow-x: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre;
}

/* drop zone inside the code */
.qzone {
  display: inline-block;
  min-width: 10ch;
  height: 1.6em;
  margin: 0 2px;
  padding: 0 8px;
  border: 2px dashed #7f9cf5;
  border-radius: 6px;
  background: #17224a;
  vertical-align: baseline;
  text-align: center;
}
.qzone.over { border-color: #22d3a6; background: #17324a; }
.qzone.empty { border-color: #ff6b6b; animation: qshake .4s; }
.qzone.filled { border-style: solid; border-color: transparent; background: transparent; padding: 0; }

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

/* draggable token */
.qchip {
  display: inline-block;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  cursor: grab;
  user-select: none;
  white-space: nowrap;
}
.qchip:active { cursor: grabbing; }
.qchip.selected { outline: 3px solid #22d3a6; outline-offset: 1px; }

/* multiple-choice option */
.q-text { font-weight: 600; margin: 0 0 8px; }
.opt {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 6px 0;
  cursor: pointer;
}
.opt:hover { background: #f5f8ff; }
.opt input { margin: 0; }
.opt:has(input:checked) { border-color: var(--accent); background: #eef3ff; }
.opt:has(input:checked) span { font-weight: 700; }

/* token pool under each question */
.qpool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #f7f9fe;
  min-height: 44px;
}

.submit-bar { display: flex; align-items: center; gap: 14px; margin: 22px 0 0; }

/* result */
.score-big { font-size: 56px; font-weight: 800; color: var(--good); margin: 6px 0 10px; }

/* stats + table */
.stats { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 18px; }
.stats li { background: #eef1f8; border-radius: 10px; padding: 12px 18px; min-width: 150px; }
.stats li span { display: block; color: var(--muted); font-size: 13px; }
.stats li strong { font-size: 24px; }

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  margin: 20px 0 8px;
}
.group-title:first-of-type { margin-top: 6px; }
.group-count {
  background: #eef1f8;
  color: var(--muted);
  border-radius: 999px;
  font-size: 12px;
  padding: 1px 9px;
}

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
thead th { background: #f2f5fb; }
.empty { text-align: center; color: var(--muted); padding: 18px; }

.on { color: var(--good); }
.off { color: var(--bad); }

.q-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px; }
