/* 资源坞 · 8-bit 像素风（NES / 马里奥配色）
   原则：硬边、零圆角、4px 黑框、硬投影、像素方块按钮；一个主色（红），黄只做选中与焦点。
   字体自托管：Fusion Pixel 12px（中文）+ Press Start 2P（数字/拉丁）。 */

@font-face {
  font-family: "PixelSC";
  src: url("../fonts/fusion-pixel-12px-sc.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "PressStart";
  src: url("../fonts/press-start-2p.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f8f4e6;
  --card: #fffdf7;
  --ink: #1a1a1a;
  --ink-2: #4a453c;
  --ink-3: #7d766a;
  --red: #d93a2b;
  --red-dark: #a8291d;
  --yellow: #f5b71e;
  --sky: #5c94fc;
  --green: #2fa84f;
  --brick: #b4531b;

  --px: 4px;        /* 基础像素单位 */
  --shell: 760px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: "PixelSC", "PingFang SC", "Microsoft YaHei", monospace;
  font-size: 14px;
  line-height: 1.9;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* 极淡的像素网格，像文档纸 */
  background-image:
    linear-gradient(90deg, rgba(26, 26, 26, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(26, 26, 26, 0.035) 1px, transparent 1px);
  background-size: 8px 8px;
}

a { color: inherit; text-decoration: none; }

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

.mono { font-family: "PressStart", "PixelSC", monospace; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: var(--px) solid var(--ink);
}

.topbar-inner {
  max-width: var(--shell);
  margin: 0 auto;
  min-height: 56px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  white-space: nowrap;
}

/* 像素方块 logo：橙底黑框 + 问号 */
.brand-mark {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--yellow);
  border: 3px solid var(--ink);
  font-family: "PressStart", monospace;
  font-size: 9px;
  line-height: 1;
  color: var(--ink);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topnav a {
  padding: 4px 8px 3px;
  font-size: 13px;
  color: var(--ink-2);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.topnav a:hover { color: var(--ink); }

.topnav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--yellow);
}

/* ---------- 容器 ---------- */
.view {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 26px 16px 56px;
}

.page-head { margin-bottom: 20px; }

.page-title {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.4;
  letter-spacing: 0.01em;
}

.page-title::before {
  content: "▶";
  margin-right: 8px;
  font-size: 14px;
  color: var(--red);
  vertical-align: 2px;
}

.page-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.85;
  color: var(--ink-2);
}

.page-desc a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.search { position: relative; }

.search input {
  width: 100%;
  height: 42px;
  padding: 0 38px 0 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 0;
  box-shadow: 4px 4px 0 var(--ink);
  outline: none;
}

.search input::placeholder { color: var(--ink-3); }

.search input:focus {
  box-shadow: 4px 4px 0 var(--yellow);
  border-color: var(--ink);
}

.search-key {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: "PressStart", monospace;
  font-size: 9px;
  padding: 3px 4px;
  color: var(--ink-3);
  border: 2px solid var(--ink-3);
  pointer-events: none;
}

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

.chip {
  height: 30px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 0;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.06s linear, box-shadow 0.06s linear, background 0.12s linear;
}

.chip:hover { background: #fff8d8; }

.chip[aria-pressed="true"] {
  color: #fff;
  background: var(--red);
  box-shadow: 1px 1px 0 var(--ink);
  transform: translate(2px, 2px);
}

/* ---------- 列表卡片 ---------- */
.list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.item {
  display: block;
  padding: 14px 16px;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 0;
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform 0.07s linear, box-shadow 0.07s linear, background 0.12s linear;
}

.item:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 var(--ink);
  background: #fffef9;
}

.item:active {
  transform: translate(5px, 5px);
  box-shadow: 0 0 0 var(--ink);
}

.item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.item-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
}

.item-arrow {
  flex: none;
  font-family: "PressStart", monospace;
  font-size: 10px;
  color: var(--red);
  padding-top: 4px;
}

.item-desc {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink-2);
}

.item-meta {
  margin: 10px 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: 12px;
  color: var(--ink-3);
}

.item-meta .sep { opacity: 0.6; }

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 6px;
}

.tag {
  font-size: 12px;
  color: var(--ink-2);
}

.tag::before {
  content: "#";
  color: var(--red);
  margin-right: 1px;
}

.badge-dead {
  flex: none;
  padding: 1px 6px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--card);
  background: var(--ink-3);
  border: 2px solid var(--ink-3);
}

/* ---------- 空状态 ---------- */
.empty {
  padding: 40px 18px;
  text-align: center;
  font-size: 13px;
  line-height: 1.9;
  color: var(--ink-2);
  background: var(--card);
  border: 3px dashed var(--ink-3);
}

.empty strong {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
}

/* ---------- 详情 ---------- */
.detail { max-width: 660px; margin: 0 auto; }

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding: 0;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-2);
  background: none;
  border: none;
  cursor: pointer;
}

.backlink:hover { color: var(--ink); }

