:root {
  --bg: #0a0a0f;
  --panel: rgba(16, 19, 32, 0.82);
  --panel-strong: rgba(10, 13, 23, 0.94);
  --text: #e7eeff;
  --muted: #8d9bca;
  --cyan: #00ffd5;
  --magenta: #ff00ff;
  --blue: #0066ff;
  --green: #33ff33;
  --red: #ff3333;
  --gold: #ffcc00;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 20px 80px rgba(0, 0, 0, 0.45);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(0, 102, 255, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(255, 0, 255, 0.14), transparent 26%),
    radial-gradient(circle at bottom, rgba(0, 255, 213, 0.1), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select {
  font: inherit;
  color: inherit;
}
canvas#matrix-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -3;
  opacity: 0.48;
  pointer-events: none;
}
.noise,
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.noise {
  background-image: radial-gradient(rgba(255,255,255,0.06) 0.5px, transparent 0.5px);
  background-size: 7px 7px;
  opacity: 0.05;
  z-index: -2;
}
.scanlines {
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.03) 50%, transparent 100%);
  background-size: 100% 4px;
  opacity: 0.14;
  z-index: -1;
}
.site-shell {
  width: min(1320px, calc(100% - 2rem));
  margin: 0 auto;
}
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(18px);
  background: rgba(10, 10, 15, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  color: var(--bg);
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  box-shadow: 0 0 25px rgba(0, 255, 213, 0.35);
}
.brand-copy h1,
.brand-copy p {
  margin: 0;
}
.brand-copy h1 {
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(0, 255, 213, 0.4);
}
.brand-copy p {
  color: var(--muted);
  font-size: 0.85rem;
}
.nav-cluster {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.nav-link {
  padding: 0.7rem 1rem;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: 180ms ease;
}
.nav-link:hover,
.nav-link.is-active {
  color: var(--text);
  border-color: rgba(0, 255, 213, 0.35);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 20px rgba(0, 255, 213, 0.06);
}
.auth-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.auth-pill {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.9rem;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
}
.auth-pill__user { font-weight: 700; }
.auth-pill__role {
  color: var(--cyan);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
}
.site-main {
  padding: 2rem 0 4rem;
}
.section {
  margin-bottom: 2rem;
}
.panel,
.hero-card,
.challenge-card,
.modal-panel,
.form-panel,
.table-panel,
.mini-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(20, 24, 40, 0.95), rgba(12, 15, 26, 0.96));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel::before,
.hero-card::before,
.challenge-card::before,
.modal-panel::before,
.form-panel::before,
.table-panel::before,
.mini-card::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(120deg, rgba(0,255,213,0.6), rgba(255,0,255,0.2), rgba(0,102,255,0.55));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0.55;
  pointer-events: none;
}
.hero-grid,
.grid-2,
.grid-3,
.grid-4,
.admin-grid,
.challenge-grid,
.stat-grid,
.two-column {
  display: grid;
  gap: 1rem;
}
.hero-grid { grid-template-columns: 1.3fr 1fr; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.admin-grid { grid-template-columns: 1.1fr 0.9fr; }
.challenge-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.stat-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.two-column { grid-template-columns: 1fr 1fr; }
.hero-card,
.panel,
.form-panel,
.table-panel { padding: 1.4rem; }
.hero-title {
  margin: 0.35rem 0 1rem;
  font-size: clamp(2.2rem, 4vw, 4.8rem);
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: -0.04em;
  text-shadow: 0 0 30px rgba(0,255,213,0.22), 0 0 50px rgba(255,0,255,0.15);
}
.hero-title .accent {
  background: linear-gradient(120deg, var(--cyan), #8ffff0, var(--magenta));
  -webkit-background-clip: text;
  color: transparent;
}
.hero-subtitle,
.muted {
  color: var(--muted);
}
.kicker,
.section-title small,
.eye-brow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  color: var(--cyan);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.typewrite::after {
  content: '_';
  margin-left: 0.08em;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.hero-actions,
.button-row,
.pill-row,
.filter-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.button-row--tight { gap: 0.5rem; }
.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 1.2rem;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
  transition: 180ms ease;
}
.button:hover {
  transform: translateY(-1px);
  border-color: rgba(0,255,213,0.35);
  box-shadow: 0 10px 28px rgba(0, 255, 213, 0.12);
}
.button--primary {
  background: linear-gradient(135deg, rgba(0,255,213,0.22), rgba(0,102,255,0.3));
  border-color: rgba(0,255,213,0.4);
}
.button--ghost { background: rgba(255,255,255,0.03); }
.button--sm { padding: 0.62rem 0.88rem; border-radius: 12px; }
.button.danger { border-color: rgba(255, 51, 51, 0.3); }
.stat-card {
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.stat-card span,
.stat-chip span,
.meta-label {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}
.stat-card strong,
.stat-chip strong,
.hero-number {
  font-size: 1.8rem;
}
.category-chip,
.filter-pill,
.file-pill,
.status,
.category-tag,
.first-blood {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
}
.category-chip strong { font-size: 1rem; }
.filter-pill {
  cursor: pointer;
  color: var(--muted);
}
.filter-pill.is-active { color: var(--text); border-color: rgba(0,255,213,0.35); }
.category-tag--Rev, .category-chip--Rev, .category-border--Rev::before { color: var(--cyan); }
.category-tag--Pwn, .category-chip--Pwn, .category-border--Pwn::before { color: var(--red); }
.category-tag--Web, .category-chip--Web, .category-border--Web::before { color: var(--green); }
.category-tag--Crypto, .category-chip--Crypto, .category-border--Crypto::before { color: var(--gold); }
.category-tag--Forensics, .category-chip--Forensics, .category-border--Forensics::before { color: var(--magenta); }
.challenge-card {
  padding: 1.25rem;
  text-align: left;
  cursor: pointer;
  transition: 180ms ease;
}
.challenge-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 48px rgba(0,0,0,0.4);
}
.challenge-card h3,
.section-title {
  margin: 0.6rem 0;
}
.challenge-card__header,
.challenge-card__meta,
.modal-panel__header,
.leader-name {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
}
.challenge-card__meta {
  margin-top: 1rem;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}
.first-blood {
  color: var(--gold);
  border-color: rgba(255,204,0,0.28);
}
.search-input,
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.95rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(7, 10, 19, 0.82);
  color: var(--text);
  transition: 180ms ease;
}
.field textarea { min-height: 130px; resize: vertical; }
.search-input:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: rgba(0,255,213,0.45);
  box-shadow: 0 0 0 4px rgba(0,255,213,0.09);
}
.field {
  display: grid;
  gap: 0.5rem;
}
.field span,
.field label,
.panel h3,
.table-panel h3,
.form-panel h3 {
  font-weight: 700;
}
.stack-sm,
.stack-md,
.stack-lg,
.section-stack {
  display: grid;
  gap: 1rem;
}
.stack-lg { gap: 1.4rem; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(5, 7, 14, 0.72);
  backdrop-filter: blur(12px);
}
.modal[hidden] { display: none; }
.modal-shell { width: min(920px, 100%); }
.modal-panel { padding: 1.35rem; max-height: 88vh; overflow: auto; }
.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  cursor: pointer;
}
.hint-grid,
.mini-grid { display: grid; gap: 0.85rem; }
.hint-card,
.mini-card {
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.hint-card.is-unlocked { border-color: rgba(0,255,213,0.35); }
.stat-strip {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin: 1rem 0 1.1rem;
}
.stat-chip {
  min-width: 150px;
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.challenge-description {
  white-space: normal;
  color: #dbe4ff;
}
.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}
th, td {
  padding: 0.95rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
th { color: var(--muted); font-weight: 600; }
tr.top-ten { background: rgba(0,255,213,0.04); }
.callout,
.notice {
  padding: 1rem 1.1rem;
  border-radius: 18px;
  background: rgba(0,102,255,0.12);
  border: 1px solid rgba(0,102,255,0.28);
}
.notice.notice--warn {
  background: rgba(255, 204, 0, 0.08);
  border-color: rgba(255, 204, 0, 0.28);
}
.status--good {
  color: var(--green);
  border-color: rgba(51, 255, 51, 0.28);
}
.status--bad {
  color: var(--red);
  border-color: rgba(255, 51, 51, 0.28);
}
.footer {
  padding: 1rem 0 3rem;
  color: var(--muted);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.loading-line {
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(0,255,213,0.18), rgba(255,255,255,0.06));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  margin-bottom: 0.6rem;
}
@keyframes shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 90;
  display: grid;
  gap: 0.75rem;
}
.toast {
  position: relative;
  min-width: 280px;
  padding: 1rem 1rem 1rem 1.1rem;
  border-radius: 18px;
  background: rgba(12, 16, 28, 0.95);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow);
  transform: translateY(12px);
  opacity: 0;
  transition: 220ms ease;
}
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast__glow {
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
}
.toast--error .toast__glow { background: linear-gradient(90deg, var(--red), var(--magenta)); }
.toast--success .toast__glow { background: linear-gradient(90deg, var(--green), var(--cyan)); }

