/* Pixel Paint 游戏壳 · 移动优先设计 */
:root {
  --gp-bg: #f4faf6;
  --gp-surface: #ffffff;
  --gp-ink: #1b3a2b;
  --gp-ink-light: #4a6b5a;
  --gp-brand: #2f9e44;
  --gp-brand-dark: #237b34;
  --gp-brand-light: #d3f9d8;
  --gp-accent: #ffd43b;
  --gp-line: #c8e6c9;
  --gp-danger: #e03131;
  --gp-radius: 14px;
  --game-bg-1: #8bc34a;
  --game-bg-2: #689f38;
  --shadow-card: 0 6px 20px rgba(27, 58, 43, 0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
  color: #fff;
}

body {
  background: #4a7328;
  background-image: linear-gradient(160deg, var(--game-bg-1), var(--game-bg-2));
}

/* 桌面端: 手机壳窄栏居中 */
#app {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  background-image: linear-gradient(160deg, var(--game-bg-1), var(--game-bg-2));
}
@media (min-width: 640px) {
  #app {
    max-width: 480px;
    max-height: 92vh;
    margin-top: 4vh;
    border-radius: 28px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  }
}

/* ── 屏管理 ─────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.screen.visible {
  display: flex;
  animation: screenIn 0.28s ease-out;
}
@keyframes screenIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── 加载屏 ─────────────────────────────── */
#screen-loading {
  align-items: center;
  justify-content: center;
  gap: 22px;
}
.loading-logo {
  font-size: 52px;
  font-weight: 900;
  text-align: center;
  line-height: 1.1;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  letter-spacing: 2px;
}
.loading-bar-wrap {
  width: 200px;
  height: 10px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  overflow: hidden;
}
.loading-bar {
  width: 0%;
  height: 100%;
  background: #fff;
  border-radius: 6px;
  transition: width 0.2s ease;
}
.loading-text { font-weight: 700; opacity: 0.9; }

/* ── 图标按钮 ───────────────────────────── */
.icon-btn {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, background 0.15s;
}
.icon-btn:active { transform: scale(0.9); background: rgba(255, 255, 255, 0.5); }
.icon-btn img { width: 22px; height: 22px; object-fit: contain; pointer-events: none; }
.icon-btn { font-size: 20px; line-height: 1; color: #fff; }
.icon-btn.active { background: rgba(255, 255, 255, 0.85); }
.icon-btn.lock-btn.active { background: #fff; box-shadow: 0 0 0 3px var(--gp-accent, #ffd43b); }
/* 锁定后色板与工具条淡化提示 */
.board-locked .palette-bar,
.board-locked .tool-bar { opacity: 0.45; pointer-events: none; }
.icon-btn.cooldown { opacity: 0.5; filter: grayscale(1); }
.icon-btn.back-btn { font-size: 30px; color: #fff; font-weight: 700; line-height: 1; }

/* ── 绘板屏布局 ─────────────────────────── */
.board-header {
  display: flex;
  gap: 10px;
  padding: 14px 16px 6px;
  align-items: flex-start;
}
/* 头部六区布局（home 屏；按钮位置由版本配置 modules.header 驱动） */
.hdr-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.hdr-col-end { align-items: flex-end; }
.hdr-mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hdr-row { display: flex; gap: 8px; align-items: flex-start; }
.hdr-group { display: flex; gap: 8px; flex-wrap: wrap; }
.hdr-group-end { margin-left: auto; justify-content: flex-end; }
.hdr-zone:empty { display: none; }
.hdr-row:not(:has(.hdr-zone:not(:empty))) { display: none; }
/* 左上角固定列：Menu / Reset / 尺寸 */
.board-header-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
#size-select-slot {
  display: flex;
  flex-direction: column;
}
.board-header-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 70%;
}
.size-select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.92) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%233a5a2b' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 8px center;
  border: none;
  border-radius: 10px;
  padding: 8px 26px 8px 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--gp-ink);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.size-select:focus { outline: 2px solid var(--gp-accent); }
