/* =========================================================================
 *  FC ARCADE — 复古红白机风样式
 *  配色取自 1983 年 Family Computer 机身：米灰塑料 + 正红 + 深灰
 *  全部硬边框、硬阴影、零圆角，刻意保留 8-bit 时代的塑料质感
 * ========================================================================= */

:root {
  --fc-red: #CE2B21;
  --fc-red-d: #8F1B14;
  --fc-red-l: #E65A4E;

  --plastic: #E4E0D5;
  --plastic-2: #CFCABC;
  --plastic-3: #A9A395;

  --ink: #15161A;
  --ink-2: #4A4D54;
  --ink-3: #7E828B;

  --bg: #1B1C20;
  --bg-2: #23252B;
  --bg-3: #2C2F36;

  --gold: #C9A227;
  --gold-l: #E8C75A;

  --edge: 3px;
  --shadow: 5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow-red: 5px 5px 0 var(--fc-red-d);

  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Hiragino Sans GB",
    system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* 禁掉下拉刷新 / 回弹，避免手指在游戏里滑动时触发页面级滚动 */
  overscroll-behavior: none;
}

body {
  font-family: var(--sans);
  color: var(--plastic);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, .045) 1px, transparent 1px),
    radial-gradient(circle, rgba(255, 255, 255, .025) 1px, transparent 1px);
  background-size: 4px 4px, 8px 8px;
  background-position: 0 0, 2px 2px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

.pix-text { display: block; image-rendering: pixelated; }
.pix-icon { display: block; image-rendering: pixelated; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* ── 通用像素按钮 ───────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink);
  background: var(--plastic);
  border: var(--edge) solid var(--ink);
  box-shadow: var(--shadow-sm);
  transform: translate(0, 0);
  transition: transform .06s steps(2), box-shadow .06s steps(2), background-color .12s;
}
.btn:hover { background: #F1EDE2; }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn-red { background: var(--fc-red); color: #FFF3F1; }
.btn-red:hover { background: var(--fc-red-l); }
.btn-ghost { background: transparent; color: var(--plastic); border-color: var(--plastic-3); box-shadow: none; }
.btn-ghost:hover { background: rgba(255, 255, 255, .07); }
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* ── 顶部 ───────────────────────────────────────── */
.masthead {
  border-bottom: var(--edge) solid var(--ink);
  background: var(--bg-2);
  padding: 26px 0 22px;
}
.masthead-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.brand-line { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 54px; height: 54px;
  background: var(--fc-red);
  border: var(--edge) solid var(--ink);
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center;
  flex: none;
}
.brand-mark svg { width: 34px; height: 34px; fill: #FFF3F1; }
.brand h1 { font-size: 27px; font-weight: 800; letter-spacing: .05em; line-height: 1.2; }
.brand-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-3);
  letter-spacing: .16em;
  font-weight: 500;
}
.masthead-side { text-align: right; font-size: 12.5px; color: var(--ink-3); line-height: 1.9; }
.masthead-side b { color: var(--plastic); font-weight: 600; }

/* ── 副标题条 ───────────────────────────────────── */
.strip {
  border-bottom: var(--edge) solid var(--ink);
  background: var(--fc-red);
  padding: 11px 0;
}
.strip-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  font-size: 13px; font-weight: 600; letter-spacing: .06em; color: #FFF3F1;
}
.strip svg { fill: #FFF3F1; }

/* ── 卡带封面墙 ─────────────────────────────────── */
.gallery { padding: 44px 0 56px; }
.gallery-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 26px;
}
.gallery-head h2 { font-size: 20px; font-weight: 700; letter-spacing: .02em; }
.gallery-head p { font-size: 13px; color: var(--ink-3); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 26px;
}

