* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', sans-serif; background: #1a1a2e; color: #eee; overflow: hidden; }

/* ===================== 登录 / 注册 / 找回 ===================== */
#auth {
  display: flex; justify-content: center; align-items: center;
  height: 100vh; background: linear-gradient(135deg, #1a1a2e, #16213e);
}
.login-box {
  background: rgba(255,255,255,0.08); border-radius: 20px;
  padding: 40px; text-align: center; backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1);
}
.login-box h1 { font-size: 2em; margin-bottom: 10px; }
.login-box p { color: #aaa; margin-bottom: 20px; }
.login-box input, .login-box select {
  display: block; width: 100%; padding: 12px; margin: 10px 0;
  border: 1px solid rgba(255,255,255,0.2); border-radius: 10px;
  background: rgba(255,255,255,0.05); color: #eee; font-size: 16px;
}
.login-box button {
  width: 100%; padding: 14px; margin-top: 10px;
  background: linear-gradient(135deg, #4CAF50, #45a049);
  border: none; border-radius: 10px; color: white;
  font-size: 18px; cursor: pointer; transition: transform 0.2s;
}
.login-box button:hover { transform: scale(1.02); }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 14px; }
.auth-links a { color: #4CAF50; text-decoration: none; cursor: pointer; }
.auth-links a:hover { text-decoration: underline; }
.msg { margin-top: 12px; font-size: 13px; min-height: 16px; }
.msg.ok { color: #4CAF50; }
.msg.err { color: #ff6b6b; }

/* ===================== 游戏区 ===================== */
#game { position: fixed; inset: 0; }
#toolbar {
  position: fixed; top: 0; left: 0; right: 0; height: 50px;
  background: rgba(0,0,0,0.82); display: flex; align-items: center;
  padding: 0 16px; gap: 12px; z-index: 10;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  overflow-x: auto; white-space: nowrap;
}
#toolbar span { font-size: 15px; }
#toolbar .label { color: #7fe08a; font-weight: bold; }
#toolbar select {
  padding: 6px; border-radius: 8px; background: #333;
  color: white; border: 1px solid #555; font-size: 14px;
}
.mode-group { display: inline-flex; gap: 6px; }
.mode-btn {
  padding: 6px 14px; border: 1px solid #555; border-radius: 8px;
  background: #2a2a3a; color: #ccc; cursor: pointer; font-size: 14px;
}
.mode-btn.active {
  background: #4CAF50; color: #fff; border-color: #4CAF50;
}
#beastGateBtn { background: #5a2424; color: #ffb3ab; border-color: #7a3535; }
#beastGateBtn.active { background: #e74c3c; color: #fff; border-color: #e74c3c; }
/* 派遣 / 召回（pet-combat） */
#dispatchBtn { background: #1f3a4d; color: #bfe9ff; border-color: #2f6f8f; }
#dispatchBtn.ready { background: #2f8fbf; color: #fff; border-color: #2f8fbf; }
#dispatchBtn:disabled { opacity: 0.4; cursor: not-allowed; }
#recallBtn { background: #4a3a1f; color: #ffe0a3; border-color: #8f6f2f; }
#recallBtn.active { background: #f0a830; color: #fff; border-color: #f0a830; }
#soundToggleBtn { background: #2a2a3a; color: #ccc; border-color: #555; }
#soundToggleBtn.muted { background: #5a2424; color: #ffb3ab; border-color: #7a3535; }
.pet-hud { color: #ffd54f; font-size: 13px; align-self: center; white-space: nowrap; }
#toolbar .logout-btn {
  margin-left: auto; padding: 6px 14px; border: none; border-radius: 8px;
  background: #e74c3c; color: white; cursor: pointer; font-size: 14px;
}

/* 建造材质选择条：紧贴工具栏下方 */
#palette {
  position: fixed; top: 50px; left: 0; right: 0; height: 46px;
  display: none; align-items: center; gap: 8px; padding: 0 16px;
  background: rgba(0,0,0,0.78); z-index: 9;
  border-bottom: 1px solid rgba(255,255,255,0.08); overflow-x: auto;
}
.pal-btn {
  padding: 6px 12px; border: 1px solid #555; border-radius: 8px;
  background: #2a2a3a; color: #eee; cursor: pointer; font-size: 14px; white-space: nowrap;
}
.pal-btn.active { background: #4CAF50; color: #fff; border-color: #4CAF50; }

.mode-hint { color: #9fb3c8; font-size: 13px; align-self: center; }

#gameCanvas {
  display: block; position: fixed; top: 50px; left: 0;
  background: #0d1b0d; cursor: crosshair;
}

/* 聊天输入条 */
#chatbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 38px; z-index: 10; display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.7); padding: 6px 10px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12); max-width: 92vw;
}
#chatInput {
  width: 240px; max-width: 50vw; padding: 8px 12px; border-radius: 8px;
  border: 1px solid #555; background: #222; color: #eee; font-size: 14px;
}
#chatSend {
  padding: 8px 14px; border: none; border-radius: 8px;
  background: #4CAF50; color: #fff; cursor: pointer; font-size: 14px;
}
.emote-group { display: inline-flex; gap: 4px; }
.emote-btn {
  padding: 6px; border: 1px solid #555; border-radius: 8px;
  background: #2a2a3a; cursor: pointer; font-size: 16px; line-height: 1;
}
.emote-btn:hover { background: #3a3a4a; }

/* 聊天记录（持久显示，避免气泡一闪而过看不见） */
#chatlog {
  position: fixed; left: 10px; bottom: 72px; z-index: 9;
  width: 280px; max-width: 70vw; max-height: 32vh; overflow-y: auto;
  background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; color: #eee;
  display: flex; flex-direction: column; gap: 3px; pointer-events: none;
}
#chatlog .chat-line { line-height: 1.4; word-break: break-word; }
#chatlog .chat-line b { color: #7fe08a; margin-right: 2px; }
#chatlog .chat-line.mine b { color: #ffd54f; }

