/* 打弹珠 - 移动端优先 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #3d2b1a;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
body { display: flex; align-items: center; justify-content: center; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background: linear-gradient(180deg, #6b4a2b 0%, #8b5a2b 45%, #5c3a1c 100%);
  z-index: 1;
}
.hidden { display: none !important; }

/* 标题 - 童年手写粉笔感 */
.title {
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "华文楷体", "楷体", cursive;
  font-size: 64px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #ffd27a;
  text-shadow: 0 3px 0 #7a4a1a, 0 6px 14px rgba(0,0,0,0.4);
  /* 粉笔质感 */
  -webkit-text-stroke: 1px rgba(255,255,255,0.15);
  transform: rotate(-2deg);
}
.tagline {
  font-size: 15px;
  color: #f0d9a8;
  opacity: 0.92;
  text-align: center;
  max-width: 280px;
  line-height: 1.8;
  font-style: italic;
  letter-spacing: 0.5px;
}
.subtitle { font-size: 16px; color: #f0d9a8; opacity: 0.9; text-align: center; max-width: 260px; line-height: 1.6; }

/* 按钮 */
.btn-primary, .btn-secondary {
  width: min(260px, 80vw);
  padding: 14px 0;
  border: none;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s;
}
.btn-primary {
  background: linear-gradient(180deg, #ffd27a, #f0a030);
  color: #5c3a1c;
  box-shadow: 0 4px 0 #a06a1a, 0 6px 14px rgba(0,0,0,0.3);
}
.btn-secondary {
  background: rgba(255,255,255,0.15);
  color: #ffd27a;
  border: 1px solid rgba(255,210,122,0.4);
}
.btn-primary:active, .btn-secondary:active { transform: translateY(3px); }
.btn-link {
  background: none; border: none; color: #ffd27a; font-size: 14px; text-decoration: underline; cursor: pointer;
}

.screen-title { font-size: 28px; font-weight: 700; color: #ffd27a; margin-bottom: 8px; }

/* 选关网格 */
.level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: min(320px, 88vw);
}
.level-cell {
  aspect-ratio: 1;
  border-radius: 16px;
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(255,210,122,0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 800;
  cursor: pointer;
  color: #ffd27a;
  position: relative;
}
.level-cell .star { font-size: 12px; color: #ffd700; letter-spacing: 2px; margin-top: 4px; }
.level-cell.locked { opacity: 0.4; }
.level-cell.locked::after { content: "🔒"; position: absolute; font-size: 18px; }

/* 皮肤列表 */
.skin-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(320px, 88vw);
}
.skin-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.1);
  border-radius: 14px;
  border: 2px solid transparent;
}
.skin-item.selected { border-color: #ffd27a; }
.skin-item .skin-dot { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.skin-item .skin-name { font-size: 16px; font-weight: 600; flex: 1; }
.skin-item .skin-hint { font-size: 12px; color: #f0d9a8; opacity: 0.8; }
.skin-item.locked .skin-name { color: #999; }

/* 对局页 */
#screen-game { background: #2a1c0e; padding: 0; }
#game-hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  z-index: 5;
  background: linear-gradient(180deg, rgba(0,0,0,0.5), transparent);
}
.hud-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 16px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}
#hud-info { color: #fff; font-size: 15px; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* 结算浮层 */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.result-card {
  background: linear-gradient(180deg, #7a4a1a, #5c3a1c);
  border-radius: 24px;
  padding: 28px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(300px, 84vw);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.result-card h3 { font-size: 28px; color: #ffd27a; }
.stars { font-size: 34px; letter-spacing: 6px; color: #ffd700; min-height: 40px; }
/* 星爆动画：弹跳出现 */
.star-pop {
  display: inline-block;
  animation: starPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes starPop {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  60% { transform: scale(1.4) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
/* 本关最佳提示 */
.best-hint {
  font-size: 13px;
  color: #ffd700;
  margin-top: 6px;
  opacity: 0.9;
}

/* 版本号徽章（右下角） */#version-badge {  position: fixed;
  right: 8px;
  bottom: calc(env(safe-area-inset-bottom) + 6px);
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  background: rgba(0,0,0,0.25);
  padding: 2px 6px;
  border-radius: 6px;
  z-index: 100;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  pointer-events: none;
  user-select: none;
}

/* 操作提示（首次进关显示） */
.game-tip {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: #ffd27a;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  z-index: 20;
  text-align: center;
  max-width: 80vw;
  animation: tipFade 0.4s ease;
  pointer-events: none;
}
.game-tip.hidden { display: none; }
@keyframes tipFade {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== 对战模式 ===== */
#screen-vs { position: relative; }
#vs-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(0,0,0,0.3);
}
#vs-scores {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.vs-pouch {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.35);
  border-radius: 999px;
  padding: 3px 10px;
  min-height: 26px;
  transition: box-shadow 0.3s, background 0.3s;
}
.vs-pouch-glow {
  box-shadow: 0 0 12px rgba(255,210,122,0.7);
  background: rgba(80,50,10,0.5);
}
.vs-pouch-label { font-size: 12px; color: #ffd27a; }
.vs-pouch-ai .vs-pouch-label { color: #8ac4ff; }
.vs-pouch-count { font-size: 15px; min-width: 14px; text-align: center; }
.vs-pouch-marbles {
  display: flex;
  gap: 2px;
  align-items: center;
  max-width: 90px;
  flex-wrap: wrap;
}
.vs-pouch-marble {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: inset -1px -1px 2px rgba(0,0,0,0.4), inset 1px 1px 2px rgba(255,255,255,0.5);
}
.vs-colon { color: #aaa; }

/* 对战规则教学条（v0.7 首次进入显示） */
.vs-tutorial {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(20, 12, 5, 0.92);
  border: 1px solid rgba(255, 215, 122, 0.5);
  border-radius: 14px;
  padding: 18px 20px;
  max-width: 320px;
  width: 85%;
  z-index: 60;
  color: #f5e6c8;
  font-size: 14px;
  line-height: 1.7;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  animation: vs-tut-in 0.3s ease-out;
}
.vs-tutorial-title {
  font-size: 17px;
  font-weight: 700;
  color: #ffd27a;
  text-align: center;
  margin-bottom: 8px;
}
.vs-tutorial-row { margin: 4px 0; }
.vs-tutorial-hint {
  text-align: center;
  color: #999;
  font-size: 12px;
  margin-top: 10px;
}
@keyframes vs-tut-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* 珠子飞入袋子动画 */
.vs-fly-marble {
  position: fixed;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  z-index: 40;
  pointer-events: none;
  transition: left 0.55s cubic-bezier(0.3, 0.8, 0.4, 1), top 0.55s cubic-bezier(0.3, 0.8, 0.4, 1), opacity 0.55s, transform 0.55s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
#vs-canvas {
  display: block;
  width: 100%;
  height: calc(100dvh - 120px);
  touch-action: none;
}
.vs-turn-banner {
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,210,122,0.9);
  color: #4a2a0a;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 999px;
  z-index: 15;
  pointer-events: none;
}
.vs-turn-banner.vs-ai-turn {
  background: rgba(138,196,255,0.9);
  color: #123;
}
.vs-result-detail {
  margin-top: 8px;
  font-size: 15px;
  color: #ddd;
  text-align: center;
}
.vs-score-line {
  display: flex;
  justify-content: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}
.vs-result-sub {
  font-size: 13px;
  color: #aaa;
  margin-top: 4px;
}

/* 射击反馈横幅（大翻盘/连击） */
.vs-feedback {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.8);
  color: #ffd27a;
  font-size: 20px;
  font-weight: 800;
  padding: 14px 28px;
  border-radius: 16px;
  z-index: 30;
  text-align: center;
  animation: fbPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  white-space: nowrap;
}
@keyframes fbPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  60% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