/* 卡带本体 */
.cart {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--plastic);
  border: var(--edge) solid var(--ink);
  box-shadow: var(--shadow);
  color: var(--ink);
  transition: transform .12s steps(3), box-shadow .12s steps(3);
  overflow: hidden;
}
.cart::after {
  /* 卡带底部金手指 */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 22px;
  background: repeating-linear-gradient(90deg,
    var(--gold) 0 9px, transparent 9px 15px);
  border-top: var(--edge) solid var(--ink);
  opacity: .85;
}
.cart:hover { transform: translate(-3px, -4px); box-shadow: 8px 9px 0 var(--ink); }
.cart:focus-visible { outline: 3px solid var(--fc-red); outline-offset: 3px; }

.cart-top {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 16px 14px;
  border-bottom: var(--edge) solid var(--ink);
  background: var(--plastic-2);
}
.cart-art {
  width: 66px; height: 66px; flex: none;
  background: var(--ink);
  border: 2px solid var(--ink);
  display: grid; place-items: center;
}
.cart-art .pix-icon { width: 58px; height: 58px; }
.cart-id { min-width: 0; }
.cart-no {
  font-size: 11px; font-weight: 700; letter-spacing: .18em;
  color: var(--fc-red); margin-bottom: 3px;
}
.cart-name {
  font-size: 16.5px; font-weight: 700; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cart-en { font-size: 11px; color: var(--ink-2); letter-spacing: .08em; }

.cart-body { padding: 14px 16px 30px; flex: 1; }
.cart-desc { font-size: 13px; color: var(--ink-2); line-height: 1.65; min-height: 44px; }
.cart-meta {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px;
}
.tag {
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px;
  border: 2px solid var(--ink);
  background: #FFFDF7;
  letter-spacing: .04em;
}
.tag-red { background: var(--fc-red); color: #FFF3F1; }

/* ── 说明区 ─────────────────────────────────────── */
.notice {
  margin-top: 44px;
  border: var(--edge) solid var(--ink);
  background: var(--bg-2);
  box-shadow: var(--shadow-sm);
}
.notice-head {
  padding: 12px 20px;
  background: var(--bg-3);
  border-bottom: var(--edge) solid var(--ink);
  font-size: 13px; font-weight: 700; letter-spacing: .1em;
}
.notice-body { padding: 18px 20px 20px; font-size: 13.5px; color: var(--ink-3); line-height: 1.85; }
.notice-body b { color: var(--plastic); }
.notice-body code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--bg); padding: 2px 7px; border: 1px solid var(--bg-3);
  color: var(--gold-l);
}
.notice-body ol { margin: 8px 0 0 20px; }
.notice-body li { margin-bottom: 6px; }

.site-foot {
  border-top: var(--edge) solid var(--ink);
  background: var(--bg-2);
  padding: 22px 0 30px;
  font-size: 12.5px; color: var(--ink-3);
}
.site-foot-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════════════
 *  游玩页
 * ═══════════════════════════════════════════════════════════════ */
body.play { background: #0C0D10; overflow: hidden; }

.play-shell {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
}

.play-bar {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: var(--edge) solid var(--ink);
  z-index: 20;
}
.play-bar .back {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 12px; font-size: 13px; font-weight: 700;
  border: 2px solid var(--plastic-3); color: var(--plastic);
}
.play-bar .back:hover { background: rgba(255, 255, 255, .08); }
.play-title {
  min-width: 0; flex: 1;
  font-size: 14.5px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.play-title span { color: var(--ink-3); font-weight: 500; font-size: 12.5px; margin-left: 8px; }
.bar-actions { display: flex; gap: 8px; flex: none; }

.stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 12px;
  gap: 8px;
}
.screen-frame {
  position: relative;
  flex: 0 1 auto;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 4 / 3;
  border: var(--edge) solid var(--ink);
  background: #000;
  box-shadow: 0 0 0 3px #3A3D45, 8px 8px 0 rgba(0, 0, 0, .6);
}
.screen-frame canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
  background: #000;
}
/* CRT 扫描线 + 暗角 */
.screen-frame::after {
  content: "";
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .20) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 52%, rgba(0, 0, 0, .38) 100%);
  pointer-events: none;
}
.screen-off .screen-frame::after { display: none; }

