/* ==========================================================================
   EduCTF — visual design system
   A polished, modern dark theme. Tokens first, then components.
   ========================================================================== */

:root {
  /* Surfaces */
  --bg:        #0a0d16;
  --bg-grad-1: #10152a;
  --bg-grad-2: #0a0d16;
  --surface:   #121727;
  --surface-2: #171d31;
  --surface-3: #1d2440;
  --border:    #262d47;
  --border-hi: #3a4470;

  /* Text */
  --text:   #e8eaf4;
  --muted:  #a3abc9;
  --faint:  #6b7396;

  /* Brand + accents */
  --brand:   #6366f1;
  --brand-2: #8b5cf6;
  --cyan:    #22d3ee;
  --gold:    #fbbf24;

  /* Category accents */
  --crypto:    #a78bfa;
  --web:       #38bdf8;
  --forensics: #34d399;

  /* Status */
  --ok:   #22c55e;
  --bad:  #f43f5e;
  --warn: #f59e0b;

  /* Difficulty */
  --d-easy:   #34d399;
  --d-emed:   #22d3ee;
  --d-med:    #fbbf24;
  --d-mhard:  #fb923c;
  --d-hard:   #f43f5e;

  --radius:   14px;
  --radius-sm: 9px;
  --shadow:   0 10px 40px -12px rgba(0, 0, 0, .6);
  --shadow-sm: 0 4px 16px -6px rgba(0, 0, 0, .5);
  --ring: 0 0 0 3px rgba(99, 102, 241, .35);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(99, 102, 241, .12), transparent 60%),
    radial-gradient(1000px 500px at 0% 0%, rgba(139, 92, 246, .10), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono { font-family: var(--mono); }

h1, h2, h3 { line-height: 1.2; margin: 0; }

/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(10, 13, 22, .72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -.02em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 4px 14px -3px rgba(99, 102, 241, .6);
  font-size: 1rem;
}

.nav nav { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.nav nav a {
  color: var(--muted);
  padding: .45rem .7rem;
  border-radius: 8px;
  font-weight: 500;
  font-size: .93rem;
  transition: background .15s, color .15s;
}
.nav nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav .who {
  color: var(--text);
  font-weight: 600;
  padding: .45rem .7rem .45rem .6rem;
  display: inline-flex; align-items: center; gap: .4rem;
}
.nav .who::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 8px var(--ok);
}
.nav .cta {
  color: #fff !important;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 4px 14px -4px rgba(99, 102, 241, .7);
}
.nav .cta:hover { filter: brightness(1.08); }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) 4rem;
}

.foot {
  border-top: 1px solid var(--border);
  color: var(--faint);
  text-align: center;
  padding: 1.6rem 1rem;
  font-size: .88rem;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .7rem 1.25rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 18px -6px rgba(99, 102, 241, .6);
  transition: transform .12s, filter .15s, box-shadow .15s;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.ghost {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hi);
  box-shadow: none;
}
.btn.ghost:hover { background: var(--surface-3); }
.btn.small { padding: .55rem .9rem; font-size: .9rem; border-radius: 9px; }

/* --------------------------------------------------------------------------
   Hero (home)
   -------------------------------------------------------------------------- */
.hero {
  text-align: center;
  padding: clamp(2rem, 6vw, 4.5rem) 1rem clamp(1.5rem, 4vw, 3rem);
}
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: .4rem .8rem; border-radius: 999px;
  margin-bottom: 1.4rem;
}
.hero .eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 800;
  letter-spacing: -.03em;
  background: linear-gradient(135deg, #fff 20%, #b9bef0 60%, var(--brand-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero .lead {
  max-width: 640px; margin: 1.1rem auto 0;
  color: var(--muted); font-size: 1.12rem;
}
.hero .lead strong { color: var(--text); }
.hero .row { display: flex; gap: .8rem; justify-content: center; margin-top: 2rem; flex-wrap: wrap; }

