/* —— 游戏页 —— 与 #app 容器一致，统一缩放 */
.game-page {
  position: relative;
  width: 420px;
  height: 874px;
  overflow: hidden;
}

/* 帐篷背景 — 与棋盘同宽居中 */
.game-scene__tent {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 420px;
  height: auto;
  pointer-events: none;
  z-index: 0;
}

/* ===== 时间 — 左上角，右移120px ===== */
.game-timer-wrap {
  position: absolute;
  top: 10px;
  left: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.game-timer-bg {
  width: 108px;
  height: auto;
  display: block;
}

.game-timer {
  position: absolute;
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  pointer-events: none;
}

/* ===== 按钮 — 右上角，左移120px ===== */
.game-topbar__btns {
  position: absolute;
  top: 8px;
  right: 20px;
  display: flex;
  gap: 6px;
  z-index: 20;
}

.game-restart,
.game-close {
  width: 40px;
  height: 40px;
  border: none;
  padding: 0;
  cursor: pointer;
  background: transparent;
  touch-action: manipulation;
}

.game-restart img,
.game-close img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ===== 场景区 — 全部 absolute + 固定 px 坐标 ===== */

/* 场景容器 — 铺满 game-page */
.game-scene {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 874px;
  pointer-events: none;
  z-index: 5;
}

/* 舞台区（角色+气泡+木板）— 帐篷帘子下方 */
.game-stage {
  position: absolute;
  top: 35px;
  left: 50%;
  transform: translateX(-50%);
  width: 420px;
  pointer-events: none;
}

/* 角色区容器 */
.game-fighters {
  position: relative;
  width: 100%;
  height: 150px;
  pointer-events: none;
}

/* 水果角色 — 左侧 */
#char-fruit {
  position: absolute;
  left: 48px;
  bottom: 0;
  width: 95px;
  z-index: 3;
  pointer-events: auto;
}

/* 蔬菜角色 — 右侧 */
#char-veggie {
  position: absolute;
  right: 48px;
  bottom: 0;
  width: 95px;
  z-index: 3;
  pointer-events: auto;
}

/* 气泡对话框 — 水果在左，蔬菜在右 */
.game-piece-slot {
  position: absolute;
  top: 4px;
  z-index: 6;
  pointer-events: auto;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.game-piece-slot--fruit {
  left: 150px;
}

.game-piece-slot--veggie {
  right: 150px;
}

.game-piece-slot__bg {
  width: 68px;
  height: 68px;
  display: block;
}

.game-piece-slot__piece {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}

/* 对话框加载动画 */
.slot-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  font-size: 14px;
  font-weight: 700;
  color: #888;
  letter-spacing: 2px;
  animation: dotPulse 1.2s ease-in-out infinite;
}
@keyframes dotPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.slot-piece-img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.slot-piece-img.loaded {
  opacity: 1;
}

/* 共享木板 — 角色脚下 */
.game-fighters__platform {
  display: block;
  width: 100%;
  height: auto;
  margin-top: -17px;
  z-index: 2;
  pointer-events: none;
}

/* ===== 分数 — 叠在木板上方两侧 ===== */
.game-scores {
  position: absolute;
  top: 205px;
  left: 50%;
  transform: translateX(-50%);
  width: 380px;
  display: flex;
  justify-content: space-between;
  padding: 0 61px;
  z-index: 8;
  pointer-events: none;
}

.game-score {
  font-size: 1.3rem;
  font-weight: 900;
  min-width: 2ch;
  text-align: center;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(40, 28, 14, 0.7);
  letter-spacing: 1px;
}

.game-score--fruit {
  color: #fff;
}

.game-score--veggie {
  color: #fff;
}

/* 玩家选中时分数黄色高亮 */
.game-score.is-player {
  color: #ffeb3b;
}

/* ===== 棋盘区 — 木板正下方 ===== */
.game-board-zone {
  position: absolute;
  top: 241px;
  left: 50%;
  transform: translateX(-50%);
  width: 420px;
  z-index: 10;
  pointer-events: auto;
}