/* 浮动提示 toast */
.toast {
  position: fixed; top: 110px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px; border-radius: 10px; z-index: 50;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.25s;
  background: rgba(0,0,0,0.85); color: #eee; border: 1px solid rgba(255,255,255,0.15);
}
.toast.show { opacity: 1; }
.toast.ok { border-color: #4CAF50; color: #aef5b5; }
.toast.err { border-color: #e74c3c; color: #ffb3ab; }
.toast.warn { border-color: #f39c12; color: #ffdca0; }

/* ===================== 新手引导（3步蒙层） ===================== */
#tutorial-overlay {
  position: fixed; inset: 0; z-index: 200;
  pointer-events: none;  /* 点击穿透，让玩家能操作真实按钮 */
}
#tutorial-mask {
  position: fixed; inset: 0; z-index: 200;
  pointer-events: none;
  background: rgba(0,0,0,0.55);
}
.tutorial-step-box {
  position: fixed; z-index: 210;
  background: rgba(20,24,36,0.95);
  border: 1px solid rgba(76,175,80,0.5);
  border-radius: 16px;
  padding: 20px 24px;
  min-width: 280px;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}
.tutorial-arrow {
  position: absolute;
  width: 0; height: 0;
  border: 10px solid transparent;
}
.tutorial-content { text-align: center; }
.tutorial-title {
  font-size: 18px;
  font-weight: bold;
  color: #7fe08a;
  margin-bottom: 8px;
}
.tutorial-desc {
  font-size: 14px;
  color: #ccc;
  line-height: 1.5;
  margin-bottom: 16px;
}
.tutorial-progress {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}
.tutorial-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #444;
  transition: background 0.3s;
}
.tutorial-dot.active { background: #4CAF50; }
.tutorial-dot.done { background: #7fe08a; }
.tutorial-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
#tutorial-skip {
  background: transparent;
  border: 1px solid #555;
  color: #888;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
#tutorial-skip:hover { color: #ccc; border-color: #777; }
.tutorial-btn-primary {
  background: linear-gradient(135deg, #4CAF50, #45a049);
  border: none;
  color: white;
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
}
.tutorial-btn-primary:hover { transform: scale(1.05); }
.tutorial-btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
/* 高亮环 */
#tutorial-highlight-ring {
  position: fixed; z-index: 205;
  border: 3px solid #4CAF50;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(76,175,80,0.5), 0 0 40px rgba(76,175,80,0.2);
  pointer-events: none;
  animation: tutorial-pulse 1.5s ease-in-out infinite;
  display: none;
}
@keyframes tutorial-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(76,175,80,0.5), 0 0 40px rgba(76,175,80,0.2); }
  50% { box-shadow: 0 0 30px rgba(76,175,80,0.8), 0 0 60px rgba(76,175,80,0.4); }
}
/* 完成奖励提示 */
.tutorial-reward {
  position: fixed; z-index: 220;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(20,24,36,0.96);
  border: 2px solid #ffd700;
  border-radius: 20px;
  padding: 30px 40px;
  text-align: center;
  box-shadow: 0 0 60px rgba(255,215,0,0.3);
  pointer-events: auto;
}
.tutorial-reward h2 { color: #ffd700; font-size: 22px; margin-bottom: 10px; }
.tutorial-reward p { color: #ccc; font-size: 14px; margin-bottom: 20px; }
.tutorial-reward button {
  background: linear-gradient(135deg, #ffd700, #f0a830);
  border: none; color: #1a1a2e;
  padding: 10px 30px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px; font-weight: bold;
}

/* ===================== 重连倒计时条 ===================== */
#reconnect-bar {
  position: fixed; top: 50px; left: 0; right: 0; z-index: 150;
  background: rgba(180,40,40,0.92);
  padding: 8px 16px;
  display: flex; align-items: center;
  gap: 12px;
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
#reconnect-text {
  font-size: 14px; color: #fff;
  font-weight: bold; white-space: nowrap;
}
#reconnect-progress-track {
  flex: 1; height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  overflow: hidden;
}
#reconnect-progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff6b6b, #ffd93d, #4CAF50);
  border-radius: 3px;
}
#reconnect-attempt {
  font-size: 12px; color: rgba(255,255,255,0.8);
  white-space: nowrap;
}

