/* Fonts are served from here rather than Google Fonts, so a visit makes no third-party
   request. Latin subsets only; licenses (SIL OFL) are alongside in arcade/fonts/. */
@font-face {
  font-family: "Press Start 2P";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/press-start-2p-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700; /* one variable file covers every weight the arcade uses */
  font-display: swap;
  src: url("fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #0b0714;
  --bg-2: #140d24;
  --panel: #1a1230;
  --panel-2: #231940;
  --line: #2f2450;
  --text: #f4efff;
  --muted: #a99cc9;
  --pink: #ff4fd8;
  --cyan: #3ef2ff;
  --yellow: #ffe14f;
  --radius: 16px;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  background:
    radial-gradient(1200px 600px at 15% -10%, #3b1360 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #0e3a52 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* faint scanlines over everything in the library */
.library::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px);
  z-index: 0;
}

[hidden] { display: none !important; }

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

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--panel-2); border-color: #4a3a7a; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .card:focus-visible, select:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}
.btn-ghost { background: transparent; }
.btn-play {
  background: linear-gradient(135deg, var(--pink), #a855f7);
  border: none;
  color: #fff;
  font-weight: 700;
  padding: 12px 22px;
  box-shadow: 0 6px 24px rgba(255, 79, 216, .35);
}
.btn-play:hover { background: linear-gradient(135deg, #ff6ae0, #b874ff); }

/* ---------- library ---------- */
.library {
  position: relative;
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}
.library > * { position: relative; z-index: 1; }

.masthead { text-align: center; margin-bottom: 32px; }
.logo { margin: 0; line-height: 1; font-weight: 400; }
.logo-top {
  display: block;
  font-family: var(--pixel);
  font-size: clamp(14px, 2.2vw, 20px);
  color: var(--cyan);
  letter-spacing: .2em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(62, 242, 255, .7);
  margin-bottom: 14px;
}
.logo-main {
  display: block;
  font-family: var(--pixel);
  font-size: clamp(26px, 8vw, 76px);
  color: var(--pink);
  text-transform: uppercase;
  text-shadow:
    0 0 6px rgba(255, 79, 216, .9),
    0 0 28px rgba(255, 79, 216, .6),
    4px 4px 0 #4b0f6b;
  animation: flicker 6s infinite;
}
@keyframes flicker {
  0%, 92%, 100% { opacity: 1; }
  93% { opacity: .55; }
  94% { opacity: 1; }
  96% { opacity: .7; }
}
.tagline { color: var(--muted); margin: 18px 0 0; font-size: 15px; }

/* hero: last played game */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  background: linear-gradient(135deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  padding: 20px;
  margin-bottom: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.hero .art { aspect-ratio: 16 / 9; border-radius: var(--radius); }
.hero .kicker {
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: .15em;
  color: var(--yellow);
  text-transform: uppercase;
}
.hero h2 { font-size: clamp(26px, 3.4vw, 38px); margin: 12px 0 10px; }
.hero p { color: var(--muted); line-height: 1.55; margin: 0 0 20px; }
.hero .meta { color: var(--muted); font-size: 13px; margin-top: 14px; }

/* toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  flex: 0 1 280px;
}
.search:focus-within { border-color: var(--cyan); }
.search input {
  border: 0;
  background: transparent;
  outline: none;
  padding: 9px 0;
  width: 100%;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.toolbar-right { display: flex; gap: 8px; margin-left: auto; }
select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

/* grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.card {
  --c: #a78bfa;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
  animation: rise .4s ease both;
}
.card:hover, .card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--c);
  box-shadow: 0 14px 40px -10px var(--c);
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.art {
  --c: #a78bfa;
  position: relative;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 120%, color-mix(in srgb, var(--c) 55%, transparent), transparent 65%),
    linear-gradient(160deg, color-mix(in srgb, var(--c) 22%, #120a22), #0c0716);
}
.art::after { /* grid floor */
  content: "";
  position: absolute;
  inset: 55% -20% -10%;
  background:
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--c) 40%, transparent) 0 1px, transparent 1px 36px),
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--c) 40%, transparent) 0 1px, transparent 1px 22px);
  transform: perspective(200px) rotateX(55deg);
  opacity: .35;
}
.art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.art .emoji {
  font-size: 64px;
  z-index: 1;
  filter: drop-shadow(0 6px 18px color-mix(in srgb, var(--c) 70%, transparent));
  transition: transform .25s ease;
}
.hero .art .emoji { font-size: 96px; }
.card:hover .emoji { transform: scale(1.12) rotate(-4deg); }
.art .play-hint {
  position: absolute;
  z-index: 2;
  inset: auto 12px 12px auto;
  background: rgba(0,0,0,.65);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .15s, transform .15s;
}
.card:hover .play-hint, .card:focus-visible .play-hint { opacity: 1; transform: none; }

.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h3 { margin: 0; font-size: 17px; font-weight: 700; }
.genre {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c);
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
}
.card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.stats { margin-top: auto; padding-top: 4px; font-size: 12px; color: #7d70a3; }

.empty { text-align: center; color: var(--muted); padding: 40px; }
.footer { text-align: center; color: #6f6394; font-size: 13px; margin-top: 56px; }
code { background: var(--panel); padding: 2px 6px; border-radius: 6px; font-size: 12px; }

/* ---------- player ---------- */
.player {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #000;
}
.player-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.player-bar .btn { padding: 6px 12px; font-size: 14px; }
.player-title { flex: 1; font-weight: 700; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-actions { display: flex; gap: 6px; }
#frame { flex: 1; width: 100%; border: 0; background: #000; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 10;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .library { padding: 28px 16px 48px; }
  .hero { grid-template-columns: 1fr; }
  .toolbar-right { margin-left: 0; width: 100%; }
  .toolbar-right select { flex: 1; }
  .search { flex: 1 1 100%; }
  .player-actions .label { display: none; }
  #cover, #restart { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
