/* ========== GameBoy DMG 风格 ========== */
@font-face {
  font-family: 'Zpix';
  src: url('https://cdn.jsdelivr.net/gh/SolidZORO/zpix-pixel-font@dist/dist/Zpix.woff2') format('woff2');
  font-display: swap;
}
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

:root {
  /* GameBoy 四阶绿 */
  --gb0: #0f380f;   /* 最深（文字/描边） */
  --gb1: #306230;   /* 深 */
  --gb2: #8bac0f;   /* 浅 */
  --gb3: #9bbc0f;   /* 最浅（屏幕底色） */

  /* DMG 机身色 */
  --shell: #c8c4bc;       /* 米灰机身 */
  --shell-dark: #a8a49c;  /* 机身阴影 */
  --bezel: #5a5e6a;       /* 屏幕深灰面板 */
  --btn: #b13b3b;         /* AB 键酒红 */
  --btn-dark: #8f2e2e;
  --key: #4a4e5a;         /* start/select 深灰键 */

  --font-pixel: 'Zpix', 'VT323', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { image-rendering: pixelated; }
body {
  background: #2a2d33;
  font-family: var(--font-pixel);
  display: flex; justify-content: center;
  padding: 24px 12px 48px;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }

/* ===== 掌机机身 ===== */
.console {
  width: 100%; max-width: 560px;
  background: var(--shell);
  border: 4px solid var(--shell-dark);
  border-radius: 12px 12px 40px 12px;   /* 右下大圆角 = DMG 经典 */
  box-shadow: 8px 8px 0 rgba(0,0,0,.35);
  padding: 18px 20px 26px;
}

/* 顶部扬声器格栅（左上斜线） */
.speaker-grill {
  display: flex; gap: 6px; justify-content: flex-end;
  transform: rotate(-26deg); transform-origin: right;
  margin: -4px -14px 14px;
}
.speaker-grill span {
  width: 7px; height: 34px;
  background: var(--shell-dark);
  border-radius: 3px;
}

/* ===== 屏幕面板 ===== */
.bezel {
  background: var(--bezel);
  border-radius: 8px 8px 30px 8px;
  padding: 10px 18px 22px;
  border: 3px solid #3c3f48;
}
.bezel-top {
  display: flex; align-items: baseline; gap: 12px;
  padding: 2px 4px 8px;
  color: #b8be9e;
  font-size: 12px;
}
.led { color: #d6d2c8; letter-spacing: 1px; }
.led i {
  display: inline-block; width: 8px; height: 8px;
  background: #e0413c; border-radius: 50%;
  margin-right: 5px;
  box-shadow: 0 0 6px #e0413c;
  animation: ledblink 2s steps(1) infinite;
}
@keyframes ledblink { 50% { opacity: .35; } }
.bezel-brand { font-size: 15px; font-weight: bold; color: #d6d2c8; }
.bezel-brand .tm { font-size: 9px; }
.bezel-sub { margin-left: auto; font-size: 9px; color: #8a90a0; letter-spacing: 1px; }

/* ===== LCD 屏 ===== */
.lcd {
  background: var(--gb3);
  border: 3px solid #3c3f48;
  border-radius: 4px;
  box-shadow: inset 3px 3px 0 rgba(15,56,15,.25);
}
.lcd-inner {
  padding: 14px 16px;
  color: var(--gb0);
  font-size: 14px; line-height: 1.7;
  position: relative;
  overflow: hidden;
}
/* LCD 网格纹 */
.lcd-inner::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(15,56,15,.05) 2px 3px),
    repeating-linear-gradient(90deg, transparent 0 2px, rgba(15,56,15,.05) 2px 3px);
}

/* ===== 屏内内容 ===== */
.gb-status {
  display: flex; gap: 10px; align-items: center;
  border-bottom: 2px solid var(--gb1);
  padding-bottom: 8px; margin-bottom: 18px;
  font-size: 13px;
}
.gb-status-right { margin-left: auto; color: var(--gb1); }

.gb-hero { text-align: center; margin-bottom: 24px; }
.logo-big {
  font-family: 'VT323', monospace;
  font-size: clamp(34px, 9vw, 60px);
  letter-spacing: 4px;
  color: var(--gb0);
  line-height: 1.1;
  text-shadow: 2px 2px 0 rgba(15,56,15,.25);
}
.gb-logo {
  font-family: 'VT323', monospace;
  font-size: 12px; line-height: 1.15;
  color: var(--gb0);
  overflow-x: auto;
}
.gb-hero-sub {
  margin: 12px 0 18px; font-size: 15px;
  animation: gbblink 1.2s steps(1) infinite;
}
@keyframes gbblink { 50% { opacity: 0; } }

.gb-search {
  display: flex; gap: 8px; max-width: 380px; margin: 0 auto;
  border: 2px solid var(--gb0);
  background: var(--gb2);
  padding: 6px 10px;
}
#search {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--gb0); font-family: var(--font-pixel); font-size: 14px;
}
#search::placeholder { color: var(--gb0); opacity: .55; }

.gb-section { margin-bottom: 22px; }
.gb-section h2 {
  font-size: 14px; margin-bottom: 10px;
  border-bottom: 2px dashed var(--gb1);
  padding-bottom: 4px;
}

/* 卡带式工具卡 */
.cart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.cart {
  border: 2px solid var(--gb0);
  background: var(--gb2);
  padding: 10px;
  box-shadow: 3px 3px 0 var(--gb1);
  cursor: pointer;
}
.cart:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--gb0); }
.cart:active { transform: translate(3px,3px); box-shadow: none; }
.cart-label { font-size: 14px; margin-bottom: 4px; }
.cart-desc { font-size: 12px; color: var(--gb1); margin-bottom: 8px; }
.cart-insert { font-size: 12px; border-top: 1px dashed var(--gb1); padding-top: 5px; }

