/* v7 样式：基于v5版本，20%音量，去除年兽背景框，增加舞台高度，改进烟花特效，添加胜利结算页 */

/* 基础 */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #0e0e12;
  color: #f2f2f2;
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif;
  image-rendering: pixelated;
}
.hidden { display: none !important; }
.sr-only { 
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* 布局 */
#game {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 2fr 3fr; /* v6: 舞台:角色区 = 2:3 */
  gap: 8px;
  padding: 12px;
  max-width: 1200px;
  margin: 0 auto;
  height: 100vh; /* v6: 总高度 100% 视口高度 */
}

/* v5: 舞台区域 - 增加高度一倍 */
#stage {
  border: 2px solid #24242b;
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #16161b 0%, #0f0f14 100%);
  min-height: 160px; /* 从64px增加到160px，一倍高度 */
}

.stage-positions {
  display: grid;
  grid-template-columns: repeat(5, 64px);
  gap: 10px;
  justify-content: center;
  align-items: center;
  padding: 16px 0; /* 增加内边距 */
}

.stage-position {
  width: 64px;
  height: 64px;
  border: 2px dashed #3a3a48;
  border-radius: 6px;
  background: #15151a;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .2s ease, background .2s ease;
}
.stage-position.drop-zone {
  border-color: #8ab4f8;
  background: #1a1a22;
}
.stage-position.occupied {
  border-style: solid;
  border-color: #6a6a7a;
}

/* 角色区 */
#selection {
  border: 2px solid #24242b;
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #14141a 0%, #0e0e13 100%);
}
#selection h2 { margin: 0 0 8px 0; font-size: 16px; color: #bdbdcc; }

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 8px;
}
.character-sprite {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  display: inline-flex;
  align-items: center; justify-content: center;
  border-radius: 4px;
  background: #1c1c24;
  border: 1px solid #2b2b36;
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
}
.character-sprite:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.character-sprite.in-use { opacity: .75; cursor: default; }

/* v5: 年兽覆盖层（舞台满员后显示）- 去除背景框 */
.nian {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  /* v5: 去除背景框、边框和滤镜 */
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  backdrop-filter: none;
}
#nian-img {
  width: 128px;
  height: 128px;
  image-rendering: pixelated;
}

/* 说明浮窗（开屏后自动显示，可关闭） */
.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55);
  z-index: 30;
}
.overlay-content {
  width: min(560px, 92vw);
  max-height: 80vh;
  overflow: auto;
  background: #14141b;
  border: 1px solid #2a2a38;
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.overlay-content h2 { margin: 0 0 10px 0; font-size: 18px; color: #e6e6f0; }
.overlay-content ul { margin: 6px 0 14px 18px; color: #c9c9da; }
.overlay-content li { margin: 6px 0; line-height: 1.5; }
#instructions-close {
  padding: 8px 14px; border: none; border-radius: 6px;
  background: #2f6feb; color: #fff; font-weight: 600;
  cursor: pointer;
}
#instructions-close:hover { background: #275fd3; }

/* v5: 改进烟花特效 - 更加明显和多样化 */
#fireworks-container {
  position: fixed; inset: 0; pointer-events: none; z-index: 40;
}
/* v5: Canvas 粒子烟花画布（层级高于旧DOM粒子） */
#fireworks-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 60; /* v6: 提高层级，使烟花在结算遮罩上方 */
  display: block;
}

/* v5: 更大更明显的烟花 */
.firework {
  position: absolute;
  width: 6px; height: 6px; /* 增大尺寸 */
  background: #fff176;
  box-shadow: 0 0 12px #fff176, 0 0 24px #fff176; /* 增强发光效果 */
  border-radius: 50%;
  animation: fw-pop 1200ms ease-out forwards; /* 延长动画时间 */
}

/* v5: 更强烈的爆炸效果 */
@keyframes fw-pop {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  20%  { transform: translate(var(--dx), var(--dy)) scale(2); opacity: 1; }
  60%  { transform: translate(calc(var(--dx) * 1.5), calc(var(--dy) * 1.5)) scale(1.5); opacity: 0.8; }
  100% { transform: translate(calc(var(--dx) * 2.5), calc(var(--dy) * 2.5)) scale(0.2); opacity: 0; }
}

/* v5: 胜利结算页样式 */
#victory-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5); /* v6: 半透明黑色 50% */
  z-index: 50;
}

#victory-content {
  text-align: center;
  padding: 20px;
  background: rgba(20, 20, 30, 0.9);
  border: 1px solid #3a3a48;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

#victory-content h2 {
  margin: 0 0 20px 0;
  font-size: 32px;
  color: #ffd700;
  text-shadow: 0 0 20px #ffd700; /* 金色发光效果 */
}

/* v5: 胜利按钮在视口垂直70%处左右居中，字体发光无边框 */
#restart-button {
  /* 保留原有文字发光风格 */
  padding: 12px 24px;
  background: none;
  border: none;
  font-size: 18px;
  font-weight: bold;
  color: #ffffff;
  cursor: pointer;
  text-shadow: 0 0 10px #ffffff, 0 0 20px #ffffff, 0 0 30px #ffffff; /* 白色发光 */
  transition: all 0.3s ease;
  border-radius: 8px;

  /* 新增绝对定位：左右居中 + 垂直70% */
  position: absolute;
  left: 50%;
  top: 70%;
  transform: translateX(-50%);
}
#restart-button:hover {
  text-shadow: 0 0 15px #ffffff, 0 0 25px #ffffff, 0 0 35px #ffffff; /* 悬停时增强发光 */
  transform: translateX(-50%) scale(1.05);
}

/* v5: 持续烟花效果 */
.firework-continuous {
  position: absolute;
  width: 4px; height: 4px;
  background: #ff6b6b;
  box-shadow: 0 0 8px #ff6b6b;
  border-radius: 50%;
  animation: fw-continuous 2000ms linear infinite;
}

@keyframes fw-continuous {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  50%  { transform: translate(var(--dx), var(--dy)) scale(1.2); opacity: 0.8; }
  100% { transform: translate(calc(var(--dx) * 2), calc(var(--dy) * 2)) scale(0.5); opacity: 0; }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .stage-positions {
    grid-template-columns: repeat(5, 50px);
    gap: 8px;
  }
  
  .stage-position {
    width: 50px; height: 50px;
  }
  
  #stage {
    min-height: 120px;
  }
  
  .stage-positions {
    padding: 12px 0;
  }
}