:root {
  color-scheme: dark;
  --bg: #111319;
  --panel: #1a1d26;
  --panel-2: #212530;
  --line: #333845;
  --line-soft: #282d38;
  --text: #f4f2e8;
  --muted: #a8adba;
  --accent: #ffcc33;
  --accent-2: #f45b43;
  --cyan: #47c7c5;
  --green: #65d77b;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(0deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px) 0 0 / 28px 28px,
    radial-gradient(circle at 30% 0%, rgba(244, 91, 67, 0.18), transparent 30rem),
    #111319;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

:where(a, button, input, [tabindex]):focus-visible {
  outline: 3px solid rgba(255, 204, 51, 0.92);
  outline-offset: 3px;
}

.app-shell {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar,
.layout,
.panel-head,
.hero-strip,
.top-actions,
.quickbar,
.section-title,
.section-bar,
.gamepad-status,
.cheat-row,
.button,
.search-wrap,
.tabs {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-link {
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(255, 204, 51, 0.82);
  background: #08090d;
  border-radius: 999px;
  overflow: hidden;
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.35),
    0 8px 20px rgba(0, 0, 0, 0.35);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand h1 {
  font-size: 24px;
  letter-spacing: 0;
}

.brand p,
.panel-head p,
.active-meta,
.empty-state p {
  color: var(--muted);
}

.top-actions {
  gap: 10px;
}

.layout {
  align-items: stretch;
  gap: 16px;
  min-height: calc(100vh - 100px);
}

.library-panel,
.control-panel,
.play-panel {
  background: color-mix(in srgb, var(--panel) 92%, black);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.library-panel,
.control-panel {
  width: 330px;
  min-width: 270px;
  padding: 14px;
  overflow: hidden;
}

.play-panel {
  flex: 1;
  min-width: 0;
  padding: 14px;
}

.layout.home-mode {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
}

.layout.home-mode .library-panel {
  grid-column: 2;
  width: 100%;
}

.layout.home-mode .play-panel {
  grid-column: 1;
  grid-row: 1;
}

.layout.home-mode .control-panel,
.layout.home-mode .screen-shell,
.layout.home-mode .quickbar {
  display: none;
}

.layout.play-mode .library-panel,
.layout.play-mode .home-dashboard,
.layout.play-mode .spotlight-section {
  display: none;
}

.layout.play-mode .play-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.layout.play-mode .control-panel {
  width: 360px;
}

body[data-page="library"] #launchBtn,
body[data-page="library"] .file-pick,
body[data-page="library"] #fullscreenBtn,
body[data-page="library"] .hero-strip,
body[data-page="favorites"] .file-pick,
body[data-page="favorites"] #fullscreenBtn,
body[data-page="favorites"] #playViewBtn,
body[data-page="game"] .hero-recent,
body[data-page="game"] #launchBtn,
body[data-page="game"] #playViewBtn,
.page-library #launchBtn,
.page-library .file-pick,
.page-library #fullscreenBtn,
.page-library .hero-strip,
.page-game .hero-recent,
.page-game #launchBtn,
.page-game #playViewBtn {
  display: none;
}

.panel-head,
.hero-strip {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.runtime-notice {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(244, 91, 67, 0.45);
  background: rgba(244, 91, 67, 0.12);
  color: var(--text);
  border-radius: 6px;
  line-height: 1.45;
}

.runtime-notice code {
  color: var(--accent);
}

.panel-head h2,
.section-title h2 {
  font-size: 16px;
}

.button {
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
  border-radius: 6px;
  text-decoration: none;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.button:hover {
  border-color: #6f7582;
  transform: translateY(-1px);
}

.button:focus-visible,
.tab:focus-visible,
.game-index-row:focus-visible,
.spotlight-card:focus-visible,
.category-card:focus-visible,
.recent-card:focus-visible,
.related-card:focus-visible,
.map-button:focus-visible,
.favorite-toggle:focus-visible,
.toggle-button:focus-visible,
.switch:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 204, 51, 0.16);
}

.button:active {
  transform: translateY(0);
}

.button.primary {
  min-width: 132px;
  border-color: #d6981a;
  background: linear-gradient(180deg, #ffd451, #e59a16);
  color: #15110a;
  font-weight: 800;
}

.button.secondary {
  background: #242936;
}

.mode-button.active,
.toggle-button.active {
  border-color: rgba(255, 204, 51, 0.76);
  background: rgba(255, 204, 51, 0.14);
  color: var(--accent);
}

.icon-button {
  width: 42px;
  padding: 0;
}

.button svg,
.section-title svg,
.search-wrap svg {
  width: 18px;
  height: 18px;
}

.file-pick {
  position: relative;
  overflow: hidden;
}

.file-pick input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.search-wrap {
  gap: 8px;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: #11141b;
  border-radius: 6px;
}

.search-wrap input,
.cheat-form input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-wrap input::placeholder,
.cheat-form input::placeholder {
  color: #7f8693;
}

.tabs {
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.ip-tag-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0 12px;
}

.ip-tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid #3b4250;
  background: #151922;
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
}

.ip-tag:hover,
.ip-tag.active,
.ip-tag:focus-visible {
  border-color: rgba(255, 204, 51, 0.68);
  background: rgba(255, 204, 51, 0.1);
  color: var(--text);
}

.tab {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #151922;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
}

.tab.active {
  border-color: rgba(71, 199, 197, 0.7);
  background: rgba(71, 199, 197, 0.12);
  color: var(--text);
}

.game-list {
  display: grid;
  gap: 5px;
  max-height: calc(100vh - 245px);
  overflow: auto;
  padding-right: 4px;
}

.game-index-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-soft);
  background: #151922;
  color: var(--text);
  text-align: left;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  scroll-margin: 18px;
}

.game-index-row:hover,
.game-index-row.active {
  border-color: rgba(255, 204, 51, 0.75);
  background: #202531;
}

.game-index-num {
  display: grid;
  place-items: center;
  width: 28px;
  min-height: 28px;
  color: var(--accent);
  background: #202632;
  border: 1px solid #353c4a;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 800;
}

.game-index-main {
  min-width: 0;
}

.game-index-main .game-name,
.game-index-main .game-desc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-cover,
.active-cover-art,
.spotlight-cover {
  display: grid;
  place-items: center;
  border: 1px solid #4a5060;
  background:
    linear-gradient(45deg, rgba(255, 204, 51, 0.95) 0 22%, transparent 22% 35%, rgba(244, 91, 67, 0.95) 35% 57%, transparent 57%),
    #242936;
  color: #111319;
  font-weight: 900;
  overflow: hidden;
}

.game-cover {
  width: 46px;
  height: 46px;
  font-size: 18px;
}

.cover-image {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 12px 12px,
    linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 12px 12px,
    #090c12;
}

.cover-image img {
  width: calc(100% - 2px);
  height: calc(100% - 2px);
  object-fit: contain;
}

.cover-fallback img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-missing::before {
  content: attr(data-fallback);
  color: #111319;
}

.game-name {
  overflow-wrap: anywhere;
  font-weight: 750;
  line-height: 1.25;
}

.game-desc {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.list-more {
  padding: 10px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.tag {
  border: 1px solid #505867;
  color: var(--muted);
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.hero-strip {
  min-height: 132px;
  padding: 16px;
  background:
    linear-gradient(90deg, rgba(255, 204, 51, 0.16), transparent 38%),
    linear-gradient(135deg, #222835, #171b24);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.active-cover {
  flex: 0 0 auto;
}

.active-cover-art {
  width: 92px;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  color: var(--accent);
  font-size: 34px;
}

.active-info {
  flex: 1;
  min-width: 0;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.active-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-top: 8px;
}

.active-title-row h2 {
  min-width: 0;
  margin: 0;
}

.hero-strip h2 {
  margin-top: 8px;
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.active-title-row .favorite-toggle + h2,
.active-title-row h2 {
  margin-top: 0;
}

.favorite-toggle {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 204, 51, 0.4);
  background: rgba(255, 204, 51, 0.08);
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
}

.favorite-toggle:hover,
.favorite-toggle.active {
  border-color: rgba(255, 204, 51, 0.86);
  background: rgba(255, 204, 51, 0.16);
  color: var(--accent);
}

.favorite-toggle svg {
  width: 21px;
  height: 21px;
  fill: transparent;
}

.favorite-toggle.active svg {
  fill: currentColor;
}

.system-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid rgba(71, 199, 197, 0.65);
  color: var(--cyan);
  background: rgba(71, 199, 197, 0.1);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 800;
}

.cheat-badge {
  border-color: rgba(101, 215, 123, 0.65);
  color: var(--green);
  background: rgba(101, 215, 123, 0.1);
}

.home-dashboard {
  display: block;
  margin-bottom: 12px;
}

.category-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.category-card {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  border: 1px solid var(--line-soft);
  background: #151922;
  color: var(--text);
  border-radius: 999px;
  padding: 0 10px;
  text-align: center;
  cursor: pointer;
}

.category-card:hover,
.category-card.active {
  border-color: rgba(71, 199, 197, 0.7);
  background: #1d2430;
}

.category-card span,
.category-card strong {
  display: inline-flex;
  align-items: center;
}

.category-card span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.category-card.active span {
  color: var(--text);
}

.category-card strong {
  min-width: 24px;
  min-height: 20px;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 204, 51, 0.1);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.recent-section {
  margin-bottom: 12px;
}

.hero-recent {
  min-height: 132px;
  padding: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #1d232e, #151922);
  border-radius: 6px;
}

.recent-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.recent-card {
  position: relative;
  min-width: 0;
  min-height: 68px;
  border: 1px solid var(--line-soft);
  background: #151922;
  color: var(--text);
  border-radius: 6px;
  overflow: hidden;
}

.recent-card:hover,
.recent-card.active,
.recent-card:focus-visible {
  border-color: rgba(255, 204, 51, 0.75);
  background: #202531;
}

.recent-open {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 68px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 34px 8px 8px;
  text-align: left;
  cursor: pointer;
}

.recent-delete {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(244, 91, 67, 0.45);
  background: rgba(17, 20, 27, 0.88);
  color: #ffd1cc;
  border-radius: 999px;
  cursor: pointer;
}

.recent-delete:hover,
.recent-delete:focus-visible {
  border-color: rgba(244, 91, 67, 0.85);
  background: rgba(244, 91, 67, 0.2);
  color: #fff;
}

.recent-delete svg {
  width: 14px;
  height: 14px;
}

.recent-cover {
  display: grid;
  place-items: center;
  width: 52px;
  aspect-ratio: 4 / 3;
  border: 1px solid #4a5060;
  background: #202632;
  color: var(--accent);
  font-weight: 900;
  overflow: hidden;
}

.recent-name,
.recent-desc {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-name {
  font-weight: 750;
}

.recent-desc {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.ad-slot {
  width: 100%;
  min-height: 90px;
  margin-bottom: 12px;
  overflow: hidden;
}

.ad-slot[hidden],
.ad-slot:empty {
  display: none;
}

.spotlight-section {
  margin-bottom: 12px;
}

.section-bar {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.pager-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pager-label {
  min-width: 56px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.section-bar h2 {
  font-size: 16px;
}

.section-bar p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.spotlight-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: minmax(0, auto);
  gap: 10px;
}

.spotlight-card {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 7px;
  min-width: 0;
  border: 1px solid var(--line-soft);
  background: #151922;
  color: var(--text);
  border-radius: 6px;
  padding: 8px;
  text-align: left;
  cursor: pointer;
  scroll-margin: 18px;
}

.spotlight-card:hover,
.spotlight-card.active {
  border-color: rgba(255, 204, 51, 0.75);
  background: #202531;
}

.spotlight-cover {
  width: 100%;
  aspect-ratio: 4 / 3;
  color: var(--accent);
  font-size: 28px;
}

.spotlight-name,
.spotlight-meta {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spotlight-name {
  font-weight: 750;
}

.spotlight-meta {
  color: var(--muted);
  font-size: 12px;
}

.spotlight-placeholder {
  pointer-events: none;
}

.spotlight-placeholder .spotlight-cover,
.spotlight-placeholder .spotlight-name,
.spotlight-placeholder .spotlight-meta {
  min-height: 14px;
  border-color: #303744;
  background: linear-gradient(90deg, #161b24, #202632, #161b24);
  background-size: 180% 100%;
  animation: placeholder-pulse 1.2s ease-in-out infinite;
}

.seo-game-links {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  background: #151922;
  border-radius: 6px;
}

.seo-game-links-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.seo-game-links-head h2 {
  font-size: 15px;
}

.seo-game-links-head p {
  color: var(--muted);
  font-size: 12px;
}

.seo-game-links-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.seo-game-links a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #3a4250;
  background: #10141b;
  color: var(--text);
  border-radius: 999px;
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
}

.seo-game-links a:hover,
.seo-game-links a:focus-visible {
  border-color: rgba(255, 204, 51, 0.7);
  background: rgba(255, 204, 51, 0.1);
}

.favorites-page {
  display: grid;
  gap: 16px;
}

.favorites-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  align-items: end;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(255, 204, 51, 0.14), transparent 42%),
    linear-gradient(135deg, #1d232e, #151922);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.favorites-kicker {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.favorites-hero h1 {
  margin-top: 6px;
  font-size: clamp(28px, 5vw, 52px);
  line-height: 1.05;
}

.favorites-hero p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.favorites-tools {
  display: grid;
  gap: 10px;
}

.favorites-count {
  color: var(--muted);
  text-align: right;
  font-size: 13px;
}

.favorites-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.favorite-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line-soft);
  background: #151922;
  color: var(--text);
  border-radius: 6px;
  padding: 10px;
  text-decoration: none;
}

.favorite-card:hover,
.favorite-card:focus-visible {
  border-color: rgba(255, 204, 51, 0.75);
  background: #202531;
}

.favorite-card-cover {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid #4a5060;
  background: #090c12;
  overflow: hidden;
}

.favorite-card-cover img {
  width: calc(100% - 2px);
  height: calc(100% - 2px);
  object-fit: contain;
}

.favorite-card-body {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding-right: 30px;
}

.favorite-card-name,
.favorite-card-meta,
.favorite-card-desc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-card-name {
  font-weight: 800;
}

.favorite-card-meta,
.favorite-card-desc {
  color: var(--muted);
  font-size: 12px;
}

.favorite-remove {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 204, 51, 0.45);
  background: rgba(17, 20, 27, 0.9);
  color: var(--accent);
  border-radius: 999px;
  cursor: pointer;
}

.favorite-remove:hover,
.favorite-remove:focus-visible {
  border-color: rgba(244, 91, 67, 0.8);
  background: rgba(244, 91, 67, 0.16);
  color: #ffd1cc;
}

.favorite-remove svg {
  width: 15px;
  height: 15px;
}

.favorites-empty {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 28px;
  border: 1px dashed #4a5060;
  background: rgba(17, 20, 27, 0.72);
  border-radius: 6px;
  text-align: center;
}

.favorites-empty h2 {
  font-size: 22px;
}

.favorites-empty p {
  margin-top: 8px;
  color: var(--muted);
}

@keyframes placeholder-pulse {
  0% {
    background-position: 0% 0;
  }

  100% {
    background-position: -180% 0;
  }
}

.screen-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 380px;
  border: 1px solid #454b59;
  background: #08090d;
  border-radius: 6px;
  overflow: hidden;
}

.emulator-mount,
.emulator-frame,
.emulator-stage {
  width: 100%;
  height: 100%;
  border: 0;
}

.emulator-mount {
  position: relative;
}

.emulator-stage {
  min-height: 100%;
}

.emulator-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 10, 0.88);
  color: var(--muted);
  pointer-events: none;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  height: 100%;
  padding: 24px;
  text-align: center;
}

.cabinet-art {
  display: grid;
  grid-template-columns: repeat(4, 30px);
  gap: 8px;
  padding: 16px;
  border: 2px solid #555d6f;
  background: #191d27;
}

.cabinet-art span {
  width: 30px;
  height: 30px;
  background: var(--accent);
  box-shadow: inset 0 -6px rgba(0, 0, 0, 0.24);
}

.cabinet-art span:nth-child(2) {
  background: var(--accent-2);
}

.cabinet-art span:nth-child(3) {
  background: var(--cyan);
}

.cabinet-art span:nth-child(4) {
  background: var(--green);
}

.quickbar {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.control-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  max-height: calc(100vh - 100px);
  overflow: auto;
}

.tool-section {
  border: 1px solid var(--line-soft);
  background: #151922;
  padding: 12px;
  border-radius: 6px;
}

.section-title {
  gap: 8px;
  margin-bottom: 12px;
}

.mapping-grid {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 8px;
}

.map-label {
  min-height: 36px;
  display: flex;
  align-items: center;
  color: var(--muted);
}

.map-button {
  min-height: 36px;
  border: 1px solid #454b59;
  background: #202632;
  color: var(--text);
  border-radius: 5px;
  cursor: pointer;
}

.map-button.listening {
  border-color: var(--accent);
  color: var(--accent);
}

.mapping-grid.compact {
  grid-template-columns: 1fr 112px;
}

.gamepad-status {
  gap: 8px;
  min-height: 34px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #727986;
}

.status-dot.ready {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(101, 215, 123, 0.12);
}

.side-note {
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.related-list {
  display: grid;
  gap: 8px;
  max-height: 310px;
  overflow: auto;
  padding-right: 2px;
}

.related-card {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 58px;
  padding: 8px;
  border: 1px solid #343a47;
  background: #202632;
  color: var(--text);
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  scroll-margin: 18px;
}

.related-card:hover,
.related-card.active {
  border-color: rgba(255, 204, 51, 0.72);
  background: #262d3a;
}

.related-cover {
  display: grid;
  place-items: center;
  width: 42px;
  aspect-ratio: 4 / 3;
  border: 1px solid #4a5060;
  background: #151922;
  color: var(--accent);
  font-weight: 900;
  overflow: hidden;
}

.related-name,
.related-desc {
  display: block;
  min-width: 0;
}

.related-name {
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.25;
}

.related-desc,
.side-empty {
  color: var(--muted);
  font-size: 12px;
}

.related-desc {
  margin-top: 3px;
}

.side-empty {
  padding: 10px;
  border: 1px solid #343a47;
  background: #202632;
  border-radius: 6px;
}

.turbo-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.toggle-button {
  min-height: 36px;
  border: 1px solid #454b59;
  background: #202632;
  color: var(--text);
  border-radius: 5px;
  cursor: pointer;
}

.range-field {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.range-field strong {
  color: var(--accent);
}

.range-field input {
  width: 100%;
  accent-color: var(--accent);
}

.cheat-list {
  display: grid;
  gap: 8px;
  min-height: 40px;
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}

.cheat-source {
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.cheat-row {
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 8px;
  background: #202632;
  border: 1px solid #343a47;
  border-radius: 6px;
}

.cheat-main {
  min-width: 0;
}

.cheat-main strong,
.cheat-main code {
  display: block;
  overflow-wrap: anywhere;
}

.cheat-main code {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.switch {
  width: 42px;
  height: 24px;
  border: 1px solid #4b5260;
  border-radius: 999px;
  background: #11141b;
  padding: 2px;
  cursor: pointer;
}

.switch::before {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #79808d;
  transition: transform 160ms ease, background 160ms ease;
}

.switch.on::before {
  transform: translateX(18px);
  background: var(--accent);
}

.cheat-form {
  display: grid;
  grid-template-columns: 1fr 1fr 40px;
  gap: 8px;
  margin-top: 10px;
}

.cheat-form input {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid #3d4351;
  background: #11141b;
  border-radius: 5px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  translate: -50% 16px;
  max-width: min(520px, calc(100vw - 28px));
  padding: 11px 14px;
  border: 1px solid #535b6b;
  background: rgba(25, 29, 39, 0.96);
  color: var(--text);
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, translate 180ms ease;
}

.toast.show {
  opacity: 1;
  translate: -50% 0;
}

@media (max-width: 1180px) {
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .layout.home-mode {
    grid-template-columns: minmax(0, 1fr) minmax(290px, 330px);
  }

  .layout.play-mode {
    grid-template-columns: minmax(0, 1fr);
  }

  .layout.play-mode .play-panel,
  .layout.play-mode .control-panel {
    grid-column: 1 / -1;
  }

  .home-dashboard {
    grid-template-columns: 1fr;
  }

  .spotlight-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .recent-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-panel {
    grid-column: 1 / -1;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: none;
  }
}

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

  .app-shell {
    width: 100%;
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .topbar,
  .layout {
    display: grid;
    gap: 12px;
  }

  .topbar {
    margin-bottom: 12px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .brand h1 {
    font-size: 21px;
  }

  .brand p {
    font-size: 12px;
  }

  .layout.home-mode {
    grid-template-columns: 1fr;
  }

  .layout.home-mode .library-panel,
  .layout.home-mode .play-panel,
  .layout.play-mode .library-panel,
  .layout.play-mode .play-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .top-actions,
  .quickbar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: stretch;
    gap: 8px;
  }

  .top-actions .button,
  .quickbar .button {
    min-width: 0;
    padding: 0 8px;
  }

  .library-panel,
  .control-panel,
  .play-panel {
    width: 100%;
    min-width: 0;
    padding: 12px;
  }

  .control-panel {
    grid-template-columns: 1fr;
  }

  .game-list {
    max-height: 360px;
  }

  .hero-strip {
    display: grid;
    grid-template-columns: 92px 1fr;
    align-items: center;
    min-height: 0;
    padding: 12px;
  }

  .hero-strip .button {
    grid-column: 1 / -1;
  }

  .hero-strip h2 {
    font-size: 26px;
  }

  .recent-rail,
  .spotlight-grid,
  .favorites-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .favorites-hero {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .favorites-count {
    text-align: left;
  }

  .screen-shell {
    min-height: 280px;
    aspect-ratio: 4 / 3;
  }

  .mapping-grid,
  .mapping-grid.compact {
    grid-template-columns: minmax(0, 1fr) minmax(92px, 34%);
  }

  .cheat-form {
    grid-template-columns: 1fr;
  }

  .cheat-form .button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .top-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-actions .icon-button {
    width: auto;
  }

  .quickbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ip-tag-rail {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .ip-tag {
    flex: 0 0 auto;
  }

  .panel-head {
    align-items: flex-start;
  }

  .game-index-row {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .game-index-row .tag {
    grid-column: 2;
    justify-self: start;
  }

  .spotlight-grid {
    gap: 8px;
  }

  .recent-rail {
    grid-template-columns: 1fr;
    gap: 8px;
  }

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

  .spotlight-card {
    padding: 7px;
  }

  .spotlight-cover {
    aspect-ratio: 1 / 1;
  }

  .spotlight-name {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 2.5em;
  }

  .section-bar {
    align-items: flex-start;
  }

  .pager-controls {
    flex: 0 0 auto;
  }

  .active-cover-art {
    width: 78px;
  }

  .hero-strip {
    grid-template-columns: 78px 1fr;
  }

  .screen-shell {
    min-height: 230px;
  }
}

@media (max-width: 820px) and (orientation: landscape) {
  .layout.play-mode {
    gap: 10px;
  }

  .layout.play-mode .hero-strip {
    grid-template-columns: 70px 1fr auto;
    padding: 10px;
  }

  .layout.play-mode .hero-strip .button {
    grid-column: auto;
  }

  .layout.play-mode .active-cover-art {
    width: 70px;
  }

  .layout.play-mode .hero-strip h2 {
    font-size: 22px;
  }

  .layout.play-mode .screen-shell {
    min-height: 0;
    height: min(68svh, calc(100svh - 172px));
    aspect-ratio: 16 / 9;
  }
}

@media (min-width: 1600px) {
  .app-shell {
    width: min(1920px, 100%);
    padding: 24px;
  }

  .layout {
    gap: 20px;
    min-height: calc(100svh - 118px);
  }

  .layout.home-mode {
    grid-template-columns: minmax(0, 1fr) minmax(380px, 440px);
  }

  .layout.play-mode .control-panel {
    width: 420px;
  }

  .screen-shell {
    min-height: 560px;
    aspect-ratio: 16 / 9;
  }

  .layout.play-mode .screen-shell {
    min-height: min(680px, calc(100svh - 230px));
  }

  .spotlight-grid {
    gap: 14px;
  }

  .spotlight-card,
  .game-index-row,
  .recent-card,
  .related-card,
  .button,
  .map-button,
  .toggle-button {
    min-height: 48px;
  }
}

@media (min-width: 1900px) and (min-height: 900px) {
  .brand h1 {
    font-size: 30px;
  }

  .hero-strip h2 {
    font-size: 46px;
  }

  .spotlight-name {
    font-size: 17px;
  }

  .spotlight-meta,
  .game-desc,
  .related-desc {
    font-size: 13px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .button,
  .tab,
  .game-index-row,
  .spotlight-card,
  .recent-card,
  .related-card,
  .map-button,
  .toggle-button {
    min-height: 44px;
  }

  .button:hover,
  .spotlight-card:hover,
  .game-index-row:hover,
  .recent-card:hover,
  .related-card:hover,
  .category-card:hover {
    transform: none;
  }
}
