/* ==================== 
   基础样式
   ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #E53935;
  --primary-dark: #C62828;
  --secondary: #FFD54F;
  --gold: #FFC107;
  --gold-light: #FFE082;
  --dark: #1a1a2e;
  --light: #FFF8E1;
  --success: #4CAF50;
  --danger: #f44336;
  --shadow: 0 4px 20px rgba(0,0,0,0.15);
  --radius: 12px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: #fff;
}

.page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.page.active {
  display: block;
  opacity: 1;
}

/* ==================== 
   加载页
   ==================== */
#loading {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
}

.loading-content {
  text-align: center;
}

.loading-icon {
  font-size: 80px;
  animation: swing 2s ease-in-out infinite;
  margin-bottom: 20px;
}

.loading-text {
  font-size: 18px;
  color: var(--gold);
  margin-bottom: 30px;
}

.loading-bar {
  width: 200px;
  height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 auto;
}

.loading-progress {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--secondary));
  border-radius: 3px;
  animation: loading 2s ease-in-out infinite;
}

@keyframes swing {
  0%, 100% { transform: rotate(-10deg); }
  50% { transform: rotate(10deg); }
}

@keyframes loading {
  0% { width: 0%; margin-left: 0; }
  50% { width: 100%; margin-left: 0; }
  100% { width: 0%; margin-left: 100%; }
}

/* ==================== 
   首页
   ==================== */
#home {
  padding: 20px;
}

.home-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}

.cloud {
  position: absolute;
  background: rgba(255,255,255,0.1);
  border-radius: 100px;
  animation: float 20s infinite;
}

.cloud:nth-child(1) { width: 100px; height: 40px; top: 20%; left: -100px; animation-duration: 25s; }
.cloud:nth-child(2) { width: 80px; height: 35px; top: 40%; left: -80px; animation-duration: 20s; animation-delay: 5s; }
.cloud:nth-child(3) { width: 120px; height: 45px; top: 60%; left: -120px; animation-duration: 30s; animation-delay: 10s; }

@keyframes float {
  from { transform: translateX(0); }
  to { transform: translateX(calc(100vw + 200px)); }
}

.home-content {
  max-width: 400px;
  margin: 0 auto;
  padding-top: 20px;
}

.title-section {
  text-align: center;
  margin-bottom: 20px;
}

.main-title {
  font-size: 36px;
  font-weight: bold;
  background: linear-gradient(180deg, #FFD54F 0%, #FF8F00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 10px rgba(255, 193, 7, 0.3);
  margin-bottom: 8px;
}

.title-icon {
  -webkit-text-fill-color: initial;
}

.subtitle {
  font-size: 16px;
  color: rgba(255,255,255,0.7);
}

.god-section {
  text-align: center;
  margin-bottom: 20px;
}

.caishen-god {
  font-size: 120px;
  animation: bounce 1s ease-in-out infinite;
  display: inline-block;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.blessing-text {
  font-size: 18px;
  color: var(--gold);
  margin-top: 10px;
  text-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

/* 统计条 */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-bottom: 25px;
}

.stat-item {
  text-align: center;
  padding: 10px 20px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
}

.stat-label {
  display: block;
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-size: 20px;
  font-weight: bold;
  color: var(--gold);
}

/* 按钮 */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 25px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: linear-gradient(180deg, #FF5722 0%, #E53935 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(229, 57, 53, 0.4);
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(229, 57, 53, 0.4);
}

.btn-secondary {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
}

.btn-secondary:active {
  background: rgba(255,255,255,0.2);
}

.btn-text {
  background: transparent;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  padding: 10px;
}

.btn-icon {
  font-size: 20px;
}

/* 排行榜预览 */
.leaderboard-preview {
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius);
  padding: 15px;
}

.leaderboard-preview h3 {
  font-size: 16px;
  margin-bottom: 12px;
  text-align: center;
}

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
}

.rank-num {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
}

