﻿/* 美甲小屋 —— 样式
   设计目标：不是「粉红就行」，而是有材质、有层次、有光影的精致感。

   几个刻意的做法：
   - 玻璃拟态面板：半透明 + 背景模糊 + 内发光边，比纯色块高级
   - 分层阴影：按钮有两层阴影（近处紧、远处散），模拟真实高度
   - 主色只用在「当前选中」上，其余用低饱和，避免一片粉糊
   - 所有过渡都用带回弹的缓动，手感更「活」
   - 4-6 岁：按钮大、图标配中文、禁掉误触手势
*/

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --ink:        #6b4a5a;      /* 主文字 */
  --ink-soft:   #ad7f97;      /* 次要文字 */
  --ink-strong: #e0409a;      /* 强调文字：萌可玫红 */
  --brand:      #ff5fae;      /* 主色：萌可粉 */
  --brand-lite: #ff9ed2;
  --brand-deep: #e0409a;
  --paper:      rgba(255, 255, 255, 0.72);
  --paper-solid:#ffffff;
  --edge:       rgba(255, 255, 255, 0.85);
  --sh-sm: 0 2px 6px rgba(198, 106, 164, 0.16);
  --sh-md: 0 5px 14px rgba(198, 106, 164, 0.20), 0 1px 3px rgba(198, 106, 164, 0.13);
  --sh-lg: 0 10px 26px rgba(198, 106, 164, 0.26), 0 2px 6px rgba(198, 106, 164, 0.15);
  --sh-brand: 0 8px 20px rgba(255, 95, 174, 0.44), 0 2px 5px rgba(224, 64, 154, 0.30);
  --ease-pop: cubic-bezier(.34, 1.56, .64, 1);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #ffeef6;
  color: var(--ink);
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  /* 兜底底色。真正的背景由 canvas 画（萌可粉天空 + 爱心云）。 */
  background: linear-gradient(168deg, #fff4fb 0%, #ffe6f5 45%, #ffc2e6 100%);
}

/* 页面顶部一条爱心花边，强化萌可感（纯 CSS，无素材） */
#app::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background:
    repeating-linear-gradient(90deg,
      #ff5fae 0 14px, #ff9ed2 14px 28px, #ffd0e8 28px 42px);
  opacity: .55;
  z-index: 4;
  pointer-events: none;
}

/* ================= 舞台：手占满全屏 ================= */

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;          /* 关键：涂色时不要触发滚动/缩放 */
  /* 手占满全屏，不再需要把画布包成一个"卡片" */
  border-radius: 0;
  box-shadow: none;
}

/* 星星计数：小徽章 */
.hud {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(86px + env(safe-area-inset-left));   /* 给左侧操作列让位 */
  font-size: 22px;
  letter-spacing: 1px;
  padding: 7px 15px 7px 13px;
  border-radius: 999px;
  background: linear-gradient(160deg, rgba(255,255,255,0.96), rgba(255,244,250,0.88));
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--sh-md), inset 0 1px 0 #fff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
  max-width: 52%;
  overflow: hidden;
  white-space: nowrap;
  z-index: 5;
}

/* ===== 左侧竖排：全局操作（随机/撤销/重来/保存） ===== */
#global-bar {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 6;
}
.gbtn {
  width: 58px;
  height: 58px;
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(255,255,255,0.98), rgba(255,240,248,0.9));
  box-shadow: var(--sh-md), inset 0 1px 0 #fff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 25px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: transform .16s var(--ease-pop), box-shadow .16s ease;
}
.gbtn:active { transform: scale(0.90); box-shadow: var(--sh-sm); }

/* ===== 右侧竖排：一级分类大图标 ===== */
#rail {
  position: absolute;
  top: 50%;
  right: calc(10px + env(safe-area-inset-right));
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 6;
  max-height: calc(100% - 130px);
  overflow-y: auto;
  scrollbar-width: none;
  padding: 3px;
}
#rail::-webkit-scrollbar { display: none; }

.rail-btn {
  width: 66px;
  padding: 9px 4px 7px;
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(255,255,255,0.97), rgba(255,238,248,0.9));
  box-shadow: var(--sh-md), inset 0 1px 0 #fff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #a9527f;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform .18s var(--ease-pop), box-shadow .18s ease,
              background .18s ease, color .18s ease;
}
.rail-btn .ico { font-size: 26px; line-height: 1.1; }
.rail-btn .lbl { font-size: 12px; font-weight: 700; white-space: nowrap; }
.rail-btn:active { transform: scale(0.92); }
.rail-btn.on {
  background: linear-gradient(160deg, var(--brand-lite), var(--brand));
  border-color: rgba(255,255,255,0.75);
  color: #fff;
  box-shadow: var(--sh-brand);
  transform: scale(1.05);
}

