:root {
  color-scheme: dark;
  --bg: #11131a;
  --bg-deep: #090a0f;
  --panel: #181b25;
  --panel-raised: #202431;
  --panel-soft: #252938;
  --border: #303545;
  --border-bright: #42495e;
  --text: #f4f2e9;
  --muted: #a9adbb;
  --quiet: #7d8292;
  --lime: #b8f46d;
  --lime-deep: #87cb3e;
  --cyan: #51d7c7;
  --red: #ff6b6b;
  --shadow: 0 18px 55px rgb(0 0 0 / 28%);
  --radius: 18px;
  --radius-small: 11px;
  --sidebar: 250px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 82% -10%, rgb(81 215 199 / 8%), transparent 30rem),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
select,
a,
summary {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  color: inherit;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #10140c;
  background: var(--lime);
  font-weight: 800;
  transform: translateY(-160%);
  transition: transform 140ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 3px;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 27px 18px max(22px, env(safe-area-inset-bottom));
  border-right: 1px solid var(--border);
  background: rgb(12 14 20 / 78%);
  backdrop-filter: blur(20px);
}

.brand,
.mobile-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand {
  padding: 0 10px 28px;
}

.brand > span:last-child {
  display: flex;
  flex-direction: column;
  line-height: 1.02;
}

.brand strong,
.mobile-brand strong {
  font-size: 1rem;
  letter-spacing: -0.045em;
}

.brand small {
  margin-top: 4px;
  color: var(--quiet);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid rgb(184 244 109 / 24%);
  border-radius: 10px;
  color: #11150d;
  background: linear-gradient(135deg, var(--lime), var(--cyan));
  box-shadow: 0 7px 22px rgb(184 244 109 / 12%);
  font-size: 1rem;
  font-weight: 950;
  letter-spacing: -0.08em;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--quiet);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.library-nav {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.library-nav > .eyebrow {
  padding: 0 12px;
}

.nav-section-title {
  margin-top: 29px;
}

.nav-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 0.87rem;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover {
  color: var(--text);
  background: rgb(255 255 255 / 4%);
}

.nav-item.is-active {
  border-color: rgb(184 244 109 / 12%);
  color: var(--text);
  background: rgb(184 244 109 / 8%);
}

.nav-item.is-active > span:first-child {
  color: var(--lime);
}

.nav-item output {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 10px;
  color: var(--quiet);
  background: rgb(255 255 255 / 5%);
  font-size: 0.7rem;
  text-align: center;
}

.nav-link {
  text-decoration: none;
}

.nav-link > span:first-child {
  color: var(--cyan);
  font-weight: 900;
}

.sidebar-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: auto;
  padding: 15px 11px 3px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.sidebar-note div {
  display: flex;
  flex-direction: column;
}

.sidebar-note strong {
  color: var(--text);
}

.privacy-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 10px rgb(184 244 109 / 75%);
}

.page-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.site-intro {
  max-width: 980px;
  margin: clamp(42px, 7vw, 82px) auto 12px;
  padding: clamp(24px, 4vw, 40px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 92% 0%, rgb(81 215 199 / 9%), transparent 19rem),
    var(--panel);
}

.site-intro h2 {
  max-width: 700px;
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  line-height: 1.12;
  letter-spacing: -0.04em;
}

.site-intro > p:not(.eyebrow) {
  max-width: 720px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.intro-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.intro-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: rgb(255 255 255 / 3%);
  font-size: 0.79rem;
  font-weight: 750;
  text-decoration: none;
}

.intro-links a:hover {
  border-color: var(--border-bright);
  background: rgb(255 255 255 / 6%);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 126px;
  padding: 27px clamp(24px, 4vw, 64px) 21px;
  border-bottom: 1px solid var(--border);
}

.mobile-brand {
  display: none;
}

