/* ========================================
  1) Design Tokens (CSS Variables)
======================================== */
:root {
  --bg: #0b0f1a;
  --card: #11162a;
  --ui: #11162a;
  --text: #e8ecf1;
  --muted: #9aa7bd;
  --accent: #5ef2a2;
  --border: rgba(255, 255, 255, 0.12);
  --header-offset: 56px;
  /* space for fixed header */
}

/* ========================================
  2) Base / Reset & Accessibility
======================================== */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Helvetica, Arial, sans-serif;
  padding-top: var(--header-offset);
  background-color: #090d18;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(0, 200, 255, 0.07) 0%, transparent 50%),
    radial-gradient(circle at 60% 80%, rgba(255, 215, 0, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 30% 70%, rgba(255, 0, 100, 0.04) 0%, transparent 50%),
    /* faint pixel grid */
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: cover, cover, cover, cover, 8px 8px, 8px 8px;
  background-attachment: fixed;
}

/* Screen reader only */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Subtle animated scanlines (CRT vibe) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom,
      rgba(255, 255, 255, 0.03) 0px,
      rgba(255, 255, 255, 0.03) 1px,
      transparent 2px);
  opacity: 0.18;
  mix-blend-mode: soft-light;
  animation: scanline-glide 6s linear infinite;
}

/* ========================================
  3) Layout Helpers
======================================== */
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.wrap.narrow {
  max-width: 520px;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  padding: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

/* ========================================
  4) Components
======================================== */
/* HUD / status bar */
.hud {
  width: 100%;
  max-width: 520px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  background: var(--ui);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}

/* Cards */
.card {
  background: linear-gradient(180deg,
      rgba(255, 255, 255, 0.08),
      rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 16px;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.4),
    0 0 10px rgba(94, 242, 162, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.5),
    0 0 15px rgba(94, 242, 162, 0.25);
}

.card a {
  display: inline-block;
  margin-top: 8px;
  text-decoration: none;
  color: #0b0f1a;
  background: var(--accent);
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
}

/* Buttons */
.btn {
  background: var(--accent);
  color: #04131e;
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

.btn.secondary {
  background: #253150;
  color: #cfe7ff;
}

/* Disabled state */
button:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Generic toggle button */
.toggle {
  background: #0f1730;
  color: #e8ecf1;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

/* Old sticky mini-header (legacy utility) */
.sticky-home {
  position: fixed;
  top: 10px;
  left: 10px;
  background: rgba(15, 23, 48, 0.85);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  z-index: 9998;
  display: flex;
  justify-content: start;
  border-radius: 10px;
}

.sticky-home>a {
  margin: 0 10px 0;
  color: #04131e;
  background: var(--accent);
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
}

/* Ads */
.ad {
  width: min(100%, 728px);
  margin: 0 auto;
  min-height: 60px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Notes / helper text */
.note {
  color: var(--muted);
  max-width: 520px;
  text-align: center;
}

/* Dialogs */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.dialog {
  background: #0f1730;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px;
  min-width: 260px;
}

.dialog .actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

/* Options row */
.option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0;
}

.option input {
  transform: scale(1.2);
}

/* Consent banner */
.consent-banner {
  position: fixed;
  bottom: 10px;
  left: 10px;
  right: 10px;
  background: #11162a;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  z-index: 9999;
}

.consent-banner p {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

.consent-actions {
  display: flex;
  gap: 8px;
}

.consent-actions button {
  background: #253150;
  color: #cfe7ff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.consent-actions .accept {
  background: var(--accent);
  color: #04131e;
  border: none;
  font-weight: 700;
}

/* ========================================
  5) Header / Nav (mobile-first)
======================================== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9998;
  background: rgba(15, 23, 48, 0.85);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.site-header__bar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Logo */
.site-header__logo {
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0.3px;
  padding: 6px 8px;
  border-radius: 8px;
  line-height: 0;
  /* remove inline gap for img */
}

.site-header__logo img {
  height: 28px;
  /* mobile */
  width: auto;
  display: block;
}

/* Toggle (hamburger) */
.nav-toggle {
  appearance: none;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

/* Mobile menu */
.nav-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  display: none;
  /* hidden by default on mobile */
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 12px;
  background: #11162a;
  /* matches --ui */
  border-bottom: 1px solid var(--border);
}

.nav-menu.open {
  display: flex;
}

/* Links */
.nav-menu a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
}

.nav-menu a:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
}

.nav-menu a[aria-current="page"] {
  background: rgba(94, 242, 162, 0.15);
  box-shadow: inset 0 0 0 1px rgba(94, 242, 162, 0.35);
}

/* Lock body scroll when nav is open */
body.nav-open {
  overflow: hidden;
}

/* ========================================
  6) Media Queries
======================================== */
@media (min-width: 720px) {
  .site-header__logo img {
    height: 32px;
  }

  /* desktop logo */
  .nav-toggle {
    display: none;
  }

  .nav-menu {
    position: static;
    display: flex !important;
    /* always visible on desktop */
    flex-direction: row;
    gap: 10px;
    padding: 0;
    background: transparent;
    border: 0;
  }

  .nav-menu a {
    padding: 6px 10px;
  }
}

@media (max-width: 420px) {
  .ad {
    width: min(100%, 320px);
  }

  /* fits common mobile ad units */
}

/* ========================================
  7) Animations & Motion
======================================== */
@keyframes scanline-glide {
  0% {
    transform: translateY(0);
  }

  100% {
    transform: translateY(2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before {
    animation: none;
  }
}