/* ── 触屏性能 ─────────────────────────────────────
   手机上关掉扫描线叠加层：它每帧都要和画布做一次全屏混合，
   在中低端机上是实打实的开销；手势相关属性也能去掉点击延迟 */
@media (pointer: coarse) {
  .screen-frame::after { display: none; }
}
.screen-frame, .pad, .dpad, .pad button, .pad a {
  touch-action: none;
}
.play-shell {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ── 覆盖层（加载 / 错误 / 提示） ─────────────────── */
.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  background: rgba(8, 9, 12, .93);
  z-index: 30;
}
.overlay[hidden] { display: none; }
.overlay-title { font-size: 17px; font-weight: 700; letter-spacing: .04em; }
.overlay-text { font-size: 13.5px; color: var(--ink-3); max-width: 460px; line-height: 1.8; }
.overlay-text code {
  font-family: var(--mono); color: var(--gold-l);
  background: #000; padding: 2px 6px; border: 1px solid var(--bg-3);
}

/* 加载动画：跳动的像素方块 */
.loader { display: flex; gap: 6px; }
.loader i {
  width: 12px; height: 12px; background: var(--fc-red);
  animation: bob .9s steps(2, jump-none) infinite;
}
.loader i:nth-child(2) { animation-delay: .15s; background: var(--gold-l); }
.loader i:nth-child(3) { animation-delay: .3s; background: var(--plastic); }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-11px); } }

/* ── 虚拟手柄 ───────────────────────────────────── */
/* 手柄浮在画面层的两侧：手机横屏时 4:3 画面是窄的，
   左右剩下的横向空间正好放十字键和 A/B，画面一点都不用让位 */
