* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #2c1810;
  min-height: 100vh;
  color: #5d4037;
  overflow-x: hidden;
}

#app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  background: url('/images/bg-warm.png') center center / cover no-repeat;
  position: relative;
}

.page {
  display: none;
  min-height: 100vh;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page.active {
  display: block;
}

/* ========== 主页样式 ========== */

.home-header {
  text-align: center;
  padding: 40px 20px 30px;
  position: relative;
}

.game-icon {
  font-size: 48px;
  margin-bottom: 15px;
  filter: drop-shadow(0 4px 8px rgba(139, 69, 19, 0.3));
}

.game-title {
  font-size: 42px;
  font-weight: 900;
  color: #5d4037;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5);
  letter-spacing: 4px;
}

.game-subtitle {
  font-size: 16px;
  color: #8d6e63;
  margin-bottom: 25px;
  letter-spacing: 2px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: rgba(93, 64, 55, 0.15);
  border-radius: 20px;
  border: 1px solid rgba(93, 64, 55, 0.2);
  margin-bottom: 15px;
}

.user-avatar {
  font-size: 18px;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: #5d4037;
}

.online-count {
  font-size: 13px;
  color: #8d6e63;
  margin-top: 10px;
}

/* 菜单网格 */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  padding: 20px;
  max-width: 500px;
  margin: 0 auto;
}

.game-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px;
  background: rgba(255, 248, 240, 0.95);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 
    0 4px 12px rgba(139, 69, 19, 0.15),
    0 2px 4px rgba(139, 69, 19, 0.1);
  position: relative;
  overflow: hidden;
}

.game-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s;
}

.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 
    0 8px 20px rgba(139, 69, 19, 0.25),
    0 4px 8px rgba(139, 69, 19, 0.15);
}

.game-card:hover::before {
  opacity: 1;
}

.game-card:active {
  transform: translateY(-2px);
}

.card-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.card-content {
  flex: 1;
  text-align: left;
}

.card-title {
  font-size: 18px;
  font-weight: 800;
  color: #5d4037;
  margin-bottom: 4px;
}

.card-desc {
  font-size: 12px;
  color: #8d6e63;
  font-weight: 500;
}

.card-arrow {
  font-size: 28px;
  color: #bcaaa4;
  font-weight: 300;
}

/* 返回按钮 */
.back-btn {
  position: absolute;
  left: 20px;
  top: 20px;
  background: rgba(255, 248, 240, 0.9);
  border: 1px solid rgba(93, 64, 55, 0.2);
  color: #5d4037;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(139, 69, 19, 0.15);
  z-index: 10;
}

.back-btn:hover {
  background: rgba(255, 248, 240, 1);
  transform: translateX(-3px);
}

/* 表单页面 */
.header {
  text-align: center;
  padding: 60px 20px 30px;
}

.header h2 {
  font-size: 28px;
  font-weight: 800;
  color: #5d4037;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
}

.form-container {
  max-width: 400px;
  margin: 20px auto;
  padding: 30px;
  background: rgba(255, 248, 240, 0.95);
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(139, 69, 19, 0.2);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
  color: #5d4037;
  font-size: 15px;
}

.form-group input {
  width: 100%;
  padding: 15px;
  border: 2px solid rgba(93, 64, 55, 0.2);
  border-radius: 12px;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.8);
  color: #5d4037;
  font-weight: 600;
  transition: all 0.3s;
}

.form-group input:focus {
  outline: none;
  border-color: #ff9a3c;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 0 0 3px rgba(255, 154, 60, 0.1);
}

.form-group input::placeholder {
  color: #bcaaa4;
}

.action-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #ff9a3c 0%, #ff6b3c 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(255, 107, 60, 0.4);
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 107, 60, 0.5);
}

.action-btn:active {
  transform: translateY(0);
}

/* ========== 游戏页面 ========== */

.game-header {
  background: rgba(255, 248, 240, 0.95);
  border-bottom: 2px solid rgba(93, 64, 55, 0.15);
  padding: 0;
}

.room-info-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px 20px;
  gap: 10px;
  position: relative;
}

.room-label {
  font-size: 15px;
  font-weight: 700;
  color: #8d6e63;
}

.room-code {
  font-weight: 900;
  color: #ff9a3c;
  font-size: 20px;
  letter-spacing: 2px;
}

.leave-btn-small {
  position: absolute;
  right: 15px;
  background: rgba(244, 67, 54, 0.1);
  border: 2px solid rgba(244, 67, 54, 0.3);
  color: #f44336;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
}

.leave-btn-small:hover {
  background: rgba(244, 67, 54, 0.2);
  transform: scale(1.05);
}