.import-btn span { font-size: 20px; line-height: 1; }

.canvas-area {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}
/* 画布格子超出容器时滚动查看（格子保持物理尺寸） */
.canvas-area.canvas-scrollable {
  overflow: auto;
  align-items: flex-start;
  justify-content: flex-start;
}
.canvas-area canvas.pixi-canvas {
  display: block;
  border-radius: 12px;
  border: 4px solid #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  background: #fff;
}

#reference-preview {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 6px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 10;
}
#reference-canvas { display: block; width: 72px; height: 72px; image-rendering: pixelated; }

.board-side-btns {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}

.board-footer {
  padding: 10px 14px 18px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

/* 工具条：紧贴画布上边、靠左对齐 */
.tool-bar {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
  padding: 0 16px 4px;
}
.palette-bar {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: clamp(4px, 1.5vw, 8px);
  align-items: center;
  overflow: visible;
  background: #fff;
  border-radius: 22px;
  padding: 10px clamp(8px, 2.5vw, 16px);
  box-shadow: var(--shadow-card);
  width: 100%;
  box-sizing: border-box;
  position: relative;
  margin-top: 20px;
}
.color-swatch-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
}
/* 编号放在白色背景上方的绿色区，白字深影才看得清 */
.color-swatch-number {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  line-height: 1;
  user-select: none;
  pointer-events: none;
  white-space: nowrap;
}
.color-swatch {
  width: clamp(28px, 8.5vw, 38px);
  height: clamp(28px, 8.5vw, 38px);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(0, 0, 0, 0.08);
  transition: transform 0.1s;
  position: relative;
  flex: 0 0 auto;
}
.color-swatch:active { transform: scale(0.88); }
.color-swatch.selected {
  border: 3px solid var(--gp-ink);
  transform: scale(1.12);
}
.color-swatch.eraser {
  background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 14px 14px;
  display: flex; align-items: center; justify-content: center;
}
.color-swatch.eraser img { width: 20px; height: 20px; opacity: 0.65; }

