/* =========================================
   THEME TOKENS
   ========================================= */

/* Default: DARK */
:root {
  /* base */
  --bg: #0b0f1a;
  --grad-1: #162041;
  --grad-2: #1a1d35;
  --text: #e6f0ff;
  --muted: #96a1b3;

  /* brand */
  --neon: #7cfff5;
  --accent: #7a5cff;
  --danger: #ff4d6d;
  --success: #26e08a;
  --warning: #f5d742;

  /* surfaces */
  --panel: #0f1526cc;             /* cards */
  --surface: #0b1736;             /* pills, stats, table head, callouts */
  --surface-border: #263e86;

  /* inputs */
  --input-bg: #0c1122;
  --input-border: #2a2f54;

  /* buttons */
  --btn-bg-1: #151b34;
  --btn-bg-2: #0c1122;
  --btn-border: #2a2f54;
  --btn-text: var(--text);
  --btn-ghost-border: #2a2f54;
  --btn-ghost-hover: #0c1122;

  /* header gradient */
  --header-bg-start: #0f1526dd;
  --header-bg-end:   #0f152600;

  /* misc */
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);

  /* metro */
  --node-unsolved: #c8d2ff;

  /* overlay/lines */
  --grid-line: rgba(255,255,255,.05);
  --scanline-line: rgba(255,255,255,.04);
  --overlay-dim: rgba(0,0,0,.5);
  --success-border: #2d5f59;
  --avatar-deep: #1a2246;

  /* page background used by body::before */
  --page-bg:
    radial-gradient(1200px 800px at 10% -10%, var(--grad-1) 0%, transparent 55%),
    radial-gradient(1000px 700px at 110% 10%, var(--grad-2) 0%, transparent 50%),
    var(--bg);
}

/* Light theme override */
[data-theme="light"] {
  --bg: #f7f9fc;
  --grad-1: #cfe7ff;
  --grad-2: #e7e9f7;
  --text: #0b1020;
  --muted: #5b6780;

  --neon: #5ce6dd;
  --accent: #5a49e6;
  --danger: #d63a58;
  --success: #0f9e63;
  --warning: #e7a410;

  --panel: #ffffffcc;
  --surface: #eaf0ff;
  --surface-border: #d7deea;

  --input-bg: #ffffff;
  --input-border: #d7deea;

  --btn-bg-1: #ffffff;
  --btn-bg-2: #eef2f9;
  --btn-border: #d7deea;
  --btn-text: #0b1020;
  --btn-ghost-border: #d7deea;
  --btn-ghost-hover: #f4f7ff;

  --header-bg-start: #ffffffdd;
  --header-bg-end:   #ffffff00;

  --shadow: 0 10px 30px rgba(0,0,0,.12);

  --node-unsolved: #3a4a6b;

  /* light-mode lines/overlays */
  --grid-line: rgba(0,0,0,.06);
  --scanline-line: rgba(0,0,0,.06);
  --overlay-dim: rgba(0,0,0,.35);
  --success-border: color-mix(in srgb, var(--success) 35%, #0000);
  --avatar-deep: #cfe0ff;

  --page-bg:
    radial-gradient(1200px 800px at 10% -10%, var(--grad-1) 0%, transparent 55%),
    radial-gradient(1000px 700px at 110% 10%, var(--grad-2) 0%, transparent 50%),
    var(--bg);
}

/* =========================================
   RESETS / LAYOUT
   ========================================= */
* { box-sizing: border-box; }
html, body { min-height: 100%; height: auto; }

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

/* One fixed background layer (no restart) */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background: var(--page-bg);
  pointer-events: none;
}

/* Subtle grid overlay */
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; opacity: .10;
  background-image:
    linear-gradient(transparent 23px, var(--grid-line) 24px),
    linear-gradient(90deg, transparent 23px, var(--grid-line) 24px);
  background-size: 24px 24px;
}

/* Containers */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem; }
@media (max-width: 960px){ .container{ padding: 1.5rem; } }
@media (max-width: 640px){ .container{ padding: 1rem; } }

/* =========================================
   HEADER / FOOTER
   ========================================= */
.site-header, .site-footer {
  display:flex; align-items:center; justify-content:space-between;
  gap:1rem; padding:1rem 2rem; position:sticky; top:0; z-index:10;
  background: linear-gradient(180deg, var(--header-bg-start), var(--header-bg-end));
  backdrop-filter: blur(10px);
}
.site-footer { position: static; opacity: .8; }

.brand {
  display:inline-flex; align-items:center; gap:.75rem;
  color: var(--text); text-decoration:none; font-family: Orbitron, monospace;
}
.logo-glow { width:14px; height:14px; border-radius:50%;
  box-shadow: 0 0 30px var(--neon), 0 0 10px var(--neon); background: var(--neon);
}

.nav { display:flex; align-items:center; flex-wrap:wrap; gap:.5rem; }
.nav a { color: var(--text); text-decoration: none; margin-left: 1rem; opacity: .9; }
.nav .btn { margin-left: 1rem; }

@media (max-width: 720px){
  .site-header{ padding: .75rem 1rem; }
  .nav a, .nav .btn{ margin-left: .5rem; }
}