/* Stats strip */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  max-width: 620px;
  margin: 2.6rem auto 0;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  text-align: center;
}
.stat .num {
  font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em;
  background: linear-gradient(135deg, #fff, var(--brand-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.stat .label { color: var(--faint); font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; }

/* --------------------------------------------------------------------------
   Section headers
   -------------------------------------------------------------------------- */
.section-title {
  font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em;
  margin: 2.6rem 0 1.2rem;
}

.cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.1rem; }
.cat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  position: relative; overflow: hidden;
  transition: transform .15s, border-color .15s;
}
.cat-card:hover { transform: translateY(-3px); border-color: var(--border-hi); }
.cat-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent, var(--brand));
}
.cat-card .ico {
  width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center;
  font-size: 1.4rem; margin-bottom: .9rem;
  background: color-mix(in srgb, var(--accent, var(--brand)) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, var(--brand)) 35%, transparent);
}
.cat-card h3 { font-size: 1.2rem; }
.cat-card .muted { color: var(--faint); font-size: .85rem; margin: .2rem 0 1rem; }
.cat-card .mini { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.cat-card .mini li {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .92rem; color: var(--muted);
  padding: .3rem 0; border-top: 1px dashed var(--border);
}
.cat-card .mini li:first-child { border-top: 0; }
.cat-card .mini em { font-style: normal; color: var(--gold); font-weight: 700; font-family: var(--mono); font-size: .85rem; }

/* --------------------------------------------------------------------------
   Challenges page
   -------------------------------------------------------------------------- */
.chal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem;
}
.chal-head h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.score-pill {
  background: var(--surface); border: 1px solid var(--border);
  padding: .6rem 1.1rem; border-radius: 999px; font-weight: 600; color: var(--muted);
}
.score-pill strong { color: var(--gold); font-family: var(--mono); font-size: 1.1rem; }

