/* =========================================================
   Variables
   ========================================================= */
:root {
  /* Color palette - dark futuristic gaming */
  --color-bg: #050812;
  --color-bg-elevated: #070b18;
  --color-bg-soft: #0d1224;
  --color-surface: #101628;

  --color-text: #f5f7ff;
  --color-text-muted: #a7b0d0;
  --color-text-soft: #7b84a5;

  --color-primary: #37b3ff; /* neon blue */
  --color-primary-soft: rgba(55, 179, 255, 0.12);
  --color-primary-strong: #57c6ff;

  --color-accent-purple: #a855ff;
  --color-accent-purple-soft: rgba(168, 85, 255, 0.1);
  --color-accent-emerald: #22e3a4;
  --color-accent-emerald-soft: rgba(34, 227, 164, 0.1);

  --color-success: #22c55e;
  --color-warning: #facc15;
  --color-danger: #f97373;

  --color-gray-50: #f9fafb;
  --color-gray-100: #e5e7eb;
  --color-gray-200: #d1d5db;
  --color-gray-300: #9ca3af;
  --color-gray-400: #6b7280;
  --color-gray-500: #4b5563;
  --color-gray-600: #374151;
  --color-gray-700: #1f2933;
  --color-gray-800: #111827;
  --color-gray-900: #030712;

  /* Status variants on dark */
  --color-chip-bg: rgba(15, 23, 42, 0.9);
  --color-border-subtle: rgba(148, 163, 184, 0.25);
  --color-border-strong: rgba(148, 163, 184, 0.4);

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Rajdhani", "Oxanium", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --font-size-xs: 0.75rem;   /* 12px */
  --font-size-sm: 0.875rem;  /* 14px */
  --font-size-base: 1rem;    /* 16px */
  --font-size-lg: 1.125rem;  /* 18px */
  --font-size-xl: 1.25rem;   /* 20px */
  --font-size-2xl: 1.5rem;   /* 24px */
  --font-size-3xl: 1.875rem; /* 30px */
  --font-size-4xl: 2.25rem;  /* 36px */
  --font-size-5xl: 3rem;     /* 48px */

  --line-height-tight: 1.1;
  --line-height-snug: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.7;

  /* Spacing scale (0–96px) */
  --space-0: 0;
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */
  --space-24: 6rem;     /* 96px */

  /* Radius */
  --radius-xs: 0.25rem;  /* 4px */
  --radius-sm: 0.375rem; /* 6px */
  --radius-md: 0.5rem;   /* 8px */
  --radius-lg: 0.75rem;  /* 12px */
  --radius-xl: 1rem;     /* 16px */
  --radius-pill: 999px;

  /* Shadows - glowing / gaming style */
  --shadow-soft: 0 8px 20px rgba(15, 23, 42, 0.8);
  --shadow-strong: 0 18px 45px rgba(15, 23, 42, 0.95);
  --shadow-glow-primary: 0 0 24px rgba(55, 179, 255, 0.65);
  --shadow-glow-emerald: 0 0 24px rgba(34, 227, 164, 0.6);

  /* Transitions / motion */
  --transition-fast: 120ms ease-out;
  --transition-base: 180ms ease-out;
  --transition-slow: 260ms ease-out;

  /* Layout helpers */
  --container-width-sm: 640px;
  --container-width-md: 768px;
  --container-width-lg: 1024px;
  --container-width-xl: 1200px;
  --container-width-2xl: 1440px;
}

/* Respect reduced motion globally */
@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 1ms linear;
    --transition-base: 1ms linear;
    --transition-slow: 1ms linear;
  }
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =========================================================
   Reset / Normalize
   ========================================================= */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
}

h1, h2, h3, h4, h5, h6,
p, figure, blockquote,
dl, dd {
  margin: 0;
}

ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
  margin: 0;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  border: none;
  padding: 0;
  background: none;
}

textarea {
  resize: vertical;
}

:where(a) {
  color: inherit;
  text-decoration: none;
}

:where(table) {
  border-collapse: collapse;
  border-spacing: 0;
}

/* Prevent long strings from breaking layout */
:where(p, h1, h2, h3, h4, h5, h6, li) {
  overflow-wrap: break-word;
}

/* =========================================================
   Base Styles
   ========================================================= */
body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  background-color: radial-gradient(circle at top, #111827 0, #020617 55%, #000 100%);
  background-color: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main {
  min-height: 100vh;
}

/* Headings with display font for immersive gaming feel */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--color-text);
}

h1 {
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-4);
}

h2 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  line-height: var(--line-height-snug);
  margin-bottom: var(--space-3);
}

