/* ==================== 拼豆图纸工坊 · 8-bit 像素艺术风 ==================== */
/* 参考: stylekit.top/zh/styles/pixel-art */
/* 核心: 无圆角 · 无渐变 · 无模糊阴影 · 硬边像素阴影 · 4px粗边框 · 纯色 */

:root {
  --bg: #1a1c2c;
  --surface: #f4f4f4;
  --panel: #ffffff;
  --panel-alt: #e8e8e8;
  --ink: #1a1c2c;
  --ink-soft: #5a5a78;
  --muted: #8888a8;
  --accent: #ff004d;
  --accent-hover: #cc003d;
  --accent-light: #ffe0e8;
  --blue: #29adff;
  --blue-light: #d6f0ff;
  --green: #00e436;
  --green-light: #d6ffe0;
  --yellow: #ffec27;
  --pink: #ff77a8;
  --purple: #ab45e0;
  --border: #1a1c2c;
  --shadow: 4px 4px 0 #1a1c2c;
  --shadow-sm: 2px 2px 0 #1a1c2c;
  --shadow-lg: 6px 6px 0 #1a1c2c;
  --border-w: 4px;
  --font: "Press Start 2P", "Noto Sans SC", monospace;
  --font-body: "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: auto; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==================== 顶部导航 ==================== */
.topbar {
  position: relative; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px;
  background: #2a2d3e;
  border-bottom: var(--border-w) solid var(--border);
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-beads { display: flex; gap: 3px; }
.logo-beads i {
  display: block; width: 12px; height: 12px;
  background: var(--c); border: 2px solid var(--border);
  box-shadow: 2px 2px 0 var(--border);
}
.logo-beads i:nth-child(1) { animation: beadBounce 1s step-end infinite; }
.logo-beads i:nth-child(2) { animation: beadBounce 1s step-end infinite 0.25s; }
.logo-beads i:nth-child(3) { animation: beadBounce 1s step-end infinite 0.5s; }
.logo-beads i:nth-child(4) { animation: beadBounce 1s step-end infinite 0.75s; }
@keyframes beadBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
.logo-text {
  font-family: var(--font);
  font-size: 0.9rem; font-weight: 400;
  color: #fff; letter-spacing: 2px;
}
.logo-accent { color: var(--yellow); }
.topbar-sub {
  font-size: 0.7rem; color: rgba(255,255,255,0.6);
  font-family: var(--font); letter-spacing: 1px;
}

/* ==================== 主布局 ==================== */
.layout {
  position: relative; z-index: 10;
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: 0; padding: 12px;
  max-width: 1400px; margin: 0 auto;
  width: 100%;
  min-height: calc(100vh - 56px - 44px);
  align-items: start;
}
.panel-col { min-width: 0; display: flex; flex-direction: column; gap: 0; }

/* ==================== 面板通用 ==================== */
.panel {
  background: var(--panel);
  border: var(--border-w) solid var(--border);
  border-radius: 0;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  position: relative;
}
.panel-title {
  font-family: var(--font);
  font-size: 0.65rem; font-weight: 400;
  color: var(--ink); margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 10px;
  border-bottom: var(--border-w) solid var(--border);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.panel-title .cur-info {
  margin-left: auto; font-size: 0.65rem;
  font-weight: 400; color: var(--muted);
  text-transform: none;
}

/* ==================== 按钮系统 ==================== */
.px-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-body); font-size: 0.85rem; font-weight: 700;
  padding: 10px 16px; min-height: 44px;
  border: var(--border-w) solid var(--border);
  border-radius: 0;
  background: var(--panel); color: var(--ink);
  cursor: pointer; transition: none;
  user-select: none; white-space: nowrap;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.px-btn:hover {
  transform: translate(2px, 2px);
  box-shadow: none;
}
.px-btn:active {
  transform: translate(4px, 4px);
  box-shadow: none;
  background: var(--accent-light);
}
.px-btn.primary {
  background: var(--accent); color: #fff; border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.px-btn.primary:hover {
  background: var(--accent-hover);
  transform: translate(2px, 2px); box-shadow: none;
}
.px-btn.primary:active { transform: translate(4px, 4px); box-shadow: none; }
.px-btn.blue {
  background: var(--blue); color: #fff; border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.px-btn.blue:hover { transform: translate(2px, 2px); box-shadow: none; }
.px-btn.green {
  background: var(--green); color: #fff; border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.px-btn.green:hover { transform: translate(2px, 2px); box-shadow: none; }
.px-btn.danger { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }
.px-btn.danger:hover { background: var(--accent); color: #fff; }
.px-btn.small { font-size: 0.8rem; padding: 8px 12px; min-height: 36px; }
.px-btn.block { width: 100%; }

/* ==================== 工具网格 ==================== */
.tool-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 12px;
}
.tool-grid .px-btn {
  font-size: 0.8rem; padding: 10px 6px; min-height: 56px;
  flex-direction: column; gap: 4px; width: 100%;
  font-family: var(--font-body);
}
.tool-grid .btn-icon { font-size: 1.1rem; line-height: 1; }
.tool-row {
  display: flex; gap: 8px; margin-bottom: 8px;
  flex-wrap: wrap; align-items: center;
}
.tool-row.tight { margin-bottom: 4px; }

/* ==================== 复选框/标签 ==================== */
.px-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.85rem; color: var(--ink-soft);
  cursor: pointer; font-weight: 500;
}
.px-check input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; }
.px-label { font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); }
.px-select {
  font-family: var(--font-body); font-size: 0.85rem;
  padding: 10px 14px; min-height: 44px;
  border: var(--border-w) solid var(--border); border-radius: 0;
  background: var(--panel); color: var(--ink);
  cursor: pointer; flex: 1;
}

/* ==================== 调色板 ==================== */
.palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px; margin-bottom: 12px;
}
.palette-color {
  aspect-ratio: 1 / 1;
  width: 100%; border-radius: 0;
  border: 3px solid var(--border);
  cursor: pointer; transition: none;
  position: relative; min-width: 0;
  box-shadow: 2px 2px 0 var(--border);
}
.palette-color:hover {
  transform: translate(2px, 2px);
  box-shadow: none;
  z-index: 2;
}
.palette-color.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent), 4px 4px 0 var(--border);
  transform: translate(2px, 2px);
}
.palette-color-name { display: none; }

