[hidden] { display: none !important; }

:root {
  --bg: #000;
  --panel: #141414;
  --panel-2: #1d1d1d;
  --border: #2e2e2e;
  --text: #f2f2f2;
  --muted: #9a9a9a;
  --red: #ff2a2a;
  --red-dim: rgba(255, 42, 42, 0.15);
  --green: #3ddc84;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 28px;
  border-bottom: 2px solid var(--red);
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.18), transparent 60%), #050505;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { color: var(--text); font-weight: 700; letter-spacing: 0.5px; font-size: 1.1rem; }
.brand span { color: var(--red); }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 20px; flex: 1; }
.topbar nav a { color: #ccc; }
.topbar nav a:hover { color: var(--red); text-decoration: none; }
.account { display: flex; align-items: center; gap: 14px; }
.account form { display: inline; }
.user { display: flex; align-items: center; gap: 8px; color: var(--text); }
.user img, .who img { border-radius: 50%; vertical-align: middle; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }
.link-btn:hover { color: var(--red); }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 32px 20px 60px; flex: 1; }
.footer { text-align: center; padding: 24px; color: var(--muted); border-top: 1px solid #1a1a1a; }
.footer a { color: var(--muted); }

h1 { font-size: 2rem; color: var(--red); margin-bottom: 8px; }
h2 { font-size: 1.15rem; color: #ff4d4d; margin: 26px 0 12px; }
h2:first-child { margin-top: 0; }
.lead { font-size: 1.1rem; color: #ddd; margin-bottom: 10px; }
.muted { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit; font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:hover { border-color: var(--red); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { box-shadow: 0 0 18px rgba(255, 42, 42, 0.45); }
.btn-gh { background: #f2f2f2; color: #111; border-color: #f2f2f2; padding: 8px 14px; }
.btn-gh:hover { border-color: var(--red); }

/* ---------- home ---------- */
.hero { padding: 24px 0 32px; }
.hero h1 { font-size: 2.6rem; text-shadow: 0 0 24px rgba(255, 0, 0, 0.45); }
.hero p { color: #ccc; max-width: 640px; font-size: 1.1rem; }

.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.quiz-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  border-radius: 6px;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.quiz-card:hover { transform: translateY(-4px); border-color: var(--red); box-shadow: 0 6px 22px rgba(255, 0, 0, 0.22); text-decoration: none; }
.quiz-card h3 { color: var(--text); font-size: 1.2rem; }
.quiz-card p { color: #bbb; flex: 1; }
.meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.9rem; }
.best { color: var(--green); }

.marathon-card {
  display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap;
  margin-bottom: 10px; padding: 22px 26px;
  background: linear-gradient(110deg, rgba(255, 42, 42, 0.16), var(--panel) 60%);
  border: 1px solid var(--red); border-radius: 6px; color: var(--text);
  transition: box-shadow 0.15s;
}
.marathon-card:hover { box-shadow: 0 0 26px rgba(255, 0, 0, 0.3); text-decoration: none; }
.marathon-card h2 { margin: 6px 0 4px; font-size: 1.5rem; }
.marathon-card p { color: #bbb; margin: 0; }
.marathon-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.streak { color: var(--green); font-weight: 700; }
.q-source { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.tags { display: flex; gap: 6px; margin-bottom: 4px; }
.tag { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.6px; padding: 2px 8px; border-radius: 4px; background: var(--red-dim); color: #ff7a7a; }
.tag-dim { background: #222; color: var(--muted); }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  border-radius: 6px;
  padding: 26px;
}
.quiz-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .quiz-layout { grid-template-columns: 1fr; } }

.signin-box { margin-top: 20px; padding: 20px; background: var(--panel-2); border-radius: 6px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

.mini-board { list-style: none; counter-reset: rank; }
.mini-board li { counter-increment: rank; display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid #222; font-size: 0.92rem; }
.mini-board li span:first-child::before { content: counter(rank) ". "; color: var(--muted); }
.mini-board li span:last-child { color: var(--muted); white-space: nowrap; }

table { width: 100%; border-collapse: collapse; margin-top: 6px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #242424; }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; }
.board td:first-child { color: var(--muted); width: 40px; }
.who { display: flex; align-items: center; gap: 10px; }

/* ---------- quiz runner ---------- */
#quiz-app { margin-top: 22px; scroll-margin-top: 80px; }
.notice { margin-top: 16px; padding: 8px 12px; border-radius: 6px; background: #1c1c1c; color: #ccc; font-size: 0.9rem; }
.error { margin-bottom: 12px; padding: 10px 14px; border-radius: 6px; background: rgba(255, 42, 42, 0.12); border: 1px solid var(--red); color: #ffb3b3; }

.progress { margin-bottom: 14px; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }
.progress-bar { height: 6px; background: #222; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--red); width: 0; transition: width 0.3s; }

.q-card {
  background-color: #0e0e0e;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px;
}
.q-prompt { font-size: 1.15rem; margin-bottom: 14px; }

.code-wrap { overflow-x: auto; border: 1px solid #262626; border-radius: 6px; margin-bottom: 18px; }
.code-wrap canvas { display: block; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

.choices { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.choice {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  background: rgba(40, 40, 40, 0.35);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit; text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.choice:hover:not(:disabled) { border-color: var(--red); background: rgba(255, 42, 42, 0.08); }
.choice:disabled { cursor: default; }
.choice-text { font-family: var(--mono); font-size: 0.95rem; }
.letter {
  flex: none; width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #262626; color: #ccc;
  font-weight: 700; font-size: 0.85rem;
}
.choice.pending { border-color: #777; }
.choice.correct { border-color: var(--green); background: rgba(61, 220, 132, 0.1); }
.choice.correct .letter { background: var(--green); color: #000; }
.choice.wrong { border-color: var(--red); background: rgba(255, 42, 42, 0.1); }
.choice.wrong .letter { background: var(--red); color: #fff; }

.feedback { margin-top: 16px; color: #ddd; }
.feedback:empty { display: none; }
.feedback .ok { color: var(--green); }
.feedback .bad { color: #ff6b6b; }
.next-btn { margin-top: 16px; }

.result { text-align: center; padding: 30px 10px; }
.score { font-size: 4rem; font-weight: 800; color: var(--red); line-height: 1; margin-bottom: 12px; }
.score span { font-size: 1.6rem; color: var(--muted); font-weight: 600; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .topbar nav { order: 3; width: 100%; }
  .hero h1 { font-size: 2rem; }
  .panel { padding: 18px; }
}

/* ---------- question countdown ---------- */
.clock { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.clock-bar { flex: 1; height: 8px; background: #222; border-radius: 4px; overflow: hidden; }
.clock-fill { height: 100%; width: 100%; background: #e6e6e6; border-radius: 4px; }
.clock-text { min-width: 3.2em; text-align: right; font-family: var(--mono); font-weight: 700; color: #ddd; }
.clock.urgent .clock-fill { background: var(--red); }
.clock.urgent .clock-text { color: var(--red); }
.clock.stopped { opacity: 0.45; }

.cat-heading { margin: 34px 0 14px; color: #ff4d4d; border-bottom: 1px solid #2a2a2a; padding-bottom: 6px; }