.detail-title {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.5;
}

.detail-meta {
  margin: 0 0 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 12px;
  color: var(--ink-3);
}

.detail-meta .sep { opacity: 0.6; }

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 0 0 14px;
}

.detail-lede {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--ink-2);
}

.notice {
  margin: 0 0 18px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink);
  background: #fff3c4;
  border: 3px solid var(--ink);
}

.specs {
  margin: 0 0 22px;
  border: 3px solid var(--ink);
  background: var(--card);
}

.spec-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px;
  font-size: 13px;
}

.spec-row + .spec-row { border-top: 2px solid var(--ink); }

.spec-row dt { margin: 0; color: var(--ink-2); }

.spec-row dd {
  margin: 0;
  font-family: "PressStart", "PixelSC", monospace;
  font-size: 11px;
  line-height: 1.9;
}

.block-title {
  margin: 0 0 10px;
  font-size: 14px;
}

.block-title::before {
  content: "▪";
  margin-right: 6px;
  color: var(--red);
}

.items {
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}

.items li {
  padding: 8px 0 8px 16px;
  position: relative;
  font-size: 13.5px;
  line-height: 1.85;
  border-bottom: 2px solid var(--ink);
}

.items li:first-child { border-top: 2px solid var(--ink); }

.items li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 16px;
  width: 6px;
  height: 6px;
  background: var(--red);
}

/* 按钮：红底黑框硬投影，按下位移 */
.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 220px;
  height: 48px;
  padding: 0 18px;
  font-family: inherit;
  font-size: 15px;
  color: #fff;
  background: var(--red);
  border: 3px solid var(--ink);
  border-radius: 0;
  box-shadow: 5px 5px 0 var(--ink);
  cursor: pointer;
  text-align: center;
  transition: transform 0.06s linear, box-shadow 0.06s linear, background 0.12s linear;
}

.btn:hover { background: #e04a3a; }

.btn:active {
  transform: translate(5px, 5px);
  box-shadow: 0 0 0 var(--ink);
}

.btn-ghost {
  flex: 0 0 auto;
  color: var(--ink);
  background: var(--card);
  font-size: 14px;
  box-shadow: 5px 5px 0 var(--ink-3);
}

.btn-ghost:hover { background: #fff8d8; }

.hint {
  margin: 0 0 20px;
  font-size: 12px;
  line-height: 1.9;
  color: var(--ink-3);
}

.report {
  padding-top: 14px;
  border-top: 2px dashed var(--ink-3);
  font-size: 13px;
  color: var(--ink-3);
}

.report button,
.report a {
  padding: 0;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.report button:hover,
.report a:hover { color: var(--red); }

.report-body {
  margin: 10px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.9;
  color: var(--ink-2);
  background: var(--card);
  border: 2px solid var(--ink);
}

/* ---------- 长文（FAQ / 失效清单） ---------- */
.doc { max-width: 660px; margin: 0 auto; }

.doc-title {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.45;
}

.doc-meta {
  margin: 0 0 20px;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--ink);
  font-size: 12px;
  color: var(--ink-3);
}

.toc {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 16px;
  margin: 0 0 26px;
  padding: 12px 14px;
  background: var(--card);
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
}

.toc button {
  padding: 6px 0;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-2);
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

.toc button::before {
  content: "▸";
  margin-right: 5px;
  color: var(--red);
}

.toc button:hover { color: var(--ink); }

.doc p {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.95;
}

.doc h2 {
  margin: 30px 0 12px;
  padding-top: 16px;
  border-top: 3px solid var(--ink);
  font-size: 18px;
  line-height: 1.6;
  scroll-margin-top: 76px;
}

.doc h2::before {
  content: "▶";
  margin-right: 8px;
  font-size: 12px;
  color: var(--red);
  vertical-align: 2px;
}

.doc h3 {
  margin: 18px 0 8px;
  font-size: 14px;
}

.doc h3::before {
  content: "▪";
  margin-right: 6px;
  color: var(--red);
}

.doc ul {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.doc ul li {
  position: relative;
  padding-left: 16px;
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.9;
}

.doc ul li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 13px;
  width: 6px;
  height: 6px;
  background: var(--ink-3);
}

.doc blockquote {
  margin: 0 0 16px;
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--ink);
  background: #fff3c4;
  border: 3px solid var(--ink);
}

.doc strong { font-weight: 400; color: var(--red); }

.doc a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.doc a:hover { color: var(--red); }

.doc code {
  font-family: "PixelSC", monospace;
  font-size: 12.5px;
  padding: 1px 4px;
  background: #ffe9b0;
  border: 2px solid var(--ink);
  white-space: nowrap;
}

.doc-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 28px;
  padding-top: 14px;
  border-top: 2px dashed var(--ink-3);
  font-size: 12px;
  color: var(--ink-3);
}

.doc-foot a {
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* 失效清单 */
.dead-list {
  margin: 0 0 4px;
  border: 3px solid var(--ink);
  background: var(--card);
}

.dead-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
}