/* 教程关卡列表 */
.gb-list { list-style: none; }
.gb-list a {
  display: block; padding: 6px 8px; font-size: 13px; line-height: 1.6;
}
.gb-list a:hover { background: var(--gb2); }
.badbe, .badge {
  font-style: normal; font-size: 10px;
  background: var(--gb0); color: var(--gb3);
  padding: 1px 5px; margin-left: 6px;
}
.badge-imp {
  font-style: normal; font-size: 10px;
  background: var(--btn); color: #f3e9e2;
  padding: 1px 6px; margin-left: 6px;
}

.gb-footer {
  display: flex; justify-content: center; gap: 12px; flex-wrap: wrap;
  border-top: 2px solid var(--gb1);
  padding-top: 10px; margin-top: 20px;
  font-size: 11px; color: var(--gb1);
}
.icp:hover { text-decoration: underline; }

/* ===== 按键区 ===== */
.controls {
  display: flex; justify-content: space-between; align-items: center;
  margin: 26px 10px 6px;
}
/* 十字键 */
.dpad {
  display: grid;
  grid-template: repeat(3, 26px) / repeat(3, 26px);
  transform: rotate(0deg);
}
.dp {
  background: var(--key);
  color: var(--shell);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  border: 2px solid #33363f;
}
.dp.up    { grid-area: 1/2; border-radius: 5px 5px 0 0; }
.dp.mid   { grid-area: 2/2; background: var(--key); border-width: 0 2px; }
.dp.down  { grid-area: 3/2; border-radius: 0 0 5px 5px; }
.dp.left  { grid-area: 2/1; border-radius: 5px 0 0 5px; }
.dp.right { grid-area: 2/3; border-radius: 0 5px 5px 0; }
.dp:hover { background: #5c606d; }
.dp:active { background: #2e3138; }

/* AB 键 */
.ab { display: flex; gap: 16px; transform: rotate(-22deg); }
.ab a {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--btn);
  border: 3px solid var(--btn-dark);
  color: #f3e9e2; font-size: 14px; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 4px 0 var(--btn-dark);
  line-height: 1.1;
}
.ab a i { font-style: normal; font-size: 10px; opacity: .8; }
.ab a:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-dark); }

