/* ============================================================
   Final Destination 2.0 — Design System
   ============================================================ */

/* ---------- Variables ---------- */
:root {
  --bg:          #0a0a0f;
  --bg-elev1:    #111118;
  --bg-elev2:    #18181f;
  --bg-elev3:    #222229;
  --border:      rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.16);
  --hairline:    rgba(255,255,255,0.04);

  --text:        #eeeef3;
  --text-muted:  #8888a0;
  --text-faint:  #55556a;
  --text-dim:    #333345;

  --green:       #22c55e;
  --red:         #ef4444;
  --amber:       #f59e0b;
  --amber-bg:    rgba(245,158,11,0.10);

  --accent-1:    #a78bfa;
  --accent-2:    #667eea;
  --accent-grad: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

  --shadow-md:   0 4px 20px rgba(0,0,0,0.35);
  --shadow-lg:   0 16px 56px rgba(0,0,0,0.5);

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   18px;

  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Mono', 'Cascadia Code', 'Consolas', monospace;
}

/* ---------- Reset / Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

button { font-family: inherit; }

input, select, textarea { font-family: inherit; }

/* ---------- Aurora background ---------- */
.fd-aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.fd-aurora::before {
  content: '';
  position: absolute;
  top: -40%;
  left: -20%;
  width: 80%;
  height: 70%;
  background: radial-gradient(ellipse, rgba(102,126,234,0.12) 0%, transparent 60%);
  animation: fd-aurora-float 12s ease-in-out infinite alternate;
}
.fd-aurora::after {
  content: '';
  position: absolute;
  bottom: -30%;
  right: -10%;
  width: 70%;
  height: 60%;
  background: radial-gradient(ellipse, rgba(118,75,162,0.10) 0%, transparent 60%);
  animation: fd-aurora-float 16s ease-in-out infinite alternate-reverse;
}
@keyframes fd-aurora-float {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(4%,3%) scale(1.04); }
}

/* ---------- Grid overlay (subtle) ---------- */
.fd-grid-bg {
  background-image:
    linear-gradient(var(--hairline) 1px, transparent 1px),
    linear-gradient(90deg, var(--hairline) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ---------- Logo mark ---------- */
.fd-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent-grad);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 0 0 1px rgba(102,126,234,0.3), 0 4px 14px rgba(102,126,234,0.25);
}
.fd-mark .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.9;
  display: block;
}

/* ---------- Live dot ---------- */
.fd-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---------- Avatar ---------- */
.fd-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-elev3);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  text-transform: uppercase;
  border: 1px solid var(--border);
}

/* ---------- Card ---------- */
.fd-card {
  background: var(--bg-elev1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ---------- Buttons ---------- */
.fd-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
  white-space: nowrap;
  text-decoration: none;
}
.fd-btn:hover {
  background: var(--bg-elev3);
  color: var(--text);
  border-color: var(--border-strong);
}
.fd-btn:active { transform: scale(0.98); }

.fd-btn-primary {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.fd-btn-primary:hover {
  filter: brightness(1.1);
  color: #fff;
  border-color: transparent;
}

.fd-btn-ghost {
  background: transparent;
  border-color: transparent;
}
.fd-btn-ghost:hover {
  background: var(--bg-elev2);
  border-color: var(--border);
}

.fd-btn:disabled, .fd-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- Inputs ---------- */
.fd-input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev2);
  color: var(--text);
  font-size: 13.5px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.fd-input:focus {
  border-color: rgba(102,126,234,0.6);
  box-shadow: 0 0 0 3px rgba(102,126,234,0.12);
}
.fd-input::placeholder { color: var(--text-faint); }
select.fd-input { cursor: pointer; }

/* ---------- Chips / tags ---------- */
.fd-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elev2);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.fd-chip-green { background: rgba(34,197,94,0.10);  border-color: rgba(34,197,94,0.25);  color: var(--green); }
.fd-chip-amber { background: rgba(245,158,11,0.10); border-color: rgba(245,158,11,0.25); color: var(--amber); }
.fd-chip-red   { background: rgba(239,68,68,0.10);  border-color: rgba(239,68,68,0.25);  color: var(--red); }
.fd-chip-blue  { background: rgba(102,126,234,0.12); border-color: rgba(102,126,234,0.3); color: var(--accent-1); }

/* ---------- Navbar (user area) ---------- */
.fd-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 20px;
  height: 52px;
  background: rgba(10,10,15,0.80);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.fd-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-faint);
  cursor: pointer;
  transition: color .15s, background .15s;
  white-space: nowrap;
  text-decoration: none;
}
.fd-nav-link:hover { color: var(--text); background: var(--bg-elev2); }
.fd-nav-link.is-active { color: var(--text); }

/* ---------- Tables ---------- */
.fd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.fd-table thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev1);
  position: sticky;
  top: 0;
}
.fd-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline);
  color: var(--text-muted);
  vertical-align: middle;
}
.fd-table tbody tr:hover td { background: rgba(255,255,255,0.02); }
.fd-table tbody tr.is-me td { background: rgba(102,126,234,0.07); }