.cat-section { margin-top: 2.4rem; }
.cat-bar {
  display: flex; align-items: center; gap: .8rem; margin-bottom: 1.1rem;
}
.cat-bar .cat-title {
  font-size: 1.3rem; font-weight: 700; display: inline-flex; align-items: center; gap: .55rem;
}
.cat-bar .cat-title .swatch { width: 12px; height: 12px; border-radius: 4px; background: var(--accent); }
.cat-bar .progress-wrap { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; max-width: 340px; }
.cat-bar .progress { height: 100%; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 40%, #fff)); border-radius: 999px; transition: width .5s; }
.cat-bar .count { color: var(--faint); font-size: .85rem; font-family: var(--mono); white-space: nowrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.15rem; }

.chal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem;
  display: flex; flex-direction: column; gap: .8rem;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.chal:hover { transform: translateY(-3px); border-color: var(--border-hi); box-shadow: var(--shadow-sm); }
.chal.solved {
  border-color: color-mix(in srgb, var(--ok) 55%, var(--border));
  background: linear-gradient(180deg, color-mix(in srgb, var(--ok) 8%, var(--surface)), var(--surface));
}
.chal.solved::after {
  content: "✓"; position: absolute; top: 1rem; right: 1rem;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: .9rem; font-weight: 800;
  color: #04170c; background: var(--ok); box-shadow: 0 0 12px rgba(34, 197, 94, .6);
}

.chal-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.chal-top h3 { font-size: 1.15rem; font-weight: 700; padding-right: 1.6rem; }
.chal .pts {
  font-family: var(--mono); font-weight: 700; color: var(--gold);
  font-size: .95rem; white-space: nowrap;
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
  padding: .2rem .55rem; border-radius: 8px;
}
.badges { display: flex; gap: .4rem; flex-wrap: wrap; }
.badge {
  font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: .22rem .55rem; border-radius: 6px;
}
.badge.diff { color: var(--d); background: color-mix(in srgb, var(--d) 16%, transparent); border: 1px solid color-mix(in srgb, var(--d) 35%, transparent); }
.diff-easy   { --d: var(--d-easy); }
.diff-easymedium { --d: var(--d-emed); }
.diff-medium { --d: var(--d-med); }
.diff-mediumhard { --d: var(--d-mhard); }
.diff-hard   { --d: var(--d-hard); }

.chal .desc { color: var(--muted); font-size: .93rem; margin: 0; flex: 1; }

.chal .files, .chal .service { font-size: .85rem; color: var(--faint); display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.file-chip, .service-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  font-family: var(--mono); font-size: .8rem;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: .25rem .55rem; border-radius: 7px; color: var(--cyan);
}
.file-chip:hover { border-color: var(--border-hi); text-decoration: none; }
.service-chip { color: var(--web); }

.submit-row { display: flex; flex-direction: column; gap: .5rem; margin-top: .3rem; }
.flag-form { display: flex; gap: .5rem; }
.flag-form input {
  flex: 1; min-width: 0;
  padding: .6rem .8rem; border-radius: 9px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  font-family: var(--mono); font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
}
.flag-form input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.solved-tag { color: var(--ok); font-weight: 700; display: inline-flex; align-items: center; gap: .4rem; }
.result { font-size: .88rem; min-height: 1.1em; font-weight: 600; }
.result.ok  { color: var(--ok); }
.result.bad { color: var(--bad); }

/* --------------------------------------------------------------------------
   Auth pages (login / register) — split-screen layout
   -------------------------------------------------------------------------- */
.logout-form { display: inline; margin: 0; }
.linklike {
  background: none; border: 0; padding: .45rem .7rem; margin: 0;
  color: var(--muted); font: inherit; font-weight: 500; font-size: .93rem;
  border-radius: 8px; cursor: pointer; transition: background .15s, color .15s;
}
.linklike:hover { color: var(--text); background: var(--surface-2); }

.auth-split {
  display: grid;
  grid-template-columns: 1.02fr .98fr;
  max-width: 960px;
  margin: clamp(1.2rem, 5vw, 3.4rem) auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* Left: brand / value panel */
.auth-aside {
  position: relative;
  padding: clamp(1.8rem, 4vw, 2.6rem);
  display: flex; flex-direction: column;
  color: #eef0ff;
  background:
    radial-gradient(600px 300px at 120% -10%, rgba(255,255,255,.18), transparent 60%),
    linear-gradient(160deg, var(--brand), var(--brand-2) 70%, #6d28d9);
  overflow: hidden;
}
.auth-aside::after {
  content: ""; position: absolute; inset: auto -30% -40% -30%; height: 70%;
  background: radial-gradient(closest-side, rgba(255,255,255,.16), transparent);
  pointer-events: none;
}
.auth-aside .brand-lg {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 800; font-size: 1.15rem; color: #fff; letter-spacing: -.02em;
}
.auth-aside .brand-lg:hover { text-decoration: none; }
.auth-aside .brand-lg .logo {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3);
}
.auth-aside h2 {
  font-size: clamp(1.5rem, 3.2vw, 2rem); font-weight: 800; letter-spacing: -.02em;
  margin: auto 0 .4rem; padding-top: 2rem;
}
.auth-aside .aside-lead { color: rgba(255,255,255,.85); margin: 0 0 1.4rem; font-size: 1rem; }
.auth-aside .feature-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.auth-aside .feature-list li { display: flex; align-items: center; gap: .6rem; font-size: .95rem; color: rgba(255,255,255,.95); }
.auth-aside .tick {
  width: 22px; height: 22px; flex: none; display: grid; place-items: center;
  border-radius: 50%; background: rgba(255,255,255,.22); font-size: .8rem; font-weight: 800;
}
.auth-aside .aside-foot {
  margin-top: 1.8rem; padding-top: 1.2rem; border-top: 1px solid rgba(255,255,255,.22);
  font-size: .8rem; color: rgba(255,255,255,.75);
}

/* Right: the form */
.auth-main { padding: clamp(1.6rem, 4vw, 2.6rem); display: flex; flex-direction: column; }
.auth-head { margin-bottom: 1.3rem; }
.auth-head h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.auth-head .sub { color: var(--muted); margin: .4rem 0 0; font-size: .93rem; }

.auth-form .field { margin-bottom: 1.05rem; }
.auth-form label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .4rem; }
.auth-form label .opt { color: var(--faint); font-weight: 500; }
.auth-form input {
  width: 100%; padding: .72rem .85rem; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.auth-form input::placeholder { color: var(--faint); }
.auth-form input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.auth-form .hint { font-size: .78rem; color: var(--faint); margin: .38rem 0 0; }
.auth-form .hint.match { color: var(--warn); }
.auth-form .terms { font-size: .76rem; color: var(--faint); margin: .9rem 0 0; text-align: center; }

/* Password field with show/hide toggle */
.input-wrap { position: relative; }
.input-wrap input { padding-right: 2.8rem; }
.reveal {
  position: absolute; top: 50%; right: .5rem; transform: translateY(-50%);
  width: 2rem; height: 2rem; display: grid; place-items: center;
  background: none; border: 0; cursor: pointer; border-radius: 8px;
  font-size: 1rem; opacity: .55; transition: opacity .15s, background .15s;
}
.reveal:hover { opacity: 1; background: var(--surface-2); }
.reveal.on { opacity: 1; }

/* Remember-me checkbox */
.check { display: flex; align-items: center; gap: .55rem; font-size: .9rem; color: var(--muted); cursor: pointer; margin: .2rem 0 1.2rem; }
.check input { width: auto; accent-color: var(--brand); width: 16px; height: 16px; }

.btn.block { width: 100%; }

/* Inline alerts inside the card */
.auth-alerts { display: grid; gap: .5rem; margin-bottom: 1.1rem; }
.alert {
  padding: .7rem .9rem; border-radius: 10px; font-size: .9rem; font-weight: 500;
  border: 1px solid var(--border-hi); border-left: 4px solid var(--brand);
  background: var(--surface-2); color: var(--text);
}
.alert.error { border-left-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.alert.warn  { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
.alert.ok    { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }

/* Password strength meter */
.pw-strength { margin-top: .5rem; display: flex; align-items: center; gap: .6rem; }
.pw-strength[hidden] { display: none; }
.pw-strength .bars { display: flex; gap: .3rem; flex: 1; }
.pw-strength .bars span { height: 5px; flex: 1; border-radius: 999px; background: var(--surface-3); transition: background .2s; }
.pw-strength .pw-label { font-size: .76rem; font-weight: 600; color: var(--faint); min-width: 62px; text-align: right; }
.pw-strength[data-level="1"] .bars span.on { background: var(--bad); }
.pw-strength[data-level="1"] .pw-label { color: var(--bad); }
.pw-strength[data-level="2"] .bars span.on { background: var(--warn); }
.pw-strength[data-level="2"] .pw-label { color: var(--warn); }
.pw-strength[data-level="3"] .bars span.on { background: var(--d-emed); }
.pw-strength[data-level="3"] .pw-label { color: var(--d-emed); }
.pw-strength[data-level="4"] .bars span.on { background: var(--ok); }
.pw-strength[data-level="4"] .pw-label { color: var(--ok); }

@media (max-width: 760px) {
  .auth-split { grid-template-columns: 1fr; max-width: 460px; }
  .auth-aside { display: none; }
}

/* --------------------------------------------------------------------------
   Scoreboard
   -------------------------------------------------------------------------- */
.board-head { text-align: center; margin-bottom: 2rem; }
.board-head h1 { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; }
.board-head p { color: var(--muted); margin-top: .4rem; }

.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: end; max-width: 760px; margin: 0 auto 2.5rem; }
.podium .p {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.3rem 1rem; text-align: center; position: relative;
}
.podium .p .medal { font-size: 1.8rem; }
.podium .p .name { font-weight: 700; margin: .4rem 0 .1rem; word-break: break-word; }
.podium .p .sc { font-family: var(--mono); color: var(--gold); font-weight: 700; }
.podium .p.rank1 { border-color: color-mix(in srgb, var(--gold) 60%, var(--border)); box-shadow: 0 0 30px -10px var(--gold); transform: translateY(-12px); }
.podium .p.rank1 .medal { font-size: 2.2rem; }
.podium .p.rank2 { border-color: #9fb3c8aa; }
.podium .p.rank3 { border-color: #cd7f4faa; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.board { width: 100%; border-collapse: collapse; min-width: 480px; }
table.board th, table.board td { padding: .85rem 1.1rem; text-align: left; }
table.board thead th {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint);
  border-bottom: 1px solid var(--border); font-weight: 700;
}
table.board tbody tr { border-top: 1px solid var(--border); transition: background .12s; }
table.board tbody tr:hover { background: var(--surface-2); }
table.board .rank { font-family: var(--mono); font-weight: 700; color: var(--muted); width: 60px; }
table.board .team { font-weight: 600; }
table.board .score { font-family: var(--mono); font-weight: 700; color: var(--gold); }
table.board .num { font-family: var(--mono); color: var(--muted); }
.empty { text-align: center; color: var(--faint); padding: 3rem 1rem; }

/* --------------------------------------------------------------------------
   Flash toasts
   -------------------------------------------------------------------------- */
.toasts { position: fixed; top: 4.6rem; right: 1rem; z-index: 100; display: flex; flex-direction: column; gap: .6rem; max-width: 340px; }
.flash {
  background: var(--surface-3); border: 1px solid var(--border-hi);
  border-left: 4px solid var(--brand);
  padding: .8rem 1rem; border-radius: 10px; box-shadow: var(--shadow);
  font-size: .92rem; animation: slidein .3s ease;
}
.flash.ok    { border-left-color: var(--ok); }
.flash.error { border-left-color: var(--bad); }
.flash.warn  { border-left-color: var(--warn); }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .podium { grid-template-columns: 1fr; }
  .podium .p.rank1 { transform: none; }
}

/* ==========================================================================
   Clickable cards + meta badges
   ========================================================================== */
a.chal { text-decoration: none; color: inherit; cursor: pointer; }
a.chal:hover { text-decoration: none; }
.badge.meta {
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); text-transform: none; letter-spacing: 0;
  font-weight: 600;
}
.badge.meta.live { color: var(--web); border-color: color-mix(in srgb, var(--web) 40%, transparent); }
.badge.meta.live { animation: livepulse 1.8s infinite; }
@keyframes livepulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.chal-foot { margin-top: auto; padding-top: .3rem; }
.open-tag { color: var(--accent, var(--brand)); font-weight: 600; font-size: .9rem; }
a.chal:hover .open-tag { letter-spacing: .02em; }

/* ==========================================================================
   Challenge detail page
   ========================================================================== */
.detail { max-width: 820px; margin: 0 auto; }
.back { display: inline-block; color: var(--muted); margin-bottom: 1rem; font-size: .92rem; }
.detail-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1.4rem;
}
.detail-head h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; margin: .35rem 0 .6rem; }
.cat-tag {
  display: inline-block; font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--accent, var(--brand));
  background: color-mix(in srgb, var(--accent, var(--brand)) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, var(--brand)) 35%, transparent);
  padding: .25rem .6rem; border-radius: 7px;
}
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.4rem; margin-bottom: 1.2rem;
}
.panel-h { font-size: 1rem; font-weight: 700; margin: 0 0 .8rem; color: var(--text); }
.muted-s { color: var(--faint); font-weight: 500; font-size: .85rem; }
.detail-desc { color: var(--muted); font-size: 1.02rem; line-height: 1.7; margin: 0 0 .2rem; }
.connect-url { font-family: var(--mono); font-size: .82rem; color: var(--faint); margin: .6rem 0 0; }

