:root {
  --bg-deep: #171a21;
  --bg-bar: #22262e;
  --bg-main: #2a2e37;
  --bg-card: #31363f;
  --line: #3a404b;
  --text: #e8ebf0;
  --text-dim: #a3abb8;
  --accent: #3d8af7;
  --accent-2: #2f6fd6;
  --header-h: 52px;
  --footer-h: 40px;
  --bar-w: 320px;
  --art-w: 300px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-deep);
  color: var(--text);
  display: grid;
  grid-template-rows: var(--header-h) 1fr var(--footer-h);
  height: 100dvh;
  overflow: hidden;
}
[hidden] { display: none !important; }

/* Header / footer */
.site-header, .site-footer {
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  padding: 0 16px;
}
.site-logo { font-size: 20px; font-weight: 800; letter-spacing: .3px; }
.menu-btn {
  display: none;
  background: none; border: 0; color: var(--text);
  padding: 6px; margin-right: 8px; border-radius: 6px; cursor: pointer;
}
.menu-btn:hover { background: var(--bg-bar); }

.shell {
  display: grid;
  grid-template-columns: var(--bar-w) 1fr;
  min-height: 0;
}

/* Game bar */
.game-bar {
  background: var(--bg-bar);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.search {
  display: flex; align-items: center; gap: 8px;
  margin: 12px; padding: 0 12px;
  background: var(--bg-deep);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-dim);
}
.search:focus-within { border-color: var(--accent); }
.search input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: 0;
  color: var(--text); font: inherit; font-size: 14px;
  padding: 10px 0;
}
.game-list {
  list-style: none; margin: 0; padding: 0 8px 12px;
  overflow-y: auto; flex: 1;
}
.game-list button {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  background: none; border: 0; border-radius: 6px;
  color: var(--text-dim); font: inherit; font-size: 15px; text-align: left;
  cursor: pointer;
}
.game-list button:hover { background: #2d323b; color: var(--text); }
.game-list button.active {
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  color: #fff;
}
.game-list .icon {
  width: 24px; height: 24px; flex: none;
  border-radius: 4px; object-fit: cover;
  background: var(--bg-card);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--text-dim);
}
.game-list button.active .icon { color: #fff; background: rgba(255,255,255,.18); }
.game-list .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-list { color: var(--text-dim); padding: 0 20px; font-size: 14px; }

/* Main */
.main {
  background: var(--bg-main);
  overflow-y: auto;
  min-height: 0;
}

.hero {
  position: relative;
  height: clamp(170px, 24vw, 420px);
  background: linear-gradient(135deg, #2f3f5c, #1d2330);
  overflow: hidden;
}
.hero-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.hero::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 40%;
  background: linear-gradient(to bottom, transparent, rgba(23,26,33,.55));
  pointer-events: none;
}
.hero-logo {
  position: absolute; z-index: 1;
  left: 6%; top: 50%; transform: translateY(-50%);
  max-width: 34%; max-height: 72%;
  object-fit: contain;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,.5));
}
.hero-bg, .hero-logo, .case-art { transition: opacity .25s; }
.loading { opacity: 0; }

/* Stage: action bar + art + details */
.stage {
  display: grid;
  grid-template-columns: var(--art-w) 1fr;
  grid-template-rows: auto 1fr;
  column-gap: 32px;
  padding: 0 32px 40px;
}
.action-bar {
  grid-column: 1 / -1; grid-row: 1;
  margin: 0 -32px;
  padding: 14px 32px 14px calc(32px + var(--art-w) + 32px);
  background: rgba(23,26,33,.55);
  display: flex; align-items: center; gap: 12px 24px;
  min-height: 84px;
}
.title-block { flex: 1; min-width: 0; }
.game-name { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: .2px; line-height: 1.2; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 6px 0 0; color: var(--text-dim); font-size: 14px; }
.meta:empty { display: none; }
.action-bar .download { flex: none; }
.meta div { display: flex; gap: 6px; }
.meta dt::after { content: ":"; }
.meta dd { margin: 0; color: var(--text); }

