/* =========================================================
 * 虚拟动物养成游戏 · 样式
 * 柔和治愈系：奶油 / 浅粉 / 薄荷 渐变背景
 * ========================================================= */

/* ---------------- 基础与全局 ---------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-1: #fff8ec;        /* 奶油 */
  --bg-2: #ffeef3;        /* 浅粉 */
  --bg-3: #e8f8f0;        /* 薄荷 */
  --card: #fffdf9;
  --ink: #5c4a52;
  --ink-soft: #a08e96;
  --pink: #ff9bb3;
  --pink-deep: #f4789b;
  --pink-soft: #fff0f5;
  --line: #f4e3e8;
  --danger: #ff6b6b;
  --warn-bg: #fff8e1;
  --warn-border: #ffe08a;
  --warn-ink: #a06b00;
  --shadow: 0 12px 32px rgba(219, 160, 175, 0.28);
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 48%, var(--bg-3) 100%) fixed;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px 12px 40px;
  line-height: 1.5;
}

.app { width: 100%; max-width: 480px; }

button { font-family: inherit; cursor: pointer; touch-action: manipulation; }

.hidden { display: none !important; }

/* 主卡片容器 */
.view {
  background: var(--card);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 26px 22px;
  animation: viewIn 0.45s ease both;
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------------- 领养页 ---------------- */
.adopt-title {
  font-size: 26px;
  text-align: center;
  letter-spacing: 1px;
}

.adopt-welcome {
  margin: 12px 0 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.9;
}

.adopt-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.adopt-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 6px 14px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 18px;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.adopt-card:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(219, 160, 175, 0.25); }
.adopt-card.selected {
  border-color: var(--pink);
  background: var(--pink-soft);
  transform: translateY(-4px);
  box-shadow: 0 10px 22px rgba(244, 120, 155, 0.28);
}

.card-emoji { width: 56px; height: 56px; line-height: 0; display: inline-flex; align-items: center; justify-content: center; }
.card-emoji .pet-svg { width: 100%; height: 100%; display: block; }
.card-name { font-size: 15px; font-weight: 600; }
.card-desc { font-size: 11px; color: var(--ink-soft); text-align: center; }

.name-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }

.name-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 14px;
  outline: none;
  margin-bottom: 18px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.name-input:focus { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(255, 155, 179, 0.15); }

.primary-btn {
  width: 100%;
  padding: 14px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink) 0%, var(--pink-deep) 100%);
  border: none;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(244, 120, 155, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.2s ease;
}
.primary-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(244, 120, 155, 0.45); }
.primary-btn:active:not(:disabled) { transform: scale(0.97); }
.primary-btn:disabled { filter: grayscale(0.9); opacity: 0.55; cursor: not-allowed; box-shadow: none; }

/* ---------------- 主界面：顶栏 ---------------- */
.top-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pet-name { font-size: 22px; }

.level-badge {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ffb86b, #ff8fab);
  padding: 3px 10px;
  border-radius: 999px;
}

.stage-tag {
  font-size: 12px;
  font-weight: 600;
  color: #4a8f6d;
  background: #e3f6ec;
  border: 1px solid #c4ead6;
  padding: 3px 10px;
  border-radius: 999px;
}

.exp-row { display: flex; align-items: center; gap: 10px; margin: 12px 0 6px; }

.exp-bar {
  flex: 1;
  height: 10px;
  background: #f6e8ec;
  border-radius: 999px;
  overflow: hidden;
}

.exp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffa8c5, #b18cf1);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.exp-text {
  font-size: 12px;
  color: var(--ink-soft);
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 舞台区 ---------------- */
.stage-area {
  position: relative;
  height: 250px;
  margin-top: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 42px;
  background: linear-gradient(180deg, #fdf2f6 0%, #eefaf3 100%);
  border-radius: 22px;
}

/* 地面椭圆阴影 */
.stage-area::after {
  content: '';
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 24px;
  border-radius: 50%;
  background: rgba(219, 160, 175, 0.2);
}

.pet-wrap { position: relative; display: inline-block; z-index: 2; }

.pet-emoji {
  display: inline-block;
  line-height: 0;
  animation: idle 3.2s ease-in-out infinite; /* 待机呼吸 + 轻微摇摆（默认/平静） */
  transition: width 0.5s ease;
  will-change: transform;
}
.pet-emoji .pet-svg { width: 100%; height: auto; display: block; }
.pet-emoji.stage-young  { width: 110px; }
.pet-emoji.stage-teen   { width: 150px; }
.pet-emoji.stage-adult  { width: 190px; }

/* 情绪动作（持续态，由 mood-xxx 驱动） */
.pet-emoji.mood-happy  { animation: happyBounce 2s ease-in-out infinite; }
.pet-emoji.mood-calm   { animation: idle 3.2s ease-in-out infinite; }
.pet-emoji.mood-hungry { animation: hungryLean 1.5s ease-in-out infinite; }
.pet-emoji.mood-sleepy { animation: sleepySway 4s ease-in-out infinite; }
.pet-emoji.mood-dirty  { animation: dirtyShrink 2.5s ease-in-out infinite; }
.pet-emoji.mood-sick   { animation: sickDroop 3s ease-in-out infinite; }

.crown {
  position: absolute;
  top: -30px;
  right: -18px;
  font-size: 30px;
  animation: crownBob 2.4s ease-in-out infinite;
  z-index: 3;
}

/* 情绪气泡：显示约 2.5s 后淡出 */
.speech-bubble {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 84%;
  padding: 8px 14px;
  font-size: 14px;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(219, 160, 175, 0.3);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  z-index: 4;
}
.speech-bubble.show { opacity: 1; }
.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: #fff;
  border-bottom-width: 0;
}

