:root {
  --bay-teal: #00a6a6;
  --bay-red: #e63946;
  --bay-gold: #ffb703;
  --bay-pink: #ff9aa2;
  --ink: #2b2b2b;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: linear-gradient(160deg, #e8f6f6 0%, #fdeef0 100%);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
/* Electron 透明窗口：让桌面透出来 */
body.electron { background: transparent; }

#stage {
  position: fixed;
  inset: 0;
  pointer-events: none; /* 只有宠物本体可交互，桌面其余区域穿透 */
}

#pet {
  position: fixed;
  left: 48px;
  top: 48px;
  width: 200px;
  height: 230px;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  will-change: transform;
}
#pet:active { cursor: grabbing; }

#character {
  width: 200px;
  height: 200px;
  transform-origin: 50% 82%;
  animation: breathe 3.2s ease-in-out infinite;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

#shadow {
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 120px;
  height: 18px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(0,0,0,.18), transparent 70%);
  animation: shadow 3.2s ease-in-out infinite;
  pointer-events: none;
}

/* 眨眼：针对眼睛组做纵向压扁 */
#eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 4.5s infinite;
}

/* 对话气泡 */
#bubble {
  position: absolute;
  left: 50%;
  top: -16px;
  transform: translate(-50%, -100%) scale(.9);
  max-width: 230px;
  padding: 10px 14px;
  border-radius: 16px;
  background: #fff;
  color: #333;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 6px 18px rgba(0,0,0,.15);
  border: 2px solid var(--bay-teal);
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  white-space: pre-wrap;
  z-index: 10;
}
#bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: #fff;
}
#bubble.show { opacity: 1; transform: translate(-50%, -100%) scale(1); }
#bubble.hidden { display: none; }

/* 右键菜单 */
#menu {
  position: fixed;
  z-index: 50;
  min-width: 168px;
  background: #fff;
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  border: 2px solid var(--bay-gold);
  pointer-events: auto;
}
#menu.hidden { display: none; }

/* 移动端形象切换条（默认隐藏，仅触屏设备显示） */
#skinBar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%);
  z-index: 60;
  display: none;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  border: 2px solid var(--bay-gold);
  pointer-events: auto;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
#skinBar button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 52px; padding: 6px 4px;
  border: 0; border-radius: 12px; background: transparent;
  font-size: 11px; color: #555; cursor: pointer;
}
#skinBar button .sb-emoji { font-size: 20px; line-height: 1; }
#skinBar button.active { background: #fff3d6; color: #b08a3a; font-weight: 700; }
#skinBar button.active .sb-emoji { transform: scale(1.15); }
@media (pointer: coarse) {
  #skinBar { display: flex; }
}
#menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  color: #333;
}
#menu button:hover { background: #fff3d6; }

/* 菜单分隔线 & 小标题 */
.menu-sep { height: 1px; background: #eee; margin: 5px 8px; }
.menu-title { padding: 4px 12px 2px; font-size: 11px; color: #b08a3a; font-weight: 700; }

/* 形象选择项：当前形象高亮 + 对勾 */
#skinMenu button { display: flex; align-items: center; gap: 6px; }
#skinMenu button .sk-emoji { font-size: 15px; }
#skinMenu button.active { background: #fff3d6; color: #b08a3a; font-weight: 700; }
#skinMenu button.active::after { content: '✓'; margin-left: auto; color: #2a9d8f; }

/* 庆祝旋转 */
#pet.celebrate #character { animation: spin .7s ease-in-out 2; }
/* 拖拽时暂停呼吸动画 */
#pet.dragging #character { animation: none; }

@keyframes breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-4px) scale(1.025); }
}
@keyframes shadow {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: .5; }
  50%      { transform: translateX(-50%) scale(.85); opacity: .35; }
}
@keyframes blink {
  0%, 90%, 100% { transform: scaleY(1); }
  93%, 96%      { transform: scaleY(.08); }
}
@keyframes spin {
  0%   { transform: rotate(0); }
  100% { transform: rotate(360deg); }
}