.download {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  background: linear-gradient(180deg, #4b95fb, var(--accent-2));
  color: #fff; text-decoration: none; font-weight: 600; font-size: 15px;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(61,138,247,.3);
}
.download:hover { filter: brightness(1.1); }

.art-card {
  grid-column: 1; grid-row: 1 / span 2;
  position: relative; z-index: 1;
  margin-top: 16px; align-self: start;
  background: var(--bg-card);
  padding: 20px; border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
.case-art, .case-fallback {
  display: block; width: 100%;
  aspect-ratio: 2 / 3; object-fit: cover;
  border-radius: 4px;
}
.case-fallback {
  display: grid; place-items: center; text-align: center; padding: 16px;
  background: linear-gradient(160deg, #3a4252, #262b35);
  color: var(--text-dim); font-weight: 700; font-size: 20px;
}

.details { grid-column: 2; grid-row: 2; padding-top: 24px; max-width: 720px; }
.details h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-dim); font-weight: 600; }
.detail-list {
  display: grid; grid-template-columns: max-content 1fr;
  margin: 0 0 24px;
  background: var(--bg-card); border-radius: 8px; overflow: hidden;
}
.detail-list dt, .detail-list dd { padding: 11px 16px; border-top: 1px solid var(--line); margin: 0; }
.detail-list dt:first-of-type, .detail-list dd:first-of-type { border-top: 0; }
.detail-list dt { color: var(--text-dim); font-size: 14px; }
.detail-list dd { font-size: 15px; overflow-wrap: anywhere; }
.no-details { color: var(--text-dim); margin: 0 0 24px; }

.empty-site { color: var(--text-dim); text-align: center; padding: 80px 16px; }

/* Downloads */
.downloads h2 { margin: 8px 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-dim); font-weight: 600; }
.dl-groups { display: flex; flex-direction: column; gap: 12px; }
.dl-card { background: var(--bg-card); border-radius: 8px; overflow: hidden; }
.dl-head, .dl-row, .dl-full {
  display: flex; align-items: center; gap: 12px 16px;
  padding: 12px 16px;
}
.dl-title { font-weight: 700; font-size: 15px; margin-right: auto; display: inline-flex; align-items: center; gap: 8px; }
.dl-title .count {
  min-width: 22px; padding: 1px 7px; border-radius: 999px;
  background: rgba(255,255,255,.08); color: var(--text-dim);
  font-size: 12px; font-weight: 600; text-align: center;
}
.dl-size { color: var(--text-dim); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dl-size.total { color: var(--text); font-weight: 600; }
.dl-list { border-top: 1px solid var(--line); }
.dl-row + .dl-row { border-top: 1px solid var(--line); }
.dl-row { padding-left: 28px; }
.dl-label { margin-right: auto; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.chip {
  font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px;
  background: rgba(61,138,247,.18); color: #8dbbff;
}
.dl-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 6px 12px; border-radius: 6px;
  border: 1px solid rgba(61,138,247,.55); color: #8dbbff;
  text-decoration: none; font-size: 14px; font-weight: 600;
}
.dl-btn:hover { background: rgba(61,138,247,.15); color: #fff; }
.dl-full {
  background: linear-gradient(90deg, rgba(61,138,247,.16), rgba(61,138,247,.04));
  border: 1px solid rgba(61,138,247,.35);
}
.dl-full-text { display: flex; flex-direction: column; gap: 3px; margin-right: auto; min-width: 0; }
.dl-sub { color: var(--text-dim); font-size: 13px; }

/* Mobile */
@media (max-width: 860px) {
  :root { --art-w: 200px; }
  .menu-btn { display: inline-flex; }
  .shell { grid-template-columns: 1fr; position: relative; }
  .game-bar {
    position: absolute; z-index: 20; top: 0; bottom: 0; left: 0;
    width: min(85vw, var(--bar-w));
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .game-bar.open { transform: none; }
  .scrim { position: absolute; inset: 0; z-index: 10; background: rgba(0,0,0,.5); }

  .hero-logo { max-width: 50%; left: 50%; transform: translate(-50%, -50%); }
  .stage { grid-template-columns: 1fr; grid-template-rows: auto; padding: 0 16px 32px; }
  .action-bar { grid-column: 1; margin: 0 -16px; padding: 14px 16px; }
  .action-bar { flex-direction: column; align-items: stretch; }
  .game-name { font-size: 22px; }
  .art-card { grid-column: 1; grid-row: auto; width: var(--art-w); justify-self: center; padding: 12px; }
  .details { grid-column: 1; grid-row: auto; }
  .download { flex: 1; justify-content: center; }
  .dl-full { flex-direction: column; align-items: stretch; }
  .dl-row { padding-left: 16px; flex-wrap: wrap; }
  .dl-row .dl-label { flex-basis: 100%; }
  .dl-row .dl-size { margin-right: auto; }
}
