* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #8fb5c9 0%, #d9e4e8 55%, #e7d6bd 100%);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  overflow: hidden;
}

#game-wrapper {
  text-align: center;
  position: relative;
  padding: 12px;
}

#title {
  color: #3a3a3a;
  font-size: 28px;
  letter-spacing: 2px;
  margin-bottom: 8px;
  text-shadow: 1px 2px 0 rgba(255, 255, 255, 0.6);
}

#scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 18px;
  color: #3a3a3a;
}

#score {
  font-size: 30px;
  font-weight: bold;
  color: #e08a1e;
  min-width: 40px;
}

#best {
  margin-left: 12px;
  font-size: 14px;
  color: #666;
}

#canvas-wrap {
  position: relative;
  max-width: 100%;
}

#game-canvas {
  display: block;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  background: #b8e6f2;
  /* 同时受宽、高约束：画布保持 800x480 内在比例，
     在矮窗口 / 手机横屏下等比缩小而不是被裁掉底部（body 为 overflow:hidden，裁掉即不可见）。
     120px 预留给标题 + 记分板 + 容器内边距。 */
  max-width: 100%;
  max-height: calc(100vh - 120px);
  max-height: calc(100dvh - 120px);
  touch-action: none;
}

#pause-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  color: #3a3a3a;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#pause-btn:hover {
  background: #ffffff;
}

#pause-btn.hidden {
  display: none;
}

#warn-btn {
  position: absolute;
  top: 10px;
  right: 58px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  color: #3a3a3a;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: opacity 0.15s;
}

#warn-btn:hover {
  background: #ffffff;
}

#warn-btn.off {
  opacity: 0.45;
}

#boss-btn {
  position: absolute;
  top: 10px;
  right: 106px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  color: #3a3a3a;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: opacity 0.15s;
}

#boss-btn:hover {
  background: #ffffff;
}

/* 2026-10-29 全屏铺满切换按钮（右上按钮组第 4 位；仅 touch 平台生效时显示） */
#fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 154px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  color: #3a3a3a;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: opacity 0.15s;
}

#fullscreen-btn:hover {
  background: #ffffff;
}

body:not(.platform-touch) #fullscreen-btn {
  display: none;
}

#touch-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  /* 2026-10-29：技能 2×2 网格（💧 右下最顺手；右手拇指区） */
  display: grid;
  grid-template-columns: repeat(2, 52px);
  grid-template-rows: repeat(2, 52px);
  gap: 8px;
}

/* 2026-10-29：方向键独立左下（左手），与技能键左右分工 */
#touch-dir {
  position: absolute;
  left: 12px;
  bottom: 12px;
  /* 十字键：上▲ 下▼ 左◀ 右▶；2026-10-29 整体紧凑一档（主键 46、副键 38，仍 ≥36 触控下限） */
  display: grid;
  grid-template-columns: repeat(3, 46px);
  grid-template-rows: repeat(2, 46px);
  gap: 4px;
}

#btn-up { grid-area: 1 / 2; }
#btn-left { grid-area: 2 / 1; }
#btn-down { grid-area: 2 / 2; }
#btn-right { grid-area: 2 / 3; }

#btn-left,
#btn-right {
  width: 38px;
  height: 38px;
  align-self: center;
  justify-self: center;
  font-size: 16px;
}

/* 2026-10-29 竖屏/窄屏紧凑：画布等比缩小后按钮跟着缩小并贴边（技能键 48px；方向键主 44/副 36，
   仍 ≥36 触控下限；道具可见性优先——竖屏画布仅 ~236px 高，按钮区占比大） */
@media (max-width: 520px) {
  #touch-controls {
    right: 8px;
    bottom: 8px;
    grid-template-columns: repeat(2, 48px);
    grid-template-rows: repeat(2, 48px);
    gap: 6px;
  }
  #touch-controls button {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  #touch-dir button {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
  #btn-left,
  #btn-right {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
  #touch-dir {
    left: 8px;
    bottom: 8px;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(2, 44px);
    gap: 4px;
  }
}

#touch-controls button,
#touch-dir button {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  /* 立体底托：左上受光的球面高光 + 由亮到暗的斜面，与画面同一盏灯。
     2026-10-29 透明化：底托 alpha 0.72/0.74 → 0.42/0.45 → 0.28/0.30——道具/金币/主角
     （▲ 十字区与玩家 x≈130 重叠）滚过按钮区不再被遮死；按下态（:active）变实保证可辨识 */
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 58%),
    linear-gradient(155deg, rgba(62, 80, 102, 0.28), rgba(20, 28, 38, 0.30));
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.24),
    inset 0 2px 3px rgba(255, 255, 255, 0.14),
    inset 0 -4px 7px rgba(6, 10, 16, 0.3);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
  user-select: none;
  touch-action: none;
}