/* Animated launch button */
.launch-btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .8rem 1.4rem; border-radius: 12px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--web), var(--brand));
  box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--web) 70%, transparent);
  text-decoration: none; transition: transform .15s, box-shadow .15s;
}
.launch-btn:hover { transform: translateY(-2px); text-decoration: none; box-shadow: 0 12px 30px -8px color-mix(in srgb, var(--web) 80%, transparent); }
.launch-btn .rocket { display: inline-block; font-size: 1.2rem; transition: transform .2s; }
.launch-btn:hover .rocket { animation: wiggle .6s ease-in-out infinite; }
@keyframes wiggle { 0%,100% { transform: rotate(-8deg) translateY(0); } 50% { transform: rotate(8deg) translateY(-2px); } }
.launch-btn .shine {
  position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,.45), transparent);
  transform: skewX(-20deg); animation: shine 2.6s infinite;
}
@keyframes shine { 0% { left: -60%; } 55%,100% { left: 130%; } }
.launch-btn.launching .rocket { animation: liftoff .9s ease-in forwards; }
@keyframes liftoff {
  0% { transform: translate(0,0) rotate(0); }
  30% { transform: translate(0,4px) rotate(-6deg); }
  100% { transform: translate(60px,-120px) rotate(35deg); opacity: 0; }
}