.topbar-copy {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.topbar-copy > p:last-child {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.button,
.icon-button,
.player-tool,
.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.button {
  gap: 7px;
  padding: 10px 17px;
  font-size: 0.85rem;
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.button-primary {
  color: #11150d;
  background: var(--lime);
  box-shadow: 0 7px 22px rgb(184 244 109 / 13%);
}

.button-primary:hover {
  background: #c8ff83;
}

.button-subtle,
.button-small {
  border-color: var(--border-bright);
  color: var(--text);
  background: var(--panel-raised);
}

.button-subtle:hover,
.button-small:hover {
  border-color: #596176;
  background: var(--panel-soft);
}

.button-danger {
  color: white;
  background: #bd3f4b;
}

.button-danger:hover {
  background: #d34a57;
}

.button-small {
  min-height: 44px;
  padding: 7px 12px;
  font-size: 0.76rem;
}

.icon-button {
  width: 44px;
  padding: 0;
  border-color: var(--border);
  color: var(--muted);
  background: var(--panel);
  font-size: 1rem;
}

.icon-button:hover {
  color: var(--text);
  border-color: var(--border-bright);
}

#main-content {
  flex: 1;
  width: 100%;
  max-width: 1640px;
  margin: 0 auto;
  padding: 24px clamp(24px, 4vw, 64px) 58px;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(210px, 420px) 200px auto;
  gap: 10px;
  margin-bottom: 18px;
}

.search-field,
.select-field {
  display: flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel);
}

.search-field:focus-within,
.select-field:focus-within {
  border-color: rgb(184 244 109 / 65%);
  box-shadow: 0 0 0 3px rgb(184 244 109 / 9%);
}

.search-field > span:not(.sr-only) {
  margin-left: 15px;
  color: var(--quiet);
}

.search-icon {
  position: relative;
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.search-icon::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 6px;
  height: 2px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: left center;
}

.search-field input,
.select-field select {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.search-field input {
  padding: 0 14px 1px 9px;
}

.search-field input::placeholder {
  color: var(--quiet);
}

.select-field select {
  padding: 0 34px 0 13px;
  cursor: pointer;
}

.mobile-filter {
  display: none;
}

.storage-banner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 15px;
  margin: 0 0 18px;
  padding: 13px 44px 13px 16px;
  border: 1px solid rgb(184 244 109 / 22%);
  border-radius: 12px;
  background: rgb(184 244 109 / 6%);
}

.storage-banner div {
  margin-right: auto;
}

.storage-banner strong {
  font-size: 0.82rem;
}

.storage-banner p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.update-banner {
  padding-right: 16px;
}

.dismiss-button,
.dialog-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
}

.dismiss-button {
  position: absolute;
  right: 2px;
}

.import-zone {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 66px;
  margin-bottom: 28px;
  padding: 11px 18px;
  border: 1px dashed var(--border-bright);
  border-radius: 13px;
  color: var(--muted);
  background: rgb(255 255 255 / 1.5%);
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.import-zone.is-dragging {
  border-color: var(--lime);
  background: rgb(184 244 109 / 8%);
  transform: scale(1.005);
}

.import-zone-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--lime);
  background: rgb(184 244 109 / 8%);
  font-size: 1.2rem;
}

.import-zone div {
  display: flex;
  flex-direction: column;
  font-size: 0.78rem;
}

.import-zone strong {
  color: var(--text);
  font-size: 0.82rem;
}

.results-heading {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin: 0 0 15px;
}

.results-heading h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.results-heading span {
  color: var(--quiet);
  font-size: 0.74rem;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 205px), 1fr));
  gap: clamp(14px, 2vw, 22px);
}

.game-card {
  position: relative;
  min-width: 0;
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--panel);
  box-shadow: 0 5px 18px rgb(0 0 0 / 9%);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.game-card:hover,
.game-card:focus-within {
  border-color: color-mix(in srgb, var(--game-accent) 42%, var(--border));
  box-shadow: 0 16px 35px rgb(0 0 0 / 20%);
  transform: translateY(-2px);
}

.game-cover {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 14px 14px 5px 5px;
  color: var(--text);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--game-accent) 18%, #161925), #11131a 66%);
  text-decoration: none;
}

.game-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background-image:
    linear-gradient(90deg, transparent 95%, var(--game-accent) 95%),
    linear-gradient(transparent 95%, var(--game-accent) 95%);
  background-size: 22px 22px;
  mask-image: linear-gradient(135deg, #000, transparent 70%);
}

.cover-glyph {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  min-width: 66px;
  height: 58px;
  padding: 0 13px;
  border: 2px solid color-mix(in srgb, var(--game-accent) 70%, white);
  border-radius: 13px 13px 9px 9px;
  color: color-mix(in srgb, var(--game-accent) 84%, white);
  background: rgb(8 9 13 / 72%);
  box-shadow: 7px 7px 0 rgb(0 0 0 / 18%);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.05em;
  transform: translate(-50%, -50%) rotate(-2deg);
}

.cover-glyph::before {
  content: "";
  position: absolute;
  top: -7px;
  width: 39px;
  height: 7px;
  border-radius: 4px 4px 0 0;
  background: var(--game-accent);
}

