:root {
  color-scheme: dark;
  --bg: #090d14;
  --panel: #121923;
  --panel-2: #182230;
  --panel-3: #202b39;
  --text: #edf2f8;
  --muted: #9aa7b5;
  --line: #2a3544;
  --accent: #4cc9f0;
  --accent-2: #f72585;
  --ok: #76e4a7;
  --warn: #ffd166;
  --danger: #ff5d73;
  --focus: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  overflow-x: hidden;
}

button,
input,
select,
a {
  font: inherit;
}

button,
a,
select,
input,
.game-card {
  outline: none;
}

button:focus,
a:focus,
select:focus,
input:focus,
.game-card:focus,
.brand:focus {
  box-shadow: 0 0 0 4px var(--focus), 0 0 0 10px rgba(76, 201, 240, 0.55);
}

.brand {
  grid-area: brand;
  min-width: 190px;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 36%, #fff 0 2px, transparent 3px),
    conic-gradient(from 135deg, #4cc9f0, #7209b7, #f72585, #4361ee, #4cc9f0);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  letter-spacing: 0;
}

.brand strong {
  display: block;
  font-size: 22px;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
}

.nav-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 18px;
}

.nav-item {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 0 16px 0 10px;
  text-align: left;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
  background: var(--panel-3);
  border-color: rgba(76, 201, 240, 0.62);
}

.nav-icon {
  width: 38px;
  height: 30px;
  border-radius: 6px;
  background: #243142;
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
}

.nav-item b {
  min-width: 32px;
  padding: 5px 8px;
  border-radius: 5px;
  background: #303a49;
  text-align: center;
  font-size: 14px;
}

.dialog-actions button,
.dialog-actions a,
.cache-row button,
.cache-row a,
.text-button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  min-height: 44px;
  padding: 0 16px;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.status-panel {
  min-height: 38px;
  margin: -4px 0 18px;
  color: var(--muted);
  line-height: 1.4;
  font-size: 14px;
}

.shell {
  min-height: 100vh;
  padding: 0 clamp(24px, 3vw, 52px) 48px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  min-height: 82px;
  display: grid;
  grid-template-columns: auto minmax(360px, 1fr) auto;
  grid-template-areas:
    "brand search controls"
    "brand suggestions controls";
  gap: 16px 22px;
  align-items: center;
  background: rgba(18, 25, 35, 0.96);
  border-bottom: 1px solid #1d2632;
  margin: 0 calc(clamp(24px, 3vw, 52px) * -1);
  padding: 10px clamp(24px, 3vw, 52px);
}

.search-box {
  grid-area: search;
  height: 70px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  max-width: 1120px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  padding: 0 14px;
}

.search-box span {
  font-size: 38px;
}

.search-box input {
  width: 100%;
  height: 68px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 30px;
  outline: 0;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(70, 212, 255, 0.16);
}

