* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #ffecd2 0%, #fcb69f 100%);
  font-family: Arial, sans-serif;
  touch-action: none;
  height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
}

/* 顶部栏 - 与合成大面包统一 */
#game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: rgba(255,255,255,0.6);
  position: relative;
  z-index: 100;
}
#game-header h1 { font-size: 18px; color: #776e65; }
#score-display { font-size: 18px; color: #f59563; font-weight: bold; }
#best-display { font-size: 12px; color: #9a8474; }

#home-btn {
  width: 36px; height: 36px;
  border: none; border-radius: 8px;
  background: #8f7a66; color: white;
  font-size: 18px; cursor: pointer; line-height: 1;
}
#rank-btn {
  width: 36px; height: 36px;
  border: none; border-radius: 8px;
  background: #f59563; color: white;
  font-size: 18px; cursor: pointer; line-height: 1;
}

/* 3D画布容器 */
#game-container {
  width: 100%;
  height: calc(100% - 48px);
  position: relative;
}
#game-container canvas { display: block; }

/* 提示文字 */
#tap-hint {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(119, 110, 101, 0.6);
  font-size: 15px;
  z-index: 50;
  animation: pulse 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* 连击提示 */
#combo-text {
  position: fixed;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  font-weight: bold;
  color: #f59563;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 70;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
}

/* 图片+层数翻牌卡片 */
#floor-card {
  position: fixed;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 65;
  pointer-events: none;
  perspective: 600px;
  text-align: center;
}
#floor-card .flip-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  transform-style: preserve-3d;
}
#floor-card .card-img {
  width: 100px; height: 100px;
  border-radius: 10px;
  border: 3px solid rgba(255,255,255,0.9);
  box-shadow: 0 4px 20px rgba(245,149,99,0.35);
  object-fit: cover;
  background: rgba(255,255,255,0.3);
}
#floor-card .card-num {
  font-size: 64px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 16px rgba(0,0,0,0.35), 0 0 40px rgba(245,149,99,0.4);
  line-height: 1;
}
#floor-card .flip-inner.flipping {
  animation: flipCard 0.5s ease-in-out;
}
@keyframes flipCard {
  0%   { transform: rotateX(0deg); }
  50%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

/* 粒子画布 */
#particle-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 55;
  pointer-events: none;
}

/* 开始界面 */
#start-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.92);
  z-index: 300;
  display: flex;
  justify-content: center;
  align-items: center;
}
#start-box {
  background: white;
  border-radius: 16px;
  padding: 30px 24px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  min-width: 260px;
}
#start-box h2 { color: #776e65; margin-bottom: 4px; font-size: 24px; }
#start-box p {
  color: #776e65; font-size: 14px;
  line-height: 1.6; margin-bottom: 16px;
}
#start-btn {
  display: block; width: 100%;
  padding: 14px 20px; margin-bottom: 10px;
  font-size: 16px; font-weight: bold;
  border: none; border-radius: 10px;
  cursor: pointer; color: white;
  background: #f59563;
  transition: transform 0.1s;
}
#start-btn:active { transform: scale(0.97); }
.back-link {
  display: inline-block; margin-top: 8px;
  color: #d4894a; text-decoration: none; font-size: 14px;
}
.back-link:hover { text-decoration: underline; }

/* 游戏结束 */
#game-over-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  justify-content: center;
  align-items: center;
}
#game-over-box {
  background: white;
  border-radius: 16px;
  padding: 30px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  min-width: 260px;
}
#game-over-box h2 { color: #776e65; margin-bottom: 10px; }
#final-score { color: #f59563; font-size: 22px; margin-bottom: 20px; }
#new-record { color: #e74c3c; font-weight: bold; margin-bottom: 10px; }
#game-over-box button {
  padding: 10px 30px; font-size: 16px;
  border: none; border-radius: 8px;
  background: #f59563; color: white;
  cursor: pointer; width: 100%; margin-bottom: 8px;
}
#game-over-box button:active { transform: scale(0.97); }

/* 提交区域 */
#submit-area { margin-bottom: 15px; }
#submit-area input {
  padding: 8px 12px; font-size: 14px;
  border: 2px solid #e0c8a8; border-radius: 6px;
  width: 100%; margin-bottom: 8px; outline: none;
}
#submit-area input:focus { border-color: #f59563; }
#submit-area button {
  padding: 10px 16px; font-size: 14px;
  border: none; border-radius: 6px;
  background: #8cc152; color: white;
  cursor: pointer; width: 100%;
}

/* 排行榜 */
#leaderboard-panel {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
}
#leaderboard-box {
  background: white;
  border-radius: 16px;
  padding: 20px 30px;
  max-height: 70vh; min-width: 260px;
  overflow-y: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  text-align: center;
  display: flex; flex-direction: column;
}
#leaderboard-box h3 { color: #776e65; margin-bottom: 12px; }
#leaderboard-list {
  list-style: none; padding: 0;
  text-align: left; margin-bottom: 15px;
  max-height: 300px; overflow-y: auto; flex: 1;
}
#leaderboard-list li {
  padding: 6px 0;
  border-bottom: 1px solid #f0e6d6;
  color: #555; font-size: 14px;
  word-break: break-word;
}
#leaderboard-list li:nth-child(-n+3) {
  color: #f59563; font-weight: bold;
}
#leaderboard-box button {
  padding: 8px 24px; font-size: 14px;
  border: none; border-radius: 8px;
  background: #f59563; color: white;
  cursor: pointer; margin-top: 6px; flex-shrink: 0;
}