.cover-system {
  position: absolute;
  bottom: 10px;
  left: 11px;
  padding: 4px 7px;
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 6px;
  color: rgb(255 255 255 / 72%);
  background: rgb(7 8 12 / 68%);
  font-size: 0.59rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(5px);
}

.favorite-button {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 50%;
  color: rgb(255 255 255 / 68%);
  background: rgb(7 8 12 / 63%);
  font-size: 1.1rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.favorite-button[aria-pressed="true"] {
  color: var(--lime);
}

.game-card-body {
  padding: 13px 13px 12px;
}

.game-card-body h3 {
  overflow: hidden;
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-meta {
  display: flex;
  gap: 6px;
  margin: 5px 0 13px;
  color: var(--quiet);
  font-size: 0.68rem;
}

.game-meta span + span::before {
  content: "·";
  margin-right: 6px;
}

.game-card-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 7px;
}

.play-button {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 9px;
  color: #10120e;
  background: color-mix(in srgb, var(--game-accent) 78%, white);
  font-size: 0.75rem;
}

.card-menu {
  position: relative;
}

.card-menu summary {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--muted);
  background: var(--panel-raised);
  font-size: 1rem;
  font-weight: 800;
  list-style: none;
  cursor: pointer;
}

.card-menu summary::-webkit-details-marker {
  display: none;
}

.card-menu[open] summary {
  border-color: var(--border-bright);
}

.card-menu-popover {
  position: absolute;
  z-index: 20;
  right: 0;
  bottom: 47px;
  width: 168px;
  padding: 6px;
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  background: #252936;
  box-shadow: var(--shadow);
}

.card-menu-popover button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 0.76rem;
  text-align: left;
  cursor: pointer;
}

.card-menu-popover button:hover,
.card-menu-popover button:focus-visible {
  color: var(--text);
  background: rgb(255 255 255 / 6%);
}

.card-menu-popover .delete-action {
  color: #ff9a9a;
}

.empty-state,
.no-results {
  max-width: 600px;
  margin: clamp(18px, 5vh, 65px) auto;
  padding: 0 20px;
  text-align: center;
}

.empty-state h2,
.no-results h2 {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2.2rem);
  letter-spacing: -0.04em;
}

.empty-state > p:not(.eyebrow),
.no-results p {
  max-width: 470px;
  margin: 12px auto 20px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.empty-state .supported-copy {
  margin-top: 18px !important;
  color: var(--quiet) !important;
  font-size: 0.72rem !important;
}

.empty-art {
  position: relative;
  width: 172px;
  height: 135px;
  margin: 0 auto 13px;
}

.empty-cartridge {
  position: absolute;
  top: 12px;
  left: 39px;
  display: grid;
  place-items: center;
  width: 94px;
  height: 106px;
  border: 3px solid #454a58;
  border-radius: 10px 10px 17px 17px;
  color: var(--lime);
  background: #252936;
  box-shadow: 9px 9px 0 #090a0e;
  transform: rotate(-4deg);
}

.empty-cartridge::after {
  content: "";
  position: absolute;
  bottom: 11px;
  width: 49px;
  height: 9px;
  border-top: 3px solid #565c6e;
  border-bottom: 3px solid #565c6e;
}

.empty-cartridge i {
  position: absolute;
  top: -8px;
  width: 55px;
  height: 8px;
  border: 3px solid #454a58;
  border-bottom: 0;
  background: #252936;
}

.empty-cartridge b {
  display: grid;
  place-items: center;
  width: 56px;
  height: 48px;
  border: 2px solid rgb(184 244 109 / 35%);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  line-height: 1.25;
}

.pixel-star {
  position: absolute;
  color: var(--cyan);
}

.star-one { top: 4px; right: 8px; font-size: 1.25rem; }
.star-two { bottom: 21px; left: 6px; color: var(--lime); font-size: 2rem; }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(24px, 4vw, 64px) max(21px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  color: var(--quiet);
  font-size: 0.75rem;
}

.site-footer nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-footer nav > a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: none;
}

.site-footer nav > a:hover {
  color: var(--text);
}

.site-footer p {
  margin: 0;
}

.text-button,
.info-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 3px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  text-decoration: underline;
  text-decoration-color: rgb(169 173 187 / 35%);
  text-underline-offset: 3px;
  cursor: pointer;
}

.text-button:hover,
.info-links a:hover {
  color: var(--text);
}

