/* ============================================================
   Playing With Friends - Global Stylesheet
   Dark gaming aesthetic: electric cyan + orange on near-black
   Fonts: Righteous (display) + Nunito (body)
   ============================================================ */

/* ============================================================
   Self-hosted fonts (no external requests)
   Files are in assets/fonts/
   ============================================================ */

@font-face {
  font-family: 'Righteous';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/righteous-400.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/nunito-400.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/nunito-600.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/nunito-700.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../fonts/nunito-800.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('../fonts/nunito-900.woff2') format('woff2');
}

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  --bg:          #07070f;
  --bg2:         #0d0d1a;
  --card:        #111122;
  --card2:       #161630;
  --border:      #1e1e3a;
  --border2:     #2a2a50;

  --cyan:        #00d4ff;
  --cyan-dim:    #00d4ff55;
  --cyan-glow:   0 0 20px #00d4ff40;
  --orange:      #ff6b35;
  --orange-dim:  #ff6b3540;
  --purple:      #a855f7;
  --purple-dim:  #a855f730;
  --green:       #22c55e;
  --yellow:      #fbbf24;
  --red:         #ef4444;
  --pink:        #ec4899;

  --text:        #e8e8ff;
  --text-muted:  #7070a0;
  --text-dim:    #4a4a70;

  --radius:      12px;
  --radius-lg:   18px;
  --radius-xl:   24px;

  --transition:  .2s cubic-bezier(.4,0,.2,1);
  --shadow:      0 4px 24px rgba(0,0,0,.5);
  --shadow-lg:   0 8px 48px rgba(0,0,0,.7);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Animated background grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: .3;
  pointer-events: none;
  z-index: 0;
}

* { position: relative; }

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

input, select, textarea {
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4 {
  font-family: 'Righteous', sans-serif;
  letter-spacing: .02em;
  line-height: 1.2;
}

.display {
  font-family: 'Righteous', sans-serif;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 1;
}

.label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

.page {
  padding-top: 80px;
  min-height: 100vh;
  padding-bottom: 40px;
}

/* Grid utilities */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }

/* ============================================================
   NAVIGATION
   ============================================================ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: rgba(7,7,15,.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  height: 64px;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 24px;
}

.nav-logo {
  font-family: 'Righteous', sans-serif;
  font-size: 1.4rem;
  color: var(--cyan);
  letter-spacing: .02em;
  text-shadow: var(--cyan-glow);
}

.nav-logo span { color: var(--orange); }

.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-muted);
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.nav-link:hover { background: var(--card2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--cyan-dim); color: var(--cyan); }

.nav-notif-badge {
  background: var(--orange);
  color: #fff;
  border-radius: 50%;
  width: 18px; height: 18px;
  font-size: 10px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Righteous', sans-serif;
  font-size: .9rem;
  color: var(--bg);
  cursor: pointer;
  transition: var(--transition);
}
.nav-avatar:hover { transform: scale(1.1); }

@media (max-width: 640px) {
  /* On mobile, hide the top nav links — bottom nav takes over */
  .nav-links { display: none; }
  .nav-user .nav-username-text { display: none; }

  /* Tabs: when they wrap to a second line, centre-align them */
  .tabs { justify-content: center; }
  .tab  { flex: 0 1 auto; padding: 8px 14px; font-size: 13px; }
}

/* ============================================================
   BOTTOM NAVIGATION BAR (mobile only)
   ============================================================ */
