/* PlayDango Master Stylesheet - Dark Mode & Zero CLS */
:root {
  --bg-main: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-hover: #1c2742;
  --bg-surface: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #6c47ff;
  --primary-hover: #5835ea;
  --accent: #10b981;
  --accent-hover: #059669;
  --amber: #f59e0b;
  --danger: #ef4444;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(108, 71, 255, 0.4);
  --glass: rgba(19, 27, 46, 0.75);
  --glass-blur: blur(12px);
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

/* Layout Grid */
.layout {
  display: flex;
  min-height: calc(100vh - 64px);
}

/* Sticky Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 64px;
  background: var(--glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all 0.2s;
}
.sidebar-toggle:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.brand-icon {
  font-size: 1.6rem;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Search Bar */
.search-container {
  position: relative;
  flex: 1;
  max-width: 480px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 1rem 0 2.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--border-focus);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 100;
}

.search-dropdown.active {
  display: block;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.search-item:hover {
  background: var(--bg-card-hover);
}

.search-thumb {
  width: 48px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
}

/* Nav Actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Language Selector */
.lang-selector-wrap {
  position: relative;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-btn:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.lang-globe {
  font-size: 1rem;
}

.lang-current-code {
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.lang-arrow {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  min-width: 210px;
  max-height: 380px;
  overflow-y: auto;
  z-index: 150;
  display: none;
  padding: 6px;
}

.lang-dropdown.active {
  display: block;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.lang-option:hover {
  background: var(--bg-card-hover);
  color: var(--primary);
}

.lang-option.active {
  background: rgba(108, 71, 255, 0.18);
  color: var(--primary);
  font-weight: 700;
}

.lang-flag {
  font-size: 1.1rem;
}

.lang-name {
  flex: 1;
}

.lang-code {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.18);
}

.badge-streak {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--amber);
}

.badge-xp {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--accent);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-main);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  transition: transform 0.3s ease;
}

.sidebar-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}

.sidebar-link:hover, .sidebar-link.active {
  background: var(--bg-surface);
  color: var(--text-main);
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 14px;
  margin-bottom: 6px;
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

/* Hero Daily Hub */
.daily-hub-hero {
  background: linear-gradient(135deg, rgba(108, 71, 255, 0.2), rgba(16, 185, 129, 0.15));
  border: 1px solid rgba(108, 71, 255, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.daily-hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.daily-hub-title {
  font-size: 1.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.daily-hub-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.daily-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.daily-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.2s;
}

.daily-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.daily-card-thumb-link {
  position: relative;
  display: block;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--bg-card-hover);
}

.daily-card-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.daily-card:hover .daily-card-thumb-img {
  transform: scale(1.05);
}

.daily-card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.daily-card.solved {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.05);
}

/* Games Grid */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

.filter-tab {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  transition: all 0.15s;
}

.filter-tab.active, .filter-tab:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
}

.game-thumb-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}

.game-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.game-card:hover .game-thumb {
  transform: scale(1.05);
}

.game-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
}

.game-info {
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.game-title {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: auto;
}

.game-rating {
  color: var(--amber);
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Game Player Page */
.player-container {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

.player-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.game-iframe-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.game-iframe-wrapper.theater {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999;
  border-radius: 0;
}

.game-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Rating Stars */
.star-rating {
  display: inline-flex;
  gap: 2px;
  cursor: pointer;
}
.star-rating span {
  font-size: 1.2rem;
  color: var(--text-muted);
  transition: color 0.15s;
}
.star-rating span.active, .star-rating span:hover {
  color: var(--amber);
}

/* Zero-CLS Ad Placeholders */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  margin: 1rem 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  overflow: hidden;
}

.ad-728x90 { width: 728px; height: 90px; max-width: 100%; margin-left: auto; margin-right: auto; }
.ad-300x250 { width: 300px; height: 250px; margin-left: auto; margin-right: auto; }
.ad-300x600 { width: 300px; height: 600px; margin-left: auto; margin-right: auto; }

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  color: var(--text-muted);
  font-size: 1.25rem;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Auth Modal Components */
.auth-tabs {
  display: flex;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 4px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.auth-alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  display: none;
  line-height: 1.4;
}

.auth-alert.error {
  display: block;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.auth-alert.success {
  display: block;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.auth-social-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border);
}

.btn-social.btn-google {
  background: #ffffff;
  color: #1f2937;
  border-color: #e5e7eb;
}

.btn-social.btn-google:hover {
  background: #f3f4f6;
  transform: translateY(-1px);
}

.btn-social.btn-facebook {
  background: #1877f2;
  color: #ffffff;
  border-color: #1877f2;
}

.btn-social.btn-facebook:hover {
  background: #166fe5;
  transform: translateY(-1px);
}

.btn-social.btn-apple {
  background: #000000;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-social.btn-apple:hover {
  background: #111111;
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 0.25rem 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider span {
  padding: 0 10px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.auth-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(108, 71, 255, 0.2);
}

.auth-submit-btn {
  width: 100%;
  padding: 11px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  margin-top: 6px;
  cursor: pointer;
}

.auth-demo-wrap {
  text-align: center;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}

.btn-demo-auth {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  width: 100%;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-demo-auth:hover {
  border-color: var(--amber);
  color: var(--amber);
}

/* Leaderboard Table */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.leaderboard-table th, .leaderboard-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.leaderboard-table th {
  color: var(--text-muted);
  font-weight: 600;
}

.rank-1 { color: #ffd700; font-weight: 700; }
.rank-2 { color: #c0c0c0; font-weight: 700; }
.rank-3 { color: #cd7f32; font-weight: 700; }

/* Footer */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 2.5rem 1.5rem;
  background: var(--bg-main);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-content {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .player-container {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    top: 64px;
    bottom: 0;
    left: 0;
    z-index: 40;
    transform: translateX(-100%);
    background: var(--bg-card);
  }
  .sidebar.open {
    transform: translateX(0);
  }
}
