@font-face {
  font-family: "Press Start 2P";
  src: url("fonts/press-start-2p-latin.woff2") format("woff2");
  font-display: swap;
}
:root {
  --bg: #0d0221; --bg2: #1a0b3d; --panel: rgba(26, 11, 61, .86); --line: #3d1f7a;
  --pink: #ff2a6d; --cyan: #05d9e8; --yellow: #f9c80e; --purple: #b537f2; --text: #f2eaff; --muted: #a89cc8;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --glow-pink: 0 0 4px var(--pink), 0 0 12px rgba(255,42,109,.6);
  --glow-cyan: 0 0 4px var(--cyan), 0 0 12px rgba(5,217,232,.55);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--text); font: 15px/1.55 var(--mono); min-height: 100vh; overflow-x: hidden;
}
h1, h2, h3, button, .btn, .chip, .badge, .logo { font-family: var(--pixel); }
h2 { font-size: .7rem; letter-spacing: .15em; color: var(--cyan); text-shadow: var(--glow-cyan); margin: 1.75rem 0 .9rem; }
h3 { font-size: .85rem; margin: 0; color: var(--yellow); }
code { color: var(--cyan); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Synthwave backdrop ---------- */
.sky { position: fixed; inset: 0; z-index: -2; overflow: hidden;
  background: linear-gradient(180deg, #0d0221 0%, #1a0b3d 45%, #3b0f5c 62%, #0d0221 62.2%); }
.sun { position: absolute; left: 50%; top: 30vh; width: min(46vw, 420px); aspect-ratio: 1; transform: translateX(-50%);
  border-radius: 50%; opacity: .55; filter: drop-shadow(0 0 40px rgba(255,42,109,.7));
  background: linear-gradient(180deg, var(--yellow) 0%, #ff7b39 45%, var(--pink) 75%);
  -webkit-mask: repeating-linear-gradient(180deg, #000 0 14px, transparent 14px 20px) bottom / 100% 55% no-repeat,
    linear-gradient(#000, #000) top / 100% 45% no-repeat;
          mask: repeating-linear-gradient(180deg, #000 0 14px, transparent 14px 20px) bottom / 100% 55% no-repeat,
    linear-gradient(#000, #000) top / 100% 45% no-repeat; }
.grid-floor { position: absolute; left: -50%; right: -50%; top: 62vh; height: 80vh; transform-origin: top;
  transform: perspective(300px) rotateX(62deg);
  background-image: linear-gradient(var(--pink) 2px, transparent 2px), linear-gradient(90deg, var(--pink) 2px, transparent 2px);
  background-size: 60px 60px; opacity: .45; animation: drive 1.6s linear infinite;
  -webkit-mask: linear-gradient(#000 0%, transparent 85%); mask: linear-gradient(#000 0%, transparent 85%); }
@keyframes drive { to { background-position: 0 60px; } }
.scanlines { position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px); }

/* ---------- Header ---------- */
.top { position: sticky; top: 0; z-index: 10; display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  flex-wrap: wrap; padding: .9rem 1.25rem; background: rgba(13,2,33,.85); backdrop-filter: blur(6px);
  border-bottom: 2px solid var(--pink); box-shadow: 0 2px 18px rgba(255,42,109,.35); }
.brand { display: flex; gap: .75rem; align-items: center; }
.brand h1 { margin: 0; font-size: clamp(1rem, 3vw, 1.6rem); line-height: 1; }
.logo { font-style: italic; letter-spacing: .04em;
  background: linear-gradient(180deg, #fff 0%, var(--cyan) 45%, #2b6cff 52%, var(--purple) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(2px 2px 0 var(--pink)) drop-shadow(0 0 10px rgba(5,217,232,.5)); }
.actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

input, select { font: inherit; color: var(--text); background: rgba(13,2,33,.8); border: 2px solid var(--line);
  border-radius: 2px; padding: .55rem .7rem; }
input[type=search] { width: min(240px, 60vw); font-family: var(--pixel); font-size: .65rem; }
input:focus, select:focus { border-color: var(--cyan); box-shadow: var(--glow-cyan); outline: none; }

button, .btn { cursor: pointer; font-size: .65rem; letter-spacing: .05em; line-height: 1.4; padding: .7rem .95rem;
  border: 2px solid var(--cyan); background: transparent; color: var(--cyan); border-radius: 2px;
  text-shadow: 0 0 6px rgba(5,217,232,.7); transition: background .1s, color .1s, box-shadow .1s, transform .05s;
  display: inline-flex; align-items: center; gap: .4rem; }
button:hover, .btn:hover { background: var(--cyan); color: var(--bg); text-shadow: none; box-shadow: var(--glow-cyan); }
button:active, .btn:active { transform: translateY(2px); }
.primary { border-color: var(--pink); color: #fff; background: var(--pink); text-shadow: none; box-shadow: 4px 4px 0 #7a0a37; }
.primary:hover { background: #ff4f87; color: #fff; box-shadow: var(--glow-pink), 4px 4px 0 #7a0a37; }
.ghost { border-color: var(--line); color: var(--text); text-shadow: none; }
.danger { border-color: var(--pink); color: var(--pink); text-shadow: none; }
.danger:hover { background: var(--pink); color: #fff; box-shadow: var(--glow-pink); }
.link { border: 0; padding: .35rem .5rem; color: var(--muted); font-size: .55rem; text-shadow: none; }
.link:hover, .link[aria-pressed=true] { background: none; color: var(--yellow); box-shadow: none; text-shadow: 0 0 8px var(--yellow); }
button:focus-visible, .btn:focus-within, .bigpick:focus-within { outline: 2px dashed var(--yellow); outline-offset: 3px; }

/* ---------- System toggles ---------- */
.console-select { padding: 0 1.25rem; max-width: 1400px; margin: 0 auto; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.row-tools { display: flex; gap: .25rem; }
.toggles { display: grid; gap: .55rem; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.toggle { justify-content: space-between; width: 100%; padding: .6rem .65rem; border-color: var(--line);
  color: var(--muted); background: rgba(13,2,33,.65); text-shadow: none; box-shadow: none; font-size: .58rem; }
.toggle .led { width: 9px; height: 9px; border-radius: 50%; background: #3a2a55; flex: none; }
.toggle .count { color: var(--muted); font-size: .5rem; }
.toggle .lbl { flex: 1; text-align: left; }
.toggle[aria-pressed=true] { border-color: var(--sys); color: #fff; background: color-mix(in srgb, var(--sys) 28%, rgba(13,2,33,.85));
  box-shadow: 0 0 10px color-mix(in srgb, var(--sys) 60%, transparent), inset 0 0 12px color-mix(in srgb, var(--sys) 30%, transparent); }
.toggle[aria-pressed=true] .led { background: var(--sys); box-shadow: 0 0 8px var(--sys), 0 0 2px #fff; }
.toggle:hover { background: color-mix(in srgb, var(--sys) 35%, rgba(13,2,33,.85)); color: #fff; }
.toggle.empty-sys:not([aria-pressed=true]) { opacity: .55; }

/* ---------- Library ---------- */
main { padding: 0 1.25rem 5rem; max-width: 1400px; margin: 0 auto; }
.shelf { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); }
.card { position: relative; display: flex; flex-direction: column; background: #150734; border: 2px solid var(--line);
  border-radius: 6px 6px 2px 2px; transition: transform .12s, border-color .12s, box-shadow .12s; }
.card::before { content: ""; position: absolute; top: -2px; left: 18%; right: 18%; height: 8px; background: var(--bg);
  border: 2px solid var(--line); border-top: 0; border-radius: 0 0 4px 4px; } /* cartridge notch */
.card:hover { transform: translateY(-4px); border-color: var(--sys); box-shadow: 0 0 18px color-mix(in srgb, var(--sys) 70%, transparent); }
.cart { all: unset; cursor: pointer; display: grid; place-items: center; aspect-ratio: 5/4; margin: 14px 10px 0; padding: .75rem;
  text-align: center; border-radius: 3px; position: relative; overflow: hidden;
  background: linear-gradient(160deg, color-mix(in srgb, var(--sys) 85%, #fff 0%) 0%, color-mix(in srgb, var(--sys) 35%, #000) 100%); }
.cart::after { content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.07) 0 2px, transparent 2px 6px),
    linear-gradient(115deg, transparent 40%, rgba(255,255,255,.18) 50%, transparent 60%); pointer-events: none; }
.cart:focus-visible { outline: 2px dashed var(--yellow); outline-offset: 3px; }
.cart .title { font-family: var(--pixel); font-size: .7rem; line-height: 1.45; color: #fff;
  text-shadow: 2px 2px 0 rgba(0,0,0,.6); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.cart .play { position: absolute; bottom: .45rem; right: .5rem; font-family: var(--pixel); font-size: .5rem; color: var(--yellow);
  opacity: 0; transition: opacity .1s; text-shadow: 0 0 6px var(--yellow); }
.card:hover .play, .cart:focus-visible .play { opacity: 1; }
.meta { display: flex; align-items: center; gap: .3rem; padding: .5rem .6rem .55rem; }
.badge { background: var(--sys); color: #fff; padding: .25rem .4rem; font-size: .5rem; border-radius: 2px; text-shadow: 1px 1px 0 rgba(0,0,0,.4); }
.meta .spacer { flex: 1; }
.icon { border: 0; padding: .35rem .45rem; color: var(--muted); font-size: .9rem; text-shadow: none; font-family: var(--mono); }
.icon:hover { background: none; color: var(--yellow); box-shadow: none; }
.icon.on { color: var(--yellow); text-shadow: 0 0 8px var(--yellow); }

.shelf-note { margin: -.4rem 0 1rem; }
.more { margin-top: 1rem; width: 100%; justify-content: center; }
.badge.shared { background: transparent; border: 1px solid var(--cyan); color: var(--cyan); }
.icon.info { font-size: .85rem; }

.empty { text-align: center; padding: 3.5rem 1rem; border: 2px dashed var(--line); background: rgba(13,2,33,.6); }
.empty.small { padding: 1.5rem; }
.empty .big { font-family: var(--pixel); font-size: 1.1rem; color: var(--yellow); text-shadow: 0 0 10px var(--yellow); margin: 0 0 1rem; }
.blink { animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

.drop { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; pointer-events: none;
  background: rgba(13,2,33,.88); border: 4px dashed var(--cyan); font-family: var(--pixel); color: var(--cyan);
  text-shadow: var(--glow-cyan); font-size: 1.3rem; }

/* ---------- Menus / dialogs ---------- */
dialog.menu { background: linear-gradient(180deg, #1d0b45, #0d0221); color: var(--text); border: 2px solid var(--cyan);
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px var(--pink), 0 0 40px rgba(255,42,109,.45);
  border-radius: 2px; width: min(760px, 94vw); max-height: 88vh; padding: 1.25rem; }
dialog.small-dlg { width: min(440px, 92vw); }
dialog::backdrop { background: rgba(5, 0, 15, .75); backdrop-filter: blur(2px); }
.menu-head { display: flex; justify-content: space-between; align-items: center; }
.tabs { display: flex; gap: .4rem; margin: 1rem 0; border-bottom: 2px solid var(--line); }
.tabs button { border: 2px solid var(--line); border-bottom: 0; color: var(--muted); text-shadow: none; margin-bottom: -2px; }
.tabs button[aria-selected=true] { color: var(--bg); background: var(--yellow); border-color: var(--yellow); }
.pane p { margin-top: 0; }
dialog label { display: grid; gap: .35rem; margin: .8rem 0; }
dialog label.check, .check { display: flex; align-items: center; gap: .5rem; margin: .5rem 0; }
dialog select, dialog input:not([type=checkbox]):not([type=file]) { width: 100%; }
dialog menu { display: flex; gap: .5rem; justify-content: flex-end; padding: 0; margin: 1.25rem 0 0; flex-wrap: wrap; }
dialog menu .spacer { flex: 1; }
input[type=checkbox] { accent-color: var(--pink); width: 1.05rem; height: 1.05rem; }

.bigpick { display: grid !important; place-items: center; padding: 2.25rem 1rem; margin: 1rem 0; cursor: pointer;
  border: 2px dashed var(--cyan); color: var(--cyan); font-family: var(--pixel); font-size: .8rem; text-shadow: var(--glow-cyan); }
.bigpick:hover { background: rgba(5,217,232,.08); }
.bigpick input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.scan-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.status { font-family: var(--pixel); font-size: .55rem; color: var(--yellow); min-height: 1.2em; margin: 1rem 0 .5rem; line-height: 1.8; }
.results-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .5rem 0; border-bottom: 2px solid var(--line); }
#scanList { list-style: none; margin: 0; padding: 0; max-height: 42vh; overflow: auto; }
#scanList li { display: grid; grid-template-columns: auto 1fr minmax(150px, 210px); gap: .6rem; align-items: center;
  padding: .45rem .2rem; border-bottom: 1px solid rgba(61,31,122,.6); }
#scanList li.dupe { opacity: .45; }
#scanList .path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
#scanList .path small { display: block; color: var(--muted); font-size: .72rem; }
#scanList select { padding: .3rem .4rem; font-size: .8rem; }
#scanList select.need { border-color: var(--yellow); }

.catalog { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.catalog li { display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; align-items: center; padding: .8rem;
  border: 2px solid var(--line); background: rgba(13,2,33,.6); }
.catalog li:hover { border-color: var(--sys); }
.catalog .info strong { font-family: var(--pixel); font-size: .65rem; display: block; margin-bottom: .35rem; line-height: 1.5; }
.catalog .info span { color: var(--muted); font-size: .85rem; }
.catalog .acts { display: flex; flex-direction: column; gap: .4rem; }
.catalog .acts a { text-decoration: none; }
.catalog .owned { font-family: var(--pixel); font-size: .5rem; color: var(--yellow); }

h4.sub { font-family: var(--pixel); font-size: .6rem; color: var(--pink); text-shadow: 0 0 6px rgba(255,42,109,.6);
  margin: 1.6rem 0 .7rem; letter-spacing: .1em; }
h4.sub .muted { text-shadow: none; }
.catalog .facts { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.tag { font-size: .7rem; border: 1px solid var(--line); padding: .05rem .4rem; color: var(--muted); border-radius: 2px; }
.tag.ok { border-color: #2a9d8f; color: #6fe3c7; }
.tag.paid { border-color: var(--yellow); color: var(--yellow); }
.catalog.compact li { padding: .55rem .7rem; }
.catalog.compact .info strong { font-size: .58rem; }
.catalog.compact .acts { flex-direction: row; }
.catalog.compact .acts .btn, .catalog.compact .acts button { padding: .5rem .6rem; font-size: .55rem; }
.archive-tools { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: .7rem; }
.archive-tools input[type=search] { flex: 1; min-width: 180px; }
#archiveMore { margin-top: .75rem; width: 100%; justify-content: center; }
.sources { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.sources div { border: 2px solid var(--line); padding: .6rem .75rem; background: rgba(13,2,33,.6); }
.sources strong { font-family: var(--pixel); font-size: .52rem; color: var(--cyan); display: block; margin-bottom: .45rem; line-height: 1.6; }
.sources a { display: block; color: var(--text); font-size: .85rem; margin: .2rem 0; }
.sources a:hover { color: var(--yellow); }

.bios-row { display: flex; align-items: center; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.bios-row div { flex: 1; }
.bios-row strong { font-family: var(--pixel); font-size: .6rem; }
.bios-row small { display: block; color: var(--muted); margin-top: .3rem; }

.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); z-index: 60; font-family: var(--pixel);
  font-size: .6rem; background: var(--bg); color: var(--yellow); border: 2px solid var(--yellow); padding: .8rem 1.1rem;
  box-shadow: 0 0 16px rgba(249,200,14,.5); }

@media (max-width: 600px) {
  #scanList li { grid-template-columns: auto 1fr; }
  #scanList li select { grid-column: 2; }
  .catalog li { grid-template-columns: auto 1fr; }
  .catalog .acts { grid-column: 1 / -1; flex-direction: row; }
}
@media (prefers-reduced-motion: reduce) {
  .grid-floor, .blink { animation: none; }
  .card, button { transition: none; }
}
#infoBody a { color: var(--cyan); }
#infoBody p { margin: .5rem 0; }