.board {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 4px;
  margin: 0 auto;
  padding: 8px;
  width: fit-content;
  max-width: 100%;
  background: linear-gradient(180deg, #9a7048 0%, #7a5632 100%);
  border-radius: 10px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25), 0 4px 12px rgba(0, 0, 0, 0.12);
}

.cell {
  width: var(--cell-size, 44px);
  height: var(--cell-size, 44px);
  border: none;
  border-radius: 8px;
  background: #f6f0bb;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.06);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  overflow: hidden;
}

.cell-piece-img {
  width: 80%;
  height: 80%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.cell.playable {
  cursor: pointer;
  background: #fffef5;
}

.cell.playable:hover {
  transform: scale(1.04);
  box-shadow: 0 0 0 2px #7cb342, inset 0 -2px 0 rgba(0, 0, 0, 0.06);
  z-index: 1;
}

.cell.idle {
  opacity: 0.9;
}

.cell.filled.fruit {
  background: linear-gradient(180deg, #ffe8f0 0%, #ffcdd2 100%);
}

.cell.filled.veggie {
  background: linear-gradient(180deg, #e8f5e9 0%, #c8e6c9 100%);
}

.cell.frozen {
  background: #b3e5fc !important;
  opacity: 0.9;
}

.cell.eliminate {
  animation: pop 0.4s ease forwards;
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); background: #fff59d !important; }
  100% { transform: scale(0); opacity: 0; }
}

/* ===== 回合提示 — 气泡下方 ===== */
.turn-hint {
  position: absolute;
  top: 155px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 8px 18px;
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  color: #424939;
  pointer-events: none;
}

.turn-hint.your-turn {
  background: rgba(255, 255, 255, 0.88);
  color: #3c6a00;
}

.turn-hint.ai-turn {
  background: rgba(255, 243, 224, 0.9);
  color: #e65100;
}

/* 小屏：通过 CSS 变量自动适配，无需额外覆盖 */
@media (max-width: 380px) {
  :root {
    --cell-size: 44px;
  }
}

/* —— 阵营选择页面（设计稿布局 + 进场动画）—— */
#screen-select { position: relative; overflow: hidden; }

.select-close {
  position: absolute;
  z-index: 20;
  top: 8px;
  right: 20px;
  width: 40px; height: 40px;
  border: none;
  padding: 0;
  cursor: pointer;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
}
.select-close img {
  width: 100%; height: 100%; object-fit: contain;
}

/* 舞台容器 */
.select-stage {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  width: 100%;
  padding: 220px 4% 30px;   /* 整体内容下移 */
  flex-direction: row;
  position: relative;
  z-index: 1;
  height: 100%;
}

/* 左右阵营 */
.select-faction {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  position: relative;
}
.select-faction--left {
  margin-right: -18px; /* 靠近中间 */
}
.select-faction--right {
  margin-left: -18px; /* 靠近中间 */
}

.select-card-img {
  width: 100%;
  max-width: 175px;   /* 放大卡片 */
  height: auto;
  object-fit: contain;
  pointer-events: none;
}

/* 给两个阵营卡片容器设置统一高度，解决高度不一致问题 */
.select-faction {
  min-height: 280px;
}

.select-name-img {
  width: 70%;
  max-width: 100px;
  margin-top: -50px;   /* 叠在卡片上方 */
  object-fit: contain;
  pointer-events: none;
  position: relative;
  z-index: 10;
}

/* 选择按钮 */
.select-btn-wrap {
  border: none;
  background: transparent;
  padding: 0;
  margin-top: 14px;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.select-btn-wrap img {
  width: 130px;
  max-width: 130px;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.select-btn-wrap:active { transform: scale(0.93); }

/* VS 中间图标 — 放大，居中对齐左右卡片 */
.select-vs {
  position: absolute;
  left: 50%;
  top: 380px;         /* 随内容下移 */
  margin-left: -65px; /* half of 130px width */
  width: 130px;
  z-index: 20;
  padding-top: 0;
}
.select-vs img {
  width: 100%; height: auto; object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.25));
}

/* ========== 进场动画 ========== */

/* 左阵营：从左侧滑入 + 渐显 */
.select-faction--left {
  opacity: 0;
  transform: translateX(-90px);
  animation: slideInLeft 0.7s cubic-bezier(.22,.9,.3,1) forwards;
}

/* 右阵营：从右侧滑入 + 渐显 */
.select-faction--right {
  opacity: 0;
  transform: translateX(90px);
  animation: slideInRight 0.7s cubic-bezier(.22,.9,.3,1) forwards;
}

/* VS / 名称 / 按钮：延迟后渐显缩放 */
.select-vs,
.select-name-img,
.select-btn-wrap {
  opacity: 0;
  animation: fadeInUp 0.55s cubic-bezier(.22,.9,.3,1) forwards;
  animation-delay: 0.65s;
}
.select-faction--left .select-name-img { animation-delay: 0.72s !important; }
.select-faction--left .select-btn-wrap { animation-delay: 0.8s !important; }
.select-faction--right .select-name-img { animation-delay: 0.76s !important; }
.select-faction--right .select-btn-wrap { animation-delay: 0.84s !important; margin-top: 16px; }

@keyframes slideInLeft {
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideInRight {
  to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.85);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* —— 测试按钮 —— */
.test-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 10px 0 20px;
  position: relative;
  z-index: 1;
}

.test-btn {
  padding: 8px 12px;
  border: 2px solid #7cb342;
  border-radius: 12px;
  background: rgba(255,255,255,0.9);
  color: #3c6a00;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.test-btn:hover {
  background: #7cb342;
  color: #fff;
}

/* —— 结算页 —— */
#screen-result {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 420px;
  height: 874px;
  background: transparent;
  z-index: 200;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#screen-result.active {
  display: flex;
}

/* 彩带掉落效果 */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 30px;
  top: -40px;
  opacity: 0;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotateZ(0deg) rotateX(0deg);
    opacity: 1;
  }
  25% {
    transform: translateY(25vh) rotateZ(90deg) rotateX(180deg);
    opacity: 1;
  }
  50% {
    transform: translateY(50vh) rotateZ(180deg) rotateX(360deg);
    opacity: 1;
  }
  75% {
    transform: translateY(75vh) rotateZ(270deg) rotateX(540deg);
    opacity: 0.8;
  }
  100% {
    transform: translateY(105vh) rotateZ(360deg) rotateX(720deg);
    opacity: 0;
  }
}