.bottom-nav {
  display: none; /* desktop: hidden */
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1000;
  background: rgba(7,7,15,.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border2);
  padding: 0 8px env(safe-area-inset-bottom);
  height: calc(60px + env(safe-area-inset-bottom));
  align-items: stretch;
  justify-content: space-around;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 10px;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
  border: none;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item.active { color: var(--cyan); }
.bottom-nav-item:hover:not(.active) { color: var(--text); }
.bottom-nav-item:active { transform: scale(.9); }

.bottom-nav-icon {
  font-size: 22px;
  line-height: 1;
  position: relative;
}

.bottom-nav-label {
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.bottom-nav-badge {
  position: absolute;
  top: -4px; right: -6px;
  background: var(--orange);
  color: #fff;
  border-radius: 50%;
  width: 14px; height: 14px;
  font-size: 8px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 640px) {
  .bottom-nav { display: flex; }
  /* Extra page padding so content clears the bottom bar */
  .page { padding-bottom: 76px; }
  /* auth / full-screen pages don't need the bottom nav */
  .auth-page { padding-bottom: 20px; }
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition);
}

.card:hover { border-color: var(--border2); }

.card-cyan  { border-color: var(--cyan-dim); }
.card-orange { border-color: var(--orange-dim); }
.card-purple { border-color: var(--purple-dim); }

.card-glow-cyan  { box-shadow: 0 0 30px rgba(0,212,255,.08); }
.card-glow-orange { box-shadow: 0 0 30px rgba(255,107,53,.08); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-family: 'Righteous', sans-serif;
  font-size: 1.1rem;
  color: var(--text);
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-family: 'Righteous', sans-serif;
  font-size: 2.2rem;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}

.stat-card.cyan  .stat-value { color: var(--cyan); text-shadow: var(--cyan-glow); }
.stat-card.orange .stat-value { color: var(--orange); }
.stat-card.purple .stat-value { color: var(--purple); }
.stat-card.green  .stat-value { color: var(--green); }
.stat-card.yellow .stat-value { color: var(--yellow); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: .02em;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--cyan);
  color: var(--bg);
}
.btn-primary:hover { background: #33deff; box-shadow: var(--cyan-glow); }

.btn-orange {
  background: var(--orange);
  color: #fff;
}
.btn-orange:hover { background: #ff855a; box-shadow: 0 0 20px #ff6b3540; }

.btn-purple {
  background: var(--purple);
  color: #fff;
}
.btn-purple:hover { background: #bb77ff; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { background: var(--card2); color: var(--text); }

.btn-danger {
  background: var(--red);
  color: #fff;
}
.btn-danger:hover { background: #ff6666; }

.btn-sm  { padding: 6px 14px; font-size: 13px; border-radius: 8px; }
.btn-lg  { padding: 14px 28px; font-size: 16px; }
.btn-xl  { padding: 16px 36px; font-size: 18px; border-radius: var(--radius-lg); }
.btn-full { width: 100%; }

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 8px; }

.form-label {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  background: var(--bg2);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font-size: 15px;
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-dim);
}

.form-input::placeholder { color: var(--text-dim); }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%237070a0'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 40px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

.form-hint { font-size: 12px; color: var(--text-muted); }

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-wrap:last-child { border-bottom: none; }

.toggle {
  position: relative;
  width: 48px; height: 26px;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border2);
  border-radius: 13px;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--cyan); }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); background: var(--bg); }

/* ============================================================
   ALERTS & MESSAGES
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 14px;
  border: 1px solid;
  animation: slideIn .2s ease;
}

.alert-success { background: #052a18; border-color: var(--green); color: var(--green); }
.alert-error   { background: #2a0505; border-color: var(--red);   color: var(--red); }
.alert-info    { background: #051a2a; border-color: var(--cyan);  color: var(--cyan); }
.alert-warning { background: #2a1a05; border-color: var(--yellow);color: var(--yellow); }

@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   BADGES & TAGS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* Hide badge elements that have no content so they don't render as empty pills */
.badge:empty { display: none; }

.badge-cyan   { background: var(--cyan-dim);   color: var(--cyan); }
.badge-orange { background: var(--orange-dim); color: var(--orange); }
.badge-purple { background: var(--purple-dim); color: var(--purple); }
.badge-green  { background: rgba(34,197,94,.15); color: var(--green); }
.badge-red    { background: rgba(239,68,68,.15); color: var(--red); }
.badge-gray   { background: var(--border2);     color: var(--text-muted); }

/* Friendship level badges */
.level-acquaintance  { background: rgba(112,112,160,.2); color: #9090c0; }
.level-friend        { background: rgba(0,212,255,.15);  color: var(--cyan); }
.level-good_friends  { background: rgba(34,197,94,.15);  color: var(--green); }
.level-great_friends { background: rgba(251,191,36,.15); color: var(--yellow); }
.level-best_friends  { background: rgba(236,72,153,.2);  color: var(--pink); }

/* ============================================================
   ACHIEVEMENT & BADGE ITEMS
   ============================================================ */
.achievement-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}
.achievement-item:hover { border-color: var(--border2); }

