/**
 * ============================================================
 * 🎀 可爱养成小游戏 - 样式表 (style.css)
 *   马卡龙色系 · 圆角可爱风 · 响应式适配
 * ============================================================
 */

/* ==================== CSS 变量 & 基础重置 ==================== */
:root {
  /* 马卡龙色板 */
  --pink:       #FFB5C2;
  --pink-light: #FFE4E7;
  --pink-dark:  #F08A9C;
  --mint:       #B5EAD7;
  --mint-light: #E0F7EF;
  --mint-dark:  #8ED1B8;
  --cream:      #FFF1C1;
  --cream-light:#FFF9E6;
  --cream-dark: #F0D98C;
  --lavender:   #E2D5F1;
  --lav-light:  #F3EDFA;
  --lav-dark:   #C4B0DC;
  --sky:        #B5D8EB;
  --sky-light:  #E3F2FD;
  --sky-dark:   #8EC4DE;
  --white:      #FFFFFF;
  --bg:         #FFF5F5;
  --text:       #5D4E5D;
  --text-light: #9B8E9B;
  --gold:       #FFD700;
  --red:        #FF8A8A;
  --green:      #8ED1B8;
  --shadow:     0 4px 15px rgba(180, 160, 170, 0.2);
  --shadow-lg:  0 8px 30px rgba(180, 160, 170, 0.3);
  --radius-sm:  10px;
  --radius-md:  16px;
  --radius-lg:  24px;
  --radius-xl:  32px;
  --font:       'PingFang SC', 'Hiragino Sans GB', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: #fce4ec;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ==================== 主容器 ==================== */
.app-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

/* ==================== 顶部状态栏 ==================== */
.top-bar {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--pink-light), var(--lav-light));
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: 0 2px 10px rgba(255, 181, 194, 0.3);
  z-index: 10;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
}

.stat-icon {
  font-size: 18px;
}

.stat-value {
  color: var(--text);
  min-width: 40px;
  text-align: center;
}

/* ==================== 进度条区域 ==================== */
.stat-bars {
  padding: 10px 16px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.bar-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-light);
}

.bar-track {
  width: 100%;
  height: 10px;
  background: #EEE;
  border-radius: 5px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
}

.bar-stamina  { background: linear-gradient(90deg, var(--sky), var(--sky-dark)); }
.bar-fullness { background: linear-gradient(90deg, var(--cream-dark), var(--pink)); }
.bar-clean    { background: linear-gradient(90deg, var(--mint), var(--mint-dark)); }
.bar-exp      { background: linear-gradient(90deg, var(--lavender), var(--pink)); }

/* ==================== 主舞台 ==================== */
.main-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  margin: 6px 12px;
  min-height: 200px;
}

.scene-bg {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: background-color 0.6s ease;
}

.scene-label {
  position: absolute;
  top: 10px;
  left: 14px;
  font-size: 14px;
  font-weight: 700;
  background: rgba(255,255,255,0.8);
  padding: 4px 12px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
  color: var(--text);
  z-index: 2;
}

.scene-desc {
  position: absolute;
  top: 40px;
  left: 14px;
  font-size: 11px;
  color: var(--text-light);
  background: rgba(255,255,255,0.6);
  padding: 2px 10px;
  border-radius: 10px;
  z-index: 2;
}

/* ==================== 角色容器 ==================== */
.character-container {
  position: absolute;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 280px;
  z-index: 5;
}

.char-sprite {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 200px;
  max-height: 280px;
  object-fit: contain;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* 换装图层z-index层级: 下装(1) < 上衣(2) < 连衣裙(3) < 配饰(4) < 帽子(5) */
.outfit-bottom    { z-index: 1; }
.outfit-top       { z-index: 2; }
.outfit-dress     { z-index: 3; }
.outfit-accessory { z-index: 4; }
.outfit-hat       { z-index: 5; }

.char-base { z-index: 0; }

/* 表情浮动emoji */
.char-expression-emoji {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 32px;
  z-index: 6;
  animation: floatEmoji 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes floatEmoji {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-8px); }
}

/* CSS角色占位（无图片时显示） */
.char-placeholder {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 200px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 0;
}

