:root {
  --primary: #4a9eff;
  --primary-dark: #2a7ad8;
  --primary-light: #8bbdff;
  --primary-gradient: linear-gradient(135deg, #4a9eff, #2a7ad8);
  --primary-shadow: rgba(74, 158, 255, 0.35);
  --secondary: #6c757d;
  --secondary-dark: #5a6268;
  --secondary-light: #a0aab0;
  --secondary-gradient: linear-gradient(135deg, #6c757d, #5a6268);
  --danger: #e94560;
  --danger-dark: #c73d54;
  --danger-light: #f5a0b0;
  --danger-gradient: linear-gradient(135deg, #e94560, #c73d54);
  --success: #28a745;
  --success-dark: #1e7e34;
  --success-light: #85d99a;
  --success-gradient: linear-gradient(135deg, #28a745, #1e7e34);
  --warning: #ffc107;
  --warning-dark: #e0a800;
  --warning-light: #ffe28c;
  --bg-body: #0d1117;
  --bg-card: #161b22;
  --bg-input: #0d1117;
  --bg-hover: #1c2333;
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --border-color: #30363d;
  --shadow-sm: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.6);
  --shadow-hover: 0 12px 40px rgba(0,0,0,0.6);
  --radius: 16px;
  --radius-sm: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --header-bg: rgba(13, 17, 23, 0.85);
  --footer-bg: #0d1117;
  --scrollbar-track: #0d1117;
  --scrollbar-thumb: #30363d;
  --backdrop: blur(12px);
}

body.light-theme {
  --primary: #28a745;
  --primary-dark: #1e7e34;
  --primary-light: #85d99a;
  --primary-gradient: linear-gradient(135deg, #28a745, #1e7e34);
  --primary-shadow: rgba(40, 167, 69, 0.3);
  --secondary: #6c757d;
  --secondary-dark: #5a6268;
  --danger: #dc3545;
  --danger-dark: #bd2130;
  --success: #28a745;
  --success-dark: #1e7e34;
  --warning: #ffc107;
  --warning-dark: #e0a800;
  --bg-body: #f6f8fa;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #f0f2f5;
  --text-primary: #24292e;
  --text-secondary: #586069;
  --text-muted: #a0aab0;
  --border-color: #d1d5da;
  --shadow-sm: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.1);
  --shadow-hover: 0 12px 40px rgba(0,0,0,0.15);
  --header-bg: rgba(255,255,255,0.85);
  --footer-bg: #ffffff;
  --scrollbar-track: #f6f8fa;
  --scrollbar-thumb: #d1d5da;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-dark); }
.container { max-width: 1320px; margin: 0 auto; padding: 0 20px; width: 100%; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: 30px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  opacity: 0;
  transition: opacity 0.3s;
  border-radius: 30px;
}
.btn:active::after { opacity: 1; transition: opacity 0.1s; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); text-decoration: none; }
.btn:active { transform: translateY(0px) scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary-gradient); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--secondary-gradient); color: #fff; border-color: var(--secondary); }
.btn-secondary:hover { background: var(--secondary-dark); border-color: var(--secondary-dark); color: #fff; }
.btn-success { background: var(--success-gradient); color: #fff; border-color: var(--success); }
.btn-success:hover { background: var(--success-dark); border-color: var(--success-dark); color: #fff; }
.btn-danger { background: var(--danger-gradient); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-dark); border-color: var(--danger-dark); color: #fff; }
.btn-warning { background: var(--warning); color: #000; border-color: var(--warning); }
.btn-warning:hover { background: var(--warning-dark); border-color: var(--warning-dark); color: #000; }
.btn-outline-primary { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-outline-secondary { background: transparent; color: var(--secondary); border-color: var(--secondary); }
.btn-outline-secondary:hover { background: var(--secondary); color: #fff; }
.btn-outline-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; border-radius: 20px; }
.btn-lg { padding: 14px 32px; font-size: 1.1rem; border-radius: 36px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 10px; width: 44px; height: 44px; border-radius: 50%; justify-content: center; }
.btn-icon.btn-sm { width: 34px; height: 34px; padding: 4px; font-size: 1rem; }
.btn-icon.btn-lg { width: 56px; height: 56px; padding: 12px; font-size: 1.4rem; }
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; transform: none !important; }

.logout-btn, button.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--danger-gradient);
  color: #fff;
  border: 2px solid var(--danger);
  border-radius: 30px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.85rem;
  line-height: 1.5;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.logout-btn:hover, button.logout-btn:hover {
  background: var(--danger-dark);
  border-color: var(--danger-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.logout-btn:active, button.logout-btn:active { transform: translateY(0) scale(0.98); }

.site-header {
  background: var(--header-bg);
  backdrop-filter: var(--backdrop);
  -webkit-backdrop-filter: var(--backdrop);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: background 0.3s, border-color 0.3s;
}
.header-container {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.logo {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}
.logo a {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: opacity 0.2s;
}
.logo a:hover { opacity: 0.85; }
.main-nav { flex: 1; }
.main-nav ul {
  display: flex;
  list-style: none;
  gap: 8px 16px;
  flex-wrap: wrap;
  align-items: center;
}
.main-nav ul li a {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: 0.2s;
  font-size: 0.95rem;
  white-space: nowrap;
}
.main-nav ul li a:hover,
.main-nav ul li a.active {
  color: var(--text-primary);
  border-bottom-color: var(--primary);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}
.search-box-header {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box-header:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-shadow);
}
.search-box-header input {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  outline: none;
  width: 180px;
  font-size: 0.95rem;
}
.search-box-header input::placeholder { color: var(--text-muted); }
.search-box-header button {
  background: var(--primary);
  border: none;
  color: #fff;
  padding: 8px 18px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}
.search-box-header button:hover { background: var(--primary-dark); }
.auth-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  flex-wrap: wrap;
}
.auth-buttons .username { color: var(--text-secondary); }
.auth-buttons a { color: var(--text-secondary); font-weight: 500; }
.auth-buttons a:hover { color: var(--primary); }
.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 30px;
  color: var(--text-secondary);
  transition: 0.2s;
  line-height: 1;
}
.theme-toggle:hover { background: var(--border-color); }

.main-content {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 30px;
  margin: 30px auto;
  flex: 1;
}
.content-area { min-width: 0; }

.games-section { margin-bottom: 50px; }
.games-section h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 3px solid var(--primary);
  padding-bottom: 8px;
}
.games-section h2 a {
  font-size: 0.9rem;
  font-weight: 500;
  margin-left: auto;
}
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 24px;
}
.game-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: transform 0.4s, box-shadow 0.4s, border-color 0.3s;
  border: 1px solid var(--border-color);
  position: relative;
  will-change: transform;
}
.game-card:hover {
  transform: translateY(-8px) scale(1.01);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}
.game-card a { display: block; color: inherit; text-decoration: none; }
.game-card img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  display: block;
  background: var(--bg-input);
  transition: transform 0.5s;
}
.game-card:hover img { transform: scale(1.05); }
.game-card .no-poster {
  height: 250px;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  flex-direction: column;
  gap: 8px;
}
.game-card-info { padding: 14px 16px 16px; }
.game-card-info h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-card-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.game-card-meta span { display: inline-flex; align-items: center; gap: 4px; }
.empty-message { color: var(--text-muted); font-style: italic; padding: 20px 0; text-align: center; }
.skeleton-grid { display: contents; }
.skeleton {
  background: var(--bg-card);
  border-radius: var(--radius);
  height: 300px;
  animation: pulse 1.5s infinite;
  border: 1px solid var(--border-color);
}
@keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }
.sidebar { display: flex; flex-direction: column; gap: 25px; }
.sidebar-block {
  background: var(--bg-card);
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  transition: background 0.3s, border-color 0.3s;
}
.sidebar-block h3 {
  color: var(--primary);
  margin-bottom: 12px;
  font-size: 1.2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}
.sidebar-list { list-style: none; padding: 0; }
.sidebar-list li { margin-bottom: 6px; }
.sidebar-list a {
  color: var(--text-secondary);
  transition: 0.2s;
  display: block;
  padding: 2px 0;
}
.sidebar-list a:hover { color: var(--text-primary); padding-left: 4px; }
.about-text {
  background: var(--bg-card);
  padding: 25px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  margin-top: 30px;
}
.about-text h2 { color: var(--primary); margin-bottom: 15px; }
.about-text p { margin-bottom: 12px; line-height: 1.7; color: var(--text-secondary); }
.about-text strong { color: var(--text-primary); }

.badge-beta, .badge-dev {
  display: inline-block;
  font-size: 0.6rem;
  padding: 2px 10px;
  border-radius: 12px;
  margin-left: 5px;
  vertical-align: middle;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-beta { background: #ffc107; color: #000; }
.badge-dev { background: #e94560; color: #fff; }

.site-footer {
  background: var(--footer-bg);
  padding: 20px 0;
  margin-top: 40px;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: background 0.3s, border-color 0.3s;
}
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--primary);
  color: #fff;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: 0.3s;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.back-to-top:hover { background: var(--primary-dark); transform: scale(1.05); }
.back-to-top.visible { display: flex; }

@media (max-width: 1024px) {
  .main-content { grid-template-columns: 1fr 240px; gap: 24px; }
}
@media (max-width: 768px) {
  .header-container { flex-direction: column; align-items: stretch; gap: 12px; }
  .main-nav ul { justify-content: center; }
  .header-actions { justify-content: center; margin-left: 0; gap: 8px; }
  .search-box-header input { width: 140px; }
  .main-content { grid-template-columns: 1fr; gap: 20px; margin: 20px auto; }
  .sidebar { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
  .games-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
  .game-card img, .game-card .no-poster { height: 200px; }
  .logo { font-size: 1.5rem; text-align: center; }
  .games-section h2 { font-size: 1.4rem; }
}
@media (max-width: 480px) {
  .games-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .game-card img, .game-card .no-poster { height: 150px; }
  .game-card-info h3 { font-size: 0.9rem; }
  .game-card-meta { font-size: 0.7rem; gap: 8px; }
  .search-box-header input { width: 100px; font-size: 0.85rem; }
  .search-box-header button { padding: 6px 12px; }
  .auth-buttons { font-size: 0.85rem; }
  .theme-toggle { font-size: 1rem; padding: 2px 8px; }
  .main-nav ul li a { font-size: 0.85rem; }
  .btn { padding: 8px 16px; font-size: 0.85rem; }
  .btn-lg { padding: 12px 24px; font-size: 1rem; }
  .btn-sm { padding: 4px 12px; font-size: 0.75rem; }
  .back-to-top { width: 40px; height: 40px; font-size: 1.2rem; bottom: 20px; right: 20px; }
}