:root {
  --bg: #0f1020;
  --bg-card: #1a1b2e;
  --bg-elev: #23254040;
  --accent: #6c5ce7;
  --accent-2: #00cec9;
  --text: #f2f3f7;
  --muted: #a3a6c2;
  --border: #2c2e4a;
  --good: #00b894;
  --bad: #ff6b6b;
  --gold: #ffd166;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #2a2c52 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.admin-wrap { max-width: 900px; }

header.page {
  text-align: center;
  margin: 12px 0 22px;
}

header.page h1 {
  margin: 0 0 6px;
  font-size: 1.7rem;
  letter-spacing: 0.2px;
}

header.page p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.card {
  background: linear-gradient(180deg, var(--bg-card), #16172a);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

label { display: block; font-weight: 600; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 0.85rem; font-weight: 400; }

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px; /* prevents iOS zoom on focus */
  color: var(--text);
  background: #0e0f1f;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.25);
}

.q-block { margin-bottom: 14px; }
.q-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.q-num { font-weight: 700; }
.q-points { color: var(--muted); font-size: 0.82rem; }

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 8px;
}

.choice {
  position: relative;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: block;
  text-align: center;
  padding: 13px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0e0f1f;
  cursor: pointer;
  font-weight: 600;
  user-select: none;
  transition: all 0.12s;
  word-break: break-word;
}
.choice input:checked + span {
  background: linear-gradient(180deg, var(--accent), #5847c9);
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(108, 92, 231, 0.4);
}

button, .btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, var(--accent), #5847c9);
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  cursor: pointer;
  width: 100%;
  transition: transform 0.08s, opacity 0.15s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

button.secondary {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
}
button.danger {
  background: transparent;
  border: 1px solid var(--bad);
  color: var(--bad);
  width: auto;
  padding: 8px 12px;
  font-size: 0.85rem;
}
button.inline { width: auto; padding: 10px 16px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }

.msg { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.msg.error { background: rgba(255, 107, 107, 0.12); border: 1px solid var(--bad); color: var(--bad); }
.msg.success { background: rgba(0, 184, 148, 0.12); border: 1px solid var(--good); color: var(--good); }

.center { text-align: center; }
.hidden { display: none !important; }

/* Result screen */
.result { text-align: center; padding: 12px 0; }
.result .big { font-size: 3rem; font-weight: 800; margin: 8px 0; }
.result .score-bar {
  font-size: 2.2rem; font-weight: 800;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; background: var(--bg-elev); padding: 5px; border-radius: 12px; }
.tab {
  flex: 1; text-align: center; padding: 11px 8px; border-radius: 9px;
  cursor: pointer; font-weight: 700; color: var(--muted); width: auto;
  background: transparent; font-size: 0.92rem;
}
.tab.active { background: var(--accent); color: #fff; }

.board { width: 100%; border-collapse: collapse; }
.board th, .board td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--border); }
.board th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.4px; }
.board tr:last-child td { border-bottom: none; }
.rank { font-weight: 800; width: 38px; }
.rank.top1 { color: var(--gold); }
.rank.top2 { color: #c0c6d6; }
.rank.top3 { color: #cd7f32; }
.score-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-weight: 800;
  background: rgba(108, 92, 231, 0.2); border: 1px solid var(--accent);
}

.crumbs { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.crumb { width: 18px; height: 18px; border-radius: 5px; font-size: 0; }
.crumb.ok { background: var(--good); }
.crumb.no { background: #3a3c5c; }

.admin-q {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  background: #14152a;
}
.admin-q .q-title { font-weight: 800; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.field { margin-bottom: 10px; }
.field label { font-size: 0.85rem; margin-bottom: 5px; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.toggle-row .label { font-weight: 600; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: #3a3c5c; border-radius: 999px; transition: 0.2s; cursor: pointer;
}
.slider::before {
  content: ""; position: absolute; height: 22px; width: 22px; left: 4px; top: 4px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--good); }
.switch input:checked + .slider::before { transform: translateX(22px); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.spacer { height: 8px; }
.sticky-actions { position: sticky; bottom: 0; padding-top: 10px; }

footer.foot { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 18px; }
footer.foot a { color: var(--accent-2); text-decoration: none; }
