/* Library, project card, cover picker, Running now: the Design's rules, sized by custom properties set from script (CSP: no style attribute). */

.small { font-size: var(--text-xs); }
.scroll-x { overflow-x: auto; }

.seg { position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: var(--hairline) solid var(--line-strong); background: var(--bg-sunken); }
.seg-thumb { position: absolute; top: 0; bottom: 0; left: 0; width: calc(100% / var(--n, 2)); transform: translateX(calc(var(--i, 0) * 100%)); background: var(--accent); box-shadow: 0 0 16px -2px var(--glow); transition: transform .5s var(--ease-io); }
.seg button { position: relative; z-index: 1; border: 0; background: none; color: var(--text-dim); font: 600 var(--text-xs)/1 var(--font-display); letter-spacing: .12em; text-transform: uppercase; padding: 0 14px; min-height: 32px; cursor: pointer; white-space: nowrap; transition: color .35s var(--ease); }
.seg button:hover { color: var(--text); }
.seg button.on { color: var(--accent-ink); }

.lib-tools { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-4); align-items: center; justify-content: space-between; margin: var(--space-4) 0; }
.lib-tools > div { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  border: var(--hairline) solid var(--line-strong); background: var(--bg-sunken); color: var(--text-dim);
  font: 600 var(--text-xs)/1 var(--font-display); letter-spacing: .12em; text-transform: uppercase; padding: 0 12px; min-height: 30px; cursor: pointer;
  transition: color .3s, border-color .3s, background-color .3s, transform .2s var(--ease);
}
.chips button:hover { color: var(--text); border-color: var(--accent); }
.chips button:active { transform: scale(.95); }
.chips button.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.chips .n { margin-left: 6px; font-family: var(--font-mono); opacity: .75; }

/* Shelves: Workshop, Finished ports, Catalogue, each headed by what it holds. */
.shelves { display: grid; gap: var(--space-6); min-width: 0; }
.shelf { display: grid; gap: var(--space-4); min-width: 0; }
.shelf-head { display: grid; gap: 4px; padding-bottom: var(--space-3); border-bottom: var(--hairline) solid var(--line-strong); position: relative; }
.shelf-head::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 96px; height: 2px; background: var(--accent); transform-origin: left; }
:is(.intro, .enter, .replay) .shelf-head::after { animation: barIn .9s var(--ease-io) calc(var(--lead, 0s) + .2s) both; }
.shelf-finished .shelf-head::after { background: var(--ok); }
.shelf-workshop .shelf-head::after { background: var(--warn); }
.shelf-head h2 { display: flex; align-items: baseline; gap: var(--space-3); font: 400 20px/1.1 var(--font-title); letter-spacing: .05em; text-transform: uppercase; }
.shelf-head h2 .n { font: 500 var(--text-sm) var(--font-mono); color: var(--accent); letter-spacing: 0; }
.shelf-head p { color: var(--text-dim); font: var(--text-xs)/1.5 var(--font-mono); }
/* Inside a shelf, one section per console. */
.plat-sec { display: grid; gap: var(--space-3); min-width: 0; }
.plat-sec + .plat-sec { margin-top: var(--space-4); }
.plat-sec h3 { display: flex; align-items: baseline; gap: var(--space-2); font: 600 var(--text-sm)/1 var(--font-display); letter-spacing: .18em; text-transform: uppercase; color: var(--text-dim); }
.plat-sec h3 .n { font: 500 var(--text-xs) var(--font-mono); color: var(--accent); letter-spacing: 0; }
/* Each console keeps its box shape, the one its box art comes in: PS1 jewel case 1:1, PS2 DVD case 1:1.41, PSP UMD case 1:1.72. */
.box-ps1 { --box: 1 / 1; } .box-ps2 { --box: 512 / 722; } .box-psp { --box: 512 / 880; }
.shelf .empty { grid-column: 1 / -1; color: var(--text-dim); font: var(--text-xs)/1.6 var(--font-mono); overflow-wrap: anywhere; }