.result-close {
  position: absolute;
  top: 8px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  z-index: 10;
}

.result-close img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.result-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 80px 20px 40px;
}

/* 四层叠加容器 */
.result-layers {
  position: relative;
  width: 380px;
  height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-30px);
}

.result-layer {
  position: absolute;
  object-fit: contain;
}

/* 底层：背景 - 呼吸效果 */
.result-layer--ribbon {
  width: 340px;
  height: 340px;
  z-index: 1;
  bottom: -60px;
  animation: ribbonPulse 2.5s ease-in-out infinite;
}

/* 第二层：阴影 - 在人物脚下 */
.result-layer--shadow {
  width: 150px;
  height: auto;
  z-index: 2;
  bottom: -30px;
  opacity: 0.5;
}

/* 右侧阴影（默认隐藏） */
.result-layer--shadow-right {
  display: none;
}

/* 第三层：人物 - 左右摇晃效果（以脚为中心） */
.result-layer--char {
  width: 200px;
  height: auto;
  z-index: 3;
  bottom: -20px;
  animation: charSwing 2s ease-in-out infinite;
  transform-origin: bottom center;
}

/* 第四层：胜利标题 - 呼吸效果 */
.result-layer--title {
  width: 300px;
  height: auto;
  z-index: 4;
  top: 130px;
  animation: titleBreathe 2s ease-in-out infinite;
}

/* 顶层：阵营标题 - 静止 */
.result-layer--badge {
  width: 180px;
  height: auto;
  z-index: 5;
  top: -70px;
}

