:root {
  --orange: #FF6B00;
  --orange-light: #FF8C33;
  --gold: #FFD700;
  --pink: #FF1493;
  --cyan: #00BFFF;
  --purple: #9B59B6;
  --green: #00CC44;
  --red: #FF4444;
  --bg-primary: #1A0A2E;
  --bg-secondary: #2D1B4E;
  --bg-card: #3D2B5E;
  --text-primary: #FFFFFF;
  --text-secondary: #C8B8E8;
  --text-muted: #8B7BAB;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow-orange: 0 0 20px rgba(255,107,0,0.4);
  --font: 'Nunito', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(155,89,182,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(255,107,0,0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(0,191,255,0.1) 0%, transparent 50%);
  color: var(--text-primary);
  min-height: 100vh;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: none; background: none; font-family: var(--font); }

#header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--bg-secondary);
  border-bottom: 3px solid var(--orange); position: sticky; top: 0; z-index: 100;
}
.header-logo { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.logo-icon { font-size: 2rem; }
.logo-text {
  font-size: 1.6rem; font-weight: 900;
  background: linear-gradient(135deg, var(--orange), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
#header-nav { display: flex; align-items: center; gap: 12px; }
.nav-btn {
  padding: 8px 16px; border-radius: var(--radius-md); font-weight: 700;
  font-size: 0.9rem; color: var(--text-secondary); transition: all 0.2s;
}
.nav-btn:hover { color: var(--orange); background: rgba(255,107,0,0.1); }

#main { padding: 24px; max-width: 1000px; margin: 0 auto; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 28px; border-radius: var(--radius-lg); font-weight: 800;
  font-size: 1.1rem; text-transform: uppercase; letter-spacing: 1px;
  transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1); border: 3px solid transparent;
}
.btn:active { transform: scale(0.95); }
.btn-primary {
  background: linear-gradient(135deg, var(--orange), #CC5500); color: white;
  border-color: var(--orange-light); box-shadow: var(--shadow-glow-orange);
}
.btn-primary:hover { transform: scale(1.05); }
.btn-outline {
  background: transparent; color: var(--text-primary); border: 3px solid var(--text-muted);
}
.btn-outline:hover { border-color: var(--orange); color: var(--orange); }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; border-radius: var(--radius-md); }

/* Forms */
.input {
  width: 100%; padding: 14px 18px; background: var(--bg-secondary);
  border: 3px solid var(--bg-card); border-radius: var(--radius-md);
  color: var(--text-primary); font-size: 1rem; font-weight: 600; transition: border-color 0.2s;
}
.input:focus { outline: none; border-color: var(--orange); }
.input::placeholder { color: var(--text-muted); }
.label { display: block; font-weight: 700; font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px; }
.form-group { margin-bottom: 16px; }
.form-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.error-msg { color: var(--red); font-weight: 700; font-size: 0.9rem; margin-top: 8px; text-align: center; }

/* Hero */
.hero { text-align: center; padding: 40px 0 32px; }
.hero-title {
  font-size: 3.5rem; font-weight: 900; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--orange), var(--gold), var(--pink));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero-sub { font-size: 1.2rem; color: var(--text-secondary); margin-bottom: 8px; }
.hero-flag { font-size: 1rem; color: var(--text-muted); }

/* User bar */
.user-bar {
  display: flex; align-items: center; gap: 12px; padding: 16px;
  background: var(--bg-secondary); border-radius: var(--radius-lg);
  border: 3px solid var(--bg-card); margin-bottom: 24px;
}
.user-avatar {
  width: 48px; height: 48px; border-radius: 50%; background: var(--purple);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1.2rem; flex-shrink: 0;
}
.user-info { flex: 1; }
.user-name { font-weight: 800; font-size: 1.1rem; }
.user-level { font-size: 0.85rem; color: var(--gold); font-weight: 700; }
.xp-bar { height: 6px; background: var(--bg-card); border-radius: 3px; margin-top: 4px; overflow: hidden; }
.xp-fill { height: 100%; background: linear-gradient(90deg, var(--orange), var(--gold)); border-radius: 3px; transition: width 0.5s; }

/* Game grid */
.section-title {
  font-size: 1.4rem; font-weight: 800; margin-bottom: 16px;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 2px;
}
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 32px; }
.game-tile {
  background: var(--bg-secondary); border: 3px solid var(--bg-card);
  border-radius: var(--radius-xl); padding: 24px; transition: all 0.2s;
  cursor: pointer; text-decoration: none; color: inherit; display: block;
}
.game-tile:hover { border-color: var(--orange); transform: translateY(-4px); box-shadow: var(--shadow-lg); text-decoration: none; }
.game-emoji { font-size: 3rem; margin-bottom: 12px; }
.game-name { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.game-desc { font-size: 0.9rem; color: var(--text-muted); line-height: 1.4; }
.game-badge {
  display: inline-block; margin-top: 10px; padding: 4px 10px;
  border-radius: 20px; font-size: 0.75rem; font-weight: 800; text-transform: uppercase;
}
.badge-live { background: var(--green); color: white; }
.badge-soon { background: var(--text-muted); color: white; }

/* Leaderboard */
.lb-list { display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--bg-card); border-radius: var(--radius-md);
}
.lb-row:first-child { border: 2px solid var(--gold); }
.lb-rank { font-size: 1.3rem; font-weight: 900; width: 36px; text-align: center; }
.lb-name { font-weight: 700; flex: 1; }
.lb-xp { font-weight: 900; color: var(--gold); }
.lb-level { font-size: 0.8rem; color: var(--text-muted); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-secondary); border: 3px solid var(--bg-card);
  border-radius: var(--radius-xl); padding: 32px; max-width: 420px; width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal h2 {
  text-align: center; margin-bottom: 24px;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.modal-close {
  float: right; font-size: 1.5rem; color: var(--text-muted); cursor: pointer;
  font-weight: 900; line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-footer { text-align: center; margin-top: 16px; color: var(--text-muted); font-size: 0.9rem; }
.modal-footer a { color: var(--cyan); font-weight: 700; cursor: pointer; }

/* Recovery code display */
.recovery-display {
  background: var(--bg-card); border: 3px dashed var(--gold); border-radius: var(--radius-md);
  padding: 16px; text-align: center; margin: 16px 0;
}
.recovery-code { font-size: 2rem; font-weight: 900; color: var(--gold); letter-spacing: 4px; font-family: monospace; }
.recovery-hint { font-size: 0.85rem; color: var(--text-muted); margin-top: 8px; }

@media (max-width: 600px) {
  .hero-title { font-size: 2.5rem; }
  #header { padding: 10px 16px; }
  .logo-text { font-size: 1.3rem; }
  #main { padding: 16px; }
  .game-grid { grid-template-columns: 1fr; }
}