.app-dialog {
  width: min(calc(100% - 28px), 470px);
  max-height: min(88dvh, 720px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border-bright);
  border-radius: 18px;
  color: var(--text);
  background: #1c1f2a;
  box-shadow: 0 30px 100px rgb(0 0 0 / 60%);
}

.app-dialog::backdrop {
  background: rgb(4 5 8 / 76%);
  backdrop-filter: blur(5px);
}

.app-dialog form {
  position: relative;
  padding: 27px;
}

.import-review-dialog {
  width: min(calc(100% - 28px), 760px);
}

.import-bulk-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 9px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgb(255 255 255 / 2%);
}

.import-bulk-controls .button {
  min-height: 46px;
}

.import-review-list {
  display: grid;
  gap: 8px;
  max-height: min(44dvh, 410px);
  padding-right: 3px;
  overflow: auto;
  overscroll-behavior: contain;
}

.import-review-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 230px);
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #171923;
}

.import-file-copy {
  min-width: 0;
}

.import-file-copy strong {
  display: block;
  overflow: hidden;
  font-size: 0.79rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-file-copy span {
  display: block;
  margin-top: 4px;
  color: var(--quiet);
  font-size: 0.68rem;
}

.import-system-select {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border-bright);
  border-radius: 9px;
  outline: 0;
  color: var(--text);
  background: #101219;
}

.import-system-select:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px rgb(184 244 109 / 10%);
}

.dialog-close {
  position: absolute;
  top: 7px;
  right: 7px;
}

.app-dialog h2 {
  margin: 0 42px 10px 0;
  font-size: 1.42rem;
  letter-spacing: -0.035em;
}

.app-dialog form > p:not(.eyebrow):not(.fine-print) {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.55;
}

.dialog-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.dialog-field input,
.dialog-field select {
  width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  outline: 0;
  color: var(--text);
  background: #12141b;
}

.dialog-field input:focus,
.dialog-field select:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px rgb(184 244 109 / 10%);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 25px;
}

.info-dialog {
  width: min(calc(100% - 28px), 570px);
}

.info-highlight {
  display: flex;
  gap: 12px;
  margin: 18px 0;
  padding: 13px 14px;
  border: 1px solid rgb(184 244 109 / 18%);
  border-radius: 11px;
  background: rgb(184 244 109 / 5%);
}

.info-highlight p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.info-highlight strong {
  color: var(--text);
}

.storage-stats {
  margin: 18px 0;
  border-top: 1px solid var(--border);
}

.storage-stats div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 1px;
  border-bottom: 1px solid var(--border);
  font-size: 0.76rem;
}

.storage-stats dt {
  color: var(--muted);
}

.storage-stats dd {
  margin: 0;
  color: var(--text);
  font-weight: 700;
  text-align: right;
}

.firmware-panel {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgb(255 255 255 / 2%);
}

.firmware-panel > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.firmware-panel h3 {
  margin: 0;
  font-size: 0.84rem;
}

.firmware-panel h3 span {
  margin-left: 5px;
  color: var(--quiet);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
}

.firmware-panel p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.firmware-panel #ps1-bios-status {
  margin: 0;
  color: var(--text);
  font-weight: 700;
  text-align: right;
}

.firmware-actions {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 12px;
}

.software-panel {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgb(255 255 255 / 2%);
}

.software-panel h3 {
  margin: 0;
  font-size: 0.84rem;
}

.software-panel p {
  margin: 7px 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.software-panel a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--lime);
  font-size: 0.72rem;
  font-weight: 750;
  text-underline-offset: 3px;
}

.fine-print {
  color: var(--quiet);
  font-size: 0.7rem;
  line-height: 1.55;
}

.info-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 13px;
  margin-top: 14px;
  font-size: 0.7rem;
}

.mobile-system-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 18px 0;
}

.mobile-sort-field {
  margin-top: 18px;
}

.mobile-system-filters button {
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--muted);
  background: var(--panel);
  cursor: pointer;
}

.mobile-system-filters button.is-active {
  border-color: var(--lime);
  color: var(--text);
  background: rgb(184 244 109 / 8%);
}

.favorite-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.82rem;
}

.favorite-toggle input {
  width: 19px;
  height: 19px;
  accent-color: var(--lime);
}

.import-progress {
  position: fixed;
  z-index: 80;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 12px));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: calc(100% - 30px);
  padding: 12px 17px;
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  background: #272b38;
  box-shadow: var(--shadow);
  font-size: 0.8rem;
  transform: translateX(-50%);
}

