/* DESIGN SYSTEM & GLOBAL CONSTANTS */
:root {
  --bg-main: #090c15;
  --bg-card: #121724;
  --bg-card-hover: #192033;
  --bg-header: rgba(15, 20, 32, 0.9);
  --bg-glass: rgba(22, 28, 45, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 242, 254, 0.4);

  --accent-cyan: #00f2fe;
  --accent-blue: #4facfe;
  --accent-purple: #7928ca;
  --accent-pink: #ff0080;
  --accent-green: #00e676;

  --text-main: #ffffff;
  --text-muted: #8e9bb0;
  --text-dim: #5a667a;

  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Plus Jakarta Sans', 'Inter', sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* RESET & BASE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-main);
  -webkit-font-smoothing: antialiased;
}

body.dark-theme {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

/* APP HEADER */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* BRAND LOGO */
.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 20px rgba(121, 40, 202, 0.4);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.brand-highlight {
  color: var(--accent-cyan);
}

.brand-tag {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1.5px;
}

/* SEARCH BAR */
.header-search {
  flex: 1;
  max-width: 450px;
  position: relative;
  display: flex;
  align-items: center;
}

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

.header-search input {
  width: 100%;
  padding: 11px 40px 11px 42px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-fast);
}

.header-search input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(0, 242, 254, 0.2);
}

.clear-search {
  position: absolute;
  right: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.clear-search:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* USER WALLET ZONE */
.user-wallet-zone {
  display: flex;
  align-items: center;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  padding: 6px 14px 6px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
}

.user-meta {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}

.balance-line {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
}

.balance-label {
  color: var(--text-muted);
}

.balance-value {
  color: var(--accent-green);
  font-weight: 700;
}

.btn-reload {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border: none;
  color: #0b0e15;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: 0 2px 10px rgba(0, 242, 254, 0.3);
}

.btn-reload:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 242, 254, 0.5);
}

.btn-change-user {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: var(--transition-fast);
}

.btn-change-user:hover {
  color: #ff4757;
}

.btn-login-prompt {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border: none;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(121, 40, 202, 0.3);
  transition: var(--transition-fast);
}

.btn-login-prompt:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(121, 40, 202, 0.5);
}

/* HERO SECTION */
.hero-section {
  position: relative;
  max-width: 1440px;
  margin: 20px auto 0;
  padding: 32px 30px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(121, 40, 202, 0.25), rgba(0, 242, 254, 0.15)), var(--bg-card);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.hero-overlay {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: radial-gradient(circle at 80% 20%, rgba(0, 242, 254, 0.15) 0%, transparent 60%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 650px;
}

.hero-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 4px 10px;
  background: rgba(0, 242, 254, 0.15);
  color: var(--accent-cyan);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 242, 254, 0.3);
  margin-bottom: 12px;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 8px;
  background: linear-gradient(90deg, #ffffff, #c0c7d6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* LOBBY MAIN CONTAINER */
.lobby-main {
  max-width: 1440px;
  margin: 24px auto;
  padding: 0 20px;
}

/* PROVIDERS BAR */
.providers-bar {
  margin-bottom: 24px;
}

.providers-scroll {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.providers-scroll::-webkit-scrollbar {
  height: 4px;
}

.providers-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.provider-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.provider-tab:hover {
  background: var(--bg-card-hover);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.provider-tab.active {
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.15), rgba(79, 172, 254, 0.15));
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.2);
}

.provider-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pragmatic-dot { background: #ff9f43; }
.pgsoft-dot { background: #00d2d3; }
.amatic-dot { background: #ee5253; }
.amusnet-dot { background: #5f27cd; }

.tab-badge {
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.provider-tab.active .tab-badge {
  background: var(--accent-cyan);
  color: #000;
  font-weight: 700;
}

/* GAMES SECTION */
.games-section {
  min-height: 400px;
}

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

.section-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.section-title-wrap h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
}

.result-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* GAMES GRID - OPTIMIZED FOR PERFECT CARD FIT */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 18px;
}

/* GAME CARD */
.game-card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  aspect-ratio: 1 / 1; /* PERFECT SQUARE CARD FIT */
  cursor: pointer;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.game-card:hover {
  transform: translateY(-5px) scale(1.02);
  border-color: var(--accent-cyan);
  box-shadow: 0 10px 30px rgba(0, 242, 254, 0.3);
}

.card-media {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #0d121e;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* PERFECT FIT COVER */
  object-position: center;
  transition: transform var(--transition-normal);
}

.game-card:hover .card-media img {
  transform: scale(1.08);
}

.provider-tag-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  background: rgba(9, 12, 21, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-hover-overlay {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: linear-gradient(to top, rgba(9, 12, 21, 0.95) 0%, rgba(9, 12, 21, 0.45) 60%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 14px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 4;
}

.game-card:hover .card-hover-overlay {
  opacity: 1;
}

.card-game-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 10px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-play-hover {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border: none;
  border-radius: var(--radius-md);
  color: #0b0e15;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 242, 254, 0.4);
}

/* SKELETON LOADER */
.game-card.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeletonLoading 1.5s infinite;
  pointer-events: none;
}

@keyframes skeletonLoading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* EMPTY STATE */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state svg {
  margin-bottom: 16px;
  color: var(--text-dim);
}

.empty-state h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}

/* MODAL BACKDROP */
.modal-backdrop, .game-modal-backdrop {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 1000;
  background: rgba(5, 7, 12, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.hidden, .game-modal-backdrop.hidden, .hidden {
  display: none !important;
}

/* LOGIN MODAL CARD */
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: modalScaleIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  text-align: center;
  margin-bottom: 24px;
}

.modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 8px 25px rgba(121, 40, 202, 0.4);
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.modal-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.input-group label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.input-group input {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-fast);
}

.input-group input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.2);
}

.btn-submit {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border: none;
  border-radius: var(--radius-md);
  color: #0b0e15;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0, 242, 254, 0.4);
  transition: var(--transition-fast);
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(0, 242, 254, 0.6);
}

/* GAME PLAYER FRAME MODAL */
.game-modal-container {
  width: 100%;
  max-width: 1280px;
  height: 90vh;
  background: #090c15;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
}

.game-modal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #111624;
  border-bottom: 1px solid var(--border-color);
}

.game-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-provider-tag {
  background: rgba(0, 242, 254, 0.15);
  color: var(--accent-cyan);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

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

.game-modal-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-balance-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
}

.modal-balance-badge .lbl { color: var(--text-muted); }
.modal-balance-badge .val { color: var(--accent-green); font-weight: 700; }

.btn-icon-control {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon-control:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.btn-close:hover {
  background: #ff4757;
  color: #fff;
}

.game-frame-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  background: #000;
}

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

.game-loader {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: #090c15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  z-index: 2;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(0, 242, 254, 0.15);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* RESPONSIVE DESIGN */
@media (max-width: 900px) {
  .header-container {
    flex-wrap: wrap;
  }

  .header-search {
    order: 3;
    max-width: 100%;
    margin-top: 10px;
  }

  .hero-section {
    padding: 20px;
    margin-top: 10px;
  }

  .hero-title {
    font-size: 1.4rem;
  }

  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
  }

  .game-modal-container {
    height: 100vh;
    border-radius: 0;
  }
}