/* Light: nav links not faded */
[data-theme="light"] .nav a { opacity: 1; }

/* =========================================
   FLASH MESSAGES
   ========================================= */
.flash-area { display: grid; gap: .5rem; margin-bottom: 1rem; }
.flash { padding: .75rem 1rem; border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
.flash-success { border-left: 3px solid var(--success); }
.flash-error { border-left: 3px solid var(--danger); }
.flash-info { border-left: 3px solid var(--accent); }

/* =========================================
   HERO / METRO
   ========================================= */
.hero { text-align: center; padding: 2rem 0 0; }
.glitch {
  font-family: Orbitron, monospace;
  font-size: clamp(28px, 4vw, 56px);
  text-shadow:
    0 0 12px var(--neon),
    2px 0 0 #00f7ff88,
    -2px 0 0 #ff00ff88;
}
.tagline { opacity: .8; margin-top: .5rem; }

#metro {
  width: 100%; height: 260px; display: block; margin-top: 1rem;
  border-radius: var(--radius); background: var(--input-bg); box-shadow: var(--shadow);
}
@media (max-width: 700px){ #metro{ height: 200px; } }

/* =========================================
   CARDS / GRIDS / PILLS / BUTTONS
   ========================================= */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 1rem; margin-top: 2rem; }
@media (max-width: 520px){ .grid{ grid-template-columns: 1fr; } }

.card { background: var(--panel); padding: 1rem; border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card h3 { margin: 0; font-size: 1.1rem; }
.card h3 a { color: var(--text); text-decoration: none; }

.pill {
  font-size: .8rem; padding: .25rem .5rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--surface-border); color: var(--neon);
}

/* Buttons (theme-aware) */
.btn {
  display:inline-block; padding:.6rem 1rem; border-radius:10px;
  border:1px solid var(--btn-border);
  background: linear-gradient(180deg, var(--btn-bg-1), var(--btn-bg-2));
  color: var(--btn-text); text-decoration:none; font-weight:600;
  box-shadow: inset 0 0 10px rgba(124,255,245,.15), var(--shadow);
  transition: filter .15s ease, transform .02s ease;
}
.btn.small { padding:.4rem .75rem; font-size:.9rem; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }

.btn.with-icon{display:inline-flex;align-items:center;gap:.45rem;}
.btn.with-icon svg{flex:0 0 auto;}

/* Ghost button */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--btn-ghost-border);
  color: var(--btn-text);
}
.btn-ghost:hover { background: var(--btn-ghost-hover); }

/* Danger variant (used for destructive admin actions) */
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* Disabled */
.btn[disabled], .btn.disabled, .btn[aria-disabled="true"] {
  opacity:.55; cursor:not-allowed; filter:none; box-shadow: var(--shadow);
}

h2 { margin: 0 0 1rem; }
.muted { color: var(--muted); }

/* =========================================
   CHALLENGE PAGES
   ========================================= */
.challenge { background: var(--panel); padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.challenge-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; }
.challenge .resource { margin: 1rem 0; }
.callout { background: var(--surface); padding: .75rem 1rem; border: 1px solid var(--surface-border); border-radius: 12px; }

.flag-form { display: flex; gap: .5rem; }
.flag-form input[type="text"] {
  flex: 1; padding: .6rem .8rem; border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg); color: var(--text);
}
.badge {
  margin-top: 1rem; display: inline-block; background: var(--surface); color: var(--success);
  border: 1px solid var(--success-border); padding: .3rem .6rem; border-radius: 999px;
}

/* =========================================
   FORMS (auth/admin)
   ========================================= */
.auth-form, .admin-form {
  display: grid; gap: .5rem; background: var(--panel); padding: 1rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.auth-form input, .admin-form input, .admin-form select, .admin-form textarea {
  width: 100%; padding: .6rem .8rem; border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg); color: var(--text);
}
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.grid.three { display: grid; grid-template-columns: repeat(3,1fr); gap: .75rem; }
@media (max-width: 700px) {
  .grid.two, .grid.three { grid-template-columns: 1fr; }
}

/* =========================================
   TABLES
   ========================================= */
.table-wrap { width: 100%; overflow-x: auto; }
.table {
  width: 100%; background: var(--panel); border-radius: var(--radius);
  border-collapse: collapse; overflow: hidden; box-shadow: var(--shadow);
}
.table th, .table td { padding: .75rem 1rem; border-bottom: 1px solid var(--surface-border); }
.table thead { background: var(--surface); }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface) 65%, transparent); }