/* 背景呼吸动画 */
@keyframes ribbonPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* 胜利标题呼吸动画 */
@keyframes titleBreathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* 人物左右摇晃动画 */
@keyframes charSwing {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}
.turn-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: var(--panel);
  padding: 20px 40px;
  border-radius: 20px;
  font-size: 1.5rem;
  font-weight: 800;
  pointer-events: none;
  opacity: 0;
  z-index: 100;
  box-shadow: var(--shadow);
  transition: opacity 0.3s, transform 0.3s;
}
.turn-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.turn-banner.fruit { border: 3px solid var(--fruit); color: var(--fruit); }
.turn-banner.veggie { border: 3px solid var(--veggie); color: var(--veggie); }

.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 90; display: flex; align-items: center; justify-content: center; }
.score-pop { position: absolute; font-size: 2rem; font-weight: 800; color: var(--secondary); animation: floatUp 1.1s ease forwards; text-shadow: 0 2px 4px rgba(0,0,0,0.2); }
@keyframes floatUp { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-80px); } }

.toast {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 28, 0, 0.88);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  transition: opacity 0.3s, transform 0.3s;
  max-width: 92%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* —— 教程弹窗 —— 底部显示、Guide-img01 背景、可滚动 */
.modal { display: none; position: fixed; inset: 0; z-index: 300; align-items: flex-end; justify-content: center; padding: 0 16px; }
.modal.open { display: flex; }
.modal-content {
  background: #fff9e6;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
  overflow: hidden;
}
.tutorial-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  z-index: 5;
}
.tutorial-close img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.tutorial-scroll {
  padding: 40px 20px 24px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  /* 隐藏滚动条，保留滚动功能 */
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE / Edge */
}
.tutorial-scroll::-webkit-scrollbar {
  display: none;                /* WebKit (Chrome/Safari) */
}
.tutorial-scroll h2 {
  font-size: 1.3rem;
  color: var(--primary);
  margin-bottom: 4px;
  text-align: center;
}
.tutorial-subtitle {
  text-align: center;
  font-size: 0.95rem;
  color: #666;
  margin-bottom: 12px;
}
.tutorial-scroll h3 {
  font-size: 1.12rem;
  margin: 10px 0 4px;
  color: var(--primary);
}
.tutorial-scroll p, .tutorial-scroll li {
  font-size: 1rem;
  line-height: 1.55;
  color: #424939;
}
.tutorial-scroll ol, .tutorial-scroll ul {
  padding-left: 1.1rem;
  margin-bottom: 2px;
}
.tutorial-scroll table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 4px 0;
}
.tutorial-scroll table th, .tutorial-scroll table td {
  padding: 4px 6px;
  text-align: center;
  border: 1px solid rgba(60,106,0,0.15);
}
.tutorial-scroll table th {
  background: rgba(124,179,66,0.15);
  color: var(--primary);
}
.tutorial-scroll table td {
  color: #424939;
}
.tutorial-footer {
  text-align: center;
  font-weight: 700;
  margin-top: 12px;
  color: var(--primary) !important;
  font-size: 0.88rem !important;
}

/* —— 技能弹窗 —— */
.skill-popup {
  display: flex;
  position: absolute;
  inset: 0;
  background: transparent;
  z-index: 250;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.skill-popup.open {
  opacity: 1;
  pointer-events: auto;
}
.skill-popup__card {
  background: url('../assets/game-img21.svg') center / contain no-repeat;
  border-radius: 20px;
  padding: 48px 28px 36px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: scale(0.85);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(.22,.9,.3,1), opacity 0.3s ease;
  position: relative;
}

.skill-popup__close {
  position: absolute;
  top: 25px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  z-index: 5;
}

.skill-popup__close img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.skill-popup.open .skill-popup__card {
  transform: scale(1);
  opacity: 1;
}
.skill-popup__title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 10px;
  letter-spacing: 1px;
}
.skill-popup__title.fruit { color: #e65100; }
.skill-popup__title.veggie { color: #2e7d32; }
.skill-popup__trigger {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 6px;
}
.skill-popup__effect {
  font-size: 1.05rem;
  font-weight: 700;
  color: #333;
  line-height: 1.5;
}
