:root {
  --bg: #08111a;
  --bg-soft: #10202f;
  --panel: rgba(8, 17, 26, 0.72);
  --panel-strong: rgba(12, 26, 39, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f7f2;
  --muted: #9eb0aa;
  --accent: #f97316;
  --accent-soft: #fb923c;
  --green: #22c55e;
  --red: #f87171;
  --blue: #38bdf8;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --font-heading: "Space Grotesk", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(249, 115, 22, 0.12), transparent 30%),
    radial-gradient(circle at bottom right, rgba(56, 189, 248, 0.12), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

body {
  position: relative;
  overflow-x: hidden;
}

.background-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black, transparent 85%);
  pointer-events: none;
}

.background-glow {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.22;
  pointer-events: none;
}

.glow-1 {
  top: -120px;
  right: -60px;
  background: var(--accent);
}

.glow-2 {
  bottom: -120px;
  left: -60px;
  background: var(--blue);
}

.screen {
  position: relative;
  z-index: 1;
}

.centered-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
}

.hidden {
  display: none !important;
}

.loader-ring {
  width: 54px;
  height: 54px;
  border: 4px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.topbar {
  max-width: 1320px;
  margin: 0 auto;
  padding: 26px 26px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.topbar h1,
.hero-card h2,
.panel h3 {
  margin: 0;
  font-family: var(--font-heading);
}

.topbar h1 {
  font-size: clamp(2rem, 2.8vw, 3rem);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  color: #8cf2ad;
  border: 1px solid rgba(34, 197, 94, 0.2);
  font-size: 0.9rem;
}

.page-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 10px 26px 34px;
  display: grid;
  gap: 20px;
}

.tabs-nav {
  display: flex;
  gap: 10px;
  padding: 10px;
}

.tab-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.tab-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
}

.tab-btn.is-active {
  color: #fff;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.22), rgba(249, 115, 22, 0.12));
  border-color: rgba(249, 115, 22, 0.45);
}

.tab-pane {
  display: block;
}

.hero-grid {
  display: grid;
  grid-template-columns: 2.1fr 1fr 1fr 1fr;
  gap: 16px;
}

.hero-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hero-card strong {
  font-size: 1.9rem;
  font-family: var(--font-heading);
}

.hero-card-main h2 {
  word-break: break-all;
  font-size: 1.16rem;
  line-height: 1.35;
}

.hero-id-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero-card-main {
  background: linear-gradient(145deg, rgba(249, 115, 22, 0.16), rgba(8, 17, 26, 0.74));
}

.eyebrow {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-soft);
}

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

.content-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
}

.panel {
  padding: 22px;
}

.panel-accent {
  background: linear-gradient(180deg, rgba(17, 30, 44, 0.96), rgba(8, 17, 26, 0.9));
}

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

.catalog-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.catalog-search {
  width: min(320px, 100%);
}

.icon-only-btn {
  width: 48px;
  height: 48px;
  padding: 0;
}

.form-group {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

label {
  font-size: 0.92rem;
  color: var(--muted);
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

input:focus {
  border-color: rgba(249, 115, 22, 0.45);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}

.action-row {
  display: flex;
  gap: 12px;
  margin: 12px 0 0;
}

button {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font: inherit;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 18px;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled,
.secondary-btn:disabled,
.ghost-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #ea580c);
  color: white;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--line);
}

.ghost-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.inspect-box {
  margin-top: 16px;
  border: 1px solid rgba(56, 189, 248, 0.18);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(56, 189, 248, 0.08);
}

.inspect-title {
  font-family: var(--font-heading);
  margin-bottom: 8px;
}

.inspect-body {
  color: var(--muted);
  line-height: 1.45;
}

.universal-picker-message {
  margin-top: 14px;
}

.selected-games-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
}

.selected-games-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.selected-games-list {
  display: grid;
  gap: 8px;
}

.selected-game-chip {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.selected-game-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.selected-game-meta strong {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selected-game-meta span {
  color: var(--muted);
  font-size: 0.85rem;
}

.chip-remove-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.chip-remove-btn:hover {
  color: #fff;
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.38);
}

.library-list,
.catalog-list {
  display: grid;
  gap: 10px;
}

.library-item,
.catalog-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 15px;
  background: rgba(255, 255, 255, 0.03);
}

.library-item-title,
.catalog-item-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.library-item-subtitle,
.catalog-item-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

.catalog-item {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 18px;
}

.catalog-item-thumb {
  width: 200px;
  height: 94px;
  object-fit: cover;
  flex-shrink: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.catalog-item-meta {
  min-width: 0;
  flex: 1;
}

.catalog-item .secondary-btn {
  padding: 10px 14px;
  white-space: nowrap;
}

.catalog-status {
  color: var(--muted);
  text-align: center;
  padding: 6px 0 18px;
  font-size: 0.92rem;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 22px;
  text-align: center;
  color: var(--muted);
}

.empty-state.is-error {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.28);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(120%);
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(8, 17, 26, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease;
  z-index: 20;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.28);
}

.toast.error {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.28);
}

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

@media (max-width: 1080px) {
  .hero-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar,
  .page-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .catalog-header-actions {
    width: 100%;
  }

  .tabs-nav {
    flex-wrap: wrap;
  }

  .tab-btn {
    flex: 1;
    min-width: 120px;
  }

  .hero-grid {
    grid-template-columns: 1fr;
  }

  .catalog-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .catalog-item-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 200 / 94;
  }
}