.placeholder-body {
  width: 80px;
  height: 140px;
  background: var(--pink);
  border-radius: 40px 40px 20px 20px;
  position: relative;
  box-shadow: 0 4px 12px rgba(255, 181, 194, 0.4);
}

.placeholder-face {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 40px;
}

.placeholder-eyes {
  display: flex;
  justify-content: space-between;
  padding: 0 8px;
}

.placeholder-eye {
  width: 8px;
  height: 10px;
  background: var(--text);
  border-radius: 50%;
  display: block;
}

.placeholder-mouth {
  width: 14px;
  height: 7px;
  border-bottom: 3px solid var(--text);
  border-radius: 0 0 7px 7px;
  margin: 6px auto 0;
}

.placeholder-blush {
  position: absolute;
  width: 10px;
  height: 6px;
  background: rgba(255, 150, 150, 0.5);
  border-radius: 50%;
  top: 14px;
}
.placeholder-blush.left  { left: -2px; }
.placeholder-blush.right { right: -2px; }

/* ==================== 家具区域 ==================== */
.furniture-area {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 4;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 90%;
}

.furniture-item {
  width: 50px;
  height: 50px;
  object-fit: contain;
  animation: popIn 0.3s ease;
}

.furniture-item-placeholder {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

/* ==================== 动作按钮区 ==================== */
.action-area {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px 16px;
  flex-wrap: wrap;
  z-index: 10;
}

.btn-action {
  padding: 10px 18px;
  border: none;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-action:active {
  transform: scale(0.95);
}
.btn-action.pink    { background: var(--pink-light); }
.btn-action.mint    { background: var(--mint-light); }
.btn-action.cream   { background: var(--cream-light); }
.btn-action.lavender{ background: var(--lav-light); }
.btn-action.sky     { background: var(--sky-light); }

/* ==================== 底部导航栏 ==================== */
.bottom-nav {
  display: flex;
  justify-content: space-around;
  padding: 8px 8px 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(0deg, var(--white), rgba(255,255,255,0.9));
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -2px 15px rgba(180, 160, 170, 0.15);
  z-index: 20;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  transition: all 0.25s ease;
  font-family: var(--font);
  color: var(--text-light);
}
.nav-btn.active {
  background: var(--pink-light);
  color: var(--pink-dark);
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(255, 181, 194, 0.3);
}
.nav-emoji {
  font-size: 22px;
  transition: transform 0.25s ease;
}
.nav-btn.active .nav-emoji {
  transform: scale(1.2);
}
.nav-label {
  font-size: 11px;
  font-weight: 600;
}

/* ==================== 弹窗 ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(100, 80, 90, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.25s ease;
}

.modal-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 85%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  animation: bounceIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--pink-light);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: all 0.2s;
}
.modal-close:hover { background: var(--pink); }

.modal-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 20px;
}

.modal-footer {
  display: flex;
  justify-content: center;
}

/* ==================== 通用按钮样式 ==================== */
.btn {
  padding: 10px 28px;
  border: none;
  border-radius: 25px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.btn:active { transform: scale(0.95); }

.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  color: white;
}
.btn-outline {
  background: var(--white);
  border: 2px solid var(--pink);
  color: var(--pink-dark);
}
.btn-small {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: 15px;
}

/* ==================== 侧滑面板 ==================== */
.slide-panel {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 90;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
  max-width: 480px;
  margin: 0 auto;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--pink-light), var(--lav-light));
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.panel-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.panel-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.8);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: all 0.2s;
}
.panel-close:hover { background: var(--pink); }

/* 面板内Tab */
.panel-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
}

.tab-btn {
  padding: 8px 16px;
  border: 2px solid transparent;
  border-radius: 20px;
  background: var(--white);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  color: var(--text-light);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.tab-btn.active {
  border-color: var(--pink);
  background: var(--pink-light);
  color: var(--pink-dark);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  align-content: start;
}

.panel-footer-bar {
  padding: 12px 20px;
  text-align: center;
  border-top: 1px solid #EEE;
}

/* 商品卡片 */
.shop-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 2px solid transparent;
}
.shop-card:hover, .shop-card:active {
  border-color: var(--pink);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 181, 194, 0.25);
}