/* ===================== 新手引导（guide-overlay 备用结构） ===================== */
.guide-overlay {
  position: fixed; inset: 0; z-index: 200;
  pointer-events: none;
}
.guide-highlight {
  position: fixed; z-index: 205;
  border: 3px solid #4CAF50;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(76,175,80,0.5), 0 0 40px rgba(76,175,80,0.2);
  pointer-events: none;
  animation: tutorial-pulse 1.5s ease-in-out infinite;
  display: none;
}
.guide-tooltip {
  position: fixed; z-index: 210;
  background: rgba(20,24,36,0.95);
  border: 1px solid rgba(76,175,80,0.5);
  border-radius: 16px;
  padding: 20px 24px;
  min-width: 280px;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  display: none;
}
.guide-tooltip-title {
  font-size: 18px; font-weight: bold; color: #7fe08a; margin-bottom: 8px;
}
.guide-tooltip-desc {
  font-size: 14px; color: #ccc; line-height: 1.5; margin-bottom: 16px;
}

/* ===================== 重连倒计时条（失败灰色态） ===================== */
#reconnect-bar.failed {
  background: rgba(80,80,80,0.92);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
#reconnect-bar.failed #reconnect-progress-fill {
  background: #555;
}

/* ===================== 备案信息固定底部 ===================== */
footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(20, 20, 40, 0.92);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 10px 20px; text-align: center;
}
footer .beian-row {
  display: flex; justify-content: center; align-items: center;
  gap: 20px; flex-wrap: wrap; font-size: 12px; color: #888;
}
footer .beian-row a { color: #888; text-decoration: none; }
footer .beian-row a:hover { color: #aaa; text-decoration: underline; }

/* ===================== 手机虚拟摇杆（仅触屏显示） ===================== */
.joystick {
  position: fixed; left: 16px; bottom: 95px; z-index: 12;
  display: none; touch-action: none;   /* 默认隐藏，仅触屏显示 */
}
.joy-base {
  width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.25);
  position: relative; touch-action: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
.joy-knob {
  width: 54px; height: 54px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7fe08a, #4CAF50);
  border: 2px solid rgba(255,255,255,0.85);
  position: absolute; left: 33px; top: 33px;   /* (120-54)/2 居中 */
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
@media (pointer: coarse) {
  .joystick { display: block; }
  /* 触屏设备下把聊天面板移到顶部，避免与左下角摇杆重叠 */
  #chatlog { left: 10px; top: 60px; bottom: auto; max-height: 22vh; }
}

/* ===================== Buff HUD（BuffManager） ===================== */
.buff-hud { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; }
.buff-icon {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 7px; border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(0,0,0,0.45); font-size: 13px;
  animation: buff-pop 0.3s ease;
}
@keyframes buff-pop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.buff-emoji { font-size: 15px; }
.buff-timer { color: #ccc; font-size: 11px; font-weight: bold; }

/* ===================== 知识石碑弹窗 ===================== */
#stele-modal {
  position: fixed; inset: 0; z-index: 300;
  display: none; justify-content: center; align-items: center;
  background: rgba(0,0,0,0.65);
}
.stele-modal-content {
  background: rgba(20,24,36,0.96);
  border: 1px solid rgba(255,215,0,0.5);
  border-radius: 20px;
  padding: 30px;
  max-width: 420px;
  width: 90vw;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.stele-icon { font-size: 48px; margin-bottom: 10px; }
.stele-question {
  font-size: 18px; color: #ffd54f;
  margin-bottom: 20px; line-height: 1.5;
}
.stele-options { display: flex; flex-direction: column; gap: 10px; }
.stele-option {
  padding: 12px 16px; border: 1px solid #555;
  border-radius: 10px; background: #2a2a3a;
  color: #eee; cursor: pointer; font-size: 15px;
  transition: background 0.2s;
}
.stele-option:hover { background: #3a3a4a; border-color: #ffd700; }
.stele-option:disabled { opacity: 0.5; cursor: not-allowed; }
.stele-result { margin-top: 16px; font-size: 15px; }
.stele-correct { color: #4CAF50; font-weight: bold; margin-bottom: 8px; }
.stele-wrong { color: #e74c3c; font-weight: bold; margin-bottom: 8px; }
.stele-correct-answer { color: #ffd54f; margin-bottom: 8px; }
.stele-funfact { color: #aaa; font-size: 13px; margin-bottom: 8px; }
.stele-buff { color: #ffd700; font-weight: bold; }
.stele-close-btn {
  margin-top: 16px; padding: 8px 24px;
  border: none; border-radius: 8px;
  background: #4CAF50; color: #fff;
  cursor: pointer; font-size: 14px;
}
/* 5秒倒计时条 */
.stele-timer-bar {
  width: 100%; height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden; margin-bottom: 8px;
}
.stele-timer-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #4CAF50, #ffd93d, #ff6b6b);
  border-radius: 3px;
  transition: width 0.3s linear;
}
.stele-timer-text { color: #aaa; font-size: 12px; margin-bottom: 12px; }
