:root {
  --text: #f5f7fa;
  --dim: rgba(245, 247, 250, 0.72);
  --accent: #ffffff;
  --tile-w: clamp(180px, 20vw, 300px);
  --safe-x: max(24px, env(safe-area-inset-left), 4vw);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: #07090d;
  color: var(--text);
  font: 400 18px/1.45 "Outfit", system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- key art background ---------- */
.bg {
  position: fixed; inset: -2%;
  background: center / cover no-repeat;
  opacity: 0;
  transform: scale(1.06);
  transition: opacity .7s ease, transform 8s ease-out;
}
.bg.on { opacity: 1; transform: scale(1); }
.shade {
  position: fixed; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(7, 9, 13, .95) 0%, rgba(7, 9, 13, .75) 40%, rgba(7, 9, 13, .1) 70%),
    linear-gradient(0deg, rgba(7, 9, 13, .95) 0%, rgba(7, 9, 13, .4) 35%, rgba(7, 9, 13, 0) 60%),
    linear-gradient(180deg, rgba(7, 9, 13, .6) 0%, rgba(7, 9, 13, 0) 18%);
}

/* ---------- top bar ---------- */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: max(18px, env(safe-area-inset-top)) var(--safe-x) 0;
}
.logo { font-weight: 800; letter-spacing: .18em; font-size: 20px; display: flex; align-items: center; gap: 10px; }
.logo-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #4ade80, #22c55e 40%, #0ea5e9); font-size: 14px; color: #07090d;
}
.status { display: flex; align-items: center; gap: 14px; font-weight: 600; font-size: 20px; color: var(--dim); }
.pad-icon { display: none; }
body.pad .pad-icon { display: inline; }

/* ---------- hero (selected game) ---------- */
.hero {
  position: fixed; z-index: 2;
  left: var(--safe-x); right: var(--safe-x);
  bottom: calc(var(--tile-w) * 0.5625 + 160px);
  max-width: 720px;
}
.meta { margin: 0 0 6px; color: var(--dim); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 14px; }
h1 { margin: 0; font-weight: 800; font-size: clamp(40px, 6.4vw, 88px); line-height: .98; letter-spacing: -.01em; text-shadow: 0 4px 30px rgba(0, 0, 0, .5); }
.tagline { margin: 14px 0 0; color: var(--dim); font-size: clamp(17px, 1.6vw, 21px); max-width: 560px; }
.hero.swap h1, .hero.swap .tagline, .hero.swap .meta { animation: rise .45s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 30px 13px 16px; border-radius: 999px;
  font-weight: 800; font-size: 20px; text-decoration: none;
  transition: transform .15s ease, background .15s ease;
}
.btn.play { background: var(--accent); color: #07090d; box-shadow: 0 10px 40px rgba(255, 255, 255, .18); }
.btn.alt { background: rgba(255, 255, 255, .14); color: var(--text); backdrop-filter: blur(10px); padding-left: 24px; }
.btn:hover, .btn:focus-visible { transform: scale(1.05); outline: none; }

/* ---------- tile rail ---------- */
.rail {
  position: fixed; z-index: 2; left: 0; right: 0;
  bottom: 50px;
  display: flex; gap: 30px;
  padding: 26px var(--safe-x) 48px;
  overflow-x: auto; scrollbar-width: none;
  scroll-snap-type: x proximity;
  scroll-padding-inline: var(--safe-x);
}
.rail::-webkit-scrollbar { display: none; }
.tile {
  flex: 0 0 var(--tile-w);
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  position: relative;
  background: #1b1f27 center / cover no-repeat;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  transform-origin: center bottom;
  transition: transform .22s cubic-bezier(.2, .9, .3, 1.2), box-shadow .22s ease, filter .22s ease;
  filter: saturate(.75) brightness(.8);
  scroll-snap-align: start;
  cursor: pointer;
  border: 0; padding: 0; font: inherit;
}
.tile .name {
  position: absolute; left: 0; right: 0; bottom: -34px;
  font-weight: 600; font-size: 16px; color: var(--text);
  opacity: 0; transition: opacity .2s ease; white-space: nowrap; text-align: left;
}
.tile.sel {
  transform: scale(1.08);
  filter: none;
  box-shadow: 0 0 0 4px #fff, 0 0 40px rgba(255, 255, 255, .35), 0 20px 50px rgba(0, 0, 0, .6);
}
.tile.sel .name { opacity: 1; }
.tile:focus-visible { outline: none; }

/* ---------- controller hint bar ---------- */
.hints {
  position: fixed; z-index: 2; left: 0; right: 0; bottom: 0;
  display: flex; gap: 28px; align-items: center; justify-content: flex-end;
  padding: 0 var(--safe-x) max(22px, env(safe-area-inset-bottom));
  color: var(--dim); font-weight: 600; font-size: 16px;
}
.hints > span { display: inline-flex; align-items: center; gap: 8px; }
.glyph {
  display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px;
  border-radius: 999px; font-weight: 800; font-size: 14px; color: #fff; background: rgba(255, 255, 255, .18);
}
.glyph.a { background: #22c55e; }
.glyph.dpad { font-size: 11px; letter-spacing: 2px; }
.xbox-only { display: none !important; }
body.xbox:not(.pad) .xbox-only { display: inline-flex !important; color: #fde68a; }
/* touch screens: no controller glyphs, the buttons speak for themselves */
body.touch:not(.pad) .hints > span:not(.xbox-only) { display: none; }
body.touch:not(.pad) .btn .glyph { display: none; }
body.touch:not(.pad) .btn.play { padding-left: 30px; }

/* ---------- small / portrait screens ---------- */
@media (max-width: 700px) {
  :root { --tile-w: 46vw; }
  .hero { bottom: calc(46vw * 0.5625 + 128px); }
  .rail { bottom: 36px; gap: 20px; }
  .hints { font-size: 14px; gap: 18px; }
}
@media (max-height: 520px) {
  :root { --tile-w: 24vw; }
  .hero { bottom: calc(24vw * 0.5625 + 110px); }
  .tagline { display: none; }
}

/* TVs crop the picture edges: keep everything inside the title-safe area */
body.xbox { --safe-x: 6vw; }
body.xbox .top { padding-top: 5vh; }
body.xbox .hints { padding-bottom: 5vh; }