.search-box button {
  width: 50px;
  height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.search-box button[hidden] {
  display: none;
}

.search-suggestions {
  grid-area: suggestions;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.search-suggestions::-webkit-scrollbar {
  display: none;
}

.search-suggestions button,
.search-empty {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  padding: 0 18px;
  white-space: nowrap;
  font-size: 17px;
}

.search-suggestions button {
  cursor: pointer;
}

.search-suggestions button:focus,
.search-suggestions button:hover {
  border-color: var(--accent);
  color: var(--text);
}

.controls {
  grid-area: controls;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

select,
.icon-button,
.text-button {
  height: 44px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 6px;
  padding: 0 12px;
}

.icon-button {
  width: 48px;
  cursor: pointer;
}

.text-button {
  cursor: pointer;
  min-width: 96px;
}

.hero-strip {
  min-height: 94px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.alpha-jump {
  display: flex;
  gap: 7px;
  margin: -4px 0 18px;
  overflow-x: auto;
  scrollbar-width: none;
}

.alpha-jump::-webkit-scrollbar {
  display: none;
}

.alpha-jump button {
  min-width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.alpha-jump button:first-child {
  min-width: 78px;
}

.alpha-jump button.active,
.alpha-jump button:hover,
.alpha-jump button:focus {
  border-color: rgba(76, 201, 240, 0.72);
  background: var(--panel-3);
}

.catalog-stage {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.catalog-results {
  min-width: 0;
}

.catalog-stage.cache-stage {
  grid-template-columns: 1fr;
}

.catalog-stage.cache-stage .focus-preview {
  display: none;
}

.focus-preview {
  position: sticky;
  top: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.preview-art {
  aspect-ratio: 16 / 10;
  background:
    linear-gradient(160deg, rgba(76, 201, 240, 0.24), transparent 42%),
    linear-gradient(35deg, rgba(247, 37, 133, 0.28), transparent 50%),
    #111927;
  background-position: center;
  background-size: cover;
}

.preview-art.logo-fallback {
  background-repeat: no-repeat;
  background-size: min(58%, 260px) auto;
}

.preview-body {
  padding: 20px;
}

.preview-body h2 {
  margin: 10px 0 10px;
  font-size: 30px;
  line-height: 1.08;
}

.preview-body p {
  min-height: 112px;
  margin: 0;
  color: #c9d3de;
  font-size: 16px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 15px;
}

.preview-meta span {
  min-height: 36px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 10px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.preview-play {
  width: 100%;
  min-height: 74px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #4cc9f0, #76e4a7);
  color: #03121a;
  font-size: 30px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 14px 38px rgba(76, 201, 240, 0.24);
}

.preview-play:disabled {
  cursor: default;
  opacity: 0.45;
}

.eyebrow,
.badge {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 700;
}

h1 {
  font-size: 38px;
  margin: 8px 0 0;
  letter-spacing: 0;
}

.hero-stats {
  display: flex;
  gap: 12px;
}

.hero-stats span {
  min-width: 126px;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  place-items: center;
  color: var(--muted);
}

.hero-stats b {
  color: var(--text);
  font-size: 20px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  align-items: start;
}

.game-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
}

.game-card {
  border: 2px solid #101721;
  background: var(--panel);
  border-radius: 5px;
  overflow: hidden;
  cursor: pointer;
  transform: translateZ(0);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.game-card:hover,
.game-card:focus,
.game-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px #ffffff, 0 0 0 10px rgba(76, 201, 240, 0.62);
  transform: translateY(-4px) scale(1.025);
  z-index: 2;
}

.cover {
  position: relative;
  aspect-ratio: 3 / 4;
  background: #0f1520;
  overflow: hidden;
}

.cover img,
.fallback-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.cover img {
  object-fit: cover;
  opacity: 0;
  transition: opacity 120ms ease;
}

.cover img.loaded {
  opacity: 1;
}

.cover.logo-fallback {
  background:
    linear-gradient(160deg, rgba(76, 201, 240, 0.22), transparent 42%),
    linear-gradient(35deg, rgba(247, 37, 133, 0.28), transparent 50%),
    #111927;
}

.cover.logo-fallback img {
  object-fit: contain;
  padding: 34px;
}

.cover.has-image .fallback-cover {
  display: none;
}

.fallback-cover {
  padding: 18px;
  display: flex;
  align-items: flex-end;
  background:
    linear-gradient(160deg, rgba(76, 201, 240, 0.25), transparent 42%),
    linear-gradient(35deg, rgba(247, 37, 133, 0.35), transparent 50%),
    #182230;
}

.fallback-cover span {
  color: white;
  font-size: 24px;
  line-height: 1.05;
  font-weight: 800;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.card-footer {
  min-height: 72px;
  padding: 10px 12px;
  display: grid;
  gap: 5px;
}

.card-footer strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.card-footer span {
  color: var(--muted);
  font-size: 14px;
}

.sentinel {
  min-height: 80px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

dialog {
  width: min(1080px, calc(100vw - 80px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

#gameDialog[open] {
  display: grid;
  grid-template-columns: minmax(280px, 390px) 1fr;
}

.close-button {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #0d121a;
  color: var(--text);
  font-size: 32px;
  cursor: pointer;
  z-index: 2;
}

.dialog-art {
  min-height: 560px;
  background-size: cover;
  background-position: center;
  background-color: #111927;
}

.dialog-art.logo-fallback {
  background-repeat: no-repeat;
  background-size: min(58%, 300px) auto;
}

.dialog-body {
  padding: 54px 44px 38px;
}

.dialog-body h2 {
  font-size: 38px;
  line-height: 1.08;
  margin: 14px 0 16px;
}

.description {
  color: #c9d3de;
  line-height: 1.5;
  font-size: 18px;
}

dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 28px 0;
}

dl div {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

dt {
  color: var(--muted);
  font-size: 13px;
}

dd {
  margin: 6px 0 0;
  font-weight: 700;
}

.dialog-actions {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(160px, 0.8fr);
  gap: 12px;
  align-items: stretch;
}

.dialog-actions .primary {
  min-height: 78px;
  border: 0;
  background: linear-gradient(135deg, #4cc9f0, #76e4a7);
  color: #03121a;
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 14px 38px rgba(76, 201, 240, 0.22);
}

.dialog-actions .secondary {
  min-height: 78px;
  background: #253244;
  color: var(--text);
  border-color: #3c4a5c;
  font-size: 18px;
  font-weight: 800;
}

.dialog-actions .primary:hover,
.dialog-actions .primary:focus {
  transform: translateY(-1px);
  box-shadow: 0 18px 50px rgba(76, 201, 240, 0.34);
}

.dialog-utilities {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 2px;
}

.dialog-actions .utility,
.dialog-actions .danger {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  border-color: #2a3544;
  font-size: 14px;
}

.dialog-actions .danger {
  color: white;
  border-color: rgba(255, 93, 115, 0.45);
  background: rgba(255, 93, 115, 0.1);
}

.progress {
  margin-top: 16px;
  min-height: 34px;
  color: var(--muted);
}

.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 99px;
  background: #0b1018;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--ok);
}

.progress-bar.indeterminate span {
  width: 38%;
  min-width: 90px;
  background: linear-gradient(90deg, transparent, var(--ok), transparent);
  animation: download-sweep 1.1s linear infinite;
}

@keyframes download-sweep {
  from {
    transform: translateX(-110%);
  }

  to {
    transform: translateX(270%);
  }
}

.rights-note {
  color: var(--muted);
  font-size: 14px;
  margin-top: 20px;
}

.cache-view {
  display: none;
}

.cache-view.active {
  display: block;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 4px 0 18px;
}

.game-grid.cache-mode {
  display: block;
  margin-top: 24px;
}

.cache-row {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin: 0 0 12px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  align-items: center;
}

.cache-row strong {
  display: block;
  font-size: 20px;
}

.cache-row span {
  color: var(--muted);
}

.cache-row a,
.cache-row button {
  min-width: 112px;
  justify-content: center;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "search"
      "suggestions"
      "controls";
  }

  .brand {
    min-width: 0;
  }

  .controls {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .hero-strip {
    display: grid;
  }

  .nav-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .catalog-stage {
    grid-template-columns: 1fr;
  }

  .focus-preview {
    position: static;
  }

  .preview-body p {
    min-height: auto;
  }

  .alpha-jump button {
    min-width: 44px;
  }

  #gameDialog[open] {
    grid-template-columns: 1fr;
  }

  .dialog-art {
    min-height: 360px;
  }

  .cache-row {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .cache-row a,
  .cache-row button {
    width: 100%;
  }
}