/* ==================== 尺寸芯片 ==================== */
.size-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.size-chip {
  font-family: var(--font); font-size: 0.5rem;
  padding: 8px 12px; border-radius: 0;
  border: 3px solid var(--border); background: var(--panel);
  cursor: pointer; transition: none; color: var(--ink-soft);
  box-shadow: 2px 2px 0 var(--border);
  letter-spacing: 0.5px;
}
.size-chip:hover { transform: translate(2px, 2px); box-shadow: none; color: var(--accent); }
.size-chip.active, .size-chip.sel {
  background: var(--accent); color: #fff; border-color: var(--border);
  box-shadow: 2px 2px 0 var(--border);
}

/* ==================== 提示文字 ==================== */
.hint { font-size: 0.8rem; color: var(--muted); line-height: 1.5; margin-top: 8px; }
.hint.small { font-size: 0.75rem; }

/* ==================== 画布区域 ==================== */
.canvas-panel { display: flex; flex-direction: column; height: 100%; }
.canvas-toolbar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; flex-wrap: wrap;
  padding-bottom: 10px; border-bottom: var(--border-w) solid var(--border);
}
.toolbar-group { display: flex; align-items: center; gap: 5px; }
.toolbar-label { font-family: var(--font); font-size: 0.6rem; font-weight: 400; color: var(--ink-soft); letter-spacing: 1px; }
.grid-info {
  font-family: var(--font); font-size: 0.6rem; font-weight: 400; color: var(--accent);
  margin-left: auto; padding: 6px 14px; background: var(--accent-light);
  border: 3px solid var(--border); box-shadow: 2px 2px 0 var(--border);
  letter-spacing: 1px;
}
.canvas-wrap {
  flex: 1; min-height: 480px;
  background: var(--panel);
  border: var(--border-w) solid var(--border);
  border-radius: 0;
  padding: 12px;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow);
  min-width: 0; max-width: 100%; height: 100%;
}
#board {
  image-rendering: pixelated; border-radius: 0;
  max-width: 100% !important; max-height: 100% !important;
  width: auto; height: auto; object-fit: contain;
  background: #fff;
  box-shadow: 4px 4px 0 var(--border);
  position: relative; z-index: 1;
}
.canvas-empty {
  position: absolute; inset: 8px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  background: var(--panel);
  border: var(--border-w) dashed var(--yellow);
  box-shadow: none;
  max-width: 100%; box-sizing: border-box;
  z-index: 5;
}
.canvas-empty.hidden { display: none; }
.canvas-empty:hover { border-color: var(--accent); }
.empty-beads { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }
.empty-beads span {
  display: block; width: 18px; height: 18px; border-radius: 0;
  border: 2px solid var(--border);
  background: var(--c); animation: loaderBounce 0.8s step-end infinite;
  animation-delay: var(--d);
}
.empty-text { font-family: var(--font); font-size: 0.7rem; font-weight: 400; color: var(--ink); letter-spacing: 1px; }
.empty-sub { font-size: 0.8rem; color: var(--muted); margin-top: 6px; }

