/* ============================================
   VELTRO - Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,300&display=swap');

/* --- CSS Variables --- */
:root {
  --accent: #6C63FF;
  --accent-2: #FF6584;
  --accent-3: #43E97B;
  --coin: #FFD700;

  /* Light theme */
  --bg: #F5F5F7;
  --bg-2: #FFFFFF;
  --bg-3: #EBEBED;
  --text: #111111;
  --text-2: #555555;
  --text-3: #888888;
  --border: rgba(0,0,0,0.08);
  --shadow: 0 2px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --nav-bg: rgba(245,245,247,0.85);
}

[data-theme="dark"] {
  --bg: #0E0E10;
  --bg-2: #1A1A1E;
  --bg-3: #252528;
  --text: #F0F0F5;
  --text-2: #AAAACC;
  --text-3: #666688;
  --border: rgba(255,255,255,0.07);
  --shadow: 0 2px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
  --nav-bg: rgba(14,14,16,0.85);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  line-height: 1.6;
}

h1, h2, h3, h4, h5 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  line-height: 1.2;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

/* --- Utility --- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.hidden { display: none !important; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-3); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #574fd6; transform: translateY(-1px); box-shadow: 0 4px 20px rgba(108,99,255,0.4); }

.btn-secondary {
  background: var(--bg-3);
  color: var(--text);
}
.btn-secondary:hover { background: var(--border); }

.btn-outline {
  border: 1.5px solid var(--border);
  color: var(--text);
  background: transparent;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: #ff4444;
  color: #fff;
}
.btn-danger:hover { background: #cc0000; }

.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 14px 32px; font-size: 16px; border-radius: 16px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; border-radius: 10px; }

/* --- Cards --- */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

/* --- Avatar --- */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  color: #fff;
  font-size: 16px;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 80px; height: 80px; font-size: 28px; }
.avatar-xl { width: 100px; height: 100px; font-size: 36px; }

/* --- Badge / Tag --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'Syne', sans-serif;
}
.badge-accent { background: rgba(108,99,255,0.15); color: var(--accent); }
.badge-coin { background: rgba(255,215,0,0.15); color: #b8860b; }
.badge-green { background: rgba(67,233,123,0.15); color: #1a9a4a; }
.badge-red { background: rgba(255,100,100,0.15); color: #cc3333; }

/* --- Level Badge --- */
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Syne', sans-serif;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

/* --- Form Elements --- */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 11px 16px;
  background: var(--bg-3);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,99,255,0.15); }
.form-input::placeholder { color: var(--text-3); }

select.form-input { appearance: none; }

/* --- Divider --- */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-3);
  font-size: 12px;
  margin: 20px 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* --- Toast --- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 20px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--accent-3); }
.toast.error { border-left: 3px solid var(--accent-2); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-title {
  font-size: 20px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
}
.modal-close:hover { background: var(--accent); color: #fff; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* --- Navigation --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}
.nav-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-link {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-link:hover, .nav-link.active { background: var(--bg-3); color: var(--text); }
.nav-link.active { color: var(--accent); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Theme toggle */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
}
.theme-toggle:hover { background: var(--accent); color: #fff; }

/* Lang toggle */
.lang-toggle {
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--bg-3);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
}
.lang-toggle:hover { color: var(--accent); }

/* --- Sidebar Layout --- */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  padding-top: 64px;
}

.sidebar {
  position: fixed;
  top: 64px;
  left: 0;
  width: 240px;
  height: calc(100vh - 64px);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-3);
  padding: 12px 12px 6px;
  font-family: 'Syne', sans-serif;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.2s;
}
.sidebar-link:hover { background: var(--bg-3); color: var(--text); }
.sidebar-link.active { background: rgba(108,99,255,0.12); color: var(--accent); }
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-bottom {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.main-content {
  margin-left: 240px;
  padding: 32px 24px;
  min-height: calc(100vh - 64px);
  max-width: 800px;
}

/* --- Feed / Posts --- */
.post-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  transition: box-shadow 0.2s;
  margin-bottom: 16px;
}
.post-card:hover { box-shadow: var(--shadow-lg); }

.post-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
}
.post-meta { flex: 1; }
.post-username {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.post-time { font-size: 12px; color: var(--text-3); }

.post-body { padding: 0 20px 16px; }
.post-text { font-size: 15px; line-height: 1.6; color: var(--text); }
.post-image {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: 12px;
  margin-top: 12px;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.post-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2);
  transition: all 0.2s;
}
.post-action-btn:hover { background: var(--bg-3); color: var(--text); }
.post-action-btn.liked { color: var(--accent-2); }