/* Light tweaks for tables */
[data-theme="light"] .table thead { background: color-mix(in srgb, #ffffff 60%, var(--surface) 40%); }
[data-theme="light"] .table thead th { color: #1f2937; }
[data-theme="light"] .table tbody tr:hover { background: color-mix(in srgb, var(--surface) 85%, #fff0); }

/* =========================================
   RESPONSIVE / A11Y
   ========================================= */
@media (prefers-reduced-motion: reduce) {
  .glitch { text-shadow: 0 0 8px var(--neon); }
}

/* =========================================
   LANDING PAGE POLISH
   ========================================= */
.hero-splash {
  position: relative; display: grid; grid-template-columns: 1.1fr 0.9fr;
  gap: 2rem; align-items: center; padding-top: 1rem;
}
.hero-copy { z-index: 1; }
.hero .big { font-size: clamp(32px, 5vw, 64px); line-height: 1.05; }
.cta-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1rem; }

.btn-lg { padding: .9rem 1.2rem; font-size: 1.05rem; border-radius: 12px; }

.stats {
  display: grid; grid-template-columns: repeat(4, minmax(120px,1fr));
  gap: .75rem; margin-top: 1.25rem;
}
@media (max-width: 880px){ .stats{ grid-template-columns: repeat(2, minmax(120px,1fr)); } }
@media (max-width: 480px){ .stats{ grid-template-columns: 1fr; } }

.stat { background: var(--surface); border: 1px solid var(--surface-border); border-radius: 14px; padding: .8rem 1rem; text-align: center; }
.stat-num { font-family: Orbitron, monospace; font-size: 1.6rem; text-shadow: 0 0 12px var(--neon); }
.stat-label { color: var(--muted); font-size: .85rem; margin-top: .25rem; }

.hero-art {
  position: relative; min-height: 320px; border-radius: var(--radius);
  background: var(--input-bg); overflow: hidden; box-shadow: var(--shadow);
}
.neon-orb {
  position: absolute; width: 240px; height: 240px; border-radius: 50%; top: 15%; left: 10%;
  filter: blur(8px);
  background: radial-gradient(circle at 30% 30%, var(--neon), transparent 60%); opacity: .9;
}
.neon-arc {
  position: absolute; inset: -20% -10% auto -10%; height: 60%;
  border-top: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  filter: drop-shadow(0 0 10px var(--accent));
  transform: rotate(-8deg);
}
.scanline {
  position: absolute; inset: 0;
  background-image: linear-gradient(transparent 3px, var(--scanline-line) 4px);
  background-size: 100% 4px; mix-blend-mode: overlay; opacity: .35;
}

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 1rem; margin-top: 2rem; }
.fcard { background: var(--panel); border: 1px solid var(--surface-border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.fcard h3 { margin: .25rem 0 .25rem; }

.cat-belt { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px,1fr)); gap: .75rem; margin-top: 1.25rem; }
.cat-card { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--surface-border); border-radius: 12px; padding: .75rem 1rem; min-width: 0; }
.cat-name { font-weight: 600; flex:1 1 auto; min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.cat-count { font-family: Orbitron, monospace; opacity:.85; flex:0 0 auto; white-space:nowrap; padding:.2rem .55rem; border-radius:999px; border:1px solid var(--surface-border); background: color-mix(in srgb, var(--panel) 40%, transparent); }

.cta-final { text-align: center; margin-top: 2.25rem; background: var(--panel); padding: 1.25rem; border-radius: var(--radius); box-shadow: var(--shadow); }

@media (max-width: 980px) {
  .hero-splash { grid-template-columns: 1fr; }
  .hero-art { order: 2; min-height: 260px; }
}

/* =========================================
   LEADERBOARD POLISH
   ========================================= */
.podium {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr));
  gap: 1rem; margin: 1rem 0 1.25rem;
}
.p-card {
  position: relative; background: var(--panel);
  border: 1px solid var(--surface-border); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow);
}
.p-card .p-rank { font-family: Orbitron, monospace; opacity: .9; margin-bottom: .25rem; }
.p-card .p-user { display: flex; align-items: center; gap: .6rem; }
.p-card .p-name { font-weight: 600; }
.p-card .p-score { font-size: 1.4rem; margin-top: .5rem; text-shadow: 0 0 10px var(--neon); }
.p-card .p-sub { color: var(--muted); font-size: .85rem; }

