/* ═══════════════════════════════════════════════════════════════
   CHESSMASTER ONLINE — Design System v6
   Premium Native App Experience
   ═══════════════════════════════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ── CSS Variables ── */
:root {
  /* Backgrounds */
  --bg-base:      #060610;
  --bg-elevated:  #0c0c1a;
  --bg-surface:   rgba(255,255,255,0.04);
  --bg-surface-2: rgba(255,255,255,0.07);
  --bg-overlay:   rgba(6,6,16,0.85);

  /* Glass */
  --glass-bg:     rgba(255,255,255,0.05);
  --glass-bg-2:   rgba(255,255,255,0.09);
  --glass-border: rgba(255,255,255,0.08);
  --glass-border-2:rgba(255,255,255,0.15);
  --glass-blur:   blur(20px) saturate(180%);
  --glass-blur-lg:blur(40px) saturate(200%);

  /* Brand Colours */
  --gold:         #f5b942;
  --gold-light:   #ffd270;
  --gold-dark:    #d4950a;
  --gold-glow:    rgba(245,185,66,0.25);
  --gold-glow-lg: rgba(245,185,66,0.4);

  --purple:       #7c5cbf;
  --purple-light: #9d7de0;
  --purple-glow:  rgba(124,92,191,0.25);

  --blue:         #3d8ef5;
  --blue-glow:    rgba(61,142,245,0.25);

  --teal:         #00d4aa;
  --teal-glow:    rgba(0,212,170,0.2);

  /* Status */
  --success:      #00d4aa;
  --success-bg:   rgba(0,212,170,0.1);
  --warning:      #f5b942;
  --warning-bg:   rgba(245,185,66,0.1);
  --danger:       #ff4d6d;
  --danger-bg:    rgba(255,77,109,0.1);
  --info:         #3d8ef5;
  --info-bg:      rgba(61,142,245,0.1);

  /* Text */
  --text-primary:   rgba(255,255,255,0.95);
  --text-secondary: rgba(255,255,255,0.60);
  --text-muted:     rgba(255,255,255,0.35);
  --text-disabled:  rgba(255,255,255,0.20);

  /* Gradients */
  --grad-hero:   linear-gradient(135deg, #12012e 0%, #060610 45%, #001524 100%);
  --grad-gold:   linear-gradient(135deg, #f5b942 0%, #e8960f 100%);
  --grad-purple: linear-gradient(135deg, #7c5cbf 0%, #5a3fa0 100%);
  --grad-blue:   linear-gradient(135deg, #3d8ef5 0%, #1a5fcc 100%);
  --grad-card:   linear-gradient(135deg, rgba(245,185,66,0.08) 0%, rgba(124,92,191,0.04) 100%);
  --grad-mesh:   radial-gradient(ellipse at 20% 50%, rgba(124,92,191,0.15) 0%, transparent 60%),
                 radial-gradient(ellipse at 80% 20%, rgba(245,185,66,0.10) 0%, transparent 60%),
                 radial-gradient(ellipse at 60% 80%, rgba(61,142,245,0.10) 0%, transparent 60%);

  /* Spacing */
  --sp-xs:  4px;
  --sp-sm:  8px;
  --sp-md:  16px;
  --sp-lg:  24px;
  --sp-xl:  32px;
  --sp-2xl: 48px;
  --sp-3xl: 64px;

  /* Radius */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-2xl:  24px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.5);
  --shadow-xl:  0 20px 60px rgba(0,0,0,0.6);
  --shadow-gold: 0 4px 24px rgba(245,185,66,0.3);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.05) inset, 0 8px 32px rgba(0,0,0,0.4);

  /* Transitions */
  --t-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base:   250ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow:   400ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --header-h:    60px;
  --bottom-nav-h: 72px;
  --sidebar-w:   260px;
  --content-max: 480px;

  /* Typography */
  --font-sans: 'Inter', 'SF Pro Display', system-ui, -apple-system, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', sans-serif;
}

/* ── Light Mode Override ── */
[data-theme="light"] {
  --bg-base:       #f0f0f8;
  --bg-elevated:   #ffffff;
  --bg-surface:    rgba(0,0,0,0.03);
  --bg-surface-2:  rgba(0,0,0,0.06);
  --bg-overlay:    rgba(240,240,248,0.9);
  --glass-bg:      rgba(255,255,255,0.7);
  --glass-bg-2:    rgba(255,255,255,0.9);
  --glass-border:  rgba(0,0,0,0.08);
  --glass-border-2:rgba(0,0,0,0.12);
  --text-primary:   rgba(10,10,30,0.95);
  --text-secondary: rgba(10,10,30,0.60);
  --text-muted:     rgba(10,10,30,0.40);
  --text-disabled:  rgba(10,10,30,0.20);
  --grad-hero:   linear-gradient(135deg, #e8e0ff 0%, #f0f0f8 45%, #ddf0ff 100%);
  --grad-mesh:   radial-gradient(ellipse at 20% 50%, rgba(124,92,191,0.08) 0%, transparent 60%),
                 radial-gradient(ellipse at 80% 20%, rgba(245,185,66,0.07) 0%, transparent 60%),
                 radial-gradient(ellipse at 60% 80%, rgba(61,142,245,0.07) 0%, transparent 60%);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.10);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.12);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.8) inset, 0 4px 20px rgba(0,0,0,0.08);
}

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-base);
  background-image: var(--grad-mesh);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t-slow), color var(--t-slow);
}

/* Animated gradient orbs */
body::before {
  content: '';
  position: fixed;
  top: -30vh;
  left: -20vw;
  width: 70vw;
  height: 70vw;
  background: radial-gradient(circle, rgba(124,92,191,0.12) 0%, transparent 70%);
  border-radius: 50%;
  animation: orbFloat 20s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -20vh;
  right: -20vw;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, rgba(245,185,66,0.08) 0%, transparent 70%);
  border-radius: 50%;
  animation: orbFloat 25s ease-in-out infinite reverse;
  pointer-events: none;
  z-index: 0;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0,0) scale(1); }
  33%  { transform: translate(5vw,5vh) scale(1.05); }
  66%  { transform: translate(-3vw,3vh) scale(0.95); }
}

/* ── Typography ── */
h1,h2,h3,h4,h5,h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
h2 { font-size: clamp(1.375rem, 4vw, 1.875rem); }
h3 { font-size: clamp(1.125rem, 3vw, 1.375rem); }
h4 { font-size: 1.125rem; }

a {
  color: var(--gold);
  text-decoration: none;
  transition: color var(--t-fast), opacity var(--t-fast);
}

a:hover { opacity: 0.8; }

img { max-width: 100%; height: auto; display: block; }

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

/* ── Utility ── */
.visually-hidden {
  position: absolute; width:1px; height:1px;
  padding:0; margin:-1px; overflow:hidden;
  clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

.truncate { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.mt-auto { margin-top: auto; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ── Selection ── */
::selection { background: var(--gold-glow); color: var(--text-primary); }