/* ==================== 统计/图例 ==================== */
.stats-head {
  display: flex; gap: 12px; align-items: center; justify-content: center;
  padding: 8px 12px; margin-bottom: 8px;
  font-family: var(--font); font-size: 0.55rem; font-weight: 400;
  background: var(--panel-alt); border: 3px solid var(--border);
  box-shadow: 2px 2px 0 var(--border);
  overflow: hidden; white-space: nowrap; letter-spacing: 0.5px;
}
#totalBeads { color: var(--accent); }
#colorCount { color: var(--blue); }
.legend {
  display: flex; flex-wrap: wrap; gap: 6px;
  max-height: 80px; overflow-y: auto; padding: 2px;
}
.legend-item {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; font-size: 0.72rem;
  background: var(--panel-alt); border: 2px solid var(--border);
  box-shadow: 1px 1px 0 var(--border);
  white-space: nowrap;
}
.legend-swatch {
  width: 10px; height: 10px; border-radius: 0; flex-shrink: 0;
  border: 1px solid var(--border);
}
.legend-name { font-size: 0.72rem; }
.legend-bar-wrap, .legend-bar { display: none; }
.legend-count { font-size: 0.68rem; color: var(--muted); }

/* ==================== 标签页 ==================== */
.tab-row {
  display: flex; gap: 0; margin-bottom: 12px;
  background: var(--panel-alt); padding: 3px;
  border: 3px solid var(--border);
  box-shadow: 2px 2px 0 var(--border);
}
.tab-row .tab {
  flex: 1; padding: 8px 10px;
  font-family: var(--font-body); font-size: 0.8rem; font-weight: 700;
  border: none; background: transparent; color: var(--ink-soft);
  border-radius: 0; cursor: pointer; transition: none;
}
.tab-row .tab.active {
  background: var(--accent); color: #fff;
  box-shadow: 2px 2px 0 var(--border);
}
.tab-row .tab:not(.active):hover { background: var(--accent-light); color: var(--accent); }
.tab-row.sub { margin-bottom: 10px; }

/* ==================== 素材面板 ==================== */
.src-pane { font-size: 0.85rem; }
.src-pane.hidden { display: none; }
.dropzone {
  border: 3px dashed var(--border); border-radius: 0;
  padding: 20px; text-align: center; margin-bottom: 12px;
  background: var(--panel-alt); transition: none;
  box-shadow: 2px 2px 0 var(--border);
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-light); }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-light); }
.dropzone p { font-size: 0.8rem; color: var(--muted); margin-bottom: 8px; }
.img-preview { margin-top: 8px; }
.img-preview img { max-width: 100%; border-radius: 0; border: 3px solid var(--border); }