.players-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
  background: rgba(255, 248, 240, 0.5);
  gap: 10px;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  padding: 12px;
  background: rgba(255, 248, 240, 0.95);
  border-radius: 12px;
  border: 2px solid rgba(93, 64, 55, 0.15);
  box-shadow: 0 2px 8px rgba(139, 69, 19, 0.1);
  transition: all 0.3s;
}

.player-card.active {
  border-color: #ff9a3c;
  box-shadow: 0 4px 12px rgba(255, 154, 60, 0.3);
}

.player-avatar-large {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(93, 64, 55, 0.2);
  flex-shrink: 0;
}

.player-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: rgba(93, 64, 55, 0.1);
}

.player-details {
  flex: 1;
  min-width: 0;
}

.player-name-large {
  font-size: 14px;
  font-weight: 800;
  color: #5d4037;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-stats {
  font-size: 11px;
  color: #8d6e63;
  font-weight: 600;
  display: flex;
  gap: 8px;
}

.turn-indicator {
  font-size: 20px;
  color: #ff9a3c;
  opacity: 0.3;
  transition: all 0.3s;
}

.turn-indicator.active {
  opacity: 1;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.timer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 15px 22px;
  background: linear-gradient(135deg, rgba(255, 248, 240, 0.98) 0%, rgba(255, 240, 220, 0.98) 100%);
  border-radius: 16px;
  border: 3px solid #ff9a3c;
  box-shadow: 
    0 4px 16px rgba(255, 154, 60, 0.3),
    0 2px 8px rgba(139, 69, 19, 0.2);
  min-width: 120px;
}

.turn-text {
  font-size: 14px;
  font-weight: 800;
  color: #5d4037;
  margin-bottom: 8px;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
  letter-spacing: 0.5px;
}

.timer-display {
  font-size: 32px;
  font-weight: 900;
  color: #ff6b3c;
  font-family: 'Courier New', monospace;
  text-shadow: 0 2px 4px rgba(255, 107, 60, 0.3);
}

.board-container {
  display: flex;
  justify-content: center;
  padding: 20px;
}

#game-canvas {
  display: block;
  background: linear-gradient(135deg, #d4a574 0%, #c19a6b 100%);
  border: 5px solid #8b4513;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(139, 69, 19, 0.3);
  cursor: pointer;
}

.game-controls {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 15px;
  background: rgba(255, 248, 240, 0.5);
}

.control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: rgba(255, 248, 240, 0.95);
  border: 2px solid rgba(93, 64, 55, 0.15);
  border-radius: 10px;
  color: #5d4037;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 2px 6px rgba(139, 69, 19, 0.1);
}

.control-btn:hover {
  background: rgba(255, 248, 240, 1);
  border-color: #ff9a3c;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(255, 154, 60, 0.2);
}

.btn-icon {
  font-size: 22px;
}

.btn-text {
  font-size: 11px;
  font-weight: 700;
}

.share-container {
  margin: 15px;
  padding: 20px;
  background: rgba(255, 248, 240, 0.95);
  border-radius: 15px;
  border: 2px solid rgba(93, 64, 55, 0.15);
  box-shadow: 0 4px 12px rgba(139, 69, 19, 0.15);
}

.share-container p {
  margin-bottom: 12px;
  font-weight: 700;
  color: #5d4037;
  font-size: 14px;
}

.share-link {
  display: flex;
  gap: 10px;
}

.share-link input {
  flex: 1;
  padding: 12px;
  border: 2px solid rgba(93, 64, 55, 0.2);
  border-radius: 10px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.8);
  color: #5d4037;
}

.share-link button {
  padding: 12px 20px;
  background: linear-gradient(135deg, #ff9a3c 0%, #ff6b3c 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.3s;
}

.share-link button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 60, 0.4);
}

/* 排行榜 */
.leaderboard-container {
  padding: 10px;
}

.rank-item {
  display: flex;
  align-items: center;
  padding: 18px;
  margin-bottom: 12px;
  background: rgba(255, 248, 240, 0.95);
  border-radius: 15px;
  border: 2px solid rgba(93, 64, 55, 0.15);
  box-shadow: 0 2px 8px rgba(139, 69, 19, 0.1);
  transition: all 0.3s;
}

.rank-item:hover {
  transform: translateX(8px);
  box-shadow: 0 4px 12px rgba(139, 69, 19, 0.2);
}

.rank-number {
  font-size: 26px;
  font-weight: 900;
  width: 60px;
  text-align: center;
}