/* start/select 长条键 */
.start-select {
  display: flex; gap: 26px; justify-content: center; align-items: center;
  margin-top: 20px;
}
.start-select a, .blank-key {
  background: var(--key);
  color: var(--shell);
  font-size: 11px;
  padding: 5px 16px 6px;
  border-radius: 10px;
  border: 2px solid #33363f;
  transform: rotate(-22deg);
}
.start-select a:hover { background: #5c606d; }
.start-select a:active { background: #2e3138; }

.console-brand {
  text-align: center; margin-top: 18px;
  font-size: 12px; color: var(--bezel);
  letter-spacing: 1px;
}

/* ===== 动画工具类 ===== */
.blink-slow { animation: ledblink 2s steps(1) infinite; }

/* ===== 响应式 ===== */
/* 平板/小桌面：机身放大 */
@media (min-width: 720px) {
  .console { max-width: 820px; padding: 22px 26px 30px; }
  .lcd-inner { font-size: 16px; padding: 18px 20px; }
  .gb-logo { font-size: 15px; }
  .cart-grid { grid-template-columns: 1fr 1fr 1fr; }
  .gb-list a { font-size: 15px; }
  .gb-section h2 { font-size: 16px; }
  .gb-search { max-width: 480px; }
}
/* 大桌面：充分利用屏幕 */
@media (min-width: 1200px) {
  .console { max-width: 1020px; }
  .lcd-inner { font-size: 17px; }
  .cart-grid { grid-template-columns: repeat(4, 1fr); }
  .gb-logo { font-size: 18px; }
}
@media (max-width: 640px) {
  /* 手机：壳变薄，把宽度还给内容 */
  body { padding: 0 0 32px; }
  .console {
    max-width: none;
    border: none;
    border-radius: 0 0 18px 18px;
    box-shadow: none;
    padding: 8px 6px 16px;
  }
  .speaker-grill { display: none; }
  .bezel { padding: 8px 7px 12px; border-width: 2px; border-radius: 6px 6px 16px 6px; }
  .bezel-top { gap: 8px; font-size: 10px; padding-bottom: 6px; }
  .bezel-brand { font-size: 12px; }
  .lcd { border-width: 2px; }
  .lcd-inner { padding: 10px 9px 14px; }
  .gb-status { font-size: 11px; gap: 6px; }
  .cart-grid { grid-template-columns: 1fr; gap: 8px; }
  .gb-logo { font-size: 8.5px; }
  .bezel-sub { display: none; }
  .gb-search { padding: 5px 8px; }
  #search { font-size: 13px; }
}

/* ===== 文章素材通用样式 ===== */
/* 表格 */
.gb-table-wrap { overflow-x: auto; margin: 12px 0 16px; border: 2px solid var(--gb0); box-shadow: 3px 3px 0 var(--gb1); }
.gb-table-wrap table { border-collapse: collapse; width: 100%; font-size: 13px; }
.gb-table-wrap th {
  background: var(--gb0); color: var(--gb3);
  padding: 6px 10px; text-align: left; white-space: nowrap;
}
.gb-table-wrap td { padding: 6px 10px; border-top: 1px solid var(--gb1); }
.gb-table-wrap tr:nth-child(even) td { background: rgba(139,172,15,.35); }

/* 图片 + 描述 */
.gb-figure { margin: 14px 0 18px; text-align: center; }
.gb-figure img {
  max-width: 100%;
  border: 2px solid var(--gb0);
  box-shadow: 3px 3px 0 var(--gb1);
  background: #fff;
  image-rendering: auto; /* 文章截图是照片级图像，不做像素化放大 */
}
.gb-figure figcaption {
  font-size: 12px; color: var(--gb1);
  margin-top: 6px; line-height: 1.6;
}
.gb-figure figcaption b { color: var(--gb0); }

/* 文件下载 */
.gb-file {
  display: flex; align-items: center; gap: 10px;
  border: 2px solid var(--gb0);
  background: var(--gb2);
  padding: 8px 12px; margin: 10px 0;
  box-shadow: 3px 3px 0 var(--gb1);
  font-size: 13px;
}
.gb-file:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--gb0); }
.gb-file:active { transform: translate(3px,3px); box-shadow: none; }
.gb-file .f-icon { font-size: 16px; }
.gb-file .f-name { flex: 1; }
.gb-file .f-size { font-size: 11px; color: var(--gb1); }
.gb-file .f-dl { font-size: 11px; background: var(--gb0); color: var(--gb3); padding: 2px 8px; }

