:root {
  color-scheme: dark;
  --bg: #100e1c;
  --bg-soft: #171426;
  --panel: #211d34;
  --panel-2: #2b2640;
  --ink: #f5f0df;
  --muted: #aaa4bc;
  --line: rgba(255, 255, 255, 0.11);
  --red: #ef4557;
  --yellow: #ffc857;
  --cyan: #58d5d2;
  --violet: #8f71ff;
  --green: #6bd49b;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(143, 113, 255, 0.16), transparent 30rem),
    radial-gradient(circle at 88% 26%, rgba(239, 69, 87, 0.13), transparent 34rem),
    var(--bg);
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  opacity: 0.24;
  background-image: linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: #17131f;
  background: var(--yellow);
  border-radius: 7px;
  transform: translateY(-160%);
}

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

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 14, 28, 0.82);
  backdrop-filter: blur(18px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  min-height: 72px;
  margin: 0 auto;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
  letter-spacing: 0.05em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 5px;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 3px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 4px 4px 0 var(--red);
}

.brand-mark i {
  background: var(--ink);
}

.brand-mark i:nth-child(2),
.brand-mark i:nth-child(3) {
  background: var(--red);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.text-button,
.footer-link {
  padding: 9px 12px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.text-button:hover,
.footer-link:hover {
  color: var(--ink);
}

main {
  overflow: hidden;
}

.hero,
.library,
.control-guide {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.hero {
  display: grid;
  min-height: 610px;
  padding: 90px 0 72px;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, 0.95fr);
  align-items: center;
  gap: clamp(50px, 8vw, 110px);
}

.eyebrow {
  margin: 0 0 13px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 640px;
  margin: 0;
  font-size: clamp(46px, 6vw, 78px);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.hero-copy > p:not(.eyebrow) {
  max-width: 590px;
  margin: 25px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  margin-top: 34px;
  gap: 12px;
}

.primary-button,
.secondary-button,
.play-button {
  display: inline-flex;
  min-height: 46px;
  padding: 0 19px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-button,
.play-button {
  color: #160f18;
  background: var(--red);
  box-shadow: 4px 4px 0 rgba(255, 200, 87, 0.9);
}

.secondary-button {
  border-color: var(--line);
  background: var(--panel);
}

.primary-button:hover,
.secondary-button:hover,
.play-button:hover {
  transform: translate(-1px, -1px);
}

.primary-button:active,
.secondary-button:active,
.play-button:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.hero-console {
  position: relative;
  width: min(100%, 470px);
  padding: 28px 28px 32px;
  justify-self: end;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 26px 26px 52px 26px;
  background: linear-gradient(145deg, #ded9cd, #9e9b9a);
  box-shadow: 18px 22px 0 #2f2943, var(--shadow);
  transform: rotate(2.5deg);
}

.hero-console::before {
  position: absolute;
  top: 13px;
  right: 18px;
  width: 8px;
  height: 8px;
  content: "";
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 12px var(--red);
}

.console-screen {
  position: relative;
  overflow: hidden;
  aspect-ratio: 256 / 220;
  border: 14px solid #373344;
  border-radius: 13px;
  background: linear-gradient(#1b1830 0 55%, #4b305c 55% 60%, #171525 60%);
  image-rendering: pixelated;
}

.console-screen::after {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0.22;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, #fff 4px);
}

.console-screen > span {
  position: absolute;
  z-index: 3;
  top: 21px;
  left: 22px;
  padding: 6px 8px;
  color: var(--yellow);
  background: #171525;
  font-family: "Courier New", monospace;
  font-size: 13px;
  font-weight: 900;
}

.pixel-sun {
  position: absolute;
  top: 35px;
  right: 40px;
  width: 58px;
  height: 58px;
  background: var(--red);
  box-shadow: 8px 8px 0 #d32c62;
}

.pixel-city {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 45%;
  background: linear-gradient(90deg, transparent 0 8%, #28213d 8% 17%, transparent 17% 21%, #36274c 21% 37%, transparent 37% 42%, #28213d 42% 56%, transparent 56% 63%, #342747 63% 78%, transparent 78% 82%, #28213d 82% 96%, transparent 96%);
  clip-path: polygon(0 42%, 8% 42%, 8% 18%, 17% 18%, 17% 60%, 21% 60%, 21% 0, 37% 0, 37% 48%, 42% 48%, 42% 22%, 56% 22%, 56% 65%, 63% 65%, 63% 10%, 78% 10%, 78% 52%, 82% 52%, 82% 30%, 96% 30%, 96% 58%, 100% 58%, 100% 100%, 0 100%);
}

.console-controls {
  display: flex;
  padding: 25px 6px 0;
  align-items: center;
  justify-content: space-between;
}

.mini-dpad {
  position: relative;
  width: 66px;
  height: 23px;
  background: #24212d;
  border-radius: 3px;
}

.mini-dpad::before {
  position: absolute;
  top: -21px;
  left: 22px;
  width: 23px;
  height: 66px;
  content: "";
  background: #24212d;
  border-radius: 3px;
}

.mini-slots {
  display: flex;
  gap: 8px;
}

.mini-slots i {
  width: 35px;
  height: 10px;
  border-radius: 999px;
  background: #6b6870;
}

.mini-buttons {
  display: flex;
  padding: 10px;
  gap: 10px;
  border-radius: 999px;
  background: #bbb5b0;
  transform: rotate(-12deg);
}

.mini-buttons i {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #b72442;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.25);
}

.library {
  padding: 88px 0 110px;
}

.section-heading {
  display: flex;
  margin-bottom: 30px;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2,
.control-guide h2 {
  margin: 0;
  font-size: clamp(34px, 4vw, 52px);
  letter-spacing: -0.04em;
}

.section-heading > p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.library-tools {
  position: sticky;
  z-index: 20;
  top: 72px;
  display: grid;
  margin-bottom: 28px;
  padding: 14px;
  grid-template-columns: minmax(240px, 0.75fr) minmax(0, 1.25fr);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(23, 20, 38, 0.9);
  backdrop-filter: blur(18px);
}

.search-box {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
}

.search-box > span {
  padding-left: 14px;
  color: var(--cyan);
  font-size: 24px;
  line-height: 1;
}

.search-box input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px 0 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.search-box input::placeholder {
  color: #777185;
}

.category-tabs {
  display: flex;
  min-width: 0;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-tabs button {
  display: inline-flex;
  min-height: 46px;
  padding: 0 12px;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.category-tabs button span {
  color: var(--red);
}

.category-tabs button small {
  padding: 1px 6px;
  border-radius: 99px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
}

.category-tabs button:hover,
.category-tabs button[aria-pressed="true"] {
  border-color: var(--line);
  color: var(--ink);
  background: var(--panel-2);
}

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

.game-card {
  position: relative;
  overflow: hidden;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.025), transparent 35%), var(--panel);
  box-shadow: 0 15px 38px rgba(0, 0, 0, 0.16);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.game-card:hover {
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.3);
  transform: translateY(-5px);
}

.card-art {
  position: relative;
  display: flex;
  overflow: hidden;
  height: 150px;
  padding: 15px;
  align-items: flex-end;
  background: #322b4d;
  cursor: pointer;
}

.card-art .preview-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  /* 不能用 opacity:0 隐藏：Chrome 会暂停零透明 iframe 的渲染管线，模拟器永远画不出画面。
     加载期用深色底遮盖，游戏画面出现后自然显现。 */
  background: #08070d;
  pointer-events: none;
  image-rendering: pixelated;
}

/* 预览加载中指示：盖在预览 iframe 上方，游戏画面出来后由 JS 移除 */
.card-art .preview-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #08070d;
  color: rgba(255, 255, 255, 0.55);
  font-family: "Courier New", monospace;
  font-size: 12px;
  letter-spacing: 3px;
  pointer-events: none;
  animation: previewLoadingBlink 1.1s steps(2, end) infinite;
}

@keyframes previewLoadingBlink {
  50% {
    opacity: 0.35;
  }
}

.game-card[data-category="动作平台"] .card-art {
  background: linear-gradient(145deg, #703348, #2d2441);
}

.game-card[data-category="街机挑战"] .card-art {
  background: linear-gradient(145deg, #244f58, #29233e);
}

.game-card[data-category="益智策略"] .card-art {
  background: linear-gradient(145deg, #594820, #30253f);
}

.game-card[data-category="休闲对战"] .card-art {
  background: linear-gradient(145deg, #3b3966, #29223c);
}

.card-art::before,
.card-art::after {
  position: absolute;
  content: "";
  image-rendering: pixelated;
}

.card-art::before {
  top: 20px;
  left: 24px;
  width: 10px;
  height: 10px;
  background: var(--yellow);
  box-shadow: 28px 15px 0 var(--yellow), 73px -5px 0 rgba(255, 255, 255, 0.35), 118px 22px 0 rgba(255, 255, 255, 0.28), 172px -1px 0 rgba(255, 255, 255, 0.3), 210px 34px 0 rgba(255, 255, 255, 0.2);
}

.card-art::after {
  right: -20px;
  bottom: -35px;
  width: 180px;
  height: 100px;
  border: 12px solid rgba(255, 255, 255, 0.08);
  transform: rotate(-12deg);
}

.art-icon {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  color: rgba(255, 255, 255, 0.92);
  font-size: 64px;
  line-height: 1;
  text-shadow: 7px 7px 0 rgba(0, 0, 0, 0.22);
  transform: translate(-50%, -50%) rotate(calc((var(--card-index) - 2) * 1deg));
}

.art-lines {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 0;
  left: 0;
  height: 45%;
  opacity: 0.35;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 3px, transparent 3px 18px);
  transform: perspective(120px) rotateX(58deg);
  transform-origin: bottom;
}

.card-art small {
  position: relative;
  z-index: 2;
  color: rgba(255, 255, 255, 0.62);
  font-family: "Courier New", monospace;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.card-body {
  padding: 18px;
}

.card-meta {
  display: flex;
  margin-bottom: 12px;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.card-meta span:first-child {
  color: var(--cyan);
  font-weight: 800;
}

.card-body h3 {
  overflow: hidden;
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-subtitle {
  margin: 5px 0 0;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 700;
}

.card-description {
  display: -webkit-box;
  min-height: 63px;
  margin: 13px 0 18px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 46px;
  gap: 9px;
}

.play-button {
  min-height: 42px;
  box-shadow: 3px 3px 0 rgba(255, 200, 87, 0.85);
}

.favorite-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--red);
  background: rgba(255, 255, 255, 0.04);
  font-size: 23px;
  cursor: pointer;
}

.favorite-button:hover,
.favorite-button[aria-pressed="true"] {
  background: rgba(239, 69, 87, 0.13);
}

.empty-state {
  padding: 70px 20px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
}

.empty-state > span {
  display: grid;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  place-items: center;
  border: 2px solid var(--muted);
  border-radius: 50%;
  font-size: 28px;
}

.empty-state h3 {
  margin: 0;
  color: var(--ink);
}

.empty-state p {
  margin: 8px 0 20px;
}

.control-guide {
  display: grid;
  margin-bottom: 100px;
  padding: 48px;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 60px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(88, 213, 210, 0.08), transparent 40%), var(--panel);
}

.control-guide > div:first-child > p:last-child {
  color: var(--muted);
  line-height: 1.75;
}

.key-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.key-grid > div {
  display: flex;
  min-height: 84px;
  padding: 14px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
}

kbd {
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-bottom-width: 3px;
  border-radius: 5px;
  color: var(--yellow);
  background: #161322;
  font: 700 12px "Courier New", monospace;
}

.key-grid span {
  color: var(--muted);
  font-size: 12px;
}

.site-footer {
  display: flex;
  min-height: 110px;
  padding: 24px max(20px, calc((100% - 1180px) / 2));
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #0c0a14;
  font-size: 12px;
}

.footer-link {
  padding: 0;
  color: var(--cyan);
  text-align: right;
}

dialog {
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
}

dialog::backdrop {
  background: rgba(5, 4, 10, 0.82);
  backdrop-filter: blur(10px);
}

.player-dialog {
  width: min(1180px, calc(100% - 28px));
  max-width: none;
  max-height: calc(100dvh - 28px);
  overflow: auto;
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.player-shell,
.about-shell {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  background: #171425;
}

.player-header,
.about-header {
  display: flex;
  min-height: 82px;
  padding: 18px 24px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.player-header h2,
.about-header h2 {
  margin: 0;
  font-size: 24px;
}

.player-header .eyebrow,
.about-header .eyebrow {
  margin-bottom: 5px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.player-layout {
  display: grid;
  padding: 24px;
  grid-template-columns: minmax(0, 1.42fr) minmax(330px, 0.58fr);
  gap: 24px;
}

.screen-frame {
  padding: 19px 19px 12px;
  border-radius: 19px;
  background: linear-gradient(145deg, #c9c4ba, #88878c);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), 8px 9px 0 #0d0b15;
}

.screen-bezel {
  overflow: hidden;
  padding: 15px;
  border-radius: 12px;
  background: #272432;
}

.nes-mount {
  position: relative;
  display: grid;
  width: 100%;
  max-height: calc(100dvh - 290px);
  aspect-ratio: 256 / 240;
  margin: auto;
  overflow: hidden;
  place-items: center;
  background: #08070d;
}

.nes-mount > #nesGame {
  position: relative;
  width: 100%;
  height: 100%;
}

.nes-mount > #nesGame > iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.nes-mount canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.screen-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-family: "Courier New", monospace;
}

.screen-placeholder span {
  color: var(--red);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.screen-status {
  display: flex;
  min-height: 36px;
  padding: 10px 4px 0;
  align-items: center;
  gap: 8px;
  color: #25222c;
  font-size: 11px;
  font-weight: 800;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #48bb78;
  box-shadow: 0 0 9px rgba(72, 187, 120, 0.8);
}

.screen-frame[data-status="loading"] .status-dot {
  background: var(--yellow);
  box-shadow: 0 0 9px var(--yellow);
  animation: blink 800ms steps(2) infinite;
}

.screen-frame[data-status="error"] .status-dot {
  background: var(--red);
  box-shadow: 0 0 9px var(--red);
}

.screen-frame[data-status="paused"] .status-dot {
  background: #77717d;
  box-shadow: none;
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

.player-toolbar {
  display: flex;
  margin-top: 18px;
  flex-wrap: wrap;
  gap: 8px;
}

.player-toolbar button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  cursor: pointer;
}

.player-toolbar button:hover {
  border-color: rgba(255, 255, 255, 0.26);
  background: #363049;
}

.controller-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 18px;
}

.touch-controller {
  display: grid;
  min-height: 260px;
  padding: 22px 18px;
  grid-template-columns: 108px minmax(52px, 0.7fr) 120px;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 18px 18px 35px 18px;
  background: linear-gradient(145deg, #ded8cc, #98969a);
  box-shadow: 7px 8px 0 #0e0c16;
  touch-action: none;
  user-select: none;
}

.touch-dpad {
  position: relative;
  width: 108px;
  height: 108px;
  justify-self: center;
}

.touch-dpad button,
.dpad-center {
  position: absolute;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  color: #5a5662;
  background: #292631;
  font-size: 14px;
}

.touch-dpad button {
  cursor: pointer;
}

.dpad-up {
  top: 0;
  left: 36px;
  border-radius: 6px 6px 0 0 !important;
}

.dpad-left {
  top: 36px;
  left: 0;
  border-radius: 6px 0 0 6px !important;
}

.dpad-center {
  top: 36px;
  left: 36px;
}

.dpad-right {
  top: 36px;
  right: 0;
  border-radius: 0 6px 6px 0 !important;
}

.dpad-down {
  bottom: 0;
  left: 36px;
  border-radius: 0 0 6px 6px !important;
}

.touch-system {
  display: flex;
  align-self: end;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
}

.touch-system button {
  min-height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  color: #b8b2af;
  background: #625e68;
  font: 800 9px "Courier New", monospace;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.touch-actions {
  display: flex;
  padding: 9px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  background: #bbb4ad;
  transform: rotate(-12deg);
}

.touch-actions button {
  width: 50px;
  height: 50px;
  border: 0;
  border-radius: 50%;
  color: #f7d9dc;
  background: #b72846;
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.25), 0 4px 0 #7b1b31;
  font: 900 20px "Courier New", monospace;
  cursor: pointer;
}

.touch-controller button.pressed,
.touch-controller button:active {
  filter: brightness(0.78);
  transform: translateY(2px);
}

.touch-actions button.pressed,
.touch-actions button:active {
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.25);
}

.game-details {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
}

.game-details > p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.game-details dl,
.game-details dd {
  margin: 0;
}

.game-details dl {
  display: grid;
  gap: 8px;
}

.game-details dl > div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 12px;
}

.game-details dt {
  color: var(--muted);
}

.game-details a {
  color: var(--cyan);
}

.screen-frame:fullscreen {
  display: grid;
  width: 100vw;
  height: 100vh;
  padding: 24px;
  place-items: center;
  border-radius: 0;
  background: #050409;
}

.screen-frame:fullscreen .screen-bezel {
  display: grid;
  width: 100%;
  height: calc(100vh - 60px);
  padding: 0;
  place-items: center;
  background: #050409;
}

.screen-frame:fullscreen .nes-mount {
  width: min(100%, calc((100vh - 60px) * 256 / 240));
  max-height: none;
  height: calc(100vh - 60px);
}

.screen-frame:fullscreen .screen-status {
  display: none;
}

/* 横屏全屏按钮：仅触屏/小屏显示（桌面用模拟器自带全屏即可） */
.player-fullscreen-btn {
  display: none;
}

@media (max-width: 700px), (pointer: coarse) and (max-width: 1180px) {
  .player-fullscreen-btn {
    display: inline-flex;
  }
}

/* 全屏内的浮动退出按钮（手机没有 ESC 键） */
.fs-exit {
  display: none;
}

.screen-frame:fullscreen {
  position: relative;
}

.screen-frame:fullscreen .fs-exit {
  position: absolute;
  z-index: 30;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(10px, env(safe-area-inset-right, 0px));
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(5, 4, 9, 0.55);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.78;
}

.about-dialog {
  width: min(920px, calc(100% - 28px));
  max-width: none;
  max-height: calc(100dvh - 28px);
  overflow: auto;
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.about-shell {
  padding-bottom: 24px;
}

.about-intro,
.about-engine {
  margin: 22px 24px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.about-engine a,
.license-list a {
  color: var(--cyan);
}

.license-list {
  display: grid;
  margin: 0 24px;
  gap: 8px;
}

.license-list article {
  display: grid;
  padding: 13px 14px;
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, auto);
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
}

.license-list strong,
.license-list small {
  display: block;
}

.license-list small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.license-list article > span {
  color: var(--yellow);
  font: 700 11px "Courier New", monospace;
}

.license-list nav {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  font-size: 11px;
}

.license-list code {
  grid-column: 1 / -1;
  overflow: hidden;
  color: #736d80;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1050px) {
  .game-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .controller-column {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  }

  .nes-mount {
    max-height: none;
  }
}

@media (max-width: 820px) {
  .hero {
    min-height: 0;
    padding-top: 70px;
    grid-template-columns: 1fr;
  }

  .hero-console {
    width: min(100%, 450px);
    justify-self: center;
  }

  .library-tools {
    position: relative;
    top: 0;
    grid-template-columns: 1fr;
  }

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

  .control-guide {
    padding: 32px;
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .controller-column {
    grid-template-columns: 1fr;
  }

  .touch-controller {
    min-height: 230px;
  }
}

@media (max-width: 600px) {
  .header-inner,
  .hero,
  .library,
  .control-guide {
    width: min(100% - 24px, 1180px);
  }

  .header-inner {
    min-height: 64px;
  }

  .brand strong {
    font-size: 14px;
  }

  .brand small,
  .header-actions .text-button:first-child {
    display: none;
  }

  .header-actions .text-button {
    padding-inline: 6px;
    font-size: 12px;
  }

  .hero {
    padding: 54px 0 48px;
    gap: 55px;
  }

  .hero h1 {
    font-size: clamp(42px, 13vw, 58px);
  }

  .hero-copy > p:not(.eyebrow) {
    font-size: 15px;
  }

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

  .hero-console {
    width: calc(100% - 18px);
    padding: 20px 20px 25px;
    box-shadow: 12px 15px 0 #2f2943, var(--shadow);
  }

  .console-screen {
    border-width: 10px;
  }

  .mini-dpad {
    transform: scale(0.82);
  }

  .mini-slots {
    display: none;
  }

  .mini-buttons {
    transform: rotate(-12deg) scale(0.86);
  }

  .library {
    padding: 70px 0 80px;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }

  .library-tools {
    padding: 10px;
  }

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

  .card-art {
    height: 165px;
  }

  .control-guide {
    margin-bottom: 70px;
    padding: 26px 20px;
  }

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

  .site-footer {
    padding: 28px 18px;
    align-items: flex-start;
    flex-direction: column;
  }

  .footer-link {
    text-align: left;
  }

  .player-dialog,
  .about-dialog {
    width: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }

  .player-shell,
  .about-shell {
    min-height: 100dvh;
    border-radius: 0;
  }

  .player-header,
  .about-header {
    min-height: 70px;
    padding: 14px 16px;
  }

  .player-header h2,
  .about-header h2 {
    max-width: calc(100vw - 90px);
    overflow: hidden;
    font-size: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .player-layout {
    padding: 12px;
    gap: 6px;
  }

  .screen-frame {
    padding: 10px 10px 7px;
    border-radius: 12px;
    box-shadow: 5px 6px 0 #0d0b15;
  }

  .screen-bezel {
    padding: 8px;
  }

  .player-toolbar {
    display: grid;
    margin-top: 8px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .player-toolbar button {
    min-height: 36px;
    padding-inline: 2px;
    font-size: 10px;
    white-space: nowrap;
  }

  .touch-controller {
    min-height: 200px;
    padding: 16px 8px;
    grid-template-columns: 1fr 0.52fr 1fr;
    gap: 4px;
  }

  .touch-dpad {
    transform: scale(0.82);
  }

  .touch-actions {
    padding: 8px;
    gap: 7px;
    transform: rotate(-12deg) scale(0.88);
  }

  .touch-actions button {
    width: 52px;
    height: 52px;
  }

  .license-list {
    margin-inline: 14px;
  }

  .about-intro,
  .about-engine {
    margin-inline: 16px;
  }

  .license-list article {
    grid-template-columns: 1fr auto;
  }

  .license-list nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@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;
  }
}