/* Hints */
.hints { display: grid; gap: .7rem; }
.hint-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1rem; border-radius: 10px; cursor: pointer;
  background: var(--surface-2); border: 1px dashed var(--border-hi); color: var(--text);
  font: inherit; font-weight: 600; transition: background .15s, border-color .15s;
}
.hint-btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--warn); }
.hint-btn:disabled { opacity: .6; cursor: default; }
.hint-cost { color: var(--warn); font-family: var(--mono); font-size: .85rem; }
.hint-open {
  background: color-mix(in srgb, var(--warn) 9%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: 10px; padding: .8rem 1rem; animation: slidein .3s ease;
}
.hint-open .hint-num { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--warn); }
.hint-open p { margin: .35rem 0 0; color: var(--text); }

/* Submit panel */
.submit-panel .flag-form { display: flex; gap: .6rem; }
.submit-panel .flag-form input {
  flex: 1; padding: .75rem .9rem; border-radius: 10px; background: var(--bg);
  border: 1px solid var(--border); color: var(--text); font-family: var(--mono);
}
.submit-panel .flag-form input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.submit-panel .result { display: inline-block; margin-top: .7rem; font-weight: 600; }
.solved-banner {
  background: color-mix(in srgb, var(--ok) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent);
  color: var(--ok); font-weight: 700; padding: .9rem 1.1rem; border-radius: 10px;
}

