:root {
  --bg-1: #fff0f6;
  --bg-2: #f3e8ff;
  --bg-3: #fff7ed;
  --accent: #ff85a2;
  --accent-2: #c084fc;
  --gold: #fbbf24;
  --shadow: 0 8px 24px rgba(192, 132, 252, .25);
  --radius: 22px;
  --header-h: 54px;
  --tabs-h: 64px;
  --items-h: 120px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2), var(--bg-3));
  color: #6b3fa0;
  user-select: none;
  touch-action: manipulation;
}

.app {
  height: 100vh; width: 100vw;
  display: flex; flex-direction: column;
  max-width: 520px; margin: 0 auto;
  position: relative;
}

/* 顶部标题 */
.header {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 18px; font-weight: 800;
  text-shadow: 0 2px 0 #fff;
  flex-shrink: 0;
}
.header h1 { margin: 0; font-size: 20px; letter-spacing: 1px; }
.sparkle { animation: twinkle 1.6s ease-in-out infinite; }
.sparkle:nth-child(3) { animation-delay: .8s; }
@keyframes twinkle {
  0%,100% { transform: scale(1); opacity: .8; }
  50% { transform: scale(1.3); opacity: 1; }
}

/* 主区域 */
.main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; padding: 0 12px 12px;
  gap: 10px;
}

/* 公主展示台 */
.stage {
  position: relative;
  flex: 1; min-height: 0;
  display: flex; justify-content: center; align-items: center;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, rgba(255,255,255,.6), rgba(255,255,255,0));
  touch-action: none;
}
.princess {
  height: 100%; width: 100%;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  border-radius: var(--radius);
}
.accessories-layer {
  position: absolute; inset: 0;
  pointer-events: none;
}
.accessory {
  position: absolute;
  pointer-events: auto;
  cursor: grab;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.15));
  transform-origin: center center;
  touch-action: none;
}
.accessory.active { cursor: grabbing; filter: drop-shadow(0 0 10px rgba(255,133,162,.8)); z-index: 1000 !important; }

/* 快捷按钮 */
.controls {
  display: flex; justify-content: center; gap: 12px;
  flex-shrink: 0;
}
.btn {
  border: none; border-radius: 50px;
  padding: 10px 18px;
  font-size: 15px; font-weight: 700;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
  transition: transform .1s, box-shadow .1s;
}
.btn:active { transform: scale(.95); }
.btn-random { background: linear-gradient(90deg, #f472b6, #c084fc); }
.btn-reset { background: linear-gradient(90deg, #94a3b8, #cbd5e1); color: #4b5563; }
.btn-save { background: linear-gradient(90deg, #fbbf24, #f59e0b); }

/* 分类与物品 */
.category-section {
  flex-shrink: 0;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.tabs {
  display: flex; gap: 8px;
  padding: 10px 12px 6px;
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid rgba(192,132,252,.15);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 4px;
  padding: 8px 14px;
  border-radius: 50px;
  background: #fff;
  color: #6b3fa0;
  font-weight: 700; font-size: 14px;
  box-shadow: 0 2px 6px rgba(192,132,252,.15);
  cursor: pointer;
  transition: transform .1s;
}
.tab:active { transform: scale(.95); }
.tab.active {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #fff;
}

.items {
  display: flex; gap: 10px;
  padding: 10px 12px;
  overflow-x: auto; scrollbar-width: none;
  min-height: var(--items-h);
  align-items: center;
}
.items::-webkit-scrollbar { display: none; }
.item {
  flex-shrink: 0;
  width: 84px; height: 84px;
  border-radius: 18px;
  background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(192,132,252,.12);
  cursor: pointer;
  position: relative;
  transition: transform .12s, box-shadow .12s;
  overflow: hidden;
}
.item:active { transform: scale(.93); }
.item.active {
  box-shadow: 0 0 0 3px var(--accent), 0 4px 12px rgba(255,133,162,.35);
}
.item img {
  width: 62px; height: 62px;
  object-fit: contain;
  pointer-events: none;
}
.item span {
  font-size: 11px; font-weight: 700;
  color: #6b3fa0;
  margin-top: 2px;
  white-space: nowrap;
}
.item .none-mark {
  font-size: 28px; line-height: 1;
}

/* 配饰操作工具条 */
.acc-toolbar {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
  background: rgba(255,255,255,.9);
  padding: 8px 12px;
  border-radius: 50px;
  box-shadow: var(--shadow);
  z-index: 2000;
  /* 高度由内容决定，top 在 JS 中动态设置 */
}
.tb-btn {
  width: 38px; height: 38px;
  border: none; border-radius: 50%;
  background: #f3e8ff;
  color: #6b3fa0;
  font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.tb-btn.tb-remove { background: #ffe4e6; }

/* Toast */
.toast {
  position: fixed; bottom: 120px; left: 50%; transform: translateX(-50%);
  background: rgba(107,63,160,.92); color: #fff;
  padding: 10px 18px; border-radius: 50px;
  font-size: 14px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .3s;
  z-index: 3000;
}
.toast.show { opacity: 1; }

/* 漂浮装饰 */
.floater {
  position: fixed; pointer-events: none;
  font-size: 20px; opacity: .6;
  animation: floatUp 2.5s ease-in forwards;
  z-index: 2500;
}
@keyframes floatUp {
  0% { transform: translateY(0) scale(.8); opacity: .8; }
  100% { transform: translateY(-120px) scale(1.2); opacity: 0; }
}

/* 大屏简单放大 */
@media (min-width: 768px) {
  .app { max-width: 580px; }
  .item { width: 92px; height: 92px; }
  .item img { width: 68px; height: 68px; }
}