#touch-controls button:hover,
#touch-dir button:hover {
  filter: brightness(1.12);
}

#touch-controls button:active,
#touch-dir button:active {
  /* 按下态：底托变实（操作可辨识）+ 沉下去 + 外投影收干净 + 内阴影加深，手感才按得动 */
  transform: translateY(2px) scale(0.9);
  filter: brightness(1.0);
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 58%),
    linear-gradient(155deg, rgba(62, 80, 102, 0.72), rgba(20, 28, 38, 0.74));
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.34),
    inset 0 3px 8px rgba(4, 8, 14, 0.62);
}

#overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  padding: 22px 30px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  width: 74%;
  max-width: 470px;
  /* 2026-10-29 溢出保险：竖屏小视口/全屏下内容超高时滚动而非溢出画面 */
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
}

#overlay.hidden {
  display: none;
}

#overlay-title {
  color: #e08a1e;
  font-size: 30px;
  margin-bottom: 12px;
}

#overlay-text {
  color: #555;
  font-size: 16px;
  line-height: 1.6;
}

/* 2026-11-02 第十轮玩法侧 A：开局天赋面板（ready 态，复用皮肤/平台卡片视觉语言） */
#talent-panel {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

#talent-panel .talent-card {
  flex: 1 1 30%;
  min-width: 118px;
  min-height: 88px;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 9px;
  background: linear-gradient(180deg, #fbfaf6, #efece3);
  color: #4a4a4a;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
  padding: 6px 6px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform 0.08s, border-color 0.12s, box-shadow 0.12s;
}

#talent-panel .talent-card:hover {
  transform: translateY(-1px);
  border-color: #b48cdc;
}

#talent-panel .talent-card.selected {
  border-color: #8a5cf0;
  background: linear-gradient(180deg, #f3ecff, #e2d3ff);
  box-shadow: 0 0 0 2px rgba(138, 92, 240, 0.25), 0 2px 6px rgba(138, 92, 240, 0.22);
}

#talent-panel .talent-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

#talent-panel .talent-emoji { font-size: 22px; line-height: 1; }
#talent-panel .talent-name { font-weight: bold; font-size: 13px; color: #333; }
#talent-panel .talent-cat {
  font-size: 10px;
  color: #8a5cf0;
  border: 1px solid rgba(138, 92, 240, 0.45);
  border-radius: 6px;
  padding: 0 5px;
}
#talent-panel .talent-desc { color: #555; font-size: 10.5px; }
#talent-panel .talent-tag { color: #d2691e; font-size: 10px; }
#talent-panel .talent-hint {
  flex-basis: 100%;
  text-align: center;
  font-size: 11px;
  color: #777;
  margin-top: 2px;
}

/* 2026-10-28 步骤2：平台选择卡片（复用皮肤卡片视觉语言） */
#platform-panel {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  justify-content: center;
}

.platform-card {
  flex: 1;
  max-width: 170px;
  min-height: 52px;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 9px;
  background: linear-gradient(180deg, #fbfaf6, #efece3);
  color: #4a4a4a;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  font-family: inherit;
  padding: 5px 8px;
  transition: transform 0.08s, border-color 0.12s, box-shadow 0.12s;
}

.platform-card:hover {
  transform: translateY(-1px);
  border-color: #e0b46a;
}

.platform-card.selected {
  border-color: #e08a1e;
  background: linear-gradient(180deg, #fff6df, #ffe9b8);
  box-shadow: 0 0 0 2px rgba(224, 138, 30, 0.25), 0 2px 6px rgba(224, 138, 30, 0.25);
}

/* 平台生效为电脑端时隐藏触屏控制（未选平台时保持现状显示，不破坏既有可见性断言） */
#touch-controls.hidden,
#touch-dir.hidden {
  display: none;
}

/* 2026-10-29 手机端画面放大：touch 平台生效时隐藏页头大标题（标题仅装饰，无功能），
   画布高度上限从 120px 预留让到 44px（只留记分板+小边距）；宽度仍受容器 max-width 约束 */
body.platform-touch #title {
  display: none;
}

body.platform-touch #game-canvas {
  max-height: calc(100dvh - 44px);
  max-height: calc(100vh - 44px);
}

/* 2026-10-28 步骤3：新手引导教程（盖画布，样式沿用 overlay 卡片语言）
   2026-10-29 修正：absolute 居中于画布容器在手机竖屏小画布下会盖满画布且溢出被裁（实测 modal
   250px 高 > Pixel 5 画布 236px）→ 改 fixed 视口居中，永不被画布容器裁切；极端小屏加滚动保险 */
#tutorial-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(86%, 420px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 16px;
  padding: 18px 22px 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  z-index: 30;
  text-align: center;
}

#tutorial-modal.hidden {
  display: none;
}