.achievement-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.achievement-name { font-weight: 800; font-size: 14px; }
.achievement-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.achievement-date { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* ============================================================
   FRIEND LIST
   ============================================================ */
.friend-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}
.friend-item:hover { border-color: var(--border2); }

.friend-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Righteous', sans-serif;
  font-size: 1.1rem;
  color: var(--bg);
  flex-shrink: 0;
}

.friend-info { flex: 1; min-width: 0; }
.friend-name { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.friend-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ============================================================
   GAME CARDS
   ============================================================ */
.game-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
}
.game-card:hover { border-color: var(--cyan); transform: translateY(-2px); box-shadow: var(--shadow), 0 0 30px rgba(0,212,255,.1); }

.game-card-header {
  padding: 20px;
  background: linear-gradient(135deg, #0d0d2a, #111130);
  border-bottom: 1px solid var(--border);
}

.game-card-emoji {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 10px;
  display: block;
}

.game-card-name {
  font-family: 'Righteous', sans-serif;
  font-size: 1.2rem;
  color: var(--text);
  margin-bottom: 6px;
}

.game-card-body { padding: 16px 20px; }
.game-card-meta { font-size: 12px; color: var(--text-muted); }

.game-status-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.status-active       { background: rgba(34,197,94,.2);  color: var(--green); }
.status-pre_registration { background: rgba(251,191,36,.2); color: var(--yellow); }
.status-upcoming     { background: var(--border2);      color: var(--text-muted); }
.status-completed    { background: rgba(112,112,160,.1);color: var(--text-dim); }

/* ============================================================
   CLICK FRENZY GAME
   ============================================================ */
.click-btn {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #00f5ff, #0088aa);
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Righteous', sans-serif;
  color: var(--bg);
  font-size: 1.2rem;
  transition: transform .1s, box-shadow .1s;
  box-shadow: 0 0 40px var(--cyan-dim), 0 8px 32px rgba(0,0,0,.5), inset 0 -4px 0 rgba(0,0,0,.3);
  user-select: none;
  touch-action: manipulation;
}

.click-btn:hover { transform: scale(1.04); box-shadow: 0 0 60px rgba(0,212,255,.5), 0 8px 32px rgba(0,0,0,.5); }
.click-btn:active { transform: scale(.95); box-shadow: 0 0 20px var(--cyan-dim); }
.click-btn.inactive { background: radial-gradient(circle at 35% 35%, #3a3a5a, #222240); color: var(--text-muted); cursor: not-allowed; }

.click-count {
  font-family: 'Righteous', sans-serif;
  font-size: 5rem;
  line-height: 1;
  color: var(--cyan);
  text-shadow: var(--cyan-glow);
  text-align: center;
}

.click-timer {
  font-family: 'Righteous', sans-serif;
  font-size: 2.5rem;
  color: var(--orange);
  text-align: center;
}

.click-timer.urgent { color: var(--red); animation: pulse .5s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .6; }
}

/* ============================================================
   QR CODE SECTION
   ============================================================ */
.qr-container {
  background: #fff;
  padding: 16px;
  border-radius: var(--radius);
  display: inline-block;
}

.qr-wrapper {
  text-align: center;
  padding: 24px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ============================================================
   INVITE LINK CARD
   ============================================================ */
.invite-link-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.invite-link-url {
  flex: 1;
  font-family: monospace;
  font-size: 13px;
  color: var(--cyan);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   NOTIFICATION BANNER
   ============================================================ */
.notif-banner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;   /* above modal overlay (2000) so toasts always visible */
  max-width: 480px;
  width: calc(100% - 40px);
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card2);
  border: 1px solid var(--cyan);
  border-radius: var(--radius);
  margin-bottom: 8px;
  animation: slideIn .3s ease;
  box-shadow: var(--cyan-glow);
}

.notif-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  padding: 0;
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg2);
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  flex-wrap: wrap;        /* allow wrapping so tabs never clip off-screen */
}