.dead-item + .dead-item { border-top: 2px solid var(--ink); }

.dead-item-title {
  display: block;
  font-size: 14px;
  line-height: 1.7;
}

.dead-item-sub {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
}

.dead-item a {
  flex: none;
  font-size: 13px;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.dead-item a:hover { color: var(--red); }

.all-ok {
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.9;
  background: var(--card);
  border: 3px solid var(--ink);
}

/* ---------- 页脚 + 地砖 ---------- */
.foot {
  border-top: var(--px) solid var(--ink);
  padding: 18px 16px 0;
  background: var(--paper);
}

.foot-inner {
  max-width: var(--shell);
  margin: 0 auto 18px;
  font-size: 12px;
  line-height: 1.9;
  color: var(--ink-3);
}

.foot-inner p { margin: 0 0 4px; }

.foot-inner a {
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.foot-dim span { margin: 0 3px; }

/* 马里奥地砖条 */
.ground {
  height: 18px;
  border-top: 3px solid var(--ink);
  background-color: var(--brick);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='18'%3E%3Crect width='32' height='18' fill='%23b4531b'/%3E%3Cpath d='M0 0h32M0 9h32M16 0v9M8 9v9M24 9v9' stroke='%231a1a1a' stroke-width='2'/%3E%3C/svg%3E");
  background-size: 32px 18px;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- 二维码块（单条资源页） ---------- */
.qr-block {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 4px 0 26px;
  padding: 14px;
  background: var(--card);
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
}

.qr-box {
  flex: none;
  width: 132px;
  height: 132px;
  padding: 6px;
  background: #fff;
  border: 3px solid var(--ink);
  display: grid;
  place-items: center;
}

.qr-box img { display: block; width: 100%; height: auto; image-rendering: pixelated; }

.qr-text {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.qr-text strong { font-weight: 400; font-size: 14px; }

.qr-text span { font-size: 12px; line-height: 1.85; color: var(--ink-3); }

.qr-link {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--ink-2);
  word-break: break-all;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.qr-link:hover { color: var(--red); }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translate(-50%, 10px);
  z-index: 60;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  color: var(--card);
  background: var(--ink);
  border: 3px solid var(--card);
  box-shadow: 4px 4px 0 var(--red);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s linear, transform 0.15s linear;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 移动端 ---------- */
@media (max-width: 620px) {
  body { font-size: 13.5px; }

  .topbar-inner { min-height: 50px; padding: 6px 10px; gap: 4px; }
  .brand { gap: 6px; font-size: 14px; }
  .brand-mark { width: 20px; height: 20px; border-width: 2px; font-size: 8px; }
  .topnav { gap: 0; flex: none; }
  .topnav a { padding: 4px 5px 3px; font-size: 12px; border-bottom-width: 2px; letter-spacing: -0.02em; }

  .view { padding: 20px 12px 44px; }

  .page-title { font-size: 20px; }
  .page-title::before { font-size: 12px; margin-right: 6px; }
  .page-desc { font-size: 12.5px; }

  .search input { height: 44px; font-size: 14px; box-shadow: 3px 3px 0 var(--ink); }
  .search-key { display: none; }

  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 2px 2px 6px;
    -webkit-mask-image: linear-gradient(to right, #000 90%, transparent 100%);
    mask-image: linear-gradient(to right, #000 90%, transparent 100%);
  }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; height: 32px; font-size: 12.5px; box-shadow: 2px 2px 0 var(--ink); }

  .list { gap: 12px; }
  .item { padding: 12px 13px; box-shadow: 4px 4px 0 var(--ink); }
  .item-title { font-size: 15px; }
  .item-desc { font-size: 12.5px; }
  .item-meta { font-size: 11.5px; }
  .item-arrow { display: none; }

  .detail-title, .doc-title { font-size: 19px; }

  .spec-row { font-size: 12.5px; padding: 7px 10px; }
  .spec-row dd { font-size: 10px; }

  .items li { font-size: 13px; }

  .btn { flex: 1 1 100%; height: 46px; font-size: 14.5px; box-shadow: 4px 4px 0 var(--ink); }
  .btn-ghost { flex: 1 1 100%; }
  .btn:active { transform: translate(4px, 4px); }

  .toc { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; padding: 10px 12px; box-shadow: 4px 4px 0 var(--ink); }
  .toc button { font-size: 12px; padding: 7px 0; }

  .doc p, .doc ul li { font-size: 13px; }
  .doc h2 { font-size: 16px; }
  .doc h3 { font-size: 13.5px; }
  .doc blockquote { font-size: 12.5px; }

  .foot { padding: 16px 12px 0; }
  .foot-inner { font-size: 11.5px; }

  .qr-block { gap: 12px; padding: 12px; box-shadow: 4px 4px 0 var(--ink); }
  .qr-box { width: 108px; height: 108px; padding: 5px; }
  .qr-text strong { font-size: 13px; }
  .qr-text span { font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}