:root {
  --bg: #0b1020;
  --panel: #121a2f;
  --card: #151f3d;
  --accent: #4da3ff;
  --text: #ffffff;
  --muted: #9aa4c7;
  --header-height: 72px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -200px, #1b2550 0%, var(--bg) 60%);
  background-color: var(--bg); /* Fallback */
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
}

/* ===== Header ===== */
header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 32px;
  background-color: rgba(11, 16, 32, 0.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo {
  font-size: 24px;
  font-weight: bold;
  background: linear-gradient(45deg, #fff, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  cursor: pointer;
}

.controls {
  margin-left: auto;
  display: flex;
  gap: 16px;
  align-items: center;
}

/* Custom Select Styling */
.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

select {
  appearance: none;
  background-color: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 32px 8px 12px;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
  min-width: 120px;
  width: 100%;
}

select:hover {
  border-color: var(--accent);
  background-color: var(--card);
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(77, 163, 255, 0.2);
}

.select-wrapper::after {
  content: '▼';
  font-size: 10px;
  color: var(--muted);
  position: absolute;
  right: 12px;
  pointer-events: none;
}

/* ===== Main Lobby ===== */
#lobby-view {
  display: block;
  animation: fadeIn 0.5s ease-out;
}

/* ===== Banner ===== */
.banner {
  margin: 32px;
  height: 360px;
  border-radius: 24px;
  background: 
    linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.6)), 
    linear-gradient(135deg, #2a3568 0%, #151f3d 100%); /* Fallback gradient if image fails */
  display: flex;
  align-items: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}

/* Decorative element for banner */
.banner::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(77, 163, 255, 0.1) 0%, transparent 70%);
  border-radius: 50%;
}

.banner-content {
  position: relative;
  z-index: 1;
}

.banner h1 {
  font-size: 56px;
  margin: 0;
  line-height: 1.1;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.banner p {
  font-size: 18px;
  color: var(--muted);
  margin-top: 16px;
  max-width: 480px;
}

/* ===== Provider Bar ===== */
.providers {
  display: flex;
  gap: 16px;
  padding: 0 32px 32px;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
}

.providers::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.provider {
  min-width: 80px;
  height: 48px;
  padding: 0 20px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.provider:hover {
  background: var(--card);
  color: var(--text);
  transform: translateY(-2px);
}

.provider.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(77, 163, 255, 0.3);
}

/* ===== Game Grid ===== */
.section {
  padding: 0 32px 48px;
}

.section h2 {
  font-size: 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section h2::before {
  content: '';
  width: 4px;
  height: 24px;
  background: var(--accent);
  border-radius: 2px;
}

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

.card {
  background: var(--panel);
  border-radius: 20px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-8px);
  background: var(--card);
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
  border-color: rgba(77, 163, 255, 0.2);
}

.card-img-wrapper {
  position: relative;
  width: 100%;
  padding-top: 75%; /* 4:3 Aspect Ratio */
  border-radius: 16px;
  overflow: hidden;
  background: #000;
}

.card img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s;
}

.card:hover img {
  transform: scale(1.1);
}

.card .info {
  margin-top: 16px;
  padding: 0 8px 8px;
}

.card .name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.card .provider-tag {
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.05);
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
}

/* ===== Game View (Iframe) ===== */
#game-view {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  height: calc(100vh - var(--header-height));
  background: #000;
  z-index: 50;
  flex-direction: column;
}

#game-view.active {
  display: flex;
}

.game-toolbar {
  height: 48px;
  background: var(--panel);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.back-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  transition: all 0.2s;
}

.back-btn:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--text);
}

.game-title {
  margin-left: 20px;
  font-weight: 600;
  color: var(--muted);
}

iframe {
  flex: 1;
  width: 100%;
  border: none;
}

/* ===== Modal Styles ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

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

.modal-content {
  background: var(--panel);
  width: 90%;
  max-width: 420px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to right, rgba(255, 255, 255, 0.02), transparent);
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  color: var(--text);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.modal-footer {
  padding: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.2);
}

.btn-cancel, .btn-start {
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-cancel {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.btn-start {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 12px rgba(77, 163, 255, 0.3);
}

.btn-start:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-start:active {
  transform: translateY(0);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--panel);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}
