/* 2048 宠物版 - 可爱动物主题 */
.game-page {
  --pet-bg: #fff8f0;
  --pet-card: #fff5eb;
  --pet-border: #ffd4b8;
  --pet-2: #ffecd2;
  --pet-4: #ffd9b3;
  --pet-8: #ffc494;
  --pet-16: #ffb366;
  --pet-32: #ff9f33;
  --pet-64: #ff8c00;
  --pet-128: #e67e22;
  --pet-256: #d35400;
  --pet-512: #c0392b;
  --pet-1024: #a93226;
  --pet-2048: #e74c3c;
}

.game-main {
  background: linear-gradient(180deg, #e8f4fc 0%, #ffe8e0 100%);
}

.game-header {
  text-align: center;
  padding: 1.5rem 1rem;
}

.game-header h1 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.game-header p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.game-scores {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.score-box {
  background: var(--bg-card);
  padding: 0.5rem 1rem;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15);
}

.score-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.score-box span:last-child {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-deep);
}

.btn-new, .btn-again, .btn-continue {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.game-wrap {
  position: relative;
  max-width: 360px;
  margin: 0 auto 2rem;
  padding: 0 1rem;
}

.game-container {
  position: relative;
  border-radius: 16px;
  padding: 10px;
  background: rgba(255, 200, 160, 0.35);
  box-shadow: 0 8px 32px rgba(255, 140, 0, 0.2);
}

.grid-bg {
  position: absolute;
  inset: 10px;
  border-radius: 12px;
  overflow: hidden;
}

.grid-inner {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
      0deg,
      transparent,
      transparent 79px,
      rgba(255, 180, 140, 0.25) 79px,
      rgba(255, 180, 140, 0.25) 80px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 79px,
      rgba(255, 180, 140, 0.25) 79px,
      rgba(255, 180, 140, 0.25) 80px
    );
  background-size: 320px 320px;
  background-position: 0 0;
}

.tiles {
  position: relative;
  z-index: 2;
  width: 320px;
  height: 320px;
  margin: 0 auto;
}

.particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}

.tile {
  position: absolute;
  width: 72px;
  height: 72px;
  margin: 4px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.5rem;
  transition: transform 0.15s ease-out, top 0.15s ease-out, left 0.15s ease-out;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tile .pet-emoji {
  font-size: 2rem;
  line-height: 1;
}

.tile.merged {
  animation: pop 0.2s ease-out;
}

.tile.new {
  animation: appear 0.2s ease-out;
}

@keyframes pop {
  0% { transform: scale(1.1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

@keyframes appear {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.tile-2 { background: var(--pet-2); color: #8b4513; }
.tile-4 { background: var(--pet-4); color: #8b4513; }
.tile-8 { background: var(--pet-8); color: #5d3a1a; }
.tile-16 { background: var(--pet-16); color: #5d3a1a; }
.tile-32 { background: var(--pet-32); color: #fff; }
.tile-64 { background: var(--pet-64); color: #fff; }
.tile-128 { background: var(--pet-128); color: #fff; font-size: 1.2rem; }
.tile-256 { background: var(--pet-256); color: #fff; font-size: 1.2rem; }
.tile-512 { background: var(--pet-512); color: #fff; font-size: 1.1rem; }
.tile-1024 { background: var(--pet-1024); color: #fff; font-size: 1rem; }
.tile-2048 { background: var(--pet-2048); color: #fff; font-size: 0.95rem; }

.game-over, .win-over {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 16px;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  z-index: 10;
}

.game-over.visible, .win-over.visible {
  display: flex;
}

.game-over p, .win-over p {
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
}

.game-tip {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* 屏幕震动 */
.game-container.shake {
  animation: shake 0.3s ease-out;
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 0); }
  40% { transform: translate(6px, 0); }
  60% { transform: translate(-4px, 0); }
  80% { transform: translate(4px, 0); }
}

/* 粒子 */
.particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  animation: particle-fly 0.5s ease-out forwards;
}

@keyframes particle-fly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0);
  }
}

/* 移动端适配 */
@media (max-width: 400px) {
  .tiles {
    width: 280px;
    height: 280px;
  }
  .tile {
    width: 62px;
    height: 62px;
    margin: 3px;
    font-size: 1.2rem;
  }
  .tile .pet-emoji {
    font-size: 1.6rem;
  }
  .grid-inner {
    background-size: 280px 280px;
  }
}