h3 {
  font-size: clamp(1.4rem, 2.2vw, 1.8rem);
  line-height: var(--line-height-snug);
  margin-bottom: var(--space-2);
}

h4 {
  font-size: 1.25rem;
  margin-bottom: var(--space-2);
}

p {
  margin-bottom: var(--space-3);
  color: var(--color-text-muted);
}

strong {
  font-weight: 600;
  color: var(--color-text);
}

small {
  font-size: var(--font-size-xs);
}

a {
  position: relative;
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-base), text-shadow var(--transition-base);
}

a:hover {
  color: var(--color-primary-strong);
  text-shadow: 0 0 14px rgba(55, 179, 255, 0.7);
}

a:active {
  color: var(--color-accent-emerald);
}

code, pre {
  font-family: var(--font-mono);
}

hr {
  border: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  margin: var(--space-6) 0;
}

/* =========================================================
   Accessibility & Focus
   ========================================================= */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

/* High-contrast focus for key interactive elements */
button:focus-visible,
[role="button"]:focus-visible,
a[href]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 1), 0 0 0 3px rgba(55, 179, 255, 0.9);
}

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

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* =========================================================
   Layout Utilities
   ========================================================= */
.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
  max-width: var(--container-width-xl);
}

@media (min-width: 1440px) {
  .container {
    max-width: var(--container-width-2xl);
  }
}

.section {
  padding-top: var(--space-10);
  padding-bottom: var(--space-10);
}

.section--dense {
  padding-top: var(--space-6);
  padding-bottom: var(--space-6);
}

/* Flex helpers */
.flex {
  display: flex;
}

.inline-flex {
  display: inline-flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-column {
  display: flex;
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.gap-2 {
  gap: var(--space-2);
}

.gap-3 {
  gap: var(--space-3);
}

.gap-4 {
  gap: var(--space-4);
}

.gap-6 {
  gap: var(--space-6);
}

/* Grid helpers for cards, game tiles, leaderboards */
.grid {
  display: grid;
}

.grid-auto-fit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}

.grid-auto-fit-lg {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-6);
}

/* Alignment & text */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--color-text-muted);
}

.text-soft {
  color: var(--color-text-soft);
}

/* Width utilities */
.w-full {
  width: 100%;
}

/* Spacing utilities (commonly needed) */
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.py-4 {
  padding-top: var(--space-4);
  padding-bottom: var(--space-4);
}
.py-6 {
  padding-top: var(--space-6);
  padding-bottom: var(--space-6);
}

/* Badge / chip utility for status labels, difficulty, fantasy tags */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--color-chip-bg);
  border: 1px solid rgba(55, 65, 81, 0.9);
  font-size: var(--font-size-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-soft);
}

.chip--primary {
  border-color: rgba(55, 179, 255, 0.7);
  background: linear-gradient(135deg, rgba(55, 179, 255, 0.15), rgba(22, 163, 255, 0.02));
  color: var(--color-primary);
}

.chip--emerald {
  border-color: rgba(34, 227, 164, 0.7);
  background: linear-gradient(135deg, rgba(34, 227, 164, 0.15), rgba(16, 185, 129, 0.02));
  color: var(--color-accent-emerald);
}

/* =========================================================
   Components - Buttons
   ========================================================= */
.btn {
  --btn-bg: var(--color-primary);
  --btn-bg-hover: var(--color-primary-strong);
  --btn-text: #020617;
  --btn-border: transparent;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;

  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-pill);

  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--btn-border);

  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;

  cursor: pointer;
  transition:
    background-color var(--transition-base),
    color var(--transition-base),
    box-shadow var(--transition-base),
    transform var(--transition-fast),
    border-color var(--transition-base);

  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.4);
}

.btn:hover {
  background: var(--btn-bg-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-primary);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.85);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn--outline {
  --btn-bg: transparent;
  --btn-bg-hover: rgba(15, 23, 42, 0.95);
  --btn-text: var(--color-primary);
  --btn-border: rgba(55, 179, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(55, 179, 255, 0.4);
}

.btn--ghost {
  --btn-bg: rgba(15, 23, 42, 0.85);
  --btn-bg-hover: rgba(15, 23, 42, 1);
  --btn-text: var(--color-text);
  --btn-border: rgba(51, 65, 85, 0.9);
  box-shadow: 0 0 0 1px rgba(30, 64, 175, 0.4);
}

.btn--emerald {
  --btn-bg: var(--color-accent-emerald);
  --btn-bg-hover: #4df0bd;
  box-shadow: var(--shadow-glow-emerald);
}

.btn--sm {
  padding: 0.5rem 0.95rem;
  font-size: 0.8rem;
}

.btn--lg {
  padding: 0.85rem 1.8rem;
  font-size: 1rem;
}

/* Icon-only circular buttons (e.g., scroll, play, next) */
.btn-icon {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 999px;
}

/* =========================================================
   Components - Form Elements
   ========================================================= */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
}

