@font-face {
  font-family: "Press Start 2P";
  src: url("../fonts/press-start-2p-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Silkscreen";
  src: url("../fonts/silkscreen-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Silkscreen";
  src: url("../fonts/silkscreen-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f3eeff;
  --fg: #0d0b1a;
  --muted: #5b5480;
  --accent: #d6186e;
  --on-accent: #fff;
  --surface: #ffffff;
  --line: #0d0b1a;
  --cover-bg: #e4dcff;
  --cta: #ffe600;
  --on-cta: #0d0b1a;
  --error: #b00030;
  --dots: rgba(13, 11, 26, .08);
  --display: "Press Start 2P", "Bricolage Grotesque", system-ui, sans-serif;
  --pixel: "Silkscreen", system-ui, sans-serif;
  --title: #0d0b1a;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0b1a;
  --fg: #f4f1ff;
  --muted: #9d94c7;
  --accent: #ff2e88;
  --on-accent: #0d0b1a;
  --surface: #1b1733;
  --line: #ffe600;
  --cover-bg: #241f42;
  --error: #ff6b9a;
  --dots: rgba(255, 230, 0, .08);
  --title: #ffe600;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0b1a;
    --fg: #f4f1ff;
    --muted: #9d94c7;
    --accent: #ff2e88;
    --on-accent: #0d0b1a;
    --surface: #1b1733;
    --line: #ffe600;
    --cover-bg: #241f42;
    --error: #ff6b9a;
    --dots: rgba(255, 230, 0, .08);
    --title: #ffe600;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.site-header, main, .site-footer, .filters {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
.site-header { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding-bottom: 8px; }
.site-header h1, .player-bar h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.site-header h1 { font-size: clamp(1.6rem, 6vw, 2.6rem); line-height: 1.15; }
.site-header p { flex-basis: 100%; order: 3; margin: 0; color: var(--muted); }
.empty { color: var(--muted); }

.theme-toggle {
  flex: none;
  white-space: nowrap;
  margin-left: auto;
  font: inherit;
  font-size: .85rem;
  padding: 6px 12px;
  border: 2px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
}
.theme-toggle[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); color: var(--bg); }

/* Buttons */
.site-header .btn-cta { order: 4; margin-top: 12px; }
.btn {
  font: inherit;
  font-family: var(--display);
  font-weight: 700;
  padding: 10px 18px;
  border: 2px solid var(--line);
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-cta {
  display: block;
  width: 100%;
  padding: 14px 18px;
  font-size: 1.15rem;
  background: var(--cta);
  color: var(--on-cta);
  border-color: var(--line);
  box-shadow: 4px 4px 0 var(--line);
  transition: transform .1s, box-shadow .1s;
}
.btn-cta:hover:not(:disabled), .btn-cta:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--line); }

/* Filters */
.filters { padding-top: 8px; padding-bottom: 0; display: grid; gap: 12px; align-content: start; min-height: 116px; }
#catalog { min-height: 60vh; }
.search {
  width: 100%;
  font: inherit;
  padding: 11px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
}
.search::placeholder { color: var(--muted); }
.sort-control { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.sort-select {
  max-width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
}
.chips {
  display: flex;
  gap: 8px;
  margin: 0 -16px;
  padding: 2px 16px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  font: inherit;
  font-size: .9rem;
  padding: 6px 14px;
  border: 2px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.clear-filters {
  justify-self: start;
  font: inherit;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
}
.results-count { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }

/* Catalog */
.grid {
  display: grid;
  gap: 20px 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.card {
  --tile: #3a5bff;
  position: relative;
  color: inherit;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 4px;
  box-shadow: 5px 5px 0 var(--accent);
  overflow: hidden;
  transition: transform .1s, box-shadow .1s;
}
.card:hover { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--accent); }
.card-open { display: flex; flex-direction: column; height: 100%; color: inherit; text-decoration: none; }
.card-open:focus-visible { outline-offset: 5px; }
.favorite-button {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--fg);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.favorite-button.is-favorite { color: #c12856; }
.favorite-button:focus-visible { z-index: 1; }
.storage-status { margin: 0 0 12px; color: var(--error); font-size: .9rem; }
.card-cover {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--cover-bg);
  border-bottom: 2px solid var(--line);
}
.card-cover.no-cover { background: var(--tile); }
.card-body { display: flex; flex-direction: column; flex: 1; gap: 6px; padding: 10px 12px 12px; }
.card-title { margin: 0; font-family: var(--display); font-weight: 700; font-size: 1.1rem; line-height: 1.2; }
.card-desc {
  margin: 0;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: auto 0 0; padding: 0; list-style: none; }
.tag { font-size: .75rem; padding: 1px 8px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); }
.card-record { margin: 0; font-size: .85rem; font-weight: 700; }

/* Player */
.player-page { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.player-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 2px solid var(--line); }
.player-bar .theme-toggle { padding: 6px 10px; }
.player-bar h1 { font-size: 1.05rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back {
  flex: none;
  padding: 6px 10px;
  border: 2px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.stage { flex: 1; min-height: 0; max-width: none; margin: 0; padding: 0; }
.game-frame { display: block; width: 100%; height: 100%; border: 0; }

/* Data page */
.panel {
  margin: 16px 0;
  padding: 16px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 14px;
}
.panel h2 { margin: 0 0 8px; font-family: var(--display); font-size: 1.2rem; }
.panel p { margin: 0 0 12px; }
.status { min-height: 1.5em; font-weight: 700; }
.status.error { color: var(--error); }

/* Footer */
.site-footer { display: flex; gap: 16px; color: var(--muted); }

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 24px 20px; }
  .btn-cta { width: auto; display: inline-block; }
  .filters { grid-template-columns: 1fr; }
  .chips { margin: 0; padding: 2px 0 6px; flex-wrap: wrap; overflow: visible; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .btn-cta { transition: none; }
}

/* Comic-book finish */
body {
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(to bottom, transparent 0 3px, rgba(0, 0, 0, .05) 3px 4px),
    radial-gradient(var(--dots) .8px, transparent .8px);
  background-size: auto, 14px 14px;
}
.site-header {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin-top: 18px;
  padding: 22px 20px 18px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg);
  box-shadow: 7px 7px 0 var(--accent);
}
.site-header::before {
  position: absolute;
  z-index: -1;
  top: -18px;
  right: -10px;
  width: 150px;
  height: 120px;
  background-image: radial-gradient(var(--line) 1.5px, transparent 1.5px);
  background-size: 12px 12px;
  content: "";
  opacity: .16;
  transform: rotate(-8deg);
}
.site-header h1 { color: var(--title); text-shadow: 3px 3px 0 var(--accent); }
.site-header .btn-cta { border-color: var(--fg); }
.site-header p { max-width: 30ch; font-weight: 650; color: var(--fg); }
.btn-cta {
  border-width: 3px;
  border-radius: 4px;
  box-shadow: 5px 5px 0 var(--accent);
  text-transform: uppercase;
  letter-spacing: .035em;
}
.btn-cta:hover:not(:disabled), .btn-cta:active:not(:disabled) {
  box-shadow: 2px 2px 0 var(--line);
}
.filters { gap: 14px; }
.search, .sort-select, .clear-filters {
  border-width: 2px;
  border-radius: 6px;
  box-shadow: 3px 3px 0 var(--line);
}
.search { min-height: 48px; }
.chips { padding-top: 5px; padding-bottom: 9px; }
.chip {
  min-height: 42px;
  border-radius: 6px;
  box-shadow: 2px 2px 0 var(--line);
  font-weight: 650;
}
.chip[aria-pressed="true"] { box-shadow: 1px 1px 0 var(--line); }
.results-count {
  display: inline-block;
  padding: 5px 10px;
  border: 2px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--fg);
  font-weight: 700;
  transform: rotate(-1deg);
}
.grid { gap: 22px 18px; }
.card {
  border-width: 3px;
  border-radius: 4px;
  box-shadow: 6px 6px 0 var(--line), 9px 9px 0 var(--accent);
}
.card:hover {
  transform: translate(3px, 3px) rotate(-.4deg);
  box-shadow: 3px 3px 0 var(--line), 6px 6px 0 var(--tile);
}
.card:focus-within { outline: 3px solid var(--accent); outline-offset: 4px; }
.card:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--line), 4px 4px 0 var(--tile); }
.card-open:focus-visible { outline: none; }
.card-cover { border-bottom-width: 3px; }
.card-title { font-size: 1.15rem; }
.tag {
  font-family: var(--pixel);
  border-width: 2px;
  border-radius: 4px;
  color: var(--fg);
  font-weight: 650;
}
.favorite-button {
  top: 9px;
  right: 9px;
  width: 42px;
  height: 42px;
  border-width: 3px;
  border-radius: 6px;
  box-shadow: 3px 3px 0 var(--line);
  background: var(--cta);
}
.favorite-button.is-favorite { color: var(--accent); }
.favorite-button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.site-footer { padding-top: 24px; padding-bottom: 24px; }
.site-footer a { font-weight: 700; }
.player-bar {
  border-bottom: 3px solid var(--line);
  background: var(--cta);
  box-shadow: 0 4px 0 var(--line);
}
.back, .player-bar .theme-toggle {
  border-width: 2px;
  border-radius: 6px;
  box-shadow: 2px 2px 0 var(--line);
}
.panel {
  border-width: 3px;
  border-radius: 7px;
  box-shadow: 5px 5px 0 var(--line);
}

