:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #171e29;
  --border: #243041;
  --text: #e8eef7;
  --muted: #8fa3bc;
  --accent: #3b82f6;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #101722, #0b0f14);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; gap: 0.75rem; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  font-weight: 700;
}
.brand h1 { margin: 0; font-size: 1.05rem; }
.subtitle { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.82rem; }

.player-bar { display: flex; gap: 0.65rem; align-items: end; flex-wrap: wrap; }
.player-bar label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.75rem; color: var(--muted); }
.player-bar input {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  min-width: 90px;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(320px, 1fr) minmax(360px, 42vw);
  min-height: calc(100vh - 68px);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-head { padding: 0.75rem; border-bottom: 1px solid var(--border); }
.sidebar-head input, .games-controls input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
}

.provider-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  overflow: auto;
  flex: 1;
}

.provider-list li button {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.provider-list li button:hover { background: var(--panel-2); }
.provider-list li button.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.45);
}

.provider-list .count {
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.games-panel {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.games-toolbar {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.games-toolbar h2 { margin: 0; font-size: 1rem; }
.meta { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.82rem; }
.games-controls { display: flex; gap: 0.5rem; min-width: 240px; flex: 1; max-width: 420px; }

.game-grid {
  padding: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem;
  overflow: auto;
  flex: 1;
  align-content: start;
}

.game-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.game-card:hover {
  border-color: rgba(59, 130, 246, 0.6);
  transform: translateY(-1px);
}

.game-card.loading { opacity: 0.6; pointer-events: none; }
.game-card .uid { font-family: ui-monospace, monospace; font-size: 0.78rem; word-break: break-all; }
.game-card .name { margin-top: 0.35rem; font-weight: 600; }
.game-card .tags { margin-top: 0.35rem; display: flex; gap: 0.35rem; flex-wrap: wrap; }
.tag {
  font-size: 0.68rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem;
  border-top: 1px solid var(--border);
}

.player-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #0a0d12;
}

.player-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.player-head h2 { margin: 0; font-size: 1rem; }

.launch-status {
  padding: 0.55rem 1rem;
  font-size: 0.82rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.launch-status.ok { color: var(--accent-2); }
.launch-status.err { color: var(--danger); }

.iframe-wrap {
  position: relative;
  flex: 1;
  min-height: 320px;
  background: #000;
}

.iframe-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #64748b;
  pointer-events: none;
}

#gameFrame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

#gameFrame[src=""], #gameFrame:not([src]) { opacity: 0; }

.launch-details {
  border-top: 1px solid var(--border);
  padding: 0.35rem 0.75rem 0.75rem;
}

.launch-details pre {
  margin: 0.35rem 0 0;
  max-height: 160px;
  overflow: auto;
  background: var(--panel);
  border-radius: 8px;
  padding: 0.55rem;
  font-size: 0.72rem;
}

.btn {
  border: 1px solid var(--border);
  background: var(--accent);
  color: white;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.btn.ghost { background: var(--panel-2); color: var(--text); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  max-width: 360px;
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 220px 1fr; grid-template-rows: auto 50vh; }
  .player-panel { grid-column: 1 / -1; min-height: 50vh; }
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { max-height: 220px; }
}