.rank-number.top1 { color: #ffd700; }
.rank-number.top2 { color: #c0c0c0; }
.rank-number.top3 { color: #cd7f32; }

.rank-info {
  flex: 1;
  margin-left: 15px;
}

.rank-name {
  font-size: 18px;
  font-weight: 800;
  color: #5d4037;
  margin-bottom: 6px;
}

.rank-stats {
  font-size: 13px;
  color: #8d6e63;
  font-weight: 600;
}

.rank-score {
  font-size: 22px;
  font-weight: 900;
  color: #ff9a3c;
}

/* 响应式 */
@media (max-width: 480px) {
  .game-title { font-size: 32px; }
  .menu-grid { grid-template-columns: 1fr; }
  .players-container { flex-direction: column; }
  .game-controls { grid-template-columns: repeat(3, 1fr); }
}

/* 微粒子 */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: rgba(255, 154, 60, 0.4);
  border-radius: 50%;
  animation: float 10s infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-100vh) translateX(30px); opacity: 0; }
}

/* ========== 专业版游戏界面 ========== */

.game-header-pro {
  text-align: center;
  padding: 12px;
  background: rgba(255, 248, 240, 0.95);
  border-bottom: 2px solid rgba(93, 64, 55, 0.2);
}

.room-code-pro {
  font-size: 18px;
  font-weight: 900;
  color: #ff9a3c;
  letter-spacing: 2px;
}

.players-row-pro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 10px;
  background: rgba(255, 248, 240, 0.5);
  gap: 8px;
}

.player-card-pro {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 10px;
  background: rgba(255, 248, 240, 0.98);
  border-radius: 12px;
  border: 2px solid rgba(93, 64, 55, 0.15);
  box-shadow: 0 2px 8px rgba(139, 69, 19, 0.1);
  transition: all 0.3s;
  max-width: 160px;
}

.player-card-pro.active {
  border-color: #ff9a3c;
  box-shadow: 0 4px 12px rgba(255, 154, 60, 0.3);
}

.player-avatar-pro {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(93, 64, 55, 0.2);
  flex-shrink: 0;
}

.player-avatar-pro img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder-pro {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: rgba(93, 64, 55, 0.1);
}

.player-info-pro {
  flex: 1;
  min-width: 0;
}

.player-name-pro {
  font-size: 13px;
  font-weight: 800;
  color: #5d4037;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-stats-pro {
  font-size: 10px;
  color: #8d6e63;
  font-weight: 600;
}

.turn-dot-pro {
  font-size: 18px;
  color: #ff9a3c;
  opacity: 0.3;
  transition: all 0.3s;
}

.turn-dot-pro.active {
  opacity: 1;
  animation: pulse 1.5s ease-in-out infinite;
}

.timer-box-pro {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px;
  background: linear-gradient(135deg, rgba(255, 248, 240, 0.98) 0%, rgba(255, 240, 220, 0.98) 100%);
  border-radius: 16px;
  border: 3px solid #ff9a3c;
  box-shadow: 
    0 4px 16px rgba(255, 154, 60, 0.3),
    0 2px 8px rgba(139, 69, 19, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  min-width: 100px;
}

.turn-label-pro {
  font-size: 12px;
  font-weight: 800;
  color: #5d4037;
  margin-bottom: 6px;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
  letter-spacing: 0.5px;
}

.timer-num-pro {
  font-size: 36px;
  font-weight: 900;
  color: #ff6b3c;
  font-family: 'Courier New', monospace;
  text-shadow: 0 2px 4px rgba(255, 107, 60, 0.3);
  line-height: 1;
}

.board-wrapper-pro {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 10px;
  flex: 1;
}

#game-canvas {
  display: block;
  border-radius: 8px;
  box-shadow: 
    0 10px 30px rgba(139, 69, 19, 0.4),
    0 5px 15px rgba(0, 0, 0, 0.2),
    inset 0 -3px 8px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  touch-action: none;
}

.main-controls-pro {
  display: flex;
  justify-content: center;
  gap: 15px;
  padding: 15px;
  background: rgba(255, 248, 240, 0.5);
}

.main-btn-pro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 24px;
  background: linear-gradient(135deg, rgba(255, 248, 240, 0.98) 0%, rgba(255, 240, 220, 0.98) 100%);
  border: 2px solid rgba(93, 64, 55, 0.2);
  border-radius: 14px;
  color: #5d4037;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 3px 10px rgba(139, 69, 19, 0.15);
  flex: 1;
  max-width: 110px;
}

.main-btn-pro:hover {
  background: linear-gradient(135deg, rgba(255, 248, 240, 1) 0%, rgba(255, 240, 220, 1) 100%);
  border-color: #ff9a3c;
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(255, 154, 60, 0.3);
}

.main-btn-pro:active {
  transform: translateY(-1px);
}

.main-btn-icon {
  font-size: 28px;
}

.main-btn-text {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* 响应式 - 专业版 */
@media (max-width: 480px) {
  .players-row-pro {
    flex-wrap: wrap;
  }
  
  .player-card-pro {
    max-width: 45%;
  }
  
  .timer-box-pro {
    width: 100%;
    order: -1;
    margin-bottom: 10px;
  }
}