.rank-item:nth-child(1) .rank-num { background: linear-gradient(180deg, #FFD700, #FFA000); }
.rank-item:nth-child(2) .rank-num { background: linear-gradient(180deg, #C0C0C0, #808080); }
.rank-item:nth-child(3) .rank-num { background: linear-gradient(180deg, #CD7F32, #8B4513); }
.rank-item:nth-child(n+4) .rank-num { background: rgba(255,255,255,0.2); }

.rank-name {
  flex: 1;
  font-size: 14px;
}

.rank-score {
  font-size: 14px;
  color: var(--gold);
  font-weight: bold;
}

/* ==================== 
   游戏规则页
   ==================== */
#rules {
  background: var(--dark);
}

.page-header {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  background: rgba(0,0,0,0.2);
  position: sticky;
  top: 0;
  z-index: 10;
}

.back-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: white;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  margin-right: 15px;
}

.page-header h2 {
  font-size: 18px;
}

.rules-content {
  padding: 20px;
}

.rule-section {
  margin-bottom: 30px;
}

.rule-section h3 {
  font-size: 18px;
  color: var(--gold);
  margin-bottom: 15px;
}

.rule-section p {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255,255,255,0.8);
  margin-bottom: 15px;
}

.game-demo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius);
}

.demo-item {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
}

.demo-basket {
  font-size: 40px;
}

/* 物品网格 */
.items-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.item-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 15px 10px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius);
  text-align: center;
}

.item-card.danger {
  background: rgba(244, 67, 54, 0.1);
}

.item-icon {
  font-size: 32px;
  margin-bottom: 5px;
}

.item-name {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 3px;
}

.item-score {
  font-size: 14px;
  font-weight: bold;
  color: var(--gold);
}

.item-card.danger .item-score {
  color: var(--danger);
}

/* 连击显示 */
.combo-display {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.combo-display span {
  padding: 8px 15px;
  background: linear-gradient(90deg, rgba(255,193,7,0.2), rgba(255,193,7,0.1));
  border: 1px solid rgba(255,193,7,0.3);
  border-radius: 20px;
  font-size: 14px;
}

/* 奖励等级 */
.reward-levels {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.level {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius);
}

.level-range {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  min-width: 80px;
}

.level-name {
  flex: 1;
  font-size: 14px;
  font-weight: bold;
}

.level-prize {
  font-size: 12px;
  color: var(--gold);
}

/* ==================== 
   游戏页
   ==================== */
#game {
  overflow: hidden;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
}

#gameCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.game-ui {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 10;
}

.game-stats {
  display: flex;
  justify-content: space-around;
  padding: 15px 20px;
  background: linear-gradient(180deg, rgba(0,0,0,0.5), transparent);
}

.game-stats .stat {
  text-align: center;
}

.game-stats .stat-label {
  display: block;
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}

.game-stats .stat-value {
  display: block;
  font-size: 28px;
  font-weight: bold;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

.combo-effect {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  font-weight: bold;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 193, 7, 0.8);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
}

.combo-effect.show {
  animation: comboPop 0.8s ease-out;
}

@keyframes comboPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1) translateY(-50px); }
}

.game-tips {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: rgba(0,0,0,0.6);
  border-radius: 20px;
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  opacity: 0;
  transition: opacity 0.3s;
}

.game-tips.show {
  opacity: 1;
}

.pause-btn {
  position: fixed;
  top: 15px;
  right: 15px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  z-index: 15;
}

/* ==================== 
   结果页
   ==================== */
#result {
  padding: 20px;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
}

.result-content {
  max-width: 400px;
  margin: 0 auto;
  padding-top: 30px;
}

.result-title {
  text-align: center;
  font-size: 24px;
  color: var(--gold);
  margin-bottom: 20px;
}

.result-score {
  text-align: center;
  margin-bottom: 15px;
}

.score-label {
  display: block;
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 5px;
}

.score-value {
  display: block;
  font-size: 56px;
  font-weight: bold;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 193, 7, 0.5);
}

.result-rating {
  text-align: center;
  margin-bottom: 25px;
}

.rating-badge {
  display: inline-block;
  padding: 8px 25px;
  background: linear-gradient(90deg, #FFD54F, #FF8F00);
  color: #1a1a2e;
  border-radius: 20px;
  font-size: 18px;
  font-weight: bold;
}

/* 锦囊卡片 */
.chest-card {
  background: linear-gradient(135deg, rgba(255,215,0,0.1), rgba(255,140,0,0.1));
  border: 2px solid rgba(255,193,7,0.3);
  border-radius: var(--radius);
  margin-bottom: 25px;
  overflow: hidden;
}

.chest-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px;
  background: rgba(255,193,7,0.1);
  border-bottom: 1px solid rgba(255,193,7,0.2);
}

.chest-icon {
  font-size: 24px;
}

.chest-title {
  font-size: 16px;
  font-weight: bold;
  color: var(--gold);
}