/* ==================== Emoji 面板 ==================== */
.emoji-search-row { display: flex; gap: 6px; margin-bottom: 10px; }
.emoji-search-row input {
  flex: 1; font-family: var(--font-body); font-size: 0.85rem;
  padding: 8px 12px; border: 3px solid var(--border);
  border-radius: 0; background: var(--panel);
  box-shadow: 2px 2px 0 var(--border);
}
.emoji-cats {
  display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px;
  padding: 4px; background: var(--panel-alt);
  border: 3px solid var(--border);
  box-shadow: 2px 2px 0 var(--border);
}
.emoji-cat {
  font-family: var(--font); font-size: 0.45rem;
  padding: 6px 8px; border: 3px solid var(--border);
  border-radius: 0; background: var(--panel);
  cursor: pointer; font-weight: 400; color: var(--ink-soft);
  transition: none; letter-spacing: 0.5px;
  box-shadow: 2px 2px 0 var(--border);
}
.emoji-cat:hover { transform: translate(1px, 1px); box-shadow: none; color: var(--accent); }
.emoji-cat:active { transform: translate(2px, 2px); box-shadow: none; }
.emoji-cat.active {
  background: var(--accent); color: #fff; border-color: var(--border);
  box-shadow: 2px 2px 0 var(--border);
}
.emoji-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px; max-height: 300px; overflow-y: auto; padding: 2px;
}
.emoji-item {
  position: relative; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0; border: 3px solid var(--border);
  background: var(--panel); cursor: pointer;
  transition: none; min-width: 0; overflow: hidden;
  box-shadow: 2px 2px 0 var(--border);
}
.emoji-item:hover { transform: translate(1px, 1px); box-shadow: none; }
.emoji-item img { width: 72%; height: 72%; object-fit: contain; display: block; }
.emoji-item .sys { font-size: 1.1rem; line-height: 1; }
.emoji-item.broken { opacity: 0.3; }

/* ==================== 预设模板卡片 ==================== */
.tpl-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tpl-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px 8px;
  border: 3px solid var(--border); background: var(--panel-alt);
  cursor: pointer; transition: none;
  min-width: 0; box-sizing: border-box; overflow: hidden;
  box-shadow: 3px 3px 0 var(--border);
}
.tpl-card:hover { transform: translate(2px, 2px); box-shadow: none; }
.tpl-card canvas {
  width: 100%; max-width: 100%; height: auto; aspect-ratio: 1;
  image-rendering: pixelated; border-radius: 0;
  background: #fff; border: 2px solid var(--border);
  object-fit: contain;
}
.tpl-card .tname {
  font-family: var(--font); font-size: 0.45rem;
  color: var(--ink-soft); text-align: center; line-height: 1.4;
  width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: 0.5px;
}
.tpl-card:hover .tname { color: var(--accent); }

/* ==================== 自定义下拉 ==================== */
.panel { overflow: visible; }
.cdd { position: relative; flex: 1; min-width: 0; }
.cdd-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-family: var(--font-body); font-size: 0.85rem; font-weight: 700;
  padding: 10px 14px; min-height: 44px;
  border: var(--border-w) solid var(--border); border-radius: 0;
  background: var(--panel); color: var(--ink);
  cursor: pointer; transition: none; text-align: left;
  box-shadow: var(--shadow-sm);
}
.cdd-btn:hover { transform: translate(2px, 2px); box-shadow: none; }
.cdd-btn.open { transform: translate(2px, 2px); box-shadow: none; }
.cdd-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cdd-arrow { color: var(--muted); flex-shrink: 0; transition: none; }
.cdd-btn.open .cdd-arrow { transform: rotate(180deg); }
.cdd-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--panel); border: var(--border-w) solid var(--border);
  border-radius: 0; box-shadow: var(--shadow); z-index: 80;
}
.cdd-menu.hidden { display: none; }
.cdd-item {
  padding: 10px 14px; font-size: 0.85rem; font-weight: 600;
  color: var(--ink-soft); cursor: pointer; transition: none;
}
.cdd-item:hover { background: var(--accent-light); color: var(--accent); }
.cdd-item.sel { background: var(--accent); color: #fff; }

/* ==================== 页脚 ==================== */
.foot {
  position: relative; z-index: 10;
  text-align: center; padding: 14px 20px;
  font-family: var(--font); font-size: 0.5rem; color: rgba(255,255,255,0.5);
  border-top: var(--border-w) solid var(--border);
  background: #2a2d3e; letter-spacing: 1px;
}

/* ==================== 加载动画 ==================== */
.loader {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg); transition: none;
}
.loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-beads { display: flex; gap: 10px; margin-bottom: 20px; }
.loader-beads span {
  display: block; width: 20px; height: 20px; border-radius: 0;
  border: 3px solid var(--border);
  animation: loaderBounce 0.8s step-end infinite;
  box-shadow: 3px 3px 0 var(--border);
}
.loader-beads span:nth-child(1) { background: #ff004d; animation-delay: 0s; }
.loader-beads span:nth-child(2) { background: #ffec27; animation-delay: 0.15s; }
.loader-beads span:nth-child(3) { background: #00e436; animation-delay: 0.3s; }
.loader-beads span:nth-child(4) { background: #29adff; animation-delay: 0.45s; }
.loader-beads span:nth-child(5) { background: #ff77a8; animation-delay: 0.6s; }
@keyframes loaderBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
.loader-text {
  font-family: var(--font); font-size: 0.6rem; color: rgba(255,255,255,0.8);
  letter-spacing: 2px; animation: loaderPulse 1s step-end infinite;
}
@keyframes loaderPulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--panel-alt); border: 2px solid var(--border); }
::-webkit-scrollbar-thumb { background: var(--ink); border: 2px solid var(--border); }

/* ==================== 响应式 ==================== */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 240px 1fr 240px; }
  .tool-grid .px-btn { font-size: 0.75rem; }
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr 1fr; }
  .center { grid-column: 1 / -1; order: -1; }
  .topbar { height: 48px; }
  .topbar-sub { display: none; }
  .canvas-wrap { min-height: 380px; }
}
@media (max-width: 640px) {
  .layout { grid-template-columns: 1fr; gap: 8px; padding: 8px; }
  .topbar { height: 44px; padding: 0 12px; }
  .logo-text { font-size: 0.75rem; }
  .panel { padding: 12px; }
  .palette { grid-template-columns: repeat(7, 1fr); gap: 5px; }
  .canvas-wrap { min-height: 300px; }
  .px-btn { font-size: 0.8rem; padding: 8px 10px; min-height: 40px; }
}