.medal-1 { border-color: #ffd16655; box-shadow: 0 0 0 1px #ffd16633 inset, var(--shadow); }
.medal-2 { border-color: #a1b5ff55; box-shadow: 0 0 0 1px #a1b5ff33 inset, var(--shadow); }
.medal-3 { border-color: #ff9f6e55; box-shadow: 0 0 0 1px #ff9f6e33 inset, var(--shadow); }

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-grid; place-items: center; font-weight: 700;
  background: radial-gradient(60% 60% at 30% 30%, var(--neon) 0%, var(--avatar-deep) 70%);
  border: 1px solid var(--surface-border);
}
.avatar.sm { width: 28px; height: 28px; font-size: .9rem; }

.table.leaderboard thead th {
  text-transform: uppercase; font-size: .8rem; letter-spacing: .04em; color: var(--muted);
}
.table.leaderboard tbody tr { transition: background .15s ease; }
.table.leaderboard tbody tr:hover { background: color-mix(in srgb, var(--surface) 65%, transparent); }
.table.leaderboard .rank-cell { width: 70px; text-align: center; font-family: Orbitron, monospace; }
.table.leaderboard .player-cell { display: flex; align-items: center; gap: .6rem; }
.table.leaderboard .score-cell { text-align: right; }

/* =========================================
   DEMO PUZZLE WIDGET
   ========================================= */
.hidden { display: none; }

.demo-wrap { margin-top: 2rem; }
.demo-card {
  background: var(--panel); border: 1px solid var(--surface-border);
  border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow);
}
.demo-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.demo-timer {
  font-family: Orbitron, monospace;
  background: var(--surface); border: 1px solid var(--surface-border); border-radius: 10px;
  padding: .4rem .7rem; min-width: 56px; text-align: center;
}
.demo-prompt {
  margin: 1rem 0; background: var(--surface); border: 1px solid var(--surface-border); border-radius: 12px;
  padding: .8rem 1rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.demo-action { display: flex; gap: .5rem; }
.demo-input {
  flex: 1; padding: .6rem .8rem; border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg); color: var(--text);
}
.demo-feedback { height: 1.25rem; margin-top: .5rem; color: var(--muted); }
.demo-feedback.ok { color: var(--success); text-shadow: 0 0 8px var(--success); }
.demo-feedback.err { color: var(--danger); }

/* Theme toggle button */
.theme-toggle {
  display:inline-flex; align-items:center; justify-content:center;
  width:38px; height:38px; border-radius:10px;
  background: linear-gradient(180deg, var(--btn-bg-1), var(--btn-bg-2));
  border:1px solid var(--btn-border); color: var(--btn-text);
  cursor:pointer; box-shadow: var(--shadow); margin-right:.5rem;
}
.theme-toggle:hover { filter: brightness(1.06); }
.theme-icon { font-size: 18px; line-height: 1; }
.sr-only { position: absolute; width:1px; height:1px; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* =========================================
   PROFILE
   ========================================= */
.profile-header {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem;
  border: 1px solid var(--surface-border);
}
.ph-name { font-size: 1.25rem; font-weight: 700; }
.ph-right { display: grid; gap: .35rem; justify-items: end; }
.level-chip {
  padding: .25rem .6rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--surface-border); color: var(--accent);
  font-weight: 700; font-size: .9rem;
}
.lvl-progress {
  width: 220px; height: 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--surface-border); overflow: hidden;
}
.lvl-progress .bar {
  height: 100%;
  width: var(--p, 0%);
  background: linear-gradient(90deg, var(--accent), var(--neon));
  box-shadow: 0 0 10px var(--accent);
}
.tiny { font-size: .8rem; }

/* Stat tiles */
.profile-stats {
  display: grid; grid-template-columns: repeat(4, minmax(160px,1fr));
  gap: .75rem; margin: 1rem 0;
}
.stat-mini {
  background: var(--surface); border: 1px solid var(--surface-border);
  border-radius: var(--radius); padding: .9rem 1rem; text-align: center;
}
.stat-mini-num { font-family: Orbitron, monospace; font-size: 1.2rem; text-shadow: 0 0 10px var(--neon); }
.stat-mini-label { color: var(--muted); font-size: .85rem; }

/* Category chips */
.profile-cats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr));
  gap: .6rem; margin-bottom: 1rem;
}
.cat-chip {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--surface-border);
  border-radius: var(--radius); padding: .6rem .8rem;
}

/* Solves table */
.table.profile thead th { text-transform: none; font-weight: 600; color: var(--text); opacity: .9; }
.table.profile tbody tr { transition: background .15s ease; }
.table.profile tbody tr:nth-child(odd) { background: color-mix(in oklab, var(--surface) 22%, transparent); }
.table.profile tbody tr:hover { background: color-mix(in srgb, var(--surface) 65%, transparent); }
.table.profile .rank-cell { width: 64px; text-align: center; font-family: Orbitron, monospace; }
.table.profile .player-cell { display: flex; align-items: center; gap: .6rem; }
.table.profile .score-cell, .table.profile .time-cell { text-align: right; }

/* Responsive */
@media (max-width: 900px) {
  .profile-stats { grid-template-columns: repeat(2, minmax(160px,1fr)); }
}
@media (max-width: 640px) {
  .profile-header { grid-template-columns: 1fr; justify-items: start; }
  .ph-right { justify-items: start; width: 100%; }
  .lvl-progress { width: 100%; }
  .profile-stats { grid-template-columns: 1fr; }
  .table.profile .time-cell { display: none; }
}

/* Activity feed */
.activity-list { list-style: none; margin: 0; padding: .5rem; border: 1px solid var(--surface-border); }
.activity-item {
  display: grid; grid-template-columns: 14px 1fr; gap: .6rem; align-items: start;
  padding: .5rem .5rem; border-radius: var(--radius);
}
.activity-item + .activity-item { border-top: 1px dashed var(--surface-border); }
.activity-item .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--success); box-shadow: 0 0 10px var(--success);
  margin-top: .4rem;
}
.activity-title { display: flex; align-items: center; gap: .5rem; }
.activity-title .points { color: var(--success); font-weight: 700; }
.activity-empty { padding: .5rem; }

.pill.tiny { font-size: .72rem; padding: .15rem .45rem; }