.tab {
  flex: 1;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.tab.active {
  background: var(--card2);
  color: var(--cyan);
  border: 1px solid var(--border2);
}

.tab:hover:not(.active) { color: var(--text); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  animation: modalIn .25s cubic-bezier(.34,1.56,.64,1);
}

@keyframes modalIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title { font-family: 'Righteous', sans-serif; font-size: 1.3rem; }

.modal-close {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--border2); color: var(--text); }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-family: 'Righteous', sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  color: var(--text);
  margin-bottom: 6px;
}

.page-subtitle { color: var(--text-muted); font-size: 15px; }

/* ============================================================
   LEADERBOARD
   ============================================================ */
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: var(--transition);
}

.leaderboard-row:hover { border-color: var(--border2); }

.rank {
  font-family: 'Righteous', sans-serif;
  font-size: 1.2rem;
  min-width: 36px;
  text-align: center;
}

.rank-1 { color: var(--yellow); }
.rank-2 { color: var(--text-muted); }
.rank-3 { color: var(--orange); }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar {
  height: 6px;
  background: var(--border2);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  border-radius: 3px;
  transition: width .5s ease;
}

/* Leaderboard sub-tabs (inside game page) */
.lb-tab-bar {
  display: -webkit-flex;
  display: flex;
  gap: 3px;
  background: var(--bg2);
  padding: 3px;
  border-radius: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;          /* Firefox */
}
.lb-tab-bar::-webkit-scrollbar { display: none; }

.lb-tab, .lb-sub-tab, .lb-scope {
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  padding: 7px 12px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.lb-tab.active, .lb-sub-tab.active, .lb-scope.active {
  background: var(--card2);
  color: var(--cyan);
  border: 1px solid var(--border2);
}
.lb-tab:hover:not(.active), .lb-sub-tab:hover:not(.active), .lb-scope:hover:not(.active) {
  color: var(--text);
}

/* ── Notification dropdown: viewport-aware on mobile ─── */
@media (max-width: 640px) {
  #notif-dropdown {
    position: fixed !important;
    top: 68px !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: none !important;
  }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state-title { font-family: 'Righteous', sans-serif; font-size: 1.2rem; color: var(--text); margin-bottom: 8px; }
.empty-state-text { font-size: 14px; max-width: 280px; margin: 0 auto 24px; }

/* ============================================================
   SPINNER / LOADER
   ============================================================ */
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7,7,15,.8);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  z-index: 10;
}

/* ============================================================
   UTILITY
   ============================================================ */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-cyan   { color: var(--cyan); }
.text-orange { color: var(--orange); }
.text-purple { color: var(--purple); }
.text-green  { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red    { color: var(--red); }
.text-muted  { color: var(--text-muted); }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }

.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

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

.divider { height: 1px; background: var(--border); margin: 24px 0; }

.hidden { display: none !important; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a60; }

/* ============================================================
   SELECTION
   ============================================================ */
::selection { background: var(--cyan); color: var(--bg); }

/* ============================================================
   AUTH PAGE SPECIFIC
   ============================================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  font-family: 'Righteous', sans-serif;
  font-size: 2rem;
  color: var(--cyan);
  text-align: center;
  margin-bottom: 6px;
  text-shadow: var(--cyan-glow);
}

.auth-logo span { color: var(--orange); }
.auth-tagline { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--bg2);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 28px;
}

.auth-tab {
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.auth-tab.active { background: var(--card2); color: var(--cyan); }

/* ============================================================
   INVITE PAGE
   ============================================================ */
.invite-hero {
  text-align: center;
  padding: 60px 24px;
}

/* ============================================================
   RESPONSIVE FIXES
   ============================================================ */
@media (max-width: 640px) {
  .auth-card { padding: 28px 20px; }
  .modal { padding: 24px; }
  .card { padding: 16px; }
  .page { padding-top: 72px; }
  .click-btn { width: 160px; height: 160px; }
  .click-count { font-size: 3.5rem; }
}

/* ── Inline help-icon links ──────────────────────────────────────── */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
  opacity: 0.45;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  vertical-align: middle;
  margin-left: 6px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.help-icon:hover {
  opacity: 1;
  transform: scale(1.25);
}