/* ==================== 动画 ==================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.src-pane:not(.hidden) { animation: fadeIn 0.15s step-end; }
.panel { animation: fadeIn 0.15s step-end both; }
.canvas-empty:not(.hidden) { animation: fadeIn 0.15s step-end; }
.tool-grid .tool.active {
  animation: none;
  background: var(--accent); border-color: var(--border); color: #fff;
  box-shadow: 2px 2px 0 var(--border);
}
.palette-color.active { animation: none; }

#totalBeads { color: var(--accent); }
#colorCount { color: var(--blue); }

.px-select:focus,
.emoji-search-row input:focus,
input[type="color"]:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 2px 2px 0 var(--accent);
}

/* ==================== 8-bit 卡通像素场景背景 ==================== */
.pixel-scene {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; overflow: hidden;
  width: 100%; height: 100%;
}

/* 天空: 纯色分层(无渐变) */
.scene-sky {
  position: absolute; inset: 0;
  background: #1a1c2c;
}
.scene-sky::before {
  content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 25%;
  background: #2a3a5c;
}
.scene-sky::after {
  content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 12%;
  background: #3d2a5c;
}

/* 星星: 用 box-shadow 画像素点 */
.scene-stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(2px 2px at 5% 8%, #fff 50%, transparent 50%),
    radial-gradient(2px 2px at 12% 3%, #fff 50%, transparent 50%),
    radial-gradient(3px 3px at 20% 12%, #29adff 50%, transparent 50%),
    radial-gradient(2px 2px at 28% 5%, #fff 50%, transparent 50%),
    radial-gradient(2px 2px at 35% 15%, #fff 50%, transparent 50%),
    radial-gradient(3px 3px at 42% 2%, #ffec27 50%, transparent 50%),
    radial-gradient(2px 2px at 50% 10%, #fff 50%, transparent 50%),
    radial-gradient(2px 2px at 58% 6%, #fff 50%, transparent 50%),
    radial-gradient(3px 3px at 65% 14%, #29adff 50%, transparent 50%),
    radial-gradient(2px 2px at 72% 4%, #fff 50%, transparent 50%),
    radial-gradient(2px 2px at 80% 11%, #fff 50%, transparent 50%),
    radial-gradient(2px 2px at 88% 7%, #ffec27 50%, transparent 50%),
    radial-gradient(2px 2px at 95% 13%, #fff 50%, transparent 50%),
    radial-gradient(2px 2px at 8% 22%, #fff 50%, transparent 50%),
    radial-gradient(2px 2px at 25% 28%, #fff 50%, transparent 50%),
    radial-gradient(3px 3px at 45% 20%, #ffec27 50%, transparent 50%),
    radial-gradient(2px 2px at 62% 25%, #fff 50%, transparent 50%),
    radial-gradient(2px 2px at 78% 22%, #29adff 50%, transparent 50%),
    radial-gradient(2px 2px at 92% 28%, #fff 50%, transparent 50%);
  background-repeat: repeat;
  background-size: 200px 180px;
  opacity: 0.7;
  animation: starBlink 2s step-end infinite alternate;
}
@keyframes starBlink {
  0% { opacity: 0.5; } 100% { opacity: 0.9; }
}
.scene-stars-2 { display: none; }

/* 月亮: 像素方块 */
.scene-sun {
  position: absolute; top: 6%; left: 80%;
  width: 24px; height: 24px;
  background: #ffec27;
  border: 3px solid #1a1c2c;
  box-shadow: 4px 4px 0 #1a1c2c;
}
.scene-sun::before {
  content: ""; position: absolute; top: -6px; left: -6px;
  width: 8px; height: 8px; background: #fffde7;
  border: 2px solid #1a1c2c;
}
.scene-sun::after {
  content: ""; position: absolute; bottom: -4px; right: -4px;
  width: 6px; height: 6px; background: #ffd54f;
  border: 2px solid #1a1c2c;
}

/* 云: 像素方块组合 */
.scene-clouds {
  position: absolute; top: 10%; left: 0; width: 100%; height: 50px;
}
.scene-clouds::before {
  content: ""; position: absolute; left: 15%; top: 0;
  width: 40px; height: 12px; background: #3d4a6e;
  border: 2px solid #1a1c2c;
  box-shadow: 4px -4px 0 #1a1c2c, 8px 0 0 #3d4a6e, 8px -4px 0 #1a1c2c,
              -4px 0 0 #3d4a6e, -4px -4px 0 #1a1c2c;
}
.scene-clouds::after {
  content: ""; position: absolute; left: 55%; top: 10px;
  width: 50px; height: 12px; background: #3d4a6e;
  border: 2px solid #1a1c2c;
  box-shadow: 4px -4px 0 #1a1c2c, 8px 0 0 #3d4a6e, 8px -4px 0 #1a1c2c,
              -4px 0 0 #3d4a6e, -4px -4px 0 #1a1c2c;
}

/* 山脉: 4层剪影(无圆角无渐变) */
.scene-mountains { position: absolute; bottom: 18%; left: 0; right: 0; height: 140px; }
.scene-mountains-layer1 {
  position: absolute; bottom: 0; left: 0; right: 0; height: 100px;
  background: #1a1c2c;
  clip-path: polygon(0% 100%, 0% 60%, 5% 45%, 10% 55%, 15% 35%, 20% 50%, 25% 30%, 30% 45%, 35% 25%, 40% 40%, 45% 20%, 50% 35%, 55% 15%, 60% 30%, 65% 25%, 70% 40%, 75% 20%, 80% 35%, 85% 30%, 90% 45%, 95% 25%, 100% 40%, 100% 100%);
}
.scene-mountains-layer2 {
  position: absolute; bottom: 0; left: 0; right: 0; height: 85px;
  background: #2a3a5c;
  clip-path: polygon(0% 100%, 0% 70%, 8% 50%, 15% 60%, 22% 35%, 28% 50%, 35% 28%, 42% 45%, 48% 22%, 55% 40%, 62% 18%, 68% 35%, 75% 25%, 82% 42%, 88% 30%, 95% 48%, 100% 35%, 100% 100%);
}
.scene-mountains-layer3 {
  position: absolute; bottom: 0; left: 0; right: 0; height: 65px;
  background: #3d4a6e;
  clip-path: polygon(0% 100%, 0% 65%, 10% 45%, 18% 55%, 25% 32%, 33% 48%, 40% 25%, 48% 42%, 55% 18%, 63% 38%, 70% 22%, 78% 40%, 85% 28%, 92% 45%, 100% 32%, 100% 100%);
}
.scene-mountains-layer4 {
  position: absolute; bottom: 0; left: 0; right: 0; height: 50px;
  background: #4a5a7a;
  clip-path: polygon(0% 100%, 0% 70%, 12% 50%, 20% 60%, 28% 38%, 36% 52%, 44% 30%, 52% 48%, 60% 25%, 68% 42%, 76% 30%, 84% 48%, 92% 35%, 100% 50%, 100% 100%);
}

/* 树: 像素三角 */
.scene-forest {
  position: absolute; bottom: 16%; left: 0; right: 0; height: 60px;
  display: flex; justify-content: space-around; align-items: flex-end;
  padding: 0 3%;
}
.pixel-tree { position: relative; width: 20px; height: 48px; }
.pixel-tree-trunk {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 4px; height: 12px; background: #5a3a1a;
  border: 1px solid #1a1c2c;
}
.pixel-tree-crown {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  width: 18px; height: 36px; background: #00e436;
  border: 2px solid #1a1c2c;
  clip-path: polygon(50% 0%, 10% 35%, 25% 35%, 0% 65%, 20% 65%, 0% 100%, 100% 100%, 80% 65%, 100% 65%, 75% 35%, 90% 35%);
}

/* 地面: 纯色 */
.scene-ground {
  position: absolute; bottom: 0; left: 0; right: 0; height: 16%;
  background: #00e436;
  border-top: 4px solid #1a1c2c;
}
.scene-ground::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: #00b82e;
}

/* 萤火虫: 像素亮点 */
.scene-firefly {
  position: absolute; width: 4px; height: 4px;
  background: #ffec27; border: 1px solid #1a1c2c;
  box-shadow: 0 0 8px #ffec27;
}
.scene-firefly:nth-child(10) { top: 50%; left: 10%; animation: fireflyMove 3s step-end infinite; }
.scene-firefly:nth-child(11) { top: 55%; left: 30%; animation: fireflyMove 3s step-end infinite 1s; }
.scene-firefly:nth-child(12) { top: 48%; left: 50%; animation: fireflyMove 3s step-end infinite 2s; }
.scene-firefly:nth-child(13) { top: 52%; left: 70%; animation: fireflyMove 3s step-end infinite 0.5s; }
.scene-firefly:nth-child(14) { top: 46%; left: 85%; animation: fireflyMove 3s step-end infinite 1.5s; }
@keyframes fireflyMove {
  0%, 100% { opacity: 0.2; transform: translate(0, 0); }
  25% { opacity: 1; transform: translate(4px, -4px); }
  50% { opacity: 0.3; transform: translate(-2px, -8px); }
  75% { opacity: 0.8; transform: translate(2px, -2px); }
}

/* 小房子: 像素方块 */
.scene-house {
  position: absolute; bottom: 16%; left: 20%;
  width: 28px; height: 24px;
  background: #8b5a2a;
  border: 2px solid #1a1c2c;
  box-shadow: 3px 3px 0 #1a1c2c;
}
.scene-house::before {
  content: ""; position: absolute; top: -14px; left: -4px;
  width: 0; height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-bottom: 14px solid #ff004d;
  filter: drop-shadow(2px -2px 0 #1a1c2c);
}
.scene-house-door {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 8px; height: 10px; background: #3a2a1a;
  border: 2px solid #1a1c2c;
}
.scene-house-window {
  position: absolute; top: 4px; right: 3px;
  width: 6px; height: 6px; background: #29adff;
  border: 2px solid #1a1c2c;
}

/* 栅栏: 像素线 */
.scene-fence {
  position: absolute; bottom: 16%; left: 35%; display: flex; gap: 4px;
}
.scene-fence-post {
  width: 4px; height: 16px; background: #8b5a2a;
  border: 1px solid #1a1c2c;
  position: relative;
}
.scene-fence-rail {
  position: absolute; top: 4px; left: -2px;
  width: 12px; height: 3px; background: #8b5a2a;
  border: 1px solid #1a1c2c;
}

/* 面板像素场景背景 */
body {
  background: #1a1c2c;
}
.layout {
  background: transparent;
}
.panel {
  background: #f4f4f4;
  border: 4px solid #1a1c2c;
  box-shadow: 4px 4px 0 #1a1c2c;
}
.topbar {
  background: #2a2d3e;
  border-bottom: 4px solid #1a1c2c;
}
.foot {
  background: #2a2d3e;
  border-top: 4px solid #1a1c2c;
}

/* 打印样式 */
@media print {
  .pixel-scene, .topbar, .foot, .panel-col.left, .panel-col.right { display: none !important; }
  .layout { grid-template-columns: 1fr; padding: 0; }
  .panel { box-shadow: none; border: 2px solid #000; padding: 0; }
  .canvas-wrap { border: 2px solid #000; padding: 0; }
  #board { box-shadow: none; }
}