.lib { display: grid; min-width: 0; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: var(--space-5) var(--space-4); perspective: 1200px; }
.game { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 10px; align-content: start; }
/* Filters replay the first cards only: the rest of a 349-card grid appears at once. */
.lib.replay .game:nth-child(-n+24) { animation: cardA .6s var(--ease) both; }
.lib.replay .game:nth-child(2) { animation-delay: .05s; } .lib.replay .game:nth-child(3) { animation-delay: .1s; } .lib.replay .game:nth-child(4) { animation-delay: .15s; }
.lib.replay .game:nth-child(5) { animation-delay: .2s; } .lib.replay .game:nth-child(6) { animation-delay: .25s; } .lib.replay .game:nth-child(n+7) { animation-delay: .3s; }
.cover-btn { position: relative; display: block; width: 100%; aspect-ratio: var(--box, 5 / 7); padding: 0; border: 0; cursor: pointer; background: none; transform-style: preserve-3d; transform-origin: center bottom; transition: transform .6s var(--ease), filter .4s; }
.game:hover .cover-btn { transform: translateY(-8px) rotateX(6deg) rotateY(-8deg); filter: drop-shadow(0 22px 22px rgba(0, 0, 0, .45)); }
.art {
  position: absolute; inset: 0; overflow: hidden; display: grid; align-content: end; padding: 14px; text-align: left;
  border: var(--hairline) solid var(--line-strong);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 0 100%);
}
.art::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .05) 0 2px, transparent 2px 10px); }
.art::after { content: ""; position: absolute; inset: -40%; background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, .22) 50%, transparent 60%); transform: translateX(-60%); transition: transform .9s var(--ease); pointer-events: none; }
.game:hover .art::after { transform: translateX(60%); }
.art .spine { position: absolute; z-index: 1; top: 0; left: 0; right: 0; height: 26px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; font: 700 10px/1 var(--font-display); letter-spacing: .18em; text-transform: uppercase; }
.art .initials { position: relative; font: 400 50px/0.95 var(--font-title); letter-spacing: 0; color: rgba(255, 255, 255, .92); text-shadow: 0 4px 20px rgba(0, 0, 0, .35); }
.art .region { position: relative; margin-top: 8px; font: 600 10px/1 var(--font-mono); letter-spacing: .14em; color: rgba(255, 255, 255, .8); overflow-wrap: anywhere; }
.art.custom { background: linear-gradient(160deg, #3f6f5a, #0f2a20); } .art.custom .spine { background: #0b1a14; color: #c7ff6b; }
.art.ph { background: var(--bg-sunken); } .art.ph .spine { background: var(--bg-raised); color: var(--text-dim); } .art.ph .initials { color: var(--text-dim); text-shadow: none; } .art.ph .region { color: var(--text-dim); }
.art.photo { padding: 0; background: var(--bg-sunken); }
.art.photo::before { display: none; }
.art.photo .spine { background: rgba(0, 0, 0, .55); color: #f3eee0; }
.art.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* 3D box: the whole box with its spine on a transparent background, so no frame, corner cut, spine band or sheen. */
.art.d3 { background: none; border: 0; clip-path: none; }
.art.d3::after, .art.d3 .spine { display: none; }
.art.d3 img { object-fit: contain; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .45)); }
.ring-badge { position: absolute; right: 10px; bottom: 10px; width: 50px; height: 50px; z-index: 1; }
.ring-badge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-badge .bgc { fill: rgba(0, 0, 0, .55); stroke: rgba(255, 255, 255, .18); stroke-width: 3; }
.ring-badge .val { fill: none; stroke: var(--accent); stroke-width: 3; animation: ringIn 1.4s var(--ease-io) .35s both; }
.ring-badge span { position: absolute; inset: 0; display: grid; place-items: center; font: 600 10px/1 var(--font-mono); color: #fff; }
@keyframes ringIn { from { stroke-dasharray: 0 100; } }
.cover-edit {
  position: absolute; top: 34px; right: 8px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; min-height: 30px;
  border: var(--hairline) solid var(--accent); background: color-mix(in srgb, var(--bg-sunken) 88%, transparent); color: var(--accent);
  font: 600 10px/1 var(--font-display); letter-spacing: .12em; text-transform: uppercase; cursor: pointer;
  opacity: 0; transform: translateY(-6px); transition: opacity .3s var(--ease), transform .3s var(--ease), background-color .2s;
}
.game:hover .cover-edit, .cover-edit:focus-visible { opacity: 1; transform: none; }
.cover-edit:hover { background: var(--accent); color: var(--accent-ink); }
@media (hover: none) { .cover-edit { opacity: 1; transform: none; } }
.game-meta { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.game-meta .st { white-space: normal; }
.game-title { font: 400 15px/1.25 var(--font-title); letter-spacing: .03em; text-transform: uppercase; overflow-wrap: anywhere; }
.game-sub { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); font: var(--text-xs) var(--font-mono); color: var(--text-dim); }
.plat { font: 600 9px/1.6 var(--font-display); letter-spacing: .14em; text-transform: uppercase; padding: 0 6px; border: var(--hairline) solid var(--line-strong); color: var(--text-dim); justify-self: start; }

.lib-list { display: grid; min-width: 640px; }
.lib-row { display: grid; grid-template-columns: 44px minmax(0, 2fr) 90px 150px minmax(120px, 1fr) 80px; gap: var(--space-3); align-items: center; padding: 8px var(--space-4); border: 0; border-bottom: var(--hairline) solid var(--line); background: none; text-align: left; cursor: pointer; width: 100%; font-size: var(--text-sm); color: var(--text); }
.replay .lib-row:nth-child(-n+30) { animation: rowA .45s var(--ease) both; }
.lib-row:hover { background: var(--bg-hover); }
.lib-row .art { position: relative; inset: auto; width: 44px; height: auto; aspect-ratio: var(--box, 44 / 60); padding: 0; clip-path: none; place-items: center; align-content: center; }
.lib-row .art .initials { font-size: 16px; } .lib-row .art .spine { height: 8px; padding: 0; font-size: 0; } .lib-row .art .region { display: none; }
.lib-row .pct { text-align: right; color: var(--accent); }

.bar { height: 10px; background: var(--bg-sunken); border: var(--hairline) solid var(--line-strong); position: relative; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); box-shadow: 0 0 10px var(--glow); transition: width 1s var(--ease-io); transform-origin: left; }
:is(.intro, .enter, .replay) .bar > span { animation: barIn 1.2s var(--ease-io) calc(var(--lead, 0s) + .3s) both; }
.bar.ticks::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), var(--bg-sunken) calc(10% - 2px) 10%); }
.bar.work > span { background: repeating-linear-gradient(-45deg, var(--warn) 0 6px, color-mix(in srgb, var(--warn) 65%, transparent) 6px 12px) 0 0 / 17px 17px; box-shadow: none; animation: march 1s linear infinite; }