/* 负面状态头顶标记（☁️ / 💦 等） */
.negative-mark {
  position: absolute;
  top: 58px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 26px;
  animation: bob 2s ease-in-out infinite;
  z-index: 3;
}

/* 飘动特效层 */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.fx {
  position: absolute;
  bottom: 34%;
  font-size: 26px;
  opacity: 0;
  animation: floatUp 1.6s ease-out forwards;
}
.fx-burst {
  bottom: 45%;
  font-size: 26px;
  animation: burst 1.3s ease-out forwards;
}

/* 状态文案 */
.status-text {
  text-align: center;
  margin: 14px 0 4px;
  font-size: 15px;
  color: var(--ink-soft);
}

/* ---------------- 属性区 ---------------- */
.stats-area { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 4px; }

.stat-row { display: flex; align-items: center; gap: 8px; }
.stat-icon { font-size: 16px; width: 22px; text-align: center; }
.stat-label { width: 56px; font-size: 13px; font-weight: 600; }

.stat-bar {
  flex: 1;
  height: 12px;
  background: #f6e8ec;
  border-radius: 999px;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.4s ease, background 0.3s ease;
}
.stat-fill[data-stat="hunger"] { background: linear-gradient(90deg, #ffd08a, #ff9d6c); }
.stat-fill[data-stat="mood"]   { background: linear-gradient(90deg, #ffb3c6, #ff8fab); }
.stat-fill[data-stat="energy"] { background: linear-gradient(90deg, #a5d8ff, #74c0fc); }
.stat-fill[data-stat="clean"]  { background: linear-gradient(90deg, #b2f2bb, #69db7c); }
.stat-fill.warning { background: linear-gradient(90deg, #ffb3b3, #ff6b6b) !important; }

.stat-value {
  width: 40px;
  text-align: right;
  font-size: 13px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.stat-value.warning { color: var(--danger); font-weight: 700; }

/* 满值视觉提示：金色发光属性条 + MAX 标记 + 已满按钮角标 */
.stat-fill.full {
  background: linear-gradient(90deg, #ffe17a, #ffb300) !important;
  animation: fullGlow 1.6s ease-in-out infinite;
}
@keyframes fullGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 200, 0, 0.45); }
  50%      { box-shadow: 0 0 14px rgba(255, 200, 0, 0.85); }
}
.stat-value.full {
  color: #e69500;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-shadow: 0 0 6px rgba(255, 200, 0, 0.5);
}
.action-btn.maxed {
  opacity: 0.55;
  filter: grayscale(0.7);
  position: relative;
}
.action-btn.maxed::after {
  content: '已满';
  position: absolute;
  top: -7px;
  right: -6px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ffc53c, #ff8800);
  padding: 2px 7px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(255, 150, 0, 0.55);
  letter-spacing: 0.5px;
}

/* ---------------- 提醒区 ---------------- */
.reminders { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 2px; }

.reminder {
  font-size: 12px;
  color: var(--warn-ink);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  padding: 4px 10px;
  border-radius: 999px;
  animation: bob 2.2s ease-in-out infinite;
}

/* ---------------- 操作区 ---------------- */
.actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 2px;
  min-height: 60px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.action-btn:hover { border-color: var(--pink); background: var(--pink-soft); box-shadow: 0 6px 14px rgba(244, 120, 155, 0.2); }
.action-btn:active { transform: scale(0.93); }
.action-icon { font-size: 22px; line-height: 1; }
.action-text { font-size: 12px; font-weight: 600; }

/* ---------------- 底部设置行 ---------------- */
.settings-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }

.ghost-btn {
  flex: 1;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  background: transparent;
  border: 2px solid var(--line);
  border-radius: 999px;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.ghost-btn:hover { color: var(--pink-deep); border-color: var(--pink); background: var(--pink-soft); }
.ghost-btn:active { transform: scale(0.97); }

/* ---------------- 通用动画 ---------------- */
/* 待机：呼吸 + 轻微摇摆 */
@keyframes idle {
  0%, 100% { transform: scale(1) rotate(-1.5deg); }
  50%      { transform: scale(1.05) rotate(1.5deg); }
}

/* 情绪动作 keyframes */
@keyframes happyBounce {
  0%, 100% { transform: translateY(0) scale(1) rotate(0deg); }
  25%      { transform: translateY(-7px) scale(1.03) rotate(4deg); }
  50%      { transform: translateY(0) scale(1) rotate(0deg); }
  75%      { transform: translateY(-3px) scale(1.02) rotate(-3deg); }
}
@keyframes hungryLean {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  30%      { transform: rotate(4deg) translateY(2px); }
  60%      { transform: rotate(0deg) translateY(0); }
}
@keyframes sleepySway {
  0%, 100% { transform: rotate(-5deg) translateY(0); }
  50%      { transform: rotate(5deg) translateY(2px); }
}
@keyframes dirtyShrink {
  0%, 100% { transform: scale(0.95) translateY(0); }
  50%      { transform: scale(0.95) translateY(-2px); }
}
@keyframes sickDroop {
  0%, 100% { transform: translateY(4px) rotate(0deg); }
  50%      { transform: translateY(6px) rotate(-2deg); }
}

/* 上下浮动（标记 / 提醒） */
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* 皇冠摆动 */
@keyframes crownBob {
  0%, 100% { transform: rotate(12deg) translateY(0); }
  50%      { transform: rotate(12deg) translateY(-5px); }
}

/* 喂食：咀嚼点头 */
@keyframes chew {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25%      { transform: translateY(8px) rotate(4deg); }
  50%      { transform: translateY(0) rotate(0deg); }
  75%      { transform: translateY(8px) rotate(-4deg); }
}
.pet-emoji.anim-chew { animation: chew 0.5s ease-in-out 3; }

/* 玩耍：开心跳跃 */
@keyframes jump {
  0%, 100% { transform: translateY(0); }
  30%      { transform: translateY(-26px) scale(1.05); }
  55%      { transform: translateY(0); }
  70%      { transform: translateY(-12px); }
  85%      { transform: translateY(0); }
}
.pet-emoji.anim-jump { animation: jump 1.1s ease-out; }

/* 洗澡：左右摇晃 */
@keyframes shake {
  0%, 100% { transform: rotate(0deg); }
  20%      { transform: rotate(-10deg); }
  40%      { transform: rotate(10deg); }
  60%      { transform: rotate(-8deg); }
  80%      { transform: rotate(8deg); }
}
.pet-emoji.anim-shake { animation: shake 0.9s ease-in-out 2; }

/* 睡觉：闭眼缩小 */
@keyframes sleepAnim {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(0.9) rotate(6deg); }
}
.pet-emoji.anim-sleep { animation: sleepAnim 1.6s ease-in-out; }

/* 抚摸：微微放大 */
@keyframes petAnim {
  0%, 100% { transform: scale(1); }
  40%      { transform: scale(1.12); }
}
.pet-emoji.anim-pet { animation: petAnim 0.9s ease-in-out 2; }

/* 升级：弹跳庆祝 */
@keyframes levelup {
  0%, 100% { transform: translateY(0) scale(1); }
  25%      { transform: translateY(-20px) scale(1.1) rotate(-6deg); }
  50%      { transform: translateY(0) scale(1); }
  75%      { transform: translateY(-12px) scale(1.06) rotate(6deg); }
}
.pet-emoji.anim-levelup { animation: levelup 1.2s ease-in-out; }

/* 飘字：上浮消散 */
@keyframes floatUp {
  0%   { opacity: 0; transform: translateY(10px) scale(0.5); }
  18%  { opacity: 1; transform: translateY(-8px) scale(1.15); }
  100% { opacity: 0; transform: translateY(-96px) scale(1); }
}

/* 星星爆裂（升级庆祝） */
@keyframes burst {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.4); }
  25%  { opacity: 1; transform: translate(calc(var(--dx, 0px) * 0.45), calc(var(--dy, -80px) * 0.45)) scale(1.25); }
  100% { opacity: 0; transform: translate(var(--dx, 0px), var(--dy, -80px)) scale(0.85); }
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 380px) {
  .view { padding: 22px 14px; }
  .adopt-title { font-size: 22px; }
  .card-emoji { width: 44px; height: 44px; }
  .pet-emoji.stage-young { width: 90px; }
  .pet-emoji.stage-teen  { width: 124px; }
  .pet-emoji.stage-adult { width: 158px; }
  .stat-label { width: 50px; font-size: 12px; }
  .action-text { font-size: 11px; }
}

/* ---------------- 确认模态 ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(92, 74, 82, 0.45);
  backdrop-filter: blur(3px);
  animation: modalFade 0.25s ease both;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: 24px;
  box-shadow: 0 20px 48px rgba(60, 40, 50, 0.35);
  padding: 26px 22px 22px;
  text-align: center;
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes modalPop {
  from { opacity: 0; transform: translateY(16px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-icon { font-size: 40px; line-height: 1; margin-bottom: 6px; }
.modal-title { font-size: 20px; margin-bottom: 8px; }
.modal-desc {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.7;
  margin-bottom: 20px;
}
.modal-desc strong { color: var(--ink); font-weight: 700; }

.modal-actions { display: flex; gap: 10px; }
.modal-actions .ghost-btn { flex: 1; }
.modal-confirm-btn { flex: 1.4; padding: 12px 14px; font-size: 15px; }