.shop-card-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 12px;
}

.shop-card-emoji {
  font-size: 40px;
  line-height: 56px;
}

.shop-card-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.shop-card-price {
  font-size: 11px;
  color: var(--gold);
  font-weight: 700;
}

.shop-card-owned {
  font-size: 10px;
  color: var(--green);
  font-weight: 600;
}

.shop-card-desc {
  font-size: 10px;
  color: var(--text-light);
}

/* ==================== 升级动画 ==================== */
.levelup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 245, 245, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.3s ease;
}

.levelup-content {
  text-align: center;
  position: relative;
}

.levelup-sparkles {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 20px;
}

.sparkle {
  position: absolute;
  font-size: 36px;
  animation: sparkleFloat 1.5s ease-out forwards;
  opacity: 0;
}
.sparkle.s1 { top: 10%;  left: 20%; animation-delay: 0s; }
.sparkle.s2 { top: 0%;   left: 50%; animation-delay: 0.1s; }
.sparkle.s3 { top: 15%;  left: 75%; animation-delay: 0.2s; }
.sparkle.s4 { top: 50%;  left: 85%; animation-delay: 0.15s; }
.sparkle.s5 { top: 60%;  left: 10%; animation-delay: 0.05s; }
.sparkle.s6 { top: 40%;  left: 5%;  animation-delay: 0.25s; }

@keyframes sparkleFloat {
  0%   { opacity: 1; transform: scale(0) rotate(0deg); }
  60%  { opacity: 1; transform: scale(1.5) rotate(180deg); }
  100% { opacity: 0; transform: scale(2) translateY(-40px) rotate(360deg); }
}

.levelup-title {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--pink), var(--lavender), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: titlePulse 0.8s ease infinite alternate;
}

@keyframes titlePulse {
  0%   { transform: scale(1); }
  100% { transform: scale(1.08); }
}

.levelup-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-top: 8px;
}

.levelup-stage {
  font-size: 16px;
  font-weight: 600;
  color: var(--pink-dark);
  margin-top: 4px;
}

/* ==================== 点击特效 ==================== */
.click-effects {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
}

.click-ripple {
  position: absolute;
  font-size: 24px;
  animation: clickPop 0.6s ease-out forwards;
  pointer-events: none;
}

@keyframes clickPop {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(0.3); }
  50%  { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(0.5); }
}

/* ==================== Toast 提示 ==================== */
.toast-container {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 90%;
}

.toast {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  padding: 10px 20px;
  border-radius: 25px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
  text-align: center;
  white-space: nowrap;
}

@keyframes toastIn {
  0%   { opacity: 0; transform: translateY(-20px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-20px); }
}

/* ==================== 通用工具类 ==================== */
.hidden { display: none !important; }

@keyframes fadeIn {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes bounceIn {
  0%   { opacity: 0; transform: scale(0.8); }
  60%  { transform: scale(1.03); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
  0%   { transform: translateY(100%); }
  100% { transform: translateY(0); }
}

@keyframes popIn {
  0%   { opacity: 0; transform: scale(0); }
  80%  { transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

/* ==================== 响应式适配 ==================== */

/* 平板及以上：居中显示手机宽度 */
@media (min-width: 481px) {
  .app-container {
    border-radius: var(--radius-xl);
    margin-top: 20px;
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
  }
  body {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .slide-panel {
    border-radius: var(--radius-xl);
    margin-top: 20px;
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
  }
}

/* 小屏幕手机适配 */
@media (max-width: 360px) {
  .character-container {
    width: 150px;
    height: 220px;
  }
  .char-sprite {
    max-width: 150px;
    max-height: 220px;
  }
  .btn-action {
    padding: 8px 14px;
    font-size: 12px;
  }
  .shop-card-img { width: 44px; height: 44px; }
  .shop-card-emoji { font-size: 30px; line-height: 44px; }
  .panel-content {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 横屏/宽屏适配 */
@media (min-width: 768px) and (max-height: 600px) {
  .app-container {
    flex-direction: row;
    flex-wrap: wrap;
    max-width: 768px;
  }
  .main-stage { min-height: 300px; }
}