/* ---------- Collapsible ---------- */
.fd-collapsible {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elev1);
  margin-bottom: 10px;
  overflow: hidden;
}
.fd-collapsible-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}
.fd-collapsible-head:hover { background: var(--bg-elev2); }
.fd-collapsible-title {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.fd-collapsible-meta {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.fd-collapsible-chevron {
  color: var(--text-faint);
  transition: transform .15s;
  flex-shrink: 0;
}
.fd-collapsible-chevron.open { transform: rotate(90deg); }
.fd-collapsible-body {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--hairline);
}

/* ---------- Toggle switch ---------- */
.fd-switch {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--bg-elev3);
  border: 1px solid var(--border-strong);
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.fd-switch .thumb {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: left .2s, background .2s;
}
.fd-switch.on {
  background: rgba(34,197,94,0.25);
  border-color: rgba(34,197,94,0.5);
}
.fd-switch.on .thumb {
  left: 18px;
  background: var(--green);
}

/* ---------- Stat card accent line ---------- */
.fd-stat-accent {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* ---------- Preference row ---------- */
.fd-pref-row {
  border-radius: var(--radius-sm);
  transition: background .12s;
}
.fd-pref-row:hover { background: var(--bg-elev2); }

/* ---------- Admin layout ---------- */
.fd-admin {
  display: flex;
  min-height: 100vh;
}

.fd-admin-side {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-elev1);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.fd-admin-side-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
}
.fd-admin-brand {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.fd-admin-brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
}
.fd-admin-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
}
.fd-admin-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 8px 4px;
}
.fd-admin-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-faint);
  cursor: pointer;
  transition: color .12s, background .12s;
  text-decoration: none;
}
.fd-admin-link:hover { color: var(--text); background: var(--bg-elev2); }
.fd-admin-link.is-active { color: var(--text); background: var(--bg-elev2); border: 1px solid var(--border); }
.fd-admin-link-badge {
  margin-left: auto;
  font-size: 10.5px;
  background: var(--bg-elev3);
  color: var(--text-faint);
  padding: 1px 6px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.fd-admin-user {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.fd-admin-content {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 60px;
  overflow-x: hidden;
}

/* ---------- Admin stat grid ---------- */
.fd-admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

/* ---------- Utilities ---------- */
.fd-mono { font-family: var(--font-mono); }
.fd-tnum { font-variant-numeric: tabular-nums; }
.fd-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ---------- Progress bar ---------- */
.fd-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--bg-elev3);
  overflow: hidden;
}
.fd-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-grad);
  transition: width .3s;
}

/* ---------- Login page ---------- */
.fd-login-wrap {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
}
.fd-login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elev1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

/* ---------- Ban overlay ---------- */
@keyframes fd-vignette { 0%,100%{opacity:.7} 50%{opacity:1} }
@keyframes fd-glitch-pulse {
  0%{text-shadow:0 0 32px rgba(255,0,0,0.6),0 0 4px rgba(255,80,80,0.8)}
  49%{text-shadow:0 0 32px rgba(255,0,0,0.6),0 0 4px rgba(255,80,80,0.8)}
  50%{text-shadow:-3px 0 rgba(255,0,0,0.9),3px 0 rgba(80,80,255,0.5),0 0 32px rgba(255,0,0,0.6)}
  51%{text-shadow:0 0 32px rgba(255,0,0,0.6),0 0 4px rgba(255,80,80,0.8)}
  100%{text-shadow:0 0 32px rgba(255,0,0,0.6),0 0 4px rgba(255,80,80,0.8)}
}

/* ---------- Hall of Fame ---------- */
.fd-hof-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
}
.fd-hof-row:last-child { border-bottom: 0; }
.fd-hof-pos {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  width: 18px;
  text-align: right;
}
.fd-hof-medal {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.fd-hof-medal.gold   { background: linear-gradient(135deg,#fde68a,#f59e0b); color: #6b4500; }
.fd-hof-medal.silver { background: linear-gradient(135deg,#e5e7eb,#9ca3af); color: #374151; }
.fd-hof-medal.bronze { background: linear-gradient(135deg,#fed7aa,#c2410c); color: #7c2d12; }
.fd-hof-medal.plain  { background: var(--bg-elev3); color: var(--text-dim); }

/* ---------- Responsive helpers ---------- */
@media (max-width: 768px) {
  .fd-desktop-only { display: none !important; }
  .fd-admin { flex-direction: column; }
  .fd-admin-side { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--border); }
  .fd-admin-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
  .fd-admin-section-label { display: none; }
  .fd-admin-content { padding: 16px; }
  .fd-admin-stats { grid-template-columns: 1fr 1fr; }
  .fd-stats-grid { grid-template-columns: 1fr 1fr !important; }
  .fd-two-col { grid-template-columns: 1fr !important; }
}
@media (min-width: 769px) {
  .fd-mobile-only { display: none !important; }
}

/* ---- inline SVG icon shim (used via <i class="fd-icon">) ---- */
.fd-icon { display: inline-flex; align-items: center; justify-content: center; }
