:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --ink: #121826;
  --muted: #647084;
  --line: #dfe5ee;
  --brand: #2563eb;
  --green: #13966b;
  --red: #df3f4f;
  --amber: #b7791f;
  --shadow: 0 14px 40px rgba(18, 24, 38, 0.10);
  --radius: 8px;
  --rail: 216px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c111d;
  --surface: #131a29;
  --surface-2: #1b2435;
  --ink: #edf2ff;
  --muted: #9aa7bc;
  --line: #263248;
  --brand: #6aa5ff;
  --green: #4fc59a;
  --red: #ff7280;
  --amber: #e6b85c;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(18, 24, 38, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(18, 24, 38, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: 40px 40px;
  color: var(--ink);
}

a { color: inherit; text-decoration: none; }
img { display: block; width: 100%; }
button, input, select { font: inherit; }

.app-shell {
  min-height: 100vh;
  display: block;
}

.rail {
  position: sticky;
  top: 0;
  min-height: 70px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  gap: 24px;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--surface);
  font-weight: 800;
}

.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 17px; }
.brand-copy small, .muted { color: var(--muted); }

.rail-nav {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.rail-link {
  min-height: 38px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
}

.rail-link:hover, .rail-link.active {
  color: var(--ink);
  background: var(--surface-2);
}

.theme-toggle { margin-left: 0; }

.page {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar, .detail-topbar, .player-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(34px, 5vw, 64px); line-height: 0.95; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 22px; letter-spacing: 0; }

.search-panel {
  width: min(480px, 100%);
  min-height: 48px;
  padding: 4px;
  display: grid;
  grid-template-columns: 1fr 40px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-panel input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 0 12px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 16px;
  margin-bottom: 18px;
  align-items: stretch;
}

.hero-feature {
  height: clamp(300px, 38vh, 400px);
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.hero-feature img {
  height: 100%;
  object-fit: cover;
}

.hero-feature::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(5, 9, 18, 0.82), rgba(5, 9, 18, 0.24) 60%, transparent);
}

.hero-copy {
  position: absolute;
  z-index: 1;
  inset: auto 34px 34px 34px;
  max-width: 620px;
  color: #fff;
}

.hero-copy span { color: #b8f2d2; font-weight: 800; }
.hero-copy h2 { margin: 8px 0 10px; font-size: clamp(32px, 5vw, 56px); line-height: 0.95; }
.hero-copy p { max-width: 56ch; color: rgba(255,255,255,0.84); }

.metric-stack {
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.metric-card {
  min-height: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  align-content: end;
}

.metric-card span { font-size: 34px; font-weight: 900; }
.metric-card small { color: var(--muted); font-weight: 800; text-transform: uppercase; }

.category-rail {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 20px;
}

.category-pill {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 13px;
  cursor: pointer;
  font-weight: 800;
}

.category-pill span {
  color: var(--muted);
  font-weight: 700;
}

.category-pill.active {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--line));
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  color: var(--brand);
}

.section {
  margin-top: 30px;
}

.section-head {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-head a { color: var(--brand); font-weight: 800; }

.feature-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

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

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

.game-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(18, 24, 38, 0.04);
}

.game-card.wide .game-art { aspect-ratio: 16 / 10; }
.game-art {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  overflow: hidden;
}

.game-art img {
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.game-card:hover .game-art img { transform: scale(1.04); }

.game-card-body {
  min-height: 138px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.game-card-main {
  min-height: 46px;
}

.game-title {
  display: block;
  font-weight: 900;
  line-height: 1.2;
}

.game-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.tag-row {
  min-height: 25px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-row span {
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.play-chip, .primary-button, .secondary-button {
  min-height: 40px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  padding: 0 14px;
  font-weight: 900;
}

.play-chip, .primary-button {
  background: var(--brand);
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.compact {
  min-height: 36px;
  padding-inline: 10px;
  font-size: 13px;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.lane-section {
  display: grid;
  gap: 14px;
}

.lane-section .section-head {
  margin-bottom: 0;
}

.lane-section .section-head p {
  margin: 6px 0 0;
}

.lane-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.lane-card {
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  display: grid;
  align-content: space-between;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.lane-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--brand) 42%, var(--line));
}

.lane-card.active {
  border-color: color-mix(in srgb, var(--brand) 62%, var(--line));
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
}

.lane-card strong {
  font-size: 15px;
}

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

.quick-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 80%, var(--surface-2));
}

.compact-head {
  min-height: 32px;
  margin-bottom: 10px;
}

.quick-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.mini-list {
  display: grid;
  gap: 10px;
}

.mini-item {
  min-height: 72px;
  padding: 8px;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.mini-item img {
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
}

.mini-item span { min-width: 0; }
.mini-item strong, .mini-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-item small { color: var(--muted); margin-top: 3px; }

.info-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.catalog-section {
  padding-bottom: 40px;
}

.catalog-head select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
}

.empty-state, .fatal-error {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.detail-page, .player-shell {
  min-height: 100vh;
  padding: 22px;
}

.detail-topbar, .player-topbar {
  margin-bottom: 18px;
}

.back-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 900;
}

.detail-spotlight {
  min-height: 390px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101827;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  height: 100%;
  object-fit: cover;
  opacity: 0.58;
}

.detail-spotlight::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(5, 9, 18, 0.88), rgba(5, 9, 18, 0.42) 58%, rgba(5, 9, 18, 0.14)),
    linear-gradient(0deg, rgba(5, 9, 18, 0.75), transparent 50%);
}

.detail-spotlight-copy {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  padding: clamp(28px, 5vw, 62px);
  color: #fff;
}

.detail-spotlight-copy h1 {
  margin-bottom: 16px;
}