/* Confetti overlay */
#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 200; display: none; }
#confetti.show { display: block; }

/* ==========================================================================
   UI polish: active nav, footer, home steps, challenge toolbar, scoreboard
   ========================================================================== */

/* Active nav link */
.nav nav a.active { color: var(--text); background: var(--surface-2); }
.nav nav a.active:hover { background: var(--surface-3); }

/* Richer footer */
.foot { padding: 0; text-align: left; }
.foot-grid {
  max-width: 1180px; margin: 0 auto; padding: 2.4rem clamp(1rem, 4vw, 2.5rem) 1.6rem;
  display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 1.6rem;
}
.foot-brand .brand { color: var(--text); margin-bottom: .6rem; }
.foot-brand p { color: var(--faint); font-size: .88rem; max-width: 34ch; margin: 0; }
.foot-col h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .7rem; }
.foot-col a, .foot-col .foot-note { display: block; color: var(--faint); font-size: .9rem; padding: .2rem 0; }
.foot-col a:hover { color: var(--text); text-decoration: none; }
.foot-bar {
  border-top: 1px solid var(--border); color: var(--faint); font-size: .82rem;
  padding: 1rem clamp(1rem, 4vw, 2.5rem); display: flex; justify-content: space-between;
  gap: .8rem; flex-wrap: wrap; max-width: 1180px; margin: 0 auto;
}
.foot-flag code { color: var(--muted); }

/* Home: how it works */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.1rem; }
.step {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; position: relative;
}
.step-n {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  font-weight: 800; font-size: 1.15rem; color: #fff; margin-bottom: .9rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 16px -6px rgba(99,102,241,.7);
}
.step h3 { font-size: 1.1rem; margin-bottom: .35rem; }
.step p { color: var(--muted); font-size: .92rem; margin: 0; }

/* Challenges: subheading + overall progress + toolbar */
.chal-sub { color: var(--muted); margin: .35rem 0 0; font-size: .95rem; }
.overall-progress { margin: 0 0 1.6rem; }
.overall-progress .progress-wrap {
  height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; max-width: none;
}
.overall-progress .progress {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--crypto), var(--web), var(--forensics));
  transition: width .6s;
}

.toolbar {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  margin-bottom: 1.8rem;
  position: sticky; top: 3.6rem; z-index: 20;
  background: rgba(10,13,22,.75); backdrop-filter: blur(10px);
  padding: .6rem; border: 1px solid var(--border); border-radius: 14px;
}
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box .search-ico { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); opacity: .5; font-size: .9rem; }
.search-box input {
  width: 100%; padding: .6rem .9rem .6rem 2.3rem; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text); font: inherit; font-size: .92rem;
  transition: border-color .15s, box-shadow .15s;
}
.search-box input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; }
.segmented { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.segmented .seg {
  border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; font-size: .86rem;
  padding: .4rem .8rem; border-radius: 8px; cursor: pointer; transition: background .15s, color .15s;
}
.segmented .seg:hover { color: var(--text); }
.segmented .seg.on { background: var(--brand); color: #fff; }
.select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  font: inherit; font-size: .86rem; font-weight: 600; padding: .45rem .7rem; border-radius: 10px; cursor: pointer;
}
.select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.no-results { text-align: center; color: var(--faint); padding: 3rem 1rem; }

/* Scoreboard: meta chips + current-user highlight */
.board-meta { display: flex; gap: .6rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.board-chip {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  padding: .4rem .9rem; border-radius: 999px; font-size: .85rem; font-weight: 600;
}
.board-chip.you { color: var(--brand-2); border-color: color-mix(in srgb, var(--brand-2) 45%, transparent);
  background: color-mix(in srgb, var(--brand-2) 12%, var(--surface)); }
table.board tbody tr.you { background: color-mix(in srgb, var(--brand) 12%, var(--surface)); }
table.board tbody tr.you:hover { background: color-mix(in srgb, var(--brand) 18%, var(--surface)); }
.you-tag {
  font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  color: #fff; background: var(--brand); padding: .1rem .4rem; border-radius: 5px; margin-left: .4rem;
  vertical-align: middle;
}

@media (max-width: 820px) {
  .foot-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .foot-grid { grid-template-columns: 1fr; }
  .toolbar { position: static; }
  .search-box { min-width: 100%; }
}
