/* Cosmic Merge 游戏特有样式 */

/* 宇宙融合主题的画布样式 */
canvas {
  background: 
    linear-gradient(135deg, #0f0f23 0%, #1a1a3a 25%, #2d1b69 50%, #1a1a3a 75%, #0f0f23 100%),
    radial-gradient(circle at 25% 25%, rgba(128, 0, 255, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(0, 255, 255, 0.1) 0%, transparent 60%);
  border: 2px solid rgba(128, 0, 255, 0.4);
  border-radius: 16px;
  animation: cosmic-pulse 5s ease-in-out infinite;
  display: block;
  touch-action: pan-x pan-y;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  box-sizing: border-box;
}

@keyframes cosmic-pulse {
  0%, 100% { 
    box-shadow: 
      0 0 30px rgba(0, 0, 0, 0.7),
      inset 0 0 50px rgba(128, 0, 255, 0.05);
  }
  50% { 
    box-shadow: 
      0 0 60px rgba(128, 0, 255, 0.4),
      inset 0 0 50px rgba(0, 255, 255, 0.1);
  }
}

/* 重新定义主体容器 */
body {
  /* 防止移动端下拉刷新和左滑返回 */
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  min-height: 0;
  padding: 1rem;
  padding-bottom: 0.5rem;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* 确保canvas容器能够获得剩余空间 */
main > canvas {
  flex: 1;
  width: 100% !important;
  height: auto !important;
  min-height: 350px;
  max-height: 80vh;
}

/* 分数显示区域优化 */
.score-display {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 500px;
  margin: 0 auto 0.5rem auto;
  padding: 0 1rem;
  box-sizing: border-box;
  z-index: 10;
  position: relative;
  flex-shrink: 0;
}

.score-item {
  background: 
    linear-gradient(135deg, rgba(128, 0, 255, 0.2), rgba(128, 0, 255, 0.1)),
    rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 0.8rem 1.2rem;
  border-radius: 25px;
  font-size: 0.9rem;
  font-weight: 600;
  backdrop-filter: blur(15px);
  border: 1px solid rgba(128, 0, 255, 0.3);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  text-shadow: 0 0 10px rgba(128, 0, 255, 0.5);
}

.score-item:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 
    0 8px 25px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(128, 0, 255, 0.4);
  border-color: rgba(128, 0, 255, 0.6);
}

.score-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.score-item:hover::before {
  left: 100%;
}

/* 分数增加动画 */
@keyframes scoreIncrease {
  0% {
    transform: scale(1);
    color: #fff;
    text-shadow: 0 0 10px rgba(128, 0, 255, 0.5);
  }
  50% {
    transform: scale(1.15);
    color: #00ffff;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.8);
  }
  100% {
    transform: scale(1);
    color: #fff;
    text-shadow: 0 0 10px rgba(128, 0, 255, 0.5);
  }
}

.score-animate {
  animation: scoreIncrease 0.5s ease-out;
}

/* 游戏特定的头部样式 */
header {
  padding: 1rem;
  flex-shrink: 0;
}

header p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 1rem;
  margin-top: 0.5rem;
  margin-bottom: 0;
  text-shadow: 0 0 10px rgba(128, 0, 255, 0.3);
}

/* 游戏瓦片动画效果 */
.tile-moving {
  transition: transform 0.2s ease-in-out;
}

.tile-appear {
  animation: tileAppear 0.3s ease-out;
}

.tile-merge {
  animation: tileMerge 0.4s ease-out;
}

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

@keyframes tileMerge {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

/* 移动端优化 */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.8rem;
  }
  
  header p {
    font-size: 0.9rem;
  }
  
  .score-display {
    padding: 0 0.5rem;
  }
  
  .score-item {
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
  }
}