.pad {
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 0;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 18px 10px;
  z-index: 25;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.pad-cluster { pointer-events: auto; }
.pad[hidden] { display: none; }

.pad-cluster { display: flex; align-items: center; gap: 22px; }

/* 十字键 */
.dpad {
  position: relative;
  width: 168px; height: 168px;
  touch-action: none;
}
.dpad span {
  position: absolute;
  background: rgba(20, 21, 25, .74);
  border: 3px solid rgba(255, 255, 255, .30);
  display: grid; place-items: center;
  transition: background-color .05s, border-color .05s;
}
.dpad span::before {
  content: ""; width: 0; height: 0; border-style: solid;
}
.dpad .u { left: 56px; top: 0; width: 56px; height: 58px; }
.dpad .d { left: 56px; top: 110px; width: 56px; height: 58px; }
.dpad .l { left: 0; top: 56px; width: 58px; height: 56px; }
.dpad .r { left: 110px; top: 56px; width: 58px; height: 56px; }
.dpad .c { left: 56px; top: 56px; width: 56px; height: 56px; border-color: rgba(255, 255, 255, .16); }
.dpad .u::before { border-width: 0 11px 13px 11px; border-color: transparent transparent rgba(255,255,255,.62) transparent; }
.dpad .d::before { border-width: 13px 11px 0 11px; border-color: rgba(255,255,255,.62) transparent transparent transparent; }
.dpad .l::before { border-width: 11px 13px 11px 0; border-color: transparent rgba(255,255,255,.62) transparent transparent; }
.dpad .r::before { border-width: 11px 0 11px 13px; border-color: transparent transparent transparent rgba(255,255,255,.62); }
.dpad span.on { background: var(--fc-red); border-color: #FFF3F1; }
.dpad span.on::before { border-bottom-color: #FFF3F1; border-top-color: #FFF3F1; }
.dpad .l.on::before, .dpad .l.on::before { border-right-color: #FFF3F1; }
.dpad .r.on::before { border-left-color: #FFF3F1; }

/* A / B */
.ab { display: flex; gap: 18px; transform: rotate(-8deg); }
.ab button {
  width: 74px; height: 74px; border-radius: 50%;
  background: rgba(20, 21, 25, .74);
  border: 3px solid rgba(255, 255, 255, .30);
  color: rgba(255, 255, 255, .82);
  font-size: 21px; font-weight: 800; letter-spacing: .06em;
  font-family: var(--mono);
  display: grid; place-items: center;
  transition: background-color .05s, transform .05s;
}
.ab button.on { background: var(--fc-red); color: #FFF3F1; border-color: #FFF3F1; transform: scale(.94); }

/* SELECT / START */
.ss { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.ss button {
  width: 62px; height: 22px;
  background: rgba(20, 21, 25, .74);
  border: 3px solid rgba(255, 255, 255, .26);
  color: rgba(255, 255, 255, .7);
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  font-family: var(--mono);
}
.ss button.on { background: var(--plastic-3); color: var(--ink); border-color: var(--plastic); }

/* 竖屏请旋转 */
.rotate-note {
  position: fixed; inset: 0; z-index: 60;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; padding: 32px; text-align: center;
  background: #0C0D10;
}
.rotate-note .icon-phone {
  width: 46px; height: 78px;
  border: 5px solid var(--plastic);
  animation: tilt 1.6s ease-in-out infinite;
}
@keyframes tilt {
  0%, 42% { transform: rotate(0deg); }
  62%, 100% { transform: rotate(-90deg); }
}
.rotate-note h3 { font-size: 16px; font-weight: 700; }
.rotate-note p { font-size: 13px; color: var(--ink-3); }

/* ── 响应式 ─────────────────────────────────────── */
@media (max-width: 900px) {
  .play-bar { padding: 8px 10px; gap: 8px; }
  .play-title { font-size: 13px; }
  .play-title span { display: none; }
  .dpad { width: 132px; height: 132px; }
  .dpad .u { left: 44px; top: 0; width: 44px; height: 46px; }
  .dpad .d { left: 44px; top: 86px; width: 44px; height: 46px; }
  .dpad .l { left: 0; top: 44px; width: 46px; height: 44px; }
  .dpad .r { left: 86px; top: 44px; width: 46px; height: 44px; }
  .dpad .c { left: 44px; top: 44px; width: 44px; height: 44px; }
  .ab { gap: 14px; }
  .ab button { width: 60px; height: 60px; font-size: 18px; }
  .ss button { width: 54px; height: 20px; font-size: 9.5px; }
  .pad { padding: 0 16px 14px; }
}

@media (max-width: 640px) {
  .wrap { padding: 0 18px; }
  .masthead { padding: 20px 0 16px; }
  .masthead-inner { align-items: flex-start; }
  .masthead-side { text-align: left; }
  .grid { grid-template-columns: 1fr; gap: 20px; }
  .gallery { padding: 30px 0 40px; }
}

@media (hover: none) and (pointer: coarse) {
  .cart:hover { transform: none; box-shadow: var(--shadow); }
}

/* ── 触屏按键：把「按一下卡一下」按掉 ─────────────────
   手柄是半透明盖在画布上的。原来按下要跑 50ms 的颜色过渡，这 50ms 里
   按钮每帧都要重绘，而它盖在画布上，重绘就得连画布一起重新合成；
   模拟器本身已经把主线程吃满，这段动画于是被拉长成肉眼可见的顿挫。
   改法：
   1) 反馈只留 transform —— 合成器属性，GPU 直接做，不触发重绘；
      颜色切换一次到位，不留过渡。
   2) A/B 的倾斜从容器挪到按钮自身：父层一旦带 transform，
      子按钮的 scale 就得跟着重建合成层。
   3) 手柄整体提成独立合成层，按键变化不再牵动下面的画布。 */
@media (pointer: coarse) {
  .pad { transform: translateZ(0); }
  .pad-cluster { transform: translateZ(0); }

  .dpad span,
  .ss button {
    transition: none !important;
  }

  .ab { transform: none; }
  .ab button {
    transform: rotate(-8deg);
    transition: transform .07s ease-out !important;
    will-change: transform;
  }
  .ab button.on { transform: rotate(-8deg) scale(.94); }

  .pad, .dpad, .pad button, .pad span {
    -webkit-tap-highlight-color: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
