@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/ibm-plex-sans-latin-wght-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4-latin-wght-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f5f3ed;
  --ink: #191919;
  --secondary-ink: #686762;
  --rule: #d0cec5;
  --vermilion: #c84024;
  --link-ink: #a32f18;
  --surface: #eae7de;
  --sans: "IBM Plex Sans", Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --mono: "IBM Plex Mono", monospace;
  --margin: 1rem;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); color: var(--ink); font-family: var(--sans); }
body { margin: 0; min-width: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; text-decoration-thickness: .08em; text-underline-offset: .18em; }
a:hover { color: var(--link-ink); }
:focus-visible { outline: 3px solid var(--link-ink); outline-offset: 3px; }
.container { width: min(calc(100% - 2 * var(--margin)), 90rem); margin-inline: auto; }
.skip-link { position: absolute; z-index: 10; top: .5rem; left: .5rem; padding: .75rem; background: var(--ink); color: var(--paper); transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.catalogue-label, .list-heading, .library-footer, .capacity-top {
  font: 400 .75rem/1.4 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.accent { color: var(--vermilion); }
h1, h2, h3, p { margin-top: 0; }
.access-status { border-top: 2px solid var(--ink); padding: 1.5rem 0 4rem; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(19rem, .8fr); gap: clamp(2rem, 4vw, 4rem); align-items: start; padding: 2rem 0 5rem; }
.library, .summary { min-width: 0; border-top: 2px solid var(--ink); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding: 1.5rem 0; }
h1, h2 { margin-bottom: 0; font-size: clamp(1.75rem, 2.5vw, 2.25rem); line-height: 1.1; letter-spacing: -.035em; }
.catalogue-label { margin: 0; color: var(--secondary-ink); text-align: right; letter-spacing: .03em; }
.catalogue-label span { color: var(--ink); font-size: 1rem; }
.search-wrap label, .genre-control label, .sort-control label, .save-form label { display: block; font-size: .875rem; font-weight: 600; }
.search-wrap label { margin-bottom: .5rem; }
.search-field { display: flex; align-items: center; gap: .5rem; min-height: 3rem; padding-right: .75rem; border: 1px solid var(--ink); }
.search-field:focus-within { outline: 3px solid var(--link-ink); outline-offset: 3px; }
.search-field input { flex: 1; width: 100%; min-width: 0; min-height: 2.9rem; padding: .7rem .85rem; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 1rem; }
.search-field input::placeholder { color: var(--secondary-ink); opacity: 1; }
kbd { padding: .1rem .4rem; border: 1px solid var(--rule); color: var(--secondary-ink); font: .75rem var(--mono); }
.library-controls { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 1rem; padding: 1.5rem 0; }
.filters { display: flex; flex-wrap: wrap; gap: .4rem; }
.filter { min-height: 2.75rem; padding: .55rem .8rem; border: 1px solid var(--ink); background: transparent; color: var(--ink); font-size: .875rem; font-weight: 500; }
.filter:hover { text-decoration: underline; text-underline-offset: .2em; }
.filter.active { background: var(--ink); color: var(--paper); }
.genre-control { display: flex; align-items: center; gap: .6rem; }
select, .save-form input { min-height: 2.75rem; max-width: 100%; padding: .55rem .7rem; border: 1px solid var(--ink); border-radius: 0; background: var(--paper); color: var(--ink); font-size: .875rem; }
.list-heading { display: flex; align-items: center; gap: 1rem; min-height: 3.5rem; padding: .5rem 0; border-block: 1px solid var(--ink); color: var(--secondary-ink); }
.sort-control { display: flex; align-items: center; gap: .5rem; margin-left: auto; font: .875rem var(--sans); letter-spacing: 0; text-transform: none; }
.sort-control select { max-width: 12rem; }
.size-label { min-width: 6rem; text-align: center; }
.games { max-height: 42rem; overflow: auto; overscroll-behavior: contain; }
.game-row { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) auto 2.75rem; align-items: center; gap: .8rem; min-height: 5rem; padding: .75rem 0; border-bottom: 1px solid var(--rule); }
.game-row:hover { background: var(--surface); }
.game-icon { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 1px solid var(--rule); color: var(--link-ink); font: 400 1.2rem var(--serif); }
.game-title { overflow-wrap: anywhere; font-size: 1rem; font-weight: 600; line-height: 1.3; }
.game-sub { margin-top: .25rem; color: var(--secondary-ink); font-size: .8125rem; line-height: 1.4; }
.game-size { color: var(--secondary-ink); font: .8125rem var(--mono); white-space: nowrap; }
.add, .collection-remove { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0; border: 1px solid var(--ink); border-radius: 0; background: transparent; color: var(--ink); font-size: 1.4rem; line-height: 1; }
.add:hover:not(:disabled), .collection-remove:hover:not(:disabled) { background: var(--surface); }
.add.selected { background: var(--ink); color: var(--paper); }
.empty { padding: 2.5rem 0; color: var(--secondary-ink); line-height: 1.5; }
.empty strong { display: block; color: var(--ink); }
.library-footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem 0; color: var(--secondary-ink); letter-spacing: .03em; }
.summary { padding-top: 1.5rem; }
.summary-top { margin-bottom: 2rem; }
.capacity { padding: 1.25rem; background: var(--surface); }
.capacity-top { color: var(--secondary-ink); }
.capacity-bottom { display: flex; align-items: end; gap: 1rem; margin-top: .75rem; }
.capacity-bottom strong { font-size: clamp(2.75rem, 4vw, 4rem); font-weight: 600; letter-spacing: -.055em; line-height: .95; }
.capacity-bottom span { padding-bottom: .15rem; color: var(--secondary-ink); font-size: .8125rem; line-height: 1.25; }
.meter { height: .65rem; margin-top: 1.25rem; background: var(--rule); }
.meter span { display: block; height: 100%; background: var(--ink); transition: width .2s; }
.meter.over span { background: var(--vermilion); }
.remaining { margin: .6rem 0 0; font: .8125rem/1.4 var(--mono); }
.breakdown { padding: 1.25rem 0; }
.breakdown > div { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; font-size: .875rem; }
.breakdown strong, .collection-game-size { font: .8125rem var(--mono); white-space: nowrap; }
.breakdown small { margin-left: .2rem; color: var(--secondary-ink); font: .75rem var(--mono); }
.legend { display: inline-block; width: .55rem; height: .55rem; margin-right: .6rem; border: 1px solid var(--ink); }
.rom { background: var(--ink); }
.save { background: var(--vermilion); border-color: var(--vermilion); }
.overhead { background: var(--rule); border-color: var(--rule); }
.collection-games { padding: 1.25rem 0; border-top: 1px solid var(--ink); }
.collection-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.collection-heading h3 { margin-bottom: 0; font-size: 1rem; }
.collection-heading > span { color: var(--secondary-ink); font: .8125rem var(--mono); }
.collection-games-list { max-height: 18rem; overflow: auto; overscroll-behavior: contain; }
.collection-empty { margin: 0; color: var(--secondary-ink); font: 1rem/1.5 var(--serif); }
.collection-game { display: flex; align-items: center; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--rule); }
.collection-game-details { display: flex; flex: 1; align-items: baseline; justify-content: space-between; min-width: 0; gap: .5rem; }
.collection-game-title { overflow-wrap: anywhere; font-size: .875rem; font-weight: 600; line-height: 1.4; }
.collection-game-size { color: var(--secondary-ink); }
.collection-remove { flex: 0 0 2.75rem; }
.notice { display: flex; gap: .75rem; margin: 0 0 1rem; padding: 1rem; border-left: 3px solid var(--link-ink); background: var(--surface); font-size: .875rem; line-height: 1.45; }
.notice-icon { color: var(--link-ink); font-weight: 700; }
.notice p { margin: .25rem 0 0; }
.clear, .export-games, .save-form button { width: 100%; min-height: 2.75rem; padding: .7rem .85rem; border: 1px solid var(--ink); border-radius: 0; font-weight: 600; text-align: left; }
.clear { margin-bottom: .75rem; background: transparent; color: var(--ink); }
.clear span, .export-games span { float: right; }
.export-games, .save-form button { background: var(--ink); color: var(--paper); }
.clear:hover:not(:disabled), .export-games:hover, .save-form button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: .2em; }
.save-form { display: grid; gap: .5rem; margin-top: .5rem; padding-top: 1.25rem; border-top: 1px solid var(--ink); }
.save-form input { width: 100%; font-size: 1rem; }
.save-form p { min-height: 1.4em; margin: .25rem 0 0; color: var(--secondary-ink); font-size: .875rem; line-height: 1.4; }
@media (min-width: 600px) { :root { --margin: 1.5rem; } }
@media (min-width: 960px) { :root { --margin: 2rem; } }
@media (min-width: 1200px) { :root { --margin: 3rem; } }
@media (max-width: 800px) {
  .workspace { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .section-head { align-items: start; }
  .library-controls { align-items: stretch; flex-direction: column; }
  .genre-control { justify-content: space-between; }
  .sort-control { gap: .3rem; }
  .sort-control select { max-width: 9rem; }
  .size-label { display: none; }
  .game-row { grid-template-columns: minmax(0, 1fr) auto 2.75rem; gap: .5rem; }
  .game-icon { display: none; }
}
@media (prefers-reduced-motion: reduce) { .meter span { transition: none; } }