/* Category progress bars */
.cat-progress { padding: .75rem; border: 1px solid var(--surface-border); }
.progress-row { display: grid; grid-template-columns: 180px 1fr; gap: .75rem; align-items: center; padding: .35rem 0; }
.progress-label { display: flex; align-items: center; gap: .5rem; }
.progress-rail {
  width: 100%; height: 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--surface-border); overflow: hidden;
}
.progress-rail .bar {
  height: 100%; width: var(--p, 0%);
  background: linear-gradient(90deg, var(--accent), var(--neon));
  box-shadow: 0 0 10px var(--accent);
}

/* Responsive tweaks */
@media (max-width: 640px) {
  .progress-row { grid-template-columns: 1fr; }
  .progress-label { justify-content: space-between; }
}

/* =========================================
   COOKIE BANNER & MODAL (theme-aware)
   ========================================= */
.cookie-banner{
  position:fixed; left:16px; right:16px; bottom:16px; z-index:50;
  background: var(--panel); border:1px solid var(--surface-border); border-radius:12px;
  color: var(--text); padding:14px; box-shadow: var(--shadow);
  display:flex; gap:12px; align-items:center; flex-wrap:wrap;
}
.cookie-banner__text{ flex:1 1 320px; }
.cookie-banner__actions{ display:flex; gap:10px; }

/* Use existing .btn / .btn-ghost classes for buttons */

.cookie-modal{
  position: fixed; inset: 0; z-index: 10000;
}
.cookie-modal[aria-hidden="true"]{ display:none }
.cookie-modal[aria-hidden="false"]{ display:block }
.cookie-modal__backdrop{
  position:fixed; inset:0; background: var(--overlay-dim); backdrop-filter:blur(2px);
}
.cookie-modal__card{
  position:fixed; left:50%; top:50%; transform:translate(-50%,-50%);
  width:min(680px,92vw); background: var(--panel);
  border:1px solid var(--surface-border); border-radius:16px; padding:20px; color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.cookie-modal__head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:6px }
.cookie-modal__intro{ color: var(--muted); margin-top:0 }
.cookie-modal__close{
  border:1px solid var(--btn-border); background: var(--btn-bg-2); color: var(--btn-text);
  width:36px; height:36px; border-radius:10px; cursor:pointer;
}
.cookie-row{
  display:flex; align-items:center; justify-content:space-between;
  gap:16px; padding:12px 0; border-bottom:1px solid var(--surface-border);
}
.cookie-row:last-child{ border-bottom:none }
.cookie-modal__actions{
  display:flex; gap:10px; align-items:center; margin-top:16px;
}
.spacer{ flex:1 }

/* Toggle switch */
.switch{ position:relative; width:48px; height:28px; display:inline-block }
.switch input{ position:absolute; opacity:0; width:0; height:0 }
.switch span{
  position:absolute; cursor:pointer; inset:0; background: color-mix(in srgb, var(--surface) 65%, transparent);
  border-radius:999px; transition:.2s;
}
.switch span::after{
  content:""; position:absolute; left:4px; top:4px; width:20px; height:20px; border-radius:50%;
  background: var(--btn-text); transition:.2s;
}
.switch input:checked + span{ background: color-mix(in srgb, var(--accent) 45%, var(--surface)); }
.switch input:checked + span::after{ transform:translateX(20px); background: var(--bg); }
.switch input:disabled + span{ opacity:.6; cursor:not-allowed }

/* =========================================
   AUTH CTAS / NOTICE
   ========================================= */