/* --- Profile --- */
.profile-header {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  margin-bottom: 20px;
}
.profile-cover {
  height: 120px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  margin-bottom: -40px;
}
.profile-info {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}
.profile-avatar-wrap {
  border: 4px solid var(--bg-2);
  border-radius: 50%;
  margin-top: -20px;
}
.profile-stats {
  display: flex;
  gap: 24px;
  margin-top: 16px;
}
.profile-stat { text-align: center; }
.profile-stat-num {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 20px;
}
.profile-stat-label { font-size: 12px; color: var(--text-3); }

/* --- Search --- */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-3);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 10px 16px;
  transition: border-color 0.2s;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}
.search-bar svg { color: var(--text-3); flex-shrink: 0; }

/* --- Messages --- */
.dm-list { display: flex; flex-direction: column; gap: 2px; }
.dm-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.2s;
}
.dm-item:hover, .dm-item.active { background: var(--bg-3); }
.dm-preview { flex: 1; min-width: 0; }
.dm-name { font-size: 14px; font-weight: 600; }
.dm-last { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-time { font-size: 11px; color: var(--text-3); flex-shrink: 0; }

.message-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 8px;
}
.message-bubble.sent {
  background: var(--accent);
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.message-bubble.received {
  background: var(--bg-3);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* --- Leaderboard --- */
.rank-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-radius: 14px;
  transition: background 0.2s;
}
.rank-item:hover { background: var(--bg-3); }
.rank-num {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 18px;
  width: 32px;
  text-align: center;
  color: var(--text-3);
}
.rank-num.gold { color: #FFD700; }
.rank-num.silver { color: #C0C0C0; }
.rank-num.bronze { color: #CD7F32; }

/* --- Games Hub --- */
.game-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  transition: all 0.2s;
  cursor: pointer;
}
.game-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.game-thumb {
  height: 140px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}
.game-info { padding: 16px; }
.game-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.game-genre { font-size: 12px; color: var(--text-3); }

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

/* --- Coin Display --- */
.coin-display {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,215,0,0.1);
  border: 1px solid rgba(255,215,0,0.3);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #b8860b;
}
[data-theme="dark"] .coin-display { color: var(--coin); }

/* --- Tabs --- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  gap: 4px;
}
.tab-btn {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* --- Achievement / Trophy --- */
.trophy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.trophy-card {
  background: var(--bg-3);
  border-radius: 14px;
  padding: 16px 12px;
  text-align: center;
  transition: all 0.2s;
}
.trophy-card:hover { background: rgba(108,99,255,0.1); }
.trophy-icon { font-size: 32px; margin-bottom: 8px; }
.trophy-name { font-size: 12px; font-weight: 600; }
.trophy-card.locked { opacity: 0.4; filter: grayscale(1); }

/* --- Community Board --- */
.board-post {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 12px;
  transition: box-shadow 0.2s;
}
.board-post:hover { box-shadow: var(--shadow); }
.board-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 8px;
}

/* --- Notification dot --- */
.notif-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-2);
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- Loading spinner --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Responsive --- */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
}

@media (max-width: 600px) {
  .nav-links { display: none; }
  .modal { padding: 24px 20px; }
  .profile-stats { gap: 16px; }
}