.field-helper {
  font-size: var(--font-size-xs);
  color: var(--color-text-soft);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);

  background-color: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(55, 65, 81, 0.9);

  color: var(--color-text);
  font-size: var(--font-size-sm);

  transition:
    border-color var(--transition-base),
    box-shadow var(--transition-base),
    background-color var(--transition-base),
    transform var(--transition-fast);
}

input::placeholder,
textarea::placeholder {
  color: rgba(148, 163, 184, 0.6);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: rgba(55, 179, 255, 0.9);
  background-color: rgba(15, 23, 42, 0.98);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 1), var(--shadow-glow-primary);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: rgba(248, 113, 113, 0.85);
}

select {
  cursor: pointer;
}

/* Basic checkbox / radio alignment helper */
.field-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* =========================================================
   Components - Card / Panels
   ========================================================= */
.card {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-subtle);
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), transparent 55%),
              radial-gradient(circle at bottom right, rgba(168, 85, 255, 0.12), transparent 55%),
              linear-gradient(145deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.96));
  padding: var(--space-4);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top center, rgba(55, 179, 255, 0.095), transparent 55%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.card:hover::before {
  opacity: 1;
}

.card--interactive {
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-base), border-color var(--transition-base);
}

.card--interactive:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-strong);
  border-color: rgba(55, 179, 255, 0.8);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.card-meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-soft);
}

.card-body {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.card-footer {
  margin-top: var(--space-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}

/* Compact stat panel for ranking, XP, rewards */
.stat-panel {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(55, 65, 81, 0.85);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.98));
  font-size: var(--font-size-xs);
}

.stat-panel__label {
  color: var(--color-text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-panel__value {
  margin-top: 0.2rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

/* =========================================================
   Components - Progress & Badges (achievements / challenges)
   ========================================================= */
.progress {
  position: relative;
  width: 100%;
  height: 0.55rem;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 42, 0.9);
  overflow: hidden;
}

.progress__bar {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--color-accent-emerald), var(--color-primary));
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.7);
  transition: width 220ms ease-out;
}

.badge-tier {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  min-height: 2.2rem;
  padding: 0.3rem;
  border-radius: 0.9rem;
  background: radial-gradient(circle at 30% 0, rgba(250, 250, 250, 0.35), transparent 55%),
              conic-gradient(from 160deg, #eab308, #f97316, #a855f7, #22c55e, #eab308);
  box-shadow: 0 0 18px rgba(234, 179, 8, 0.85);
  font-family: var(--font-display);
  font-size: 0.75rem;
  text-transform: uppercase;
}

/* =========================================================
   Media / Imagery helpers
   ========================================================= */
.img-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.img-rounded {
  border-radius: var(--radius-lg);
}

.img-glow {
  box-shadow: 0 0 35px rgba(37, 99, 235, 0.5);
}

/* Aspect ratio container for gameplay / fantasy scenes */
.aspect-video {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 */
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.aspect-video > * {
  position: absolute;
  inset: 0;
}

/* =========================================================
   Misc Utilities (for layout & theming)
   ========================================================= */
.bg-primary-soft {
  background: var(--color-primary-soft);
}

.bg-surface {
  background: var(--color-surface);
}

.border-subtle {
  border: 1px solid var(--color-border-subtle);
}

.rounded-md {
  border-radius: var(--radius-md);
}

.rounded-lg {
  border-radius: var(--radius-lg);
}

.shadow-soft {
  box-shadow: var(--shadow-soft);
}

.shadow-glow-primary {
  box-shadow: var(--shadow-glow-primary);
}

/* Overlay gradient for hero / immersive sections */
.hero-ambient {
  position: relative;
  isolation: isolate;
}

.hero-ambient::before {
  content: "";
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.4), transparent 55%),
    radial-gradient(circle at top right, rgba(168, 85, 255, 0.3), transparent 55%),
    radial-gradient(circle at bottom, rgba(34, 197, 94, 0.35), transparent 60%);
  opacity: 0.45;
  filter: blur(20px);
  z-index: -1;
  pointer-events: none;
}

/* =========================================================
   Responsive tweaks
   ========================================================= */
@media (max-width: 768px) {
  .section {
    padding-top: var(--space-8);
    padding-bottom: var(--space-8);
  }

  .card {
    padding: var(--space-3);
  }

  h1 {
    margin-bottom: var(--space-3);
  }
}