.st { font: 600 var(--text-xs)/1.6 var(--font-mono); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; color: var(--text-dim); }
.st::before { content: "[-] "; }
.st.ok { color: var(--ok); } .st.ok::before { content: "[=] "; }
.st.warn { color: var(--warn); } .st.warn::before { content: "[~] "; }
.st.bad { color: var(--danger); } .st.bad::before { content: "[x] "; }
.st.live { color: var(--warn); } .st.live::before { content: "[>] "; display: inline-block; white-space: pre; animation: breathe 1.2s ease-in-out infinite alternate; }

/* Drawer: project card and cover picker. */
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(5, 10, 25, .55); backdrop-filter: blur(3px); animation: fadeIn .35s var(--ease) both; border: 0; cursor: pointer; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 31; width: min(440px, 100%); overflow-y: auto;
  background: linear-gradient(180deg, var(--bg-raised), var(--bg-sunken)); border-left: var(--hairline) solid var(--line-strong);
  box-shadow: -30px 0 60px -20px rgba(0, 0, 0, .6); animation: drawerIn .55s var(--ease) both;
  display: grid; align-content: start; gap: var(--space-5); padding: var(--space-5);
}
.drawer::before { content: ""; position: absolute; top: 0; left: 0; bottom: 0; width: 3px; background: var(--accent); }
@keyframes drawerIn { from { transform: translateX(100%); } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.drawer-head h2 { font: 400 22px/1.15 var(--font-title); text-transform: uppercase; letter-spacing: .04em; }
.x { flex: none; width: 36px; height: 36px; border: var(--hairline) solid var(--line-strong); background: var(--bg-sunken); color: var(--text-dim); font: 400 20px/1 var(--font-mono); cursor: pointer; display: grid; place-items: center; transition: color .2s, border-color .2s, transform .3s var(--ease); }
.x:hover { color: var(--accent); border-color: var(--accent); transform: rotate(90deg); }
.card-face { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.card-cover { position: relative; aspect-ratio: var(--box, 5 / 7); }
.card-cover .art .initials { font-size: 34px; }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px var(--space-3); font: var(--text-xs) var(--font-mono); }
.facts dt { color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts a { color: var(--accent); }
.card-text { color: var(--text-dim); font-size: var(--text-sm); line-height: 1.5; }
.repo-list { display: grid; gap: var(--space-3); margin: calc(-1 * var(--space-3)) 0 0; padding: 0; list-style: none; counter-reset: repo; }
.repo-list li { display: grid; gap: 6px; padding: var(--space-3); border: var(--hairline) solid var(--line); background: var(--bg-sunken); animation: fadeUp .5s var(--ease) both; }
.repo-list li:nth-child(2) { animation-delay: .05s; } .repo-list li:nth-child(3) { animation-delay: .1s; } .repo-list li:nth-child(n+4) { animation-delay: .15s; }
.repo-list li.finished { border-color: var(--ok); box-shadow: inset 3px 0 0 var(--ok); }
.repo-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); font: 600 var(--text-sm) var(--font-mono); }
.repo-top a { color: var(--accent); overflow-wrap: anywhere; }
.repo-top .tag { flex: none; font: 600 var(--text-xs)/1.4 var(--font-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.repo-meta { font: var(--text-xs) var(--font-mono); color: var(--text-faint); }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.btn-primary { display: inline-grid; place-items: center; min-height: 42px; padding: 0 18px; border: 0; background: var(--accent); color: var(--accent-ink); font: 700 var(--text-sm)/1 var(--font-display); letter-spacing: .16em; text-transform: uppercase; text-decoration: none; cursor: pointer; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px)); transition: filter .2s, transform .2s var(--ease); }
.btn-primary:hover { filter: brightness(1.1); } .btn-primary:active { transform: scale(.98); } .btn-primary:disabled { filter: grayscale(1); cursor: wait; }
.btn-ghost { min-height: 42px; padding: 0 18px; border: var(--hairline) solid var(--line-strong); background: var(--bg-sunken); color: var(--text); font: 700 var(--text-sm)/1 var(--font-display); letter-spacing: .16em; text-transform: uppercase; cursor: pointer; transition: border-color .2s, color .2s; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.picks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.pick { position: relative; display: grid; gap: 8px; padding: 8px; border: var(--hairline) solid var(--line); background: var(--bg-sunken); color: var(--text); cursor: pointer; text-align: left; transition: border-color .25s, transform .3s var(--ease); animation: fadeUp .5s var(--ease) both; }
.pick:nth-child(2) { animation-delay: .06s; } .pick:nth-child(3) { animation-delay: .12s; } .pick:nth-child(4) { animation-delay: .18s; } .pick:nth-child(n+5) { animation-delay: .24s; }
.pick:hover { border-color: var(--line-strong); transform: translateY(-3px); }
.pick.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 24px -8px var(--glow); }
.pick .art { position: relative; inset: auto; aspect-ratio: var(--box, 5 / 7); }
.pick .art .initials { font-size: 40px; }
.pick .cap { font: 600 var(--text-xs)/1.3 var(--font-display); letter-spacing: .1em; text-transform: uppercase; }
.pick small { font: 10px var(--font-mono); color: var(--text-dim); overflow-wrap: anywhere; }
.pick .tick { position: absolute; top: 44px; right: 18px; z-index: 2; width: 24px; height: 24px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 700; animation: pop .4s cubic-bezier(.2, .9, .3, 1.5) both; }
@keyframes pop { from { transform: scale(0) rotate(-90deg); } }
.drop { display: grid; place-items: center; gap: 8px; padding: var(--space-5); border: var(--hairline) dashed var(--line-strong); color: var(--text-dim); font: var(--text-sm) var(--font-mono); text-align: center; cursor: pointer; transition: border-color .3s, color .3s; }
.drop:hover, .drop.over, .drop:focus-visible { border-color: var(--accent); color: var(--accent); }
.drop-icon { font-size: 22px; line-height: 1; }
.drop input[type=url] { width: 100%; height: 34px; padding: 0 10px; border: var(--hairline) solid var(--line-strong); background: var(--bg); color: var(--text); font: var(--text-xs) var(--font-mono); cursor: text; }