/* ── Solve notifications ─────────────────────────────────────────────────── */
#solve-notif {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  width: min(360px, calc(100vw - 3rem));
  background: rgba(10, 13, 23, 0.97);
  border: 1px solid rgba(0, 255, 213, 0.25);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.1rem 1.3rem;
  box-shadow: 0 0 40px rgba(0, 255, 213, 0.12), var(--shadow);
  opacity: 0;
  transform: translateX(calc(100% + 2rem));
  transition: opacity 280ms ease, transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}
#solve-notif.is-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
#solve-notif.solve-notif--first-blood {
  border-color: rgba(255, 204, 0, 0.45);
  box-shadow: 0 0 48px rgba(255, 204, 0, 0.18), var(--shadow);
}
.solve-notif__glow {
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  border-radius: 0 0 var(--radius) var(--radius);
  background: linear-gradient(90deg, var(--cyan), var(--green));
}
.solve-notif--first-blood .solve-notif__glow {
  background: linear-gradient(90deg, var(--gold), var(--magenta));
  height: 4px;
}
.solve-notif__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.solve-notif__badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--cyan);
  text-transform: uppercase;
}
.solve-notif__badge--blood {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 204, 0, 0.6);
}
.solve-notif__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0;
  line-height: 1;
  transition: color 160ms;
}
.solve-notif__close:hover { color: var(--text); }
.solve-notif__challenge {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.solve-notif__meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.solve-notif__solver {
  font-size: 0.82rem;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-nav {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.admin-nav a {
  padding: 0.7rem 1rem;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.08);
}
.admin-nav a.is-active,
.admin-nav a:hover { color: var(--text); border-color: rgba(0,255,213,0.35); }
.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
}
.inline-checkbox input { width: auto; }
.chart-wrap {
  position: relative;
  min-height: 360px;
}
.badge-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
body.modal-open { overflow: hidden; }
@media (max-width: 1040px) {
  .hero-grid,
  .admin-grid,
  .grid-2,
  .grid-3,
  .grid-4,
  .two-column { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
}
@media (max-width: 720px) {
  .site-shell { width: min(100% - 1rem, 1320px); }
  .brand { align-items: flex-start; }
  .nav-cluster,
  .auth-actions,
  .nav-links { width: 100%; }
  .nav-links { justify-content: center; }
  .auth-actions { justify-content: space-between; }
  .hero-title { font-size: 2.4rem; }
  .toast { min-width: 0; width: min(90vw, 360px); }
}