.notice{
  --notice-border: #6ae3ff;
  --notice-bg: color-mix(in srgb, var(--surface) 75%, transparent);
  --notice-text: var(--text);

  display:block;
  padding:10px 12px;
  margin-top:12px;
  border-left:3px solid var(--notice-border);
  border-radius:10px;
  background: var(--notice-bg);
  color: var(--notice-text);
  box-shadow: var(--shadow);
}
.notice a{
  color: var(--notice-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}
.notice a:hover{ color: var(--accent); }
.notice.info    { --notice-border: #6ae3ff; }
.notice.success { --notice-border: var(--success); }
.notice.warn    { --notice-border: var(--warning); }
.notice.error   { --notice-border: var(--danger);  }
[data-theme="light"] .notice{
  --notice-bg: color-mix(in srgb, #ffffff 78%, var(--surface) 22%);
}

/* CTA row under auth forms */
.auth-cta-row{
  display:flex; gap:.6rem; flex-wrap:wrap; align-items:center;
  justify-content: space-between; margin-top:.75rem;
}
.btn.with-icon { display:inline-flex; align-items:center; gap:.45rem; }
.btn.with-icon svg { width:1.05em; height:1.05em; flex:0 0 auto; }
.link-ghost{
  color: var(--muted); text-decoration: none; border-bottom: 1px dashed var(--surface-border);
  padding-bottom: 2px;
}
.link-ghost:hover{ color: var(--text); border-bottom-color: var(--accent); }

/* =========================================
   USER LINKS / CHIPS
   ========================================= */
.user-link{
  color: var(--text);
  text-decoration: none;
  position: relative;
  padding-bottom: 2px;
  border-bottom: 1px dashed transparent;
  transition: color .15s ease, border-color .15s ease, text-shadow .2s ease;
}
.user-link:hover,
.user-link:focus-visible{
  color: var(--neon);
  border-bottom-color: color-mix(in srgb, var(--neon) 65%, transparent);
  text-shadow: 0 0 8px color-mix(in srgb, var(--neon) 40%, transparent);
  outline: none;
}
.user-link:focus-visible{
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 6px;
}
[data-theme="light"] .user-link:hover,
[data-theme="light"] .user-link:focus-visible{
  text-shadow: 0 0 6px color-mix(in srgb, var(--neon) 25%, transparent);
}
[data-theme="light"] .user-link:focus-visible{
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.user-chip{
  display:inline-flex; align-items:center; gap:.45rem;
  padding:.25rem .55rem; border-radius:999px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text); text-decoration: none;
  transition: transform .08s ease, box-shadow .15s ease, border-color .15s ease;
  max-width: 240px; min-width: 0;
}
.user-chip .name{
  min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.user-chip:hover,
.user-chip:focus-visible{
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--surface-border));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
  outline: none;
}
[data-theme="light"] .user-chip:hover,
[data-theme="light"] .user-chip:focus-visible{
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}
.user-cell, .player-cell{
  display:flex; align-items:center; gap:.6rem; min-width:0;
}

/* =========================================
   TOASTS
   ========================================= */
.toast-holder{
  position: fixed; right: 1rem; bottom: 1rem; z-index: 9999;
  display: grid; gap: .5rem; pointer-events: none;
}
.toast{
  pointer-events: auto;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--surface-border);
  border-left: 4px solid var(--accent);
  border-radius: 12px; padding: .6rem .8rem; min-width: 240px; max-width: 360px;
  box-shadow: var(--shadow);
  animation: toast-slide-in .2s ease-out;
}
.toast.success{ border-left-color: var(--success); }
.toast.error{ border-left-color: var(--danger); }
.toast .title{ font-weight:600; margin-bottom:.15rem; }
.toast .msg{ opacity:.9; }
@keyframes toast-slide-in{
  from{ transform: translateY(6px); opacity:0; } to{ transform: translateY(0); opacity:1; }
}

/* =========================================
   MODALS (z-index fix)
   ========================================= */
.cookie-modal__backdrop{ z-index: 10000; }
.cookie-modal__card{ z-index: 10001; }

/* =========================================
   FILTER BAR + THEMED SELECT
   ========================================= */
.filter-bar{
  display:flex; gap:.5rem; flex-wrap:wrap; align-items:center; margin:.5rem 0 1rem;
}
.filter-bar .input{
  flex:1 1 260px; min-width: 220px;
  padding:.6rem .8rem; border-radius:10px; border:1px solid var(--input-border);
  background: var(--input-bg); color: var(--text);
}

.select-wrap{ position: relative; min-width: 170px; }
.select-wrap select{
  -webkit-appearance: none; appearance: none;
  width: 100%;
  padding: .6rem 2.3rem .6rem .8rem;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  line-height: 1.2;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.select-wrap::after{
  content: '▾';
  position: absolute; right: .7rem; top: 50%; transform: translateY(-50%);
  font-size: .95rem; color: var(--muted); pointer-events: none;
}
.select-wrap select:hover{
  border-color: color-mix(in srgb, var(--accent) 35%, var(--input-border));
}
.select-wrap:focus-within::after{ color: var(--accent); }
.select-wrap select:focus{
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--input-border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.select-wrap select:disabled{
  cursor: not-allowed;
  opacity: .65;
  background: color-mix(in srgb, var(--input-bg) 85%, var(--surface));
}
@media (max-width: 720px){ .select-wrap{ min-width: 140px; } }

/* Unify selects in forms */
.auth-form select, .admin-form select{
  -webkit-appearance:none; appearance:none;
  padding-right: 2.3rem;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  border-radius: 10px;
}

/* =========================================
   SOLVED CHALLENGE STATE
   ========================================= */
.challenge-card.is-solved{
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--success) 8%, transparent), transparent 40%),
    var(--panel);
  border: 1px solid color-mix(in srgb, var(--success) 38%, var(--surface-border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--success) 18%, transparent) inset, var(--shadow);
}
.pill.solved{
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 45%, var(--surface-border));
  background: color-mix(in srgb, var(--success) 12%, transparent);
  margin-left:.5rem;
}
[data-theme="light"] .challenge-card.is-solved{
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--success) 10%, transparent), transparent 45%),
    var(--panel);
  border-color: color-mix(in srgb, var(--success) 35%, var(--surface-border));
}
[data-theme="light"] .pill.solved{
  background: color-mix(in srgb, var(--success) 14%, transparent);
}

/* =========================================
   LIGHT-THEME COMPONENT TWEAKS
   ========================================= */