/* Overview: chart beside Running now. */
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: var(--space-4); }
.now { display: grid; align-content: start; gap: var(--space-4); }
.now-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); }
.now-fn { font: 600 var(--text-xl) var(--font-mono); color: var(--syn-function); overflow-wrap: anywhere; }
.kv { display: flex; justify-content: space-between; gap: var(--space-2); font: var(--text-xs) var(--font-mono); color: var(--text-dim); margin-bottom: 6px; }
.kv b { color: var(--text); font-weight: 500; }
.rule { height: 1px; background: repeating-linear-gradient(90deg, var(--line-strong) 0 4px, transparent 4px 8px); }
.who { display: grid; gap: var(--space-2); }
.who div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); font-size: var(--text-sm); align-items: baseline; }
.who b { font: 500 var(--text-sm) var(--font-mono); color: var(--accent); }
.tag { margin-left: 6px; font: 600 9px/1.6 var(--font-display); text-transform: uppercase; letter-spacing: .12em; color: var(--text-dim); border: var(--hairline) solid var(--line-strong); padding: 0 5px; }

@media (max-width: 1000px) { .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) {
  .lib { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-3); }
  .lib-tools > div, .lib-tools .seg { width: 100%; }
  .lib-tools .seg { grid-auto-columns: minmax(0, 1fr); }
  .lib-tools .seg button { padding: 0 4px; letter-spacing: .04em; }
  .art .initials { font-size: 36px; }
  .card-face { grid-template-columns: 88px minmax(0, 1fr); }
  .drawer { padding: var(--space-4); }
}
