:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-2: #1f2330;
  --border: #2a2f3e;
  --text: #e8eaf0;
  --muted: #9aa1b3;
  --accent: #6c8cff;
  --accent-2: #8f6cff;
  --ok: #38c98c;
  --warn: #f5b942;
  --bad: #ff6b6b;
  --radius: 14px;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
a { color: var(--accent); }
button {
  font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text); padding: 10px 16px; border-radius: 10px; transition: .15s;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; font-weight: 600; }
button.danger { border-color: var(--bad); color: var(--bad); }
button.small { padding: 6px 10px; font-size: 13px; }
input, select, textarea {
  font: inherit; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; width: 100%;
}
textarea { min-height: 160px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; margin: 0; letter-spacing: .3px; }
.topbar .who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.topbar img { width: 30px; height: 30px; border-radius: 50%; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.grid { display: grid; gap: 20px; }
@media (min-width: 900px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card h2 { margin: 0 0 12px; font-size: 16px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .8px; }
.card h3 { margin: 0 0 8px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.bad { color: var(--bad); border-color: var(--bad); }
.pill.accent { color: var(--accent); border-color: var(--accent); }

.login { display: grid; place-items: center; min-height: 80vh; text-align: center; }
.login .card { max-width: 420px; }
.login h1 { font-size: 28px; margin: 0 0 6px; }

.people { display: grid; gap: 8px; max-height: 420px; overflow: auto; padding-right: 4px; }
.person {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--panel-2);
}
.person img, .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--border); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.person .name { font-weight: 500; }
.person .email { font-size: 12px; color: var(--muted); }
.person.taken { opacity: .55; }
.person.selected { border-color: var(--accent); background: rgba(108,140,255,.12); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel-2);
  border: 1px solid var(--border); padding: 12px 18px; border-radius: 12px; max-width: 90vw; z-index: 50;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.bad { border-color: var(--bad); }
.toast.ok { border-color: var(--ok); }

/* quiz */
.question-box { padding: 28px; }
.timer { font-variant-numeric: tabular-nums; font-size: 44px; font-weight: 700; line-height: 1; }
.timer.low { color: var(--bad); }
.bar { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: 12px 0 20px; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .25s linear; }
.qtext { font-size: 22px; font-weight: 600; margin: 8px 0 18px; }
.options { display: grid; gap: 10px; }
@media (min-width: 700px) { .options { grid-template-columns: 1fr 1fr; } }
.option {
  text-align: left; padding: 16px; border-radius: 12px; font-size: 16px; border: 1px solid var(--border);
  background: var(--panel-2); display: flex; gap: 12px; align-items: center;
}
.option .key { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--bg); font-weight: 700; font-size: 13px; color: var(--muted); }
.option.chosen { border-color: var(--accent); background: rgba(108,140,255,.15); }
.option.correct { border-color: var(--ok); background: rgba(56,201,140,.15); }
.option.wrong { border-color: var(--bad); background: rgba(255,107,107,.15); }
.big { font-size: 40px; font-weight: 800; }
.stat { display: grid; gap: 2px; }
.stat .v { font-size: 26px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
tr.top1 td:first-child { color: #ffd166; }
tr.top2 td:first-child { color: #cfd8dc; }
tr.top3 td:first-child { color: #d29a6b; }
.rank { font-weight: 800; font-size: 18px; width: 40px; }
.progress { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; width: 120px; }
.progress > div { height: 100%; background: var(--accent); }
.kpi { font-size: 40px; font-weight: 800; line-height: 1; }
.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }

/* ===================== polish ===================== */
body { background:
  radial-gradient(50vw 40vh at 10% 0%, rgba(108,140,255,.16), transparent 60%),
  radial-gradient(50vw 40vh at 100% 20%, rgba(143,108,255,.12), transparent 60%), var(--bg); background-attachment: fixed; }
h1, h3, .big, .timer, .stat .v, .kpi, .rank { font-family: Sora, Inter, system-ui, sans-serif; }
.topbar { backdrop-filter: blur(10px); background: rgba(23,26,35,.85); }
.card { box-shadow: 0 10px 30px rgba(0,0,0,.25); }
button.primary { box-shadow: 0 8px 24px rgba(108,140,255,.25); }
button.primary:active { transform: translateY(1px); }
.option { min-height: 60px; }
.option:active:not(:disabled) { transform: scale(.985); }
.person { min-height: 52px; }
.person[data-select] { cursor: pointer; }
.pill { white-space: nowrap; }
.login h1 { font-size: 32px; }
.login .card { width: 100%; }
.stat .v { font-size: 24px; }

/* ===================== phones ===================== */
@media (max-width: 640px) {
  .wrap { padding: 14px 12px 40px; }
  .topbar { padding: 10px 12px; }
  .topbar h1 { font-size: 16px; }
  .topbar .who { gap: 8px; font-size: 13px; }
  .topbar .who .me-name { display: none; }
  .card { padding: 16px; border-radius: 12px; }
  .grid { gap: 14px; }
  .people { max-height: none; }
  .question-box { padding: 16px; }
  .question-box .row { gap: 12px; }
  .stat .v { font-size: 20px; }
  .stat .l { font-size: 10px; }
  .timer { font-size: 34px; }
  .qtext { font-size: 19px; }
  .options { grid-template-columns: 1fr; gap: 8px; }
  .option { padding: 14px; font-size: 15px; }
  .big { font-size: 34px; }
  table { display: block; overflow-x: auto; }
  th, td { padding: 8px 6px; font-size: 13px; }
  .toast { bottom: 12px; width: calc(100% - 24px); text-align: center; }
  input, button { font-size: 16px; } /* prevents iOS zoom on focus */
}
@media (hover: none) { button:hover { border-color: var(--border); } }

/* question images */
.qimg { display: block; width: 100%; max-height: 42vh; object-fit: contain; border-radius: 12px; background: #fff; margin: 0 0 16px; cursor: zoom-in; border: 1px solid var(--border); }
.qimg.small { max-height: 30vh; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 100; display: grid; place-items: center; cursor: zoom-out; padding: 12px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.qthumb { width: 64px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: #fff; vertical-align: middle; margin-right: 8px; }
.qform { display: grid; gap: 10px; }
.qform .opt { display: flex; gap: 8px; align-items: center; }
.qform .opt input[type=radio] { width: 18px; height: 18px; flex: none; }
.imgprev { max-height: 140px; border-radius: 8px; border: 1px solid var(--border); background: #fff; display: block; }
