* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #141a14;
  color: #eee;
  overflow: hidden;
}

/* 首页表单 */
body.home { display: flex; align-items: center; justify-content: center; }
.form-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 16px;
  padding: 28px 24px;
  width: min(420px, 92vw);
}
.form-card h1 { font-size: 28px; color: #e8c86a; text-align: center; }
.form-card .sub { text-align: center; color: #999; font-size: 13px; margin: 6px 0 20px; }
.form-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.back { color: #999; text-decoration: none; font-size: 13px; }
.back:hover { color: #e8c86a; }
.lang-toggle { color: #e8c86a; text-decoration: none; font-size: 13px; border: 1px solid rgba(212, 175, 55, 0.4); border-radius: 8px; padding: 2px 10px; }
.lang-toggle:hover { background: rgba(212, 175, 55, 0.15); }
.game-ico {
  width: 96px; height: 96px; margin: 0 auto 12px;
  border-radius: 26px;
  background: radial-gradient(circle at 32% 26%, #f4dc96, #c9a24b 58%, #7a5c1e);
  display: block;
  box-shadow: 0 8px 26px rgba(212, 175, 55, 0.38);
  image-rendering: pixelated;
}
.row { display: flex; gap: 10px; margin-bottom: 12px; }
.row label { flex: 1; font-size: 13px; color: #bbb; display: flex; flex-direction: column; gap: 4px; }
input, select {
  background: #1f271f; color: #eee; border: 1px solid #3a4a3a;
  border-radius: 8px; padding: 10px; font-size: 15px; width: 100%;
}
.btns { margin-top: 16px; }
.btns button {
  flex: 1; padding: 12px; border: none; border-radius: 10px;
  font-size: 16px; cursor: pointer;
}
#random { background: #2a3d2a; color: #ddd; }
#start { background: #d4af37; color: #1a130a; font-weight: bold; }

/* 游戏页 */
body.game { background: #000; }
#game-canvas { display: block; touch-action: none; }

/* 结局 overlay */
#result-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.82);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; z-index: 10; padding: 12px;
}
#result-card { display: flex; justify-content: center; }
#result-card canvas { border-radius: 12px; box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6); }
#result-lines { color: #e8c86a; font-size: 14px; text-align: center; max-width: 80vw; }
.result-btns { display: flex; gap: 12px; }
.result-btns button {
  padding: 12px 20px; border: none; border-radius: 10px;
  font-size: 15px; cursor: pointer; background: #d4af37; color: #1a130a; font-weight: bold;
}

/* 三选一 buff overlay */
#choice-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; z-index: 9; padding: 16px;
}
#choice-box {
  display: flex; flex-direction: column; gap: 10px; width: min(320px, 90vw);
}
.choice-title { color: #e8c86a; font-size: 18px; text-align: center; margin-bottom: 4px; font-weight: bold; }
.choice-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 14px; background: #1f271f; border: 1px solid #c9a24b;
  border-radius: 12px; color: #eee; font-size: 15px; cursor: pointer;
}
.choice-btn b { color: #e8c86a; font-size: 17px; }
.choice-btn span { color: #bbb; font-size: 13px; }
.choice-btn:active { background: #2a3d2a; }

/* 手机版放炮塔按钮（触屏设备显示，桌面隐藏） */
#tower-btn {
  position: fixed; bottom: 26px; right: 22px;
  width: 58px; height: 58px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.5); border: 1px solid rgba(212, 175, 55, 0.55);
  color: #e8c86a; font-size: 26px; line-height: 1;
  display: none; align-items: center; justify-content: center;
  z-index: 8; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
#tower-btn:active { background: rgba(212, 175, 55, 0.3); }
@media (hover: none) { #tower-btn { display: flex; } }

/* 设置按钮 + 设置面板 */
#settings-btn {
  position: fixed; top: 10px; left: 10px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.5); border: 1px solid rgba(212, 175, 55, 0.5);
  color: #e8c86a; font-size: 20px; z-index: 7; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
#settings-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7);
  display: flex; align-items: center; justify-content: center; z-index: 11;
}
.settings-box {
  background: #1b241b; border: 1px solid rgba(212, 175, 55, 0.5); border-radius: 16px;
  padding: 22px 24px; width: min(300px, 88vw); display: flex; flex-direction: column; gap: 14px;
}
.settings-box h3 { color: #e8c86a; text-align: center; margin: 0; font-size: 18px; }
.vol-row { display: flex; align-items: center; gap: 10px; color: #ddd; font-size: 14px; }
.vol-row input[type=range] { flex: 1; accent-color: #d4af37; }
.set-btn {
  padding: 12px; border: 1px solid #c9a24b; border-radius: 10px;
  background: #1f271f; color: #eee; font-size: 15px; cursor: pointer;
}
.set-btn.danger { border-color: #c0392b; color: #ffb0a8; }
.set-btn:active { background: #2a3d2a; }

/* 继续上次按钮 */
.resume-btn {
  width: 100%; margin-top: 12px; padding: 12px;
  border: 1px solid #c9a24b; border-radius: 10px;
  background: #1f271f; color: #e8c86a; font-size: 15px; cursor: pointer;
}
.resume-btn:active { background: #2a3d2a; }

/* AI 主角立绘（游戏内左上角小头像） */
.char-portrait {
  position: fixed; top: 56px; left: 10px; width: 64px; height: 64px;
  border-radius: 10px; border: 1px solid rgba(212, 175, 55, 0.5);
  z-index: 6; object-fit: cover; box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
/* Boss 登场横幅 */
#boss-intro {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.82);
  display: flex; align-items: center; justify-content: center; z-index: 12;
}
.boss-intro-box { text-align: center; }
#boss-intro-img {
  width: min(72vw, 360px); height: auto; border-radius: 16px;
  border: 3px solid rgba(212, 175, 55, 0.7); box-shadow: 0 0 60px rgba(212, 175, 55, 0.4);
}
#boss-intro-name {
  color: #e8c86a; font-size: 22px; margin-top: 12px; font-weight: bold;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.8);
}

/* AI 生成加载页 */
#ai-loading {
  position: fixed; inset: 0; background: #0e130e;
  display: flex; align-items: center; justify-content: center; z-index: 20;
}
.ai-loading-box { text-align: center; }
.ai-loading-spinner {
  width: 48px; height: 48px; margin: 0 auto 16px;
  border: 4px solid rgba(212, 175, 55, 0.2); border-top-color: #d4af37;
  border-radius: 50%; animation: ai-spin 0.9s linear infinite;
}
#ai-loading-text { color: #e8c86a; font-size: 16px; }
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* 游戏规则折叠区 */
.rules { margin-top: 16px; border: 1px solid rgba(212, 175, 55, 0.35); border-radius: 10px; padding: 10px 14px; background: rgba(0,0,0,0.2); }
.rules summary { cursor: pointer; color: #e8c86a; font-size: 14px; font-weight: bold; }
.rules-body { margin-top: 10px; font-size: 13px; color: #ccc; line-height: 1.8; }
.rules-body p { margin: 4px 0; }