[data-theme="light"] .pill {
  color: var(--text);
  border-color: var(--surface-border);
  background: color-mix(in srgb, var(--surface) 70%, #fff0);
}
[data-theme="light"] .cat-name { color: var(--text); }
[data-theme="light"] .cat-count {
  color: var(--text);
  background: color-mix(in srgb, #ffffff 70%, var(--surface) 30%);
  border-color: var(--surface-border);
}
[data-theme="light"] .stat-label,
[data-theme="light"] .demo-feedback,
[data-theme="light"] .activity-empty,
[data-theme="light"] .profile .muted,
[data-theme="light"] .muted { color: var(--muted); }
[data-theme="light"] .stat-num,
[data-theme="light"] .p-card .p-score { text-shadow: none; }
[data-theme="light"] .progress-label,
[data-theme="light"] .progress-row .pill { color: var(--text); }
[data-theme="light"] .badge {
  color: var(--success);
  border-color: var(--success-border);
  background: color-mix(in srgb, #ffffff 70%, var(--surface) 30%);
}
[data-theme="light"] .activity-title,
[data-theme="light"] .activity-item { color: var(--text); }
[data-theme="light"] .cookie-banner,
[data-theme="light"] .cookie-modal__card { color: var(--text); }
[data-theme="light"] .cookie-modal__intro { color: var(--muted); }
[data-theme="light"] .tagline { opacity: .95; color: var(--muted); }

/* =========================================
   UTILITIES
   ========================================= */
[hidden] { display: none !important; }

/* Small screens: let chips stack tighter */
@media (max-width:720px){
  .cat-belt{ grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); }
}


:root{ --ovpn-orange:#ff7a00; --ovpn-blue:#1e73be; }

/* Base nav layout */
.nav-toggle{ display:none; width:40px; height:40px; border-radius:10px;
  background: linear-gradient(180deg, var(--btn-bg-1), var(--btn-bg-2));
  border:1px solid var(--btn-border); color: var(--btn-text);
  box-shadow: var(--shadow); cursor:pointer;
}
.nav-toggle-box{ display:inline-grid; gap:4px; }
.nav-toggle-bar{ width:18px; height:2px; background: var(--btn-text); border-radius:2px; margin:0 auto; }

.nav-menu{
  display:flex; align-items:center; justify-content:flex-end;
  gap:.75rem; flex-wrap:wrap;
}

/* Desktop layout force-visible */
@media (min-width: 821px){
  .nav-menu{
    display:flex !important;
    position: static;
    width: auto; padding: 0; background: none; box-shadow: none; border: 0;
    flex-direction: row; align-items: center; gap: .75rem;
  }
  .nav-group{ flex-direction: row; align-items: center; gap:.75rem; }
  .nav-links a, .nav-actions a, .nav-actions button{
    background: none; border: 0; padding: 0;
  }
}

/* Mobile: dropdown panel */
@media (max-width: 820px){
  .nav-toggle{ display:inline-flex; align-items:center; justify-content:center; }

  /* closed by default */
  .nav-menu{
    display:none;
    position:absolute; top:calc(100% + 8px); right:0;
    width:min(92vw, 360px);
    background: var(--panel);
    border:1px solid var(--surface-border);
    border-radius: 12px;
    padding: .75rem;
    box-shadow: 0 14px 40px rgba(0,0,0,.35);
    flex-direction: column; align-items: stretch; gap:.6rem;
  }
  /* open state via class */
  .nav-menu.is-open{ display:flex; }

  .nav-group{ flex-direction: column; align-items: stretch; gap:.4rem; }
  .nav-links a, .nav-actions a, .nav-actions button{
    display:flex; align-items:center; gap:.5rem;
    padding:.6rem .7rem; border-radius:10px; text-decoration:none;
    background: color-mix(in srgb, var(--panel) 60%, transparent);
    border:1px solid var(--surface-border);
  }
  .nav-links a:hover, .nav-actions a:hover, .nav-actions button:hover{
    background: color-mix(in srgb, var(--panel) 80%, transparent);
  }
  .nav-actions .btn { width:100%; text-align:center; }
  .icon-only.btn.small{ justify-content:center; }
}

/* Keep existing nav link color */
.nav a{ color: var(--text); text-decoration:none; opacity:.9; }

/* Icon-only VPN (from earlier) */
.btn.icon-only{
  display:inline-flex; align-items:center; justify-content:center;
  padding:.5rem .6rem; width:auto; min-width:44px; min-height:36px;
}
.ico-ovpn{ display:inline-block; width:1.25rem; height:1.25rem; line-height:0; }
.ico-ovpn svg{ width:100%; height:100%; display:block; }





.modal3d{ position: fixed; inset: 0; z-index: 2000; display:none; }
.modal3d.is-open{ display:block; }
.modal3d__backdrop{ position: absolute; inset: 0; background: var(--overlay-dim); backdrop-filter: blur(2px); }
.modal3d__card{
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(1100px, 96vw); height: min(720px, 85vh);
  background: var(--panel); color: var(--text);
  border: 1px solid var(--surface-border); border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0,0,0,.35); display: grid;
  grid-template-rows: auto 1fr auto; overflow: hidden;
}
.modal3d__head, .modal3d__foot{ padding: .8rem 1rem; background: color-mix(in srgb, var(--panel) 80%, transparent); }
.modal3d__head{ display:flex; align-items:center; justify-content:space-between; gap:.75rem; }
.modal3d__body{ display:grid; grid-template-columns: 240px 1fr; gap: .75rem; padding: .75rem; min-height: 0; }
@media (max-width: 820px){ .modal3d__body{ grid-template-columns: 1fr; } }

.metro3d-legend{
  border:1px solid var(--surface-border); border-radius: 12px; padding:.6rem; overflow:auto;
  background: var(--surface); min-height: 0;
}
.metro3d-legend h4{ margin:.25rem 0 .5rem; font-size: .95rem; }
.legend-row{ display:flex; align-items:center; gap:.5rem; padding:.35rem .25rem; border-radius:8px; }
.legend-dot{ width:12px; height:12px; border-radius:50%; box-shadow: 0 0 10px rgba(0,0,0,.25) inset; border:1px solid var(--surface-border); }
.legend-count{ margin-left:auto; font-family: Orbitron, monospace; opacity:.85; }

.metro3d-stage{ position: relative; border:1px solid var(--surface-border); border-radius: 12px; background: var(--input-bg); min-height: 0; }
#metro3d-canvas{ position:absolute; inset:0; }
.metro3d-tip{
  position:absolute; pointer-events:none; transform: translate(8px, 8px);
  background: var(--panel); border:1px solid var(--surface-border); border-radius: 10px;
  padding:.4rem .55rem; box-shadow: var(--shadow); max-width: 320px;
  font-size: .9rem;
}
.metro3d-tip .t{ font-weight:600; }
.metro3d-tip .m{ color: var(--muted); }

/* OpenVPN icon colors if needed */
:root{ --ovpn-orange:#ff7a00; --ovpn-blue:#1e73be; }


.card.is-solved {
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--success) 8%, transparent), transparent 45%),
    var(--panel);
  border: 1px solid color-mix(in srgb, var(--success) 38%, var(--surface-border));
}
[data-theme="light"] .card.is-solved {
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--success) 10%, transparent), transparent 50%),
    var(--panel);
}