/* ===== 二级选项面板：浮在场景右侧，不占常驻空间 ===== */
#panel {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(88px + env(safe-area-inset-right));   /* 给 rail 让位 */
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(340px, calc(100% - 170px));
  z-index: 7;
  display: flex;
  flex-direction: column;
  background: linear-gradient(175deg, rgba(255,255,255,0.9), rgba(255,244,251,0.86));
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  border-radius: 28px;
  box-shadow: 0 18px 46px rgba(178, 116, 150, 0.30), inset 0 1px 0 #fff;
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  /* 打开：animation 做入场；可见性用 :not(.open) 兜底 ——
     元素从 display:none 变可见时 transition 不触发，而 animation 结束后
     opacity 会落回基础值，所以基础值不能写死 0，要写成「仅关闭时才 0」。 */
}
#panel:not(.open) {
  opacity: 0;
  pointer-events: none;
}
/* 入场动画。若浏览器不支持/跳过，.open 的 opacity:1 仍然生效，不会卡在透明。 */
#panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: none;
  animation: panelIn .26s var(--ease-pop);
}
/* 入场动画放在伪元素上，避免动画结束后把本体 opacity 拉回初始值 */
@keyframes panelIn {
  from { opacity: 0; transform: translateX(18px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

#panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 8px;
}
#panel-title {
  flex: 1;
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  color: var(--ink-strong);
  letter-spacing: .02em;
}
#panel-close {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1.5px solid rgba(255,255,255,0.92);
  background: linear-gradient(160deg, #fff, #fff2f9);
  box-shadow: var(--sh-sm);
  color: #a9527f;
  font-size: 17px;
  font-weight: 700;
  display: grid;
  place-items: center;
  transition: transform .16s var(--ease-pop);
}
#panel-close:active { transform: scale(0.9); }

#panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px 14px;
}

/* 提示气泡 */
#toast {
  position: absolute;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 24px);
  padding: 13px 28px;
  border-radius: 999px;
  background: linear-gradient(160deg, rgba(255,255,255,0.98), rgba(255,246,251,0.94));
  border: 1.5px solid rgba(255,255,255,0.95);
  box-shadow: var(--sh-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 21px;
  font-weight: 600;
  color: var(--ink-strong);
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s ease, transform .24s var(--ease-pop);
  white-space: nowrap;
  max-width: 88%;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 8;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== 旧常驻托盘已废除：工具改为右侧竖排图标 + 弹出面板 ===== */

.stack { display: flex; flex-direction: column; gap: 4px; }

/* 选项行：放不下就换行。
   （原来是横向滚动 —— 面板只有 340px 宽，8~12 个按钮要左右拖才能选到后面的，
   选了还会因为重建跳回最前面。换行后一屏全看到，不用拖。） */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 6px 2px 10px;
}
.row.center { justify-content: center; }

/* 分类标签例外：横滑比换行更省地方，标签也短，一眼能看全 */
.row.sub-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 7px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.row.sub-tabs::-webkit-scrollbar { display: none; }

/* ================= 色块（带指甲预览） ================= */

.swatch {
  flex: 0 0 auto;
  width: 76px;
  height: 92px;
  border-radius: 22px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  background: linear-gradient(170deg, #ffffff, #fff3f9);
  box-shadow: var(--sh-md), inset 0 1px 0 #fff;
  position: relative;
  padding: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: transform .18s var(--ease-pop), box-shadow .18s ease,
              border-color .18s ease;
}
.swatch:active { transform: scale(0.90); }
.swatch[aria-pressed="true"] {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(255, 106, 168, 0.28), var(--sh-lg);
}
.swatch[aria-pressed="true"]::after {
  content: "✓";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--brand-lite), var(--brand-deep));
  border: 1.5px solid #fff;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 7px rgba(232, 86, 143, 0.5);
}
.sw-canvas { display: block; pointer-events: none; }

/* 纯色小圆片 */
.swatch.chip {
  width: 62px;
  height: 62px;
  border-radius: 20px;
}
.swatch.chip[aria-pressed="true"]::after { right: -4px; bottom: -4px; }

/* ================= 图标按钮 ================= */