.chest-body {
  padding: 20px;
  text-align: center;
}

.chest-type {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 5px;
}

.chest-name {
  font-size: 22px;
  font-weight: bold;
  color: var(--gold);
  margin-bottom: 15px;
}

.chest-preview {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255,255,255,0.8);
  margin-bottom: 20px;
  padding: 15px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
}

.fortune-code {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.code-label {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}

.code-value {
  font-size: 36px;
  font-weight: bold;
  color: var(--gold);
  letter-spacing: 10px;
  font-family: 'Courier New', monospace;
  padding: 10px 20px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  border: 2px dashed rgba(255,193,7,0.3);
}

/* ==================== 
   我的锦囊页
   ==================== */
#myChests {
  background: var(--dark);
}

.chests-content {
  padding: 20px;
}

.chests-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  padding: 12px;
  border: none;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.6);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s;
}

.tab.active {
  background: var(--primary);
  color: white;
}

.chests-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chest-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius);
  border-left: 4px solid var(--gold);
}

.chest-item.used {
  opacity: 0.6;
  border-left-color: #666;
}

.chest-item-icon {
  font-size: 40px;
}

.chest-item-info {
  flex: 1;
}

.chest-item-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 4px;
}

.chest-item-type {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 4px;
}

.chest-item-status {
  font-size: 12px;
}

.chest-item-status.unused {
  color: var(--success);
}

.chest-item-status.expired {
  color: var(--danger);
}

.chest-item-status.used {
  color: #666;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 60px;
  margin-bottom: 15px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 16px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 8px;
}

.empty-hint {
  font-size: 14px !important;
  color: rgba(255,255,255,0.4) !important;
}

/* ==================== 
   弹窗
   ==================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.show {
  display: flex;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 350px;
  background: linear-gradient(180deg, #1a1a2e, #16213e);
  border-radius: var(--radius);
  padding: 25px;
  z-index: 1;
}

.share-modal h3 {
  text-align: center;
  margin-bottom: 20px;
  color: var(--gold);
}

.share-poster {
  background: linear-gradient(135deg, #FFD54F, #FF8F00);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  text-align: center;
}

.poster-content {
  background: white;
  border-radius: 8px;
  padding: 20px;
  color: #333;
}

.poster-title {
  font-size: 20px;
  font-weight: bold;
  color: #E53935;
  margin-bottom: 10px;
}

.poster-result {
  font-size: 14px;
  margin-bottom: 15px;
}

.qrcode-placeholder {
  width: 100px;
  height: 100px;
  margin: 0 auto 10px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #999;
}

.share-options {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.share-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.share-btn.wechat { background: #07C160; color: white; }
.share-btn.pyq { background: #07C160; color: white; }
.share-btn.copy { background: rgba(255,255,255,0.1); color: white; }

.modal-close {
  width: 100%;
  padding: 12px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: white;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

/* 消息弹窗 */
.message-modal {
  text-align: center;
}

.message-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.message-text {
  font-size: 16px;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ==================== 
   动画
   ==================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.page.active {
  animation: fadeIn 0.3s ease;
}

/* ==================== 
   响应式
   ==================== */
@media (min-width: 768px) {
  .home-content,
  .result-content {
    max-width: 500px;
  }
  
  .main-title {
    font-size: 48px;
  }
  
  .caishen-god {
    font-size: 150px;
  }
}

/* 隐藏滚动条 */
::-webkit-scrollbar {
  display: none;
}
/* ==================== 
   用户信息
   ==================== */
.user-info {
  position: absolute;
  top: 15px;
  right: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.2);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  object-fit: cover;
}

.user-name {
  font-size: 14px;
  color: #fff;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 微信登录提示 */
.wx-login-tip {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.9);
  padding: 30px;
  border-radius: var(--radius);
  text-align: center;
  z-index: 1000;
  max-width: 300px;
}

.wx-login-tip h3 {
  color: var(--gold);
  margin-bottom: 15px;
}

.wx-login-tip p {
  color: #ccc;
  font-size: 14px;
  margin-bottom: 20px;
}

/* 分享按钮优化 */
.share-options {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 20px;
}

.share-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s;
}

.share-btn.wechat {
  background: #07C160;
  color: #fff;
}

.share-btn.pyq {
  background: #07C160;
  color: #fff;
}

.share-btn.copy {
  background: var(--primary);
  color: #fff;
}

.share-btn:active {
  transform: scale(0.95);
}