/* 代码块（公共样式：所有页面统一带边框） */
.gb-code {
  border: 2px solid var(--gb0);
  box-shadow: 3px 3px 0 var(--gb1);
  margin: 12px 0 16px;
  background: var(--gb3);
}
.gb-code .head {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--gb0); color: var(--gb3);
  padding: 3px 8px; font-size: 11px;
}
.copy-btn {
  background: var(--gb2); color: var(--gb0); border: none;
  font-family: var(--font-pixel); font-size: 11px;
  padding: 1px 8px; cursor: pointer;
}
.copy-btn:active { background: var(--gb3); }
.gb-code pre {
  background: var(--gb2);
  padding: 10px 12px; font-size: 13px; line-height: 1.7;
  overflow-x: auto; font-family: 'VT323', monospace;
}
.gb-code .cm { color: var(--gb0); opacity: .6; }
.gb-code .st { text-decoration: underline; text-underline-offset: 3px; }
@media (min-width: 720px) {
  .gb-code pre { font-size: 15px; }
  .gb-code .head { font-size: 13px; }
}

/* ===== 跳转模块（传送门） ===== */
.gb-jump {
  border: 2px solid var(--gb0);
  background: var(--gb3);
  box-shadow: 3px 3px 0 var(--gb1);
  padding: 10px 12px;
  margin: 14px 0;
  font-size: 13px;
}
.gb-jump .jump-title {
  font-size: 12px; color: var(--gb1);
  border-bottom: 1px dashed var(--gb1);
  padding-bottom: 5px; margin-bottom: 8px;
}
.gb-jump a {
  display: flex; gap: 8px; align-items: baseline;
  padding: 5px 6px; line-height: 1.6;
}
.gb-jump a:hover { background: var(--gb2); }
.gb-jump a .jp-icon { flex-shrink: 0; }
.gb-jump a .jp-src { color: var(--gb1); font-size: 11px; margin-left: auto; white-space: nowrap; }
.gb-jump a:hover .jp-src::after { content: " ▸"; }

/* 图片占位框（文章补图前使用，替换为 .gb-figure 即可） */
.gb-img-placeholder {
  margin: 14px 0 6px;
  border: 2px dashed var(--gb1);
  background: repeating-linear-gradient(45deg, transparent 0 10px, rgba(48,98,48,.12) 10px 20px);
  padding: 34px 12px;
  text-align: center;
  font-size: 13px; color: var(--gb1); line-height: 1.8;
}
.gb-img-placeholder::before { content: "🖼 "; }
.gb-img-placeholder .ph-no { display: block; font-size: 11px; color: var(--gb0); opacity: .65; }

/* 「待补充」小节标记 */
.gb-todo {
  display: inline-block; font-size: 10px;
  border: 1px solid var(--gb1); color: var(--gb1);
  padding: 0 6px; margin-left: 6px; vertical-align: 2px;
}

/* NPC 对话框（双线框 + 底部闪烁箭头） */
.gb-dialog {
  border: 2px solid var(--gb0);
  box-shadow: inset 0 0 0 2px var(--gb3), inset 0 0 0 4px var(--gb1);
  background: var(--gb3);
  padding: 14px 16px 18px;
  margin: 14px 0;
  font-size: 13px; line-height: 1.9;
  position: relative;
}
.gb-dialog::after {
  content: "▼"; position: absolute; bottom: 3px; right: 10px;
  animation: gbblink 1s steps(1) infinite;
}
@media (min-width: 720px) {
  .gb-dialog { font-size: 15px; }
}

/* 平滑滚动 + 跳转目标闪烁高亮 */
html { scroll-behavior: smooth; }
.gb-doc :target { animation: targetflash .5s steps(2) 4; }
@keyframes targetflash {
  0%, 100% { background: transparent; }
  50% { background: var(--gb2); outline: 2px solid var(--gb0); outline-offset: 3px; }
}