.btn {
  flex: 0 0 auto;
  min-width: 84px;
  padding: 12px 14px;
  border-radius: 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  background: linear-gradient(165deg, #ffffff, #fff6fb);
  box-shadow: var(--sh-md), inset 0 1px 0 #fff;
  color: #a9527f;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: transform .18s var(--ease-pop), box-shadow .18s ease,
              background .18s ease, color .18s ease;
}
.btn .ico { font-size: 25px; line-height: 1.1; }
.btn:active { transform: scale(0.93); }
.btn[aria-pressed="true"] {
  background: linear-gradient(160deg, var(--brand-lite), var(--brand));
  border-color: rgba(255, 255, 255, 0.7);
  color: #fff;
  box-shadow: var(--sh-brand);
}

/* ---- 带真实预览图的按钮（萌可贴纸/纹身用）----
   9 个萌可如果都用 💖 图标，长得一模一样根本分不出来，
   所以每个按钮画出它自己的样子。 */
.prev-btn {
  min-width: 76px;
  padding: 8px 8px 7px;
  gap: 2px;
}
.prev-canvas {
  border-radius: 12px;
  background: #fff6fb;
  box-shadow: inset 0 0 0 1.5px rgba(255, 182, 216, 0.55);
}
.prev-btn[aria-pressed="true"] .prev-canvas {
  background: #ffffff;
  box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px rgba(255, 255, 255, 0.7);
}
.prev-btn .lbl { font-size: 12px; letter-spacing: .2px; }

/* ================= 分类切换条（页内二级分类） ================= */

.sub-tabs { gap: 8px; padding: 4px 2px 8px; }
.sub-tab {
  flex: 0 0 auto;
  padding: 9px 15px;
  border-radius: 16px;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  background: linear-gradient(165deg, #ffffff, #fff6fb);
  box-shadow: var(--sh-sm);
  color: #b0608a;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform .18s var(--ease-pop), background .18s ease,
              color .18s ease, box-shadow .18s ease;
}
.sub-tab:active { transform: scale(0.93); }
.sub-tab[aria-pressed="true"] {
  background: linear-gradient(160deg, var(--brand-lite), var(--brand));
  border-color: rgba(255,255,255,0.7);
  color: #fff;
  box-shadow: var(--sh-brand);
}

/* 甲油/贴纸/纹身的选项网格：多行铺开，一屏能看全 */
.grid {
  display: grid;
  /* 面板宽 340px，减内边距约 300px 可用。
     66px 最小宽 → 4 列；萌可按钮的预览图固定 56px，塞得进。 */
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  padding: 4px 0 8px;
  overflow: visible;
  min-width: 0;
}
.grid .swatch { width: 100%; height: 84px; }
.grid .swatch.chip { height: 62px; }
/* 网格里的按钮不能有最小宽度，否则会撑破格子（横向溢出的原因） */
.grid .btn,
.grid .prev-btn {
  min-width: 0;
  width: 100%;
  padding-left: 4px;
  padding-right: 4px;
}
.grid .prev-canvas { max-width: 100%; }

/* 分组小标题：带一条细线，像个正经分区 */
.group-label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 4px 3px;
  font-size: 14px;
  font-weight: 700;
  color: #c08aa6;
  letter-spacing: .03em;
}
.group-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(214,160,190,0.45), rgba(214,160,190,0));
  border-radius: 1px;
}

.hint {
  padding: 8px 4px 12px;
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.hint b { color: var(--ink-strong); font-size: 19px; }

/* 星星满格时弹一下 */
.hud.full { animation: hudPop .55s var(--ease-pop); }
@keyframes hudPop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ================= 作品展示层 ================= */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(88, 48, 74, 0.44);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  display: grid;
  place-items: center;
  padding: 18px;
  animation: fade .24s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.card {
  background: linear-gradient(170deg, #ffffff, #fff8fc);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 32px;
  padding: 20px 20px 16px;
  max-width: 620px;
  width: 100%;
  max-height: 94vh;
  overflow-y: auto;
  box-shadow: 0 26px 70px rgba(110, 54, 88, 0.38), inset 0 1px 0 #fff;
  text-align: center;
  animation: cardIn .32s var(--ease-pop);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
.card h2 {
  margin: 4px 0 14px;
  font-size: 24px;
  color: var(--ink-strong);
  letter-spacing: .01em;
}
.card img {
  width: 100%;
  max-height: 56vh;
  object-fit: contain;
  border-radius: 22px;
  background: #fff3f9;
  border: 1px solid rgba(255,255,255,0.9);
  box-shadow: var(--sh-lg);
}
.card .row { justify-content: center; }
.card .hint { padding: 12px 2px 4px; }

/* ================= 横屏（iPad 横着拿） ================= */

/* 横竖屏都是全屏舞台 + 浮动面板，不再分两套布局。
   只在小屏时把面板放宽一点。 */
@media (max-width: 700px) {
  #panel { width: calc(100% - 160px); }
  .grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------- 封面导出模式（?thumb=1） ----------------
   入口页要一张干净的游戏截图，所以把界面藏起来，只留手 */
.thumb-mode, .thumb-mode body, .thumb-mode #app { background: #ffd9ee !important; }
.thumb-mode #stage { background: #ffd9ee !important; }
.thumb-mode #hud,
.thumb-mode #global-bar,
.thumb-mode #rail,
.thumb-mode #panel,
.thumb-mode #toast { display: none !important; }