.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid rgb(255 255 255 / 20%);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast-region {
  position: fixed;
  z-index: 100;
  top: auto;
  right: 18px;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px));
  display: grid;
  gap: 8px;
  width: min(370px, calc(100% - 36px));
  pointer-events: none;
}

.toast {
  padding: 12px 15px;
  border: 1px solid var(--border-bright);
  border-left: 3px solid var(--lime);
  border-radius: 10px;
  color: var(--text);
  background: #292d3a;
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  line-height: 1.45;
  animation: toast-in 170ms ease-out;
}

.toast.is-error {
  border-left-color: var(--red);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
}

@media (max-width: 920px) {
  html {
    scroll-padding-top: 88px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    min-height: 72px;
    padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left));
    background: rgb(17 19 26 / 90%);
    backdrop-filter: blur(18px);
  }

  .mobile-brand {
    display: inline-flex;
  }

  .topbar-copy {
    display: none;
  }

  #main-content {
    padding: 20px 20px 48px;
  }

  .filter-bar {
    grid-template-columns: minmax(0, 1fr) 155px auto;
  }

  .mobile-filter {
    display: inline-flex;
  }

  .site-footer {
    padding-right: 20px;
    padding-left: 20px;
  }

}

@media (max-width: 620px) {
  .topbar {
    gap: 12px;
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  #import-button {
    width: 44px;
    padding: 0;
  }

  .install-button {
    width: 44px;
    padding: 0;
  }

  #import-button .button-label,
  .install-button .button-label {
    display: none;
  }

  #main-content {
    padding: 15px 14px 48px;
  }

  .filter-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    margin-bottom: 13px;
  }

  .select-field {
    display: none;
  }

  .mobile-filter {
    padding: 9px 13px;
  }

  .storage-banner {
    align-items: flex-start;
    flex-direction: column;
    padding-right: 44px;
  }

  .import-zone {
    display: none;
  }

  .results-heading {
    margin-top: 6px;
  }

  .game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
  }

  .game-card-body {
    padding: 10px;
  }

  .game-card-body h3 {
    font-size: 0.875rem;
  }

  .game-meta {
    display: block;
    margin: 4px 0 10px;
    font-size: 0.7rem;
  }

  .game-meta span:nth-child(2) {
    display: none;
  }

  .game-meta span + span::before {
    content: none;
  }

  .game-cover {
    aspect-ratio: 1.2;
  }

  .cover-glyph {
    min-width: 55px;
    height: 48px;
  }

  .cover-system {
    right: 8px;
    bottom: 7px;
    left: auto;
    max-width: calc(100% - 16px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .favorite-button {
    top: 6px;
    right: 6px;
    width: 44px;
    height: 44px;
  }

  .play-button {
    padding: 7px 8px;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 14px max(21px, env(safe-area-inset-bottom));
  }

  .site-footer nav {
    align-items: flex-start;
    flex-direction: column;
    gap: 0;
  }

  .site-intro {
    margin-top: 38px;
    padding: 22px 18px;
  }

  .intro-links {
    align-items: stretch;
    flex-direction: column;
  }

  .toast-region {
    top: auto;
    right: 12px;
    bottom: max(14px, calc(env(safe-area-inset-bottom) + 10px));
    width: calc(100% - 24px);
  }

  .app-dialog form {
    padding: 24px 20px max(23px, env(safe-area-inset-bottom));
  }

  .import-review-dialog {
    width: calc(100% - 16px);
    max-height: 94dvh;
  }

  .import-review-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .import-bulk-controls {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .import-review-list {
    max-height: 32dvh;
  }

  .import-review-dialog .dialog-actions {
    align-items: center;
    flex-direction: row;
  }

  .import-review-dialog .dialog-actions .button {
    width: auto;
  }

  .import-review-dialog .dialog-actions .button-primary {
    flex: 1;
  }

  .firmware-panel > div:first-child {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .firmware-panel #ps1-bios-status {
    text-align: left;
  }

  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-actions .button {
    width: 100%;
  }
}

@media (max-width: 355px) {
  .mobile-brand strong {
    display: none;
  }

  .game-grid {
    grid-template-columns: 1fr;
  }

  .game-cover {
    aspect-ratio: 16 / 8.8;
  }
}

@media (hover: none) {
  .game-card:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .privacy-dot,
  .brand-mark i {
    forced-color-adjust: none;
  }

  .game-cover::before {
    display: none;
  }
}