@media (max-width: 639px) {
  .site-header { margin: 14px 12px 0; padding: 18px 16px 16px; }
  .site-header h1 { font-size: clamp(1.4rem, 7.5vw, 2rem); }
  .site-header .btn-cta { width: 100%; }
  .filters, #catalog { padding-left: 14px; padding-right: 14px; }
  .chips { margin-left: -14px; margin-right: -14px; padding-left: 14px; padding-right: 14px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
  .card { box-shadow: 4px 4px 0 var(--line), 6px 6px 0 var(--tile); }
  .card-body { padding: 9px 9px 11px; }
  .card-title { font-size: 1rem; }
  .card-desc { font-size: .82rem; }
  .favorite-button { top: 6px; right: 6px; width: 38px; height: 38px; }
}
@media (max-width: 340px) {
  .grid { grid-template-columns: 1fr; }
}


.card-guide {
  display: block;
  margin: 0 10px 12px;
  padding: 7px 10px;
  border: 2px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  color: var(--fg);
  font-size: .85rem;
  font-weight: 750;
  text-align: center;
  text-decoration: none;
  box-shadow: 2px 2px 0 var(--line);
}
.card-guide:hover { background: var(--cta); }
.card-guide:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--line); }

.filter-selects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.select-filter {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
}
.card-meta {
  font-family: var(--pixel);
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 650;
}
@media (max-width: 420px) {
  .filter-selects { grid-template-columns: 1fr; }
}