/* --- Track page layout --- */
.track-head {
  display:grid; grid-template-columns: 1fr auto; gap:1rem; align-items:center;
  margin-bottom: 1rem;
}
.track-title { margin:0; }
.track-head__right { display:grid; gap:.5rem; justify-items:end; }

.track-progress { width: 260px; height: 10px; }
.track-progress .bar { --p:0%; width: var(--p); }

.track-counters { display:flex; gap:.5rem; flex-wrap:wrap; }

/* Two-column board */
.track-layout {
  display:grid; grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 1rem;
}

/* List panel */
.track-list { padding: .5rem; }
.track-ul { list-style: none; margin: 0; padding: 0; display:grid; gap:.5rem; }
.track-row {
  display:grid; grid-template-columns: 18px 1fr auto; align-items:center;
  gap:.6rem; padding:.55rem .6rem; border:1px solid var(--surface-border);
  border-radius: 12px; background: var(--panel);
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.track-row:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); border-color: color-mix(in srgb, var(--accent) 35%, var(--surface-border)); }
.track-dot { width:10px; height:10px; border-radius:50%; box-shadow: 0 0 10px currentColor; }
.track-titlewrap { min-width:0; display:flex; gap:.5rem; align-items:center; }
.track-titlewrap .name { min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.track-meta { display:flex; gap:.4rem; flex-wrap:wrap; }

/* Solved state */
.track-row.solved {
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--success) 10%, transparent), transparent 45%),
    var(--panel);
  border-color: color-mix(in srgb, var(--success) 35%, var(--surface-border));
}
.track-row .pill.solved { color: var(--success); border-color: color-mix(in srgb, var(--success) 45%, var(--surface-border)); background: color-mix(in srgb, var(--success) 12%, transparent); }

/* Canvas card */
.track-canvas { position: relative; padding: 0; overflow: hidden; }
#galaxy2d { width: 100%; height: 520px; display:block; }
.canvas-controls {
  position:absolute; right:.75rem; top:.6rem; display:flex; gap:.5rem; align-items:center;
}

/* Responsive */
@media (max-width: 1100px){
  .track-layout { grid-template-columns: 1fr; }
  #galaxy2d { height: 420px; }
  .track-head { grid-template-columns: 1fr; }
  .track-head__right { justify-items: start; }
  .track-progress { width: 100%; }
}
@media (max-width: 640px){
  #galaxy2d { height: 320px; }

#galaxy-wrap { position: relative; min-height: 600px; }



/* Track layout */
.track-layout{
  display:grid;
  grid-template-columns: minmax(260px, 420px) 1fr;
  gap:1rem;
}
.track-list.card{ padding:0 }
.track-ul{ list-style:none; margin:0; padding:.5rem }

.track-canvas{
  position:relative;
  min-height:420px;
  height: clamp(420px, 56vh, 720px); /* responsive */
  overflow:hidden;
}
.track-canvas .canvas-controls{
  position:absolute; right:.75rem; top:.5rem; z-index:2;
  display:flex; gap:.5rem;
}
@media (max-width: 980px){
  .track-layout{ grid-template-columns: 1fr; }
}


.table.leaderboard tbody tr.joined {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}


.rank-chip{
  display:inline-block;
  padding:.25rem .6rem; border-radius:999px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--accent); font-weight:700; font-size:.9rem;
}