.tutorial-page {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tutorial-page.hidden {
  display: none;
}

.tutorial-emoji {
  font-size: 40px;
  line-height: 46px;
}

.tutorial-page p {
  color: #555;
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}

#tutorial-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}

#tutorial-actions button {
  min-width: 88px;
  height: 34px;
  border: 1.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 17px;
  background: linear-gradient(180deg, #fbfaf6, #efece3);
  color: #4a4a4a;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s, border-color 0.12s;
}

#tutorial-actions button:hover {
  transform: translateY(-1px);
  border-color: #e0b46a;
}

#tutorial-reopen {
  margin-top: 10px;
  height: 28px;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfaf6, #efece3);
  color: #6a6a6a;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

#tutorial-reopen:hover {
  border-color: #e0b46a;
  color: #e08a1e;
}

#skin-panel {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.skin-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.skin-group-title {
  flex: 0 0 30px;
  font-size: 11px;
  color: #8a8a8a;
  text-align: right;
  letter-spacing: 1px;
}

.skin-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  justify-content: flex-start;
}

.skin-cell {
  width: 58px;
  min-height: 52px;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 9px;
  background: linear-gradient(180deg, #fbfaf6, #efece3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 3px 2px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s, border-color 0.12s, box-shadow 0.12s;
}

.skin-cell:hover {
  transform: translateY(-1px);
  border-color: #e0b46a;
}

.skin-cell.selected {
  border-color: #e08a1e;
  background: linear-gradient(180deg, #fff6df, #ffe9b8);
  box-shadow: 0 0 0 2px rgba(224, 138, 30, 0.25), 0 2px 6px rgba(224, 138, 30, 0.25);
}

.skin-cell-emoji {
  font-size: 18px;
  line-height: 19px;
}

.skin-cell-name {
  font-size: 10px;
  color: #4a4a4a;
  line-height: 12px;
  white-space: nowrap;
}

.skin-cell-cond {
  font-size: 8px;
  color: #c25a3a;
  line-height: 9px;
  max-width: 54px;
  text-align: center;
}

/* 锁定格解锁进度：迷你金色进度条（数值在 .skin-cell-cond 紧凑显示） */
.skin-cell-bar {
  display: block;
  width: 46px;
  height: 4px;
  margin: 2px auto 0;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.skin-cell-bar-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #e0b46a, #ffd23f);
  transition: width 0.3s;
}

.skin-cell.locked {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.55;
}

.skin-cell.locked .skin-cell-name {
  color: #777;
}

.skin-cell.shake {
  animation: skin-shake 0.3s;
}

@keyframes skin-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

.skin-empty {
  font-size: 11px;
  color: #999;
}

@media (max-width: 560px), (max-height: 460px) {
  .skin-cell {
    width: 50px;
    min-height: 46px;
  }
  .skin-cell-emoji {
    font-size: 15px;
  }
  .skin-cell-cond {
    font-size: 7px;
  }
}

#mission-list {
  list-style: none;
  margin-top: 14px;
  padding: 0;
  font-size: 14px;
  color: #666;
  line-height: 1.9;
}

#overlay-missions {
  margin-top: 10px;
  font-size: 13px;
  color: #3aa6a0;
  line-height: 1.5;
}

#board-list {
  list-style: none;
  margin: 12px auto 0;
  padding: 6px 0;
  max-width: 300px;
  font-size: 14px;
  color: #555;
  line-height: 1.85;
}

#board-list:empty {
  display: none;
}

#board-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-radius: 8px;
}

#board-list li.current {
  background: #fff3d6;
  color: #9a6a00;
  font-weight: bold;
}

/* 小屏 / 矮窗口：按钮随视口收缩，右下角既不压画面也不互相重叠 */
@media (max-width: 560px), (max-height: 460px) {
  #touch-controls {
    right: 8px;
    bottom: 8px;
    gap: 6px;
  }
  #touch-controls .row {
    gap: 6px;
  }
  #touch-controls button {
    width: 42px;
    height: 42px;
    font-size: 18px;
    border-width: 1.5px;
  }
}

@media (max-width: 400px), (max-height: 380px) {
  #touch-controls button {
    width: 36px;
    height: 36px;
    font-size: 15px;
  }
}

/* 2026-10-29 全屏铺满模式（用户拍板：CSS 视觉铺满，非 Fullscreen API——Esc 留给暂停不冲突）：
   game-wrapper 占满视口、页头与 DOM 记分板隐藏（分数改画布 HUD 绘制）、画布高度上限几乎占满。
   置于文件末尾：须覆盖 body.platform-touch #game-canvas 的 44px 上限（同特异性后者胜） */
body.fullscreen #game-wrapper {
  padding: 0;
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

body.fullscreen #title,
body.fullscreen #scoreboard {
  display: none;
}

body.fullscreen #game-canvas {
  max-height: calc(100dvh - 16px);
  max-height: calc(100vh - 16px);
}