.detail-spotlight-copy p {
  color: rgba(255,255,255,0.82);
  font-size: 17px;
  line-height: 1.6;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.detail-main {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
}

.detail-cover-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  align-self: start;
}

.detail-cover-card img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.detail-cover-meta {
  padding: 14px;
  display: grid;
  gap: 4px;
}

.detail-cover-meta strong {
  font-size: 18px;
}

.detail-cover-meta span {
  color: var(--muted);
  font-weight: 700;
}

.detail-overview {
  min-height: 100%;
}

.detail-overview p {
  color: var(--muted);
  line-height: 1.65;
}

.highlight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.highlight-grid span {
  min-height: 78px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  display: grid;
  align-content: end;
}

.highlight-grid small {
  color: var(--muted);
  font-weight: 800;
}

.highlight-grid strong {
  font-size: 18px;
}

.detail-launch-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.detail-launch-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.detail-side, .player-side {
  display: grid;
  gap: 14px;
  align-content: start;
}

.style-card {
  min-height: 130px;
  padding: 16px;
  border-radius: 8px;
  background: var(--surface-2);
  display: grid;
  align-content: space-between;
  gap: 10px;
}

.style-card strong {
  font-size: 22px;
}

.style-card p {
  margin: 0;
  color: var(--muted);
}

.style-card a {
  color: var(--brand);
  font-weight: 900;
}

.rich-list .mini-item {
  min-height: 82px;
}

.facts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.facts-grid span {
  min-height: 72px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  display: grid;
  align-content: end;
}

.facts-grid strong { font-size: 20px; }
.facts-grid small { color: var(--muted); font-weight: 800; }

body[data-page="play"] {
  background: #0b1020;
  color: #edf2ff;
}

.player-shell {
  background: #0b1020;
}

.player-topbar {
  min-height: 56px;
  padding: 8px 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.player-title {
  min-width: 0;
  display: grid;
  justify-items: center;
}

.player-title strong, .player-title span {
  max-width: 44vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-title span {
  color: #9aa7bc;
  font-size: 13px;
}

.player-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.player-layout {
  height: calc(100vh - 100px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  padding-top: 14px;
}

.game-frame-wrap {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  overflow: hidden;
  background: #050812;
}

.game-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.player-side .info-card {
  background: #131a29;
  border-color: rgba(255,255,255,0.12);
}

.player-side .mini-item {
  background: #131a29;
  border-color: rgba(255,255,255,0.12);
}

@media (max-width: 980px) {
  .rail {
    position: sticky;
    height: auto;
    align-items: center;
    overflow-x: auto;
    padding: 12px 18px;
  }

  .rail-nav {
    display: flex;
    margin-left: auto;
  }

  .theme-toggle {
    margin-top: 0;
  }

  .page {
    padding: 18px;
  }

  .topbar, .detail-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-panel {
    width: 100%;
  }

  .hero-grid, .detail-layout, .detail-main, .player-layout {
    grid-template-columns: 1fr;
  }

  .metric-stack {
    grid-template-columns: repeat(3, 1fr);
  }

  .feature-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lane-grid, .quick-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-spotlight {
    min-height: 420px;
  }

  .detail-launch-card {
    align-items: stretch;
    flex-direction: column;
  }

  .player-layout {
    height: auto;
  }

  .game-frame-wrap {
    height: min(62vh, 620px);
  }
}

@media (max-width: 640px) {
  .rail {
    padding: 12px;
  }

  .brand-copy small, .rail-link {
    font-size: 12px;
  }

  .topbar h1 {
    font-size: 42px;
  }

  .hero-grid {
    gap: 10px;
    margin-bottom: 10px;
  }

  .hero-feature {
    height: 168px;
  }

  .hero-copy {
    inset: auto 14px 14px;
  }

  .hero-copy span {
    font-size: 11px;
  }

  .hero-copy h2 {
    margin: 5px 0 9px;
    font-size: 24px;
    line-height: 1;
  }

  .hero-copy p {
    display: none;
  }

  .hero-copy .action-row {
    gap: 8px;
  }

  .hero-copy .primary-button,
  .hero-copy .secondary-button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  .metric-stack {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: none;
    gap: 8px;
  }

  .metric-card {
    min-height: 54px;
    padding: 8px;
    align-content: center;
    text-align: center;
  }

  .metric-card span {
    font-size: 20px;
    line-height: 1;
  }

  .metric-card small {
    font-size: 9px;
  }

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

  .feature-strip, .card-grid, .lane-grid, .quick-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px 8px;
  }

  .lane-card {
    min-height: 48px;
    padding: 7px 4px;
    align-content: center;
    text-align: center;
  }

  .lane-card strong {
    font-size: 10px;
    line-height: 1.15;
  }

  .lane-card span {
    display: none;
  }

  .quick-panel {
    padding: 10px;
  }

  .quick-list .mini-item {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .quick-list .mini-item img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
  }

  .quick-list .mini-item strong {
    font-size: 10px;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .quick-list .mini-item small {
    display: none;
  }

  .game-card {
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .game-card.wide .game-art,
  .game-art {
    aspect-ratio: 1 / 1;
    border-radius: 8px;
  }

  .game-card-body {
    min-height: 0;
    padding: 6px 0 0;
    gap: 0;
  }

  .game-card-main {
    min-height: 0;
  }

  .game-title {
    font-size: 10px;
    line-height: 1.2;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .game-card p {
    display: none;
  }

  .tag-row,
  .play-chip {
    display: none;
  }

  .player-topbar {
    flex-wrap: wrap;
    justify-content: center;
  }

  .player-title {
    order: -1;
    width: 100%;
  }

  .player-title strong, .player-title span {
    max-width: 92vw;
  }

  .player-actions {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
}
