/* 美甲小屋 —— 样式
   设计原则（4-6 岁）：
   - 按钮大、间距足、图标 + 中文双标注
   - 禁止长按选中、双击缩放、滚动回弹
   - 支持 iPad 安全区（刘海/圆角）
*/

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

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: #6b4a5a;
  touch-action: manipulation;
}

#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);
  background:
    radial-gradient(circle at 16% 10%, #fff8fc 0%, transparent 44%),
    radial-gradient(circle at 86% 88%, #ffe6f3 0%, transparent 50%),
    linear-gradient(168deg, #fff2f9 0%, #ffe3f1 58%, #ffd9ec 100%);
}

/* ================= 舞台 ================= */

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#board {
  display: block;
  touch-action: none;        /* 关键：涂色时不要触发滚动/缩放 */
  border-radius: 30px;
  box-shadow: 0 10px 34px rgba(205, 140, 180, 0.16);
}

/* 星星 */
.hud {
  position: absolute;
  top: 10px;
  left: 14px;
  font-size: 25px;
  letter-spacing: 2px;
  padding: 7px 15px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 4px 14px rgba(190, 120, 160, 0.2);
  pointer-events: none;
  max-width: 62%;
  overflow: hidden;
  white-space: nowrap;
}

/* 快捷按钮 */
#quick {
  position: absolute;
  top: 10px;
  right: 14px;
  display: flex;
  gap: 10px;
}
.qbtn {
  width: 62px;
  height: 62px;
  border: none;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(190, 120, 160, 0.22);
  font-size: 27px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: transform .12s ease;
}
.qbtn:active { transform: scale(0.9); }

/* 提示气泡 */
#toast {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 22px);
  padding: 12px 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 26px rgba(190, 120, 160, 0.3);
  font-size: 21px;
  font-weight: 600;
  color: #c2557f;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  white-space: nowrap;
  max-width: 88%;
  overflow: hidden;
  text-overflow: ellipsis;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ================= 工具区 ================= */

#tray {
  flex: 0 0 auto;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 -8px 30px rgba(200, 140, 175, 0.16);
  border-radius: 28px 28px 0 0;
  max-height: 46vh;
  display: flex;
  flex-direction: column;
}

#tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 0 0 auto;
}
#tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  flex: 1 0 auto;
  min-width: 74px;
  padding: 10px 12px;
  border: none;
  border-radius: 20px;
  background: #ffeaf3;
  color: #b0608a;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform .14s cubic-bezier(.34,1.56,.64,1), background .18s ease,
              box-shadow .18s ease;
}
.tab .ico { font-size: 24px; line-height: 1.1; }
.tab[aria-selected="true"] {
  background: linear-gradient(160deg, #ffa8ce, #ff6aa8);
  color: #fff;
  box-shadow: 0 7px 18px rgba(255, 106, 168, 0.45), inset 0 1px 0 rgba(255,255,255,.5);
}
.tab:active { transform: scale(0.94); }

/* 完成页签上的星星数 */
.tab .badge {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ffb03a;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(255, 176, 58, 0.55);
}
.tab .badge:empty { display: none; }

#pane {
  flex: 1 1 auto;
  min-height: 118px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.stack { display: flex; flex-direction: column; gap: 6px; }

/* 横向滚动行 */
.row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 6px 2px 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.row::-webkit-scrollbar { display: none; }
.row.center { justify-content: center; }

/* ================= 色块（带指甲预览） ================= */

.swatch {
  flex: 0 0 auto;
  width: 76px;
  height: 92px;
  border-radius: 22px;
  border: 3px solid rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 5px 14px rgba(180, 120, 155, 0.22);
  position: relative;
  padding: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: transform .14s cubic-bezier(.34,1.56,.64,1), box-shadow .18s ease,
              border-color .18s ease;
}
.swatch:active { transform: scale(0.90); }
.swatch[aria-pressed="true"] {
  border-color: #ff5f9e;
  box-shadow: 0 0 0 4px rgba(255, 95, 158, 0.30), 0 6px 16px rgba(180, 120, 155, 0.3);
}
.swatch[aria-pressed="true"]::after {
  content: "✓";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ff5f9e;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(255, 95, 158, 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: none;
  background: #fff;
  box-shadow: 0 4px 12px rgba(180, 120, 155, 0.2);
  color: #a9527f;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: transform .14s cubic-bezier(.34,1.56,.64,1), background .18s ease,
              box-shadow .18s ease, color .18s ease;
}
.btn .ico { font-size: 26px; line-height: 1.1; }
.btn:active { transform: scale(0.93); }
.btn[aria-pressed="true"] {
  background: linear-gradient(160deg, #ffa8ce, #ff6aa8);
  color: #fff;
  box-shadow: 0 7px 18px rgba(255, 106, 168, 0.45), inset 0 1px 0 rgba(255,255,255,.5);
}

/* 质感按钮：上面一块指甲缩略图 + 下面文字 */
.finish-btn { min-width: 88px; padding: 8px 12px 11px; }
.fin-ico { display: grid; place-items: center; height: 46px; }
.fin-canvas { display: block; pointer-events: none; }
.finish-btn .lbl { font-size: 15px; white-space: nowrap; }

/* 分组小标题 */
.group-label {
  padding: 10px 4px 2px;
  font-size: 15px;
  font-weight: 700;
  color: #b98aa4;
  letter-spacing: .02em;
}

.hint {
  padding: 8px 4px 12px;
  font-size: 16px;
  color: #a97e93;
  line-height: 1.5;
}
.hint b { color: #e8568f; font-size: 19px; }

/* 星星满格时闪一下 */
.hud.full { animation: hudPop .5s cubic-bezier(.34,1.56,.64,1); }
@keyframes hudPop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.16); }
  100% { transform: scale(1); }
}

/* ================= 作品展示层 ================= */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(90, 50, 75, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 18px;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.card {
  background: #fff;
  border-radius: 30px;
  padding: 18px 18px 14px;
  max-width: 620px;
  width: 100%;
  max-height: 94vh;
  overflow-y: auto;
  box-shadow: 0 22px 60px rgba(120, 60, 95, 0.34);
  text-align: center;
}
.card h2 {
  margin: 4px 0 12px;
  font-size: 24px;
  color: #d94e88;
}
.card img {
  width: 100%;
  max-height: 56vh;
  object-fit: contain;
  border-radius: 20px;
  background: #fff3f9;
  box-shadow: 0 6px 20px rgba(190, 140, 170, 0.2);
}
.card .row { justify-content: center; }
.card .hint { padding: 10px 2px 4px; }

/* ================= 横屏（iPad 横着拿）================= */

@media (orientation: landscape) and (min-height: 560px) {
  #app { flex-direction: row; }
  #tray {
    flex: 0 0 250px;
    max-height: none;
    border-radius: 28px 0 0 28px;
    border-top: none;
    border-left: 2px solid rgba(255, 255, 255, 0.9);
    padding: 14px 12px;
  }
  #tabs {
    flex-direction: column;
    overflow-x: visible;
    margin-bottom: 12px;
  }
  .tab {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    min-width: 0;
  }
  .tab .badge { position: static; margin-left: auto; }
  .row { flex-wrap: wrap; overflow-x: visible; }
  .swatch { width: 62px; height: 62px; }
  .card img { max-height: 62vh; }
}