/* 色相族主色点：上下拖动切换渐变，需禁止页面跟随滚动 */
.color-swatch.family { touch-action: none; }
/* 长按相近色弹窗 */
.color-family-popup {
  position: fixed;
  z-index: 300;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  padding: 12px 14px;
  /* 宽度由内容决定，仅设上限，任何设备都不越界 */
  width: max-content;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
}
.color-family-popup .cfp-grid {
  display: grid;
  grid-template-columns: repeat(8, auto);
  justify-content: center;
  gap: 8px;
  max-height: 45vh;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.color-family-popup .cfp-grid::-webkit-scrollbar { display: none; }
.color-family-popup .cfp-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.color-family-popup .cfp-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(0, 0, 0, 0.08);
}
.color-family-popup .cfp-code {
  font-size: 9px;
  font-weight: 700;
  color: var(--gp-ink-light, #4a6b5a);
  line-height: 1;
  user-select: none;
}
.color-family-popup .cfp-dot.selected { border: 3px solid var(--gp-ink, #1b3a2b); }
.color-family-popup .cfp-dot:active { transform: scale(0.9); }

/* ── 拼豆豆料清单（锚定 screen 底部，与底栏色板两边/底部对齐）────────────── */
.usage-sheet {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  z-index: 260;
  overflow: hidden;
}
/* 色块区：竖排小块横排换行，一行半高度（第二行露一半提示有更多），超出滚动 */
.usage-sheet-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 8px 12px;
  max-height: 76px;
  overflow-y: auto;
  scrollbar-width: none;
}
.usage-sheet-list::-webkit-scrollbar { display: none; }
.usage-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 2px 3px;
  border-radius: 8px;
  font-size: 10px;
  line-height: 1.2;
  color: var(--gp-ink, #1b3a2b);
}
.usage-chip-count { font-weight: 700; color: var(--gp-ink-light, #4a6b5a); }
.usage-dot { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.1); flex: 0 0 auto; }
.usage-code { font-weight: 700; }
.usage-empty { text-align: center; color: var(--gp-ink-light, #4a6b5a); font-size: 12px; padding: 10px 0; width: 100%; }
.usage-chip.tappable { cursor: pointer; }
.usage-chip.tappable:active { background: var(--gp-brand-light, #d3f9d8); }
.usage-chip.focused { background: var(--gp-brand-light, #d3f9d8); }
/* 底栏：汇总 + 导出 + 关闭 */
.usage-sheet-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--gp-ink, #1b3a2b);
  border-top: 1px solid var(--gp-line, #c8e6c9);
}
.usage-summary { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usage-export-btn {
  padding: 4px 10px;
  border: none;
  border-radius: 8px;
  background: var(--gp-brand, #2f9e44);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.usage-close-btn {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--gp-ink-light, #4a6b5a);
  font-size: 12px;
  cursor: pointer;
}

/* ── 拼豆展示模式 ─────────────────────────────────────── */
/* 工具条保留占位（画布不位移）：只隐藏工具按钮与尺寸选择器，缩放平移控件原位保留 */
.present-mode .tool-bar .tool-btn,
.present-mode .tool-bar .size-select-wrap { display: none; }
.present-mode .palette-bar { pointer-events: none; opacity: 0.75; }
.zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  padding: 6px 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  z-index: 50;
}
.zoom-controls button {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--gp-line, #c8e6c9);
  border-radius: 8px;
  background: #fff;
  font-size: 16px;
  font-weight: 700;
  color: var(--gp-ink, #1b3a2b);
  cursor: pointer;
  padding: 0 8px;
}
.zoom-controls span {
  min-width: 44px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--gp-ink, #1b3a2b);
}

/* ── 头部按钮名称标签 ─────────────────────────────── */
.header-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}
.header-btn-label {
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

/* ── 缩放平移共享控件 ─────────────────────────────── */
.zoom-pan-control {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  padding: 3px 5px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}
.zoom-pan-control .zp-btn {
  min-width: 28px;
  height: 28px;
  border: 1px solid var(--gp-line, #c8e6c9);
  border-radius: 7px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
  color: var(--gp-ink, #1b3a2b);
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}
.zoom-pan-control .zp-btn.active { background: var(--gp-brand, #2f9e44); color: #fff; border-color: var(--gp-brand, #2f9e44); }
.zoom-pan-control .zp-label {
  min-width: 40px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--gp-ink, #1b3a2b);
}
/* 描边按钮右下颜色指示点 */
.tool-btn { position: relative; }
/* 有选项的工具：右上角小三角提示 */
.tool-caret {
  position: absolute;
  right: 2px;
  top: 0;
  font-size: 8px;
  color: #fff;
  opacity: 0.9;
  pointer-events: none;
}
/* 工具选项弹层（激活态再点一次弹出） */
.tool-options-popup {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 280;
}
.tool-option-item {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--gp-ink, #1b3a2b);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.tool-option-item:active { background: var(--gp-brand-light, #d3f9d8); }
.tool-option-item.active { color: var(--gp-brand, #2f9e44); }
.tool-color-dot {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* ── 拼豆色板：全色横向滑动条 + 圆环豆粒样式 ─────────────────────── */
.palette-bar.bead-palette {
  justify-content: space-between;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  gap: 6px;
  padding: 10px 12px;
}
.palette-bar.bead-palette::-webkit-scrollbar { display: none; }
.bead-strip-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
}
.bead-peg {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.18);
  transition: transform 0.1s;
}
/* 豆粒中心孔（平面圆环，无高光立体） */
.bead-peg::after {
  content: "";
  position: absolute;
  inset: 34%;
  background: #fff;
  border-radius: 50%;
}
.bead-peg.selected {
  transform: scale(1.3);
  border: 2px solid var(--gp-ink, #1b3a2b);
}
.bead-peg-code {
  font-size: 9px;
  font-weight: 700;
  color: var(--gp-ink-light, #4a6b5a);
  line-height: 1;
  user-select: none;
}

/* ── 拼豆族面板（颜色栏上方浮出，无 Tab） ─────────────────────── */
.bead-panel {
  position: fixed;
  z-index: 280;
  width: min(420px, calc(100vw - 24px));
  max-height: 46vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  padding: 12px 14px;
  overflow: hidden;
  animation: beadSheetUp 0.18s ease-out;
}
@keyframes beadSheetUp {
  from { transform: translate(-50%, 12px); opacity: 0.6; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
.bead-sheet-close {
  position: absolute;
  top: 8px;
  left: 10px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--gp-ink-light, #4a6b5a);
  font-size: 15px;
  cursor: pointer;
}
.bead-sheet-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  justify-content: center;
  padding: 6px 2px 12px 34px;
  scrollbar-width: none;
}
.bead-sheet-tabs::-webkit-scrollbar { display: none; }
.bead-sheet-tab {
  flex: 0 0 auto;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}
/* 族 Tab 色环与主栏/网格同尺寸（28px），选中加描边 */
.bead-sheet-tab .bead-peg {
  pointer-events: none;
}
.bead-sheet-tab.active .bead-peg {
  transform: scale(1.2);
  border: 2px solid var(--gp-ink, #1b3a2b);
}
.bead-sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 10px 6px;
  overflow-y: auto;
  padding: 4px 2px 8px;
  scrollbar-width: none;
}
.bead-sheet-grid::-webkit-scrollbar { display: none; }
.bead-sheet-grid .bead-peg-code { font-size: 10px; }

/* ── 尺寸选择：原位自定义下拉 ─────────────────────────────── */
.size-select-wrap { position: relative; }
.size-select-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 12px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.size-select-caret { font-size: 12px; opacity: 0.85; }
.size-select-popup {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 120;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: none;
}
.size-select-popup::-webkit-scrollbar { display: none; }
.size-select-item {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--gp-ink, #1b3a2b);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.size-select-item:hover { background: var(--gp-surface-2, #f8fdf9); }
.size-select-item.active { background: var(--gp-brand, #2f9e44); color: #fff; }

.done-btn {
  min-width: 220px;
  min-height: 52px;
  border: 3px solid #fff;
  border-radius: 28px;
  background: var(--gp-brand);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s;
}
.done-btn:active { transform: scale(0.95); background: var(--gp-brand-dark); }

.tutorial-tip {
  position: absolute;
  left: 50%;
  bottom: 150px;
  transform: translateX(-50%);
  background: rgba(27, 58, 43, 0.92);
  color: #fff;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 14px;
  max-width: 82%;
  text-align: center;
  z-index: 30;
  box-shadow: var(--shadow-card);
  animation: tipPulse 1.6s ease-in-out infinite;
}
@keyframes tipPulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.04); }
}

/* ── 结算屏 ─────────────────────────────── */
#screen-result { align-items: center; justify-content: center; padding: 20px; }
.result-card {
  width: 100%;
  max-width: 380px;
  background: rgba(0, 0, 0, 0.16);
  border-radius: 24px;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: cardIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes cardIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
.result-title {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  margin-bottom: 14px;
}
.result-stars { display: flex; gap: 12px; margin-bottom: 10px; min-height: 56px; }
.result-stars img {
  width: 56px;
  height: 56px;
  opacity: 0.25;
  filter: grayscale(1);
  transform: scale(0.8);
  transition: all 0.3s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.result-stars img.earned { opacity: 1; filter: none; transform: scale(1.1); }
.result-accuracy { font-size: 42px; font-weight: 900; margin-bottom: 12px; }
.result-reward {
  background: var(--gp-accent);
  color: var(--gp-ink);
  font-weight: 800;
  border-radius: 14px;
  padding: 10px 16px;
  margin-bottom: 14px;
  text-align: center;
  font-size: 15px;
  align-self: center;
  animation: rewardPulse 1.4s ease-in-out infinite;
}
@keyframes rewardPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.result-compare { display: flex; gap: 22px; margin-bottom: 22px; }
.compare-label { font-size: 12px; font-weight: 700; opacity: 0.85; text-align: center; margin-bottom: 6px; letter-spacing: 1px; }
.compare-item canvas {
  width: 120px;
  height: 120px;
  border: 4px solid #fff;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  image-rendering: pixelated;
}
.result-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }

.main-btn {
  min-height: 48px;
  border: 2px solid #fff;
  border-radius: 24px;
  background: var(--gp-brand);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: transform 0.1s;
  width: 100%;
}
.main-btn:active { transform: scale(0.96); }
.main-btn.secondary { background: #fff; color: var(--gp-brand-dark); }
.main-btn.text { background: transparent; border: none; box-shadow: none; }

/* ── 二级页(挑战/画廊/我的) ─────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}
.page-title { font-size: 22px; font-weight: 900; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); }
.thumb-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 8px 16px 24px;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}
.level-card {
  background: #fff;
  border-radius: var(--gp-radius);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform 0.12s;
  color: var(--gp-ink);
  position: relative;
}
.level-done-badge {
  position: absolute;
  top: -7px;
  right: -5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gp-brand);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  border: 2px solid #fff;
}
.level-card:active { transform: scale(0.95); }
.level-card.locked { opacity: 0.75; cursor: default; }
.level-card canvas { width: 100%; aspect-ratio: 1; border-radius: 8px; image-rendering: pixelated; background: #fff; }
.level-card .lock-img { width: 40%; margin: 22% 0; opacity: 0.5; }
.level-name { font-size: 12px; font-weight: 700; text-align: center; line-height: 1.25; }
.level-stars { display: flex; gap: 3px; min-height: 14px; }
.level-stars img { width: 14px; height: 14px; opacity: 0.25; filter: grayscale(1); }
.level-stars img.earned { opacity: 1; filter: none; }
.level-price { font-size: 12px; font-weight: 800; color: var(--gp-brand-dark); min-height: 14px; }
.gallery-convert-btn {
  width: 100%;
  margin-top: 4px;
  padding: 6px 4px;
  border: none;
  border-radius: var(--gp-radius-sm);
  background: var(--gp-brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.gallery-convert-btn:disabled {
  background: var(--gp-line-strong);
  cursor: default;
}

.home-actions { display: flex; gap: 10px; align-items: center; }
.home-lib-btn { width: 52px; height: 52px; font-size: 22px; border-radius: 26px; }

/* ── 我的 ───────────────────────────────── */
.me-content { flex: 1; overflow-y: auto; padding: 8px 18px 24px; }
.me-card {
  background: #fff;
  color: var(--gp-ink);
  border-radius: var(--gp-radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}
.me-name { font-size: 20px; font-weight: 900; }
.me-email { color: var(--gp-ink-light); font-size: 13px; margin-top: 2px; }
.me-stats { display: flex; gap: 12px; margin-top: 14px; }
.me-stat { flex: 1; background: var(--gp-bg); border-radius: 10px; padding: 12px; text-align: center; }
.me-stat-num { font-size: 22px; font-weight: 900; color: var(--gp-brand-dark); }
.me-stat-label { font-size: 12px; color: var(--gp-ink-light); margin-top: 2px; }
.me-actions { display: flex; flex-direction: column; gap: 10px; }
.me-actions .main-btn { letter-spacing: 0; }

/* ── 抽屉 ───────────────────────────────── */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 90;
}
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(78vw, 300px);
  background: var(--gp-surface);
  color: var(--gp-ink);
  z-index: 91;
  transform: translateX(-102%);
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  display: flex;
  flex-direction: column;
  padding: calc(18px + env(safe-area-inset-top)) 14px 18px;
  box-shadow: 6px 0 30px rgba(0, 0, 0, 0.25);
}
.drawer.open { transform: translateX(0); }
.drawer-user {
  padding: 10px 12px 16px;
  border-bottom: 1px solid var(--gp-line);
  margin-bottom: 10px;
  font-weight: 800;
}
.drawer-user .sub { font-weight: 400; font-size: 12px; color: var(--gp-ink-light); margin-top: 2px; }
.drawer-login-btn {
  margin-top: 8px;
  width: 100%;
  min-height: 40px;
  border: none;
  border-radius: 20px;
  background: var(--gp-brand);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.drawer-login-btn:active { background: var(--gp-brand-dark); }
.drawer-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-size: 17px;
  font-weight: 700;
  color: var(--gp-ink);
  padding: 14px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.drawer-item:active { background: var(--gp-brand-light); }
.drawer-logout { color: var(--gp-danger); margin-top: 6px; }
.drawer-foot { margin-top: auto; font-size: 12px; color: var(--gp-ink-light); padding: 10px 12px; }

/* ── 弹层(登录墙) ───────────────────────── */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal-mask.open { display: flex; }
.modal-card {
  width: 100%;
  max-width: 340px;
  background: #fff;
  color: var(--gp-ink);
  border-radius: 20px;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
  animation: cardIn 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.modal-emoji { font-size: 42px; }
.modal-title { font-size: 20px; font-weight: 900; }
.modal-desc { font-size: 14px; color: var(--gp-ink-light); margin-bottom: 8px; }
.modal-card .main-btn.text { color: var(--gp-ink-light); }

/* ── 活动横幅(挑战页) ───────────────────── */
.event-banner {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #fff8e1, #ffecb3);
  border: 3px solid var(--gp-accent);
  border-radius: var(--gp-radius);
  padding: 12px;
  box-shadow: var(--shadow-card);
}
.event-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--gp-ink); }
.event-tag {
  background: var(--gp-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 8px;
}
.event-head b { font-size: 16px; flex: 1; }
.event-dates { font-size: 11px; color: var(--gp-ink-light); font-weight: 700; }
.event-levels { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; }
.event-level-card { flex: 0 0 96px; background: #fff; }
.event-level-card.claimed { opacity: 0.65; }

/* ── 积分余额条(商店等共用) ─────────────── */
.daily-wallet {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.daily-wallet b { font-size: 20px; }

/* ── 分类筛选条 ─────────────────────────── */
.cat-chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; -webkit-overflow-scrolling: touch; }
.gallery-chips { flex: 0 0 auto; padding: 0 16px 8px; }
.cat-chip {
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.cat-chip.active { background: #fff; color: var(--gp-brand-dark); border-color: #fff; }

/* ── 作品库 ─────────────────────────────── */
.works-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.work-item { display: flex; flex-direction: column; gap: 4px; }
.work-item img, .work-item canvas { width: 100%; aspect-ratio: 1; border-radius: 8px; image-rendering: pixelated; background: #fff; border: 1px solid var(--gp-line); }
.work-name { font-size: 11px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-ops { display: flex; gap: 4px; }
.work-ops button {
  flex: 1;
  border: 1px solid var(--gp-line);
  background: var(--gp-bg);
  border-radius: 8px;
  padding: 4px 0;
  font-size: 13px;
  cursor: pointer;
}
.work-ops button:active { background: var(--gp-brand-light); }
.work-author { font-size: 11px; color: var(--gp-ink-light); }

/* ── 商店 ───────────────────────────────── */
.shop-content { flex: 1; overflow-y: auto; padding: 8px 18px 24px; display: flex; flex-direction: column; gap: 10px; }
.shop-section-title { font-size: 15px; font-weight: 900; margin-top: 8px; text-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.shop-row {
  background: #fff;
  border-radius: var(--gp-radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-card);
  color: var(--gp-ink);
}
.shop-row-info { flex: 1; min-width: 0; }
.shop-row-title { font-weight: 800; font-size: 15px; }
.shop-row-desc { font-size: 12px; color: var(--gp-ink-light); margin-top: 2px; }
.shop-row-swatches { display: flex; gap: 4px; margin-top: 6px; }
.shop-row-swatches span { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.1); }
.shop-buy-btn {
  border: none;
  border-radius: 18px;
  background: var(--gp-brand);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.shop-buy-btn:active { background: var(--gp-brand-dark); }
.shop-buy-btn.owned { background: var(--gp-brand-light); color: var(--gp-brand-dark); cursor: default; }
.shop-buy-btn.poor { background: #adb5bd; }

/* ── 工具行(创作屏) ─────────────────────── */
.tool-bar {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}
/* 缩放条内的尺寸选择器：与 zp 按钮同高同风格（紧凑） */
.zoom-pan-control .size-select-wrap { display: flex; }
.zoom-pan-control .size-select-btn {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--gp-line, #c8e6c9);
  border-radius: 7px;
  background: #fff;
  box-shadow: none;
  color: var(--gp-ink, #1b3a2b);
  font-size: 12px;
  font-weight: 700;
  gap: 4px;
}
.zoom-pan-control .size-select-caret { font-size: 9px; }
/* 缩放条靠右停靠，弹层右对齐防溢出 */
.zoom-pan-control .size-select-popup { left: auto; right: 0; }
.tool-btn {
  min-width: 36px;
  height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  transition: transform 0.1s, background 0.15s;
}
.tool-btn:active { transform: scale(0.92); }
.tool-btn.active { background: rgba(255, 255, 255, 0.9); }
.tool-btn.locked { opacity: 0.85; }
.tool-btn .tool-price { font-size: 9px; font-weight: 800; line-height: 1; }

/* ── 每日免费卡(挑战页) ─────────────────── */
.level-card.daily-card { position: relative; border: 3px solid var(--gp-accent); }
.daily-badge {
  position: absolute;
  top: -8px;
  right: -6px;
  background: var(--gp-accent);
  color: var(--gp-ink);
  font-size: 11px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 9px;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.daily-thumb-loading { width: 100%; aspect-ratio: 1; border-radius: 8px; background: var(--gp-bg); }
.new-work-btn { letter-spacing: 0; margin-bottom: 14px; }

/* ── Toast ──────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(27, 58, 43, 0.94);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 320;
  max-width: 84%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 图片导入转换弹窗 ───────────────────────────── */
.import-dialog {
  position: fixed;
  inset: 0;
  background: rgba(27, 58, 43, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.import-card {
  background: var(--gp-surface);
  border-radius: var(--gp-radius);
  padding: 20px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--gp-shadow);
}
.import-card h4 {
  margin: 0 0 14px;
  color: var(--gp-ink);
  font-size: 18px;
}
.import-file-label {
  display: block;
  border: 2px dashed var(--gp-line-strong);
  border-radius: var(--gp-radius-sm);
  padding: 18px;
  text-align: center;
  color: var(--gp-ink-light);
  cursor: pointer;
  margin-bottom: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.import-file-label:hover { border-color: var(--gp-brand); background: var(--gp-surface-2); }
.import-file-label input { display: none; }
.import-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  min-height: 80px;
}
.import-preview img {
  max-width: 100%;
  max-height: 160px;
  border-radius: var(--gp-radius-sm);
  object-fit: contain;
}
.import-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.import-row label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--gp-ink-light);
}
.import-row select {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--gp-line);
  background: #fff;
  color: var(--gp-ink);
  font-size: 14px;
}
.import-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--gp-ink);
}
.import-options label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.import-actions button {
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.import-actions .btn-primary { background: var(--gp-brand); color: #fff; }
.import-actions .btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.import-actions .btn-link { background: transparent; color: var(--gp-ink-light); }
.import-error {
  color: var(--gp-danger);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}
.import-preview-meta {
  text-align: center;
  font-size: 13px;
  color: var(--gp-ink-light);
  margin-bottom: 10px;
}
.import-preview-canvas-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
  margin-bottom: 16px;
  background: var(--gp-surface-2);
  border-radius: var(--gp-radius-sm);
  padding: 12px;
}
.import-preview-canvas-wrap canvas {
  max-width: 100%;
  image-rendering: pixelated;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(27, 58, 43, 0.08);
}

