/* ============ 公共样式 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Microsoft YaHei", "SimHei", sans-serif;
  background: linear-gradient(135deg, #2c3e50 0%, #1a1a2e 100%);
  min-height: 100vh;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

a { color: #66ccff; text-decoration: none; }

/* ============ 登录/注册页 ============ */
.auth-box {
  width: 380px;
  background: rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 36px 32px;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
.auth-box h1 {
  text-align: center;
  font-size: 26px;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #f7971e, #ffd200);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-box .sub { text-align: center; font-size: 13px; color: #aaa; margin-bottom: 24px; }

.tabs { display: flex; margin-bottom: 22px; background: rgba(0,0,0,0.2); border-radius: 8px; padding: 4px; }
.tab { flex: 1; text-align: center; padding: 10px; cursor: pointer; border-radius: 6px; font-size: 14px; color: #bbb; transition: all .2s; }
.tab.active { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: #aaa; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 14px; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; background: rgba(0,0,0,0.25); color: #fff; font-size: 14px;
}
.field input:focus { outline: none; border-color: #667eea; }

.btn {
  width: 100%; padding: 12px; border: none; border-radius: 8px; font-size: 15px;
  font-weight: bold; cursor: pointer; color: #fff; transition: all .2s;
  background: linear-gradient(135deg, #11998e, #38ef7d);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,0.35); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.msg { min-height: 20px; font-size: 13px; text-align: center; margin-top: 14px; }
.msg.err { color: #ff6b6b; }
.msg.ok { color: #38ef7d; }

/* ============ 大厅页 ============ */
.lobby-wrap { width: 720px; max-width: 100%; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
}
.topbar .user { font-size: 16px; }
.topbar .user b { color: #ffd200; }
.topbar .logout-link { font-size: 13px; color: #aaa; cursor: pointer; }
.topbar .logout-link:hover { color: #ff6b6b; }

.lobby-title { text-align: center; font-size: 30px; margin-bottom: 30px; background: linear-gradient(135deg, #f7971e, #ffd200); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card {
  background: rgba(255,255,255,0.08); border-radius: 14px; padding: 28px 24px;
  backdrop-filter: blur(10px);
}
.card h3 { font-size: 18px; margin-bottom: 10px; }
.card p { font-size: 13px; color: #bbb; margin-bottom: 18px; line-height: 1.6; }
.card .btn { width: auto; padding: 11px 20px; }

.room-input { display: flex; gap: 8px; margin-bottom: 14px; }
.room-input input {
  flex: 1; padding: 11px 14px; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; background: rgba(0,0,0,0.25); color: #fff; font-size: 16px;
  letter-spacing: 4px; text-transform: uppercase; text-align: center;
}
.room-input input:focus { outline: none; border-color: #667eea; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: none;
  justify-content: center; align-items: center; z-index: 100;
}
.modal-mask.show { display: flex; }
.modal {
  background: linear-gradient(135deg, #2c3e50, #1a1a2e); border-radius: 16px;
  padding: 36px 40px; text-align: center; min-width: 320px;
}
.modal .code {
  font-size: 48px; font-weight: bold; letter-spacing: 12px; margin: 16px 0;
  color: #ffd200; background: rgba(0,0,0,0.3); padding: 16px; border-radius: 10px;
}
.modal .tip { font-size: 14px; color: #aaa; }
.modal .small-btn { margin-top: 18px; padding: 8px 18px; font-size: 13px; background: rgba(255,255,255,0.1); }

/* ============ 对战页 ============ */
.game-container { display: flex; gap: 28px; align-items: flex-start; }
.board-wrapper { background: #f5deb3; padding: 30px; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); order: 2; }
.board { position: relative; width: 540px; height: 600px; }
.board.flipped { transform: rotate(180deg); }
.board svg { position: absolute; top: 0; left: 0; }
.pieces-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.piece {
  position: absolute; width: 56px; height: 56px; border-radius: 50%;
  display: flex; justify-content: center; align-items: center; font-size: 32px;
  font-weight: bold; cursor: pointer; user-select: none; transition: transform .15s, box-shadow .15s;
  background: radial-gradient(circle at 30% 30%, #fff8dc, #deb887);
  box-shadow: 0 3px 8px rgba(0,0,0,0.4), inset 0 -3px 6px rgba(0,0,0,0.2);
  border: 2px solid #8b4513; transform: translate(-50%, -50%);
}
.board.flipped .piece { transform: translate(-50%, -50%) rotate(180deg); }
.piece.red { color: #c41e3a; }
.piece.black { color: #1a1a1a; }
.piece:hover { transform: translate(-50%, -50%) scale(1.08); box-shadow: 0 5px 15px rgba(0,0,0,0.5), inset 0 -3px 6px rgba(0,0,0,0.2); }
.board.flipped .piece:hover { transform: translate(-50%, -50%) rotate(180deg) scale(1.08); }
.piece.selected { box-shadow: 0 0 15px #ffd700, 0 3px 8px rgba(0,0,0,0.4); border-color: #ffd700; animation: pulse 1s infinite; }
.piece.last-move { box-shadow: 0 0 10px #00bcd4, 0 3px 8px rgba(0,0,0,0.4); }
@keyframes pulse { 0%,100%{box-shadow:0 0 15px #ffd700,0 3px 8px rgba(0,0,0,0.4);} 50%{box-shadow:0 0 25px #ffd700,0 3px 8px rgba(0,0,0,0.4);} }

.move-indicator { position: absolute; width: 30px; height: 30px; border-radius: 50%; background: rgba(76,175,80,0.5); transform: translate(-50%, -50%); pointer-events: none; }
.capture-indicator { position: absolute; width: 56px; height: 56px; border-radius: 50%; border: 3px solid rgba(244,67,54,0.7); transform: translate(-50%, -50%); pointer-events: none; }

.info-panel { width: 240px; order: 1; }
.info-box { background: rgba(255,255,255,0.08); border-radius: 10px; padding: 18px; margin-bottom: 14px; backdrop-filter: blur(10px); }
.turn-indicator { text-align: center; font-size: 18px; font-weight: bold; margin-bottom: 8px; }
.turn-indicator.red { color: #ff6b6b; }
.turn-indicator.black { color: #e0e0e0; }
.status { text-align: center; font-size: 13px; padding: 8px; border-radius: 5px; min-height: 34px; }
.status.check {
  background: rgba(255, 30, 30, 0.45);
  color: #ff5252;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 0 0 8px rgba(255, 50, 50, 0.9);
  animation: shake 0.4s infinite, checkPulse 0.8s infinite;
  border: 2px solid #ff3030;
  letter-spacing: 4px;
}
.status.checkmate, .status.abandoned {
  background: rgba(244, 67, 54, 0.45);
  color: #ff5252;
  font-size: 20px;
  font-weight: bold;
  animation: checkPulse 0.6s infinite;
}
.status.thinking { color: #ffd700; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
@keyframes checkPulse {
  0%, 100% { box-shadow: 0 0 5px rgba(255, 30, 30, 0.5); }
  50% { box-shadow: 0 0 25px rgba(255, 30, 30, 1); }
}

/* 将军醒目横幅 */
.check-banner {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: linear-gradient(135deg, #d32f2f, #ff1744);
  color: #fff; font-size: 56px; font-weight: bold;
  padding: 26px 70px; border-radius: 16px;
  text-shadow: 0 4px 12px rgba(0,0,0,0.6);
  box-shadow: 0 0 80px rgba(255, 30, 30, 0.9);
  z-index: 1100; pointer-events: none;
  letter-spacing: 12px; opacity: 0;
}
.check-banner.show { animation: bannerShow 1.4s ease-out forwards; }
@keyframes bannerShow {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  20% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  35% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  75% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; }
}

/* 绝杀特效 */
.checkmate-banner {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: linear-gradient(135deg, #4a0000, #b71c1c, #ff1744);
  color: #ffd700; font-size: 72px; font-weight: bold;
  padding: 36px 90px; border-radius: 20px;
  text-shadow: 0 0 20px #ff0, 0 4px 16px rgba(0,0,0,0.8);
  box-shadow: 0 0 120px rgba(255, 0, 0, 1), inset 0 0 40px rgba(255, 215, 0, 0.3);
  z-index: 1200; pointer-events: none;
  letter-spacing: 16px; border: 4px solid #ffd700; opacity: 0;
}
.checkmate-banner.show { animation: checkmateShow 2.5s ease-out forwards; }
@keyframes checkmateShow {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(-15deg); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.3) rotate(5deg); opacity: 1; }
  25% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  80% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.5) rotate(0deg); opacity: 0; }
}
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.online-dot.on { background: #38ef7d; }
.online-dot.off { background: #666; }

.voice-box { font-size: 13px; }
.voice-row { display: flex; justify-content: space-between; align-items: center; margin: 6px 0; }
.voice-btn { padding: 6px 12px; font-size: 12px; border: none; border-radius: 6px; cursor: pointer; color: #fff; background: linear-gradient(135deg,#667eea,#764ba2); }
.voice-btn.off { background: linear-gradient(135deg,#f5576c,#f093fb); }
.voice-state { font-size: 12px; color: #aaa; }

.captured-pieces { display: flex; gap: 5px; flex-wrap: wrap; min-height: 26px; }
.captured-piece { font-size: 16px; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.1); border-radius: 50%; }
.captured-piece.red { color: #ff6b6b; }
.captured-piece.black { color: #e0e0e0; }

.move-history { max-height: 200px; overflow-y: auto; font-size: 12px; }
.move-history::-webkit-scrollbar { width: 4px; }
.move-history::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 2px; }
.move-item { padding: 4px 6px; border-bottom: 1px solid rgba(255,255,255,0.08); display: flex; justify-content: space-between; }

.winner-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: none; justify-content: center; align-items: center; z-index: 1000; }
.winner-overlay.show { display: flex; }
.winner-box { background: linear-gradient(135deg, #667eea, #764ba2); padding: 40px 60px; border-radius: 20px; text-align: center; animation: bounceIn .5s; }
.winner-box h1 { font-size: 42px; margin-bottom: 14px; }
.winner-box p { font-size: 16px; margin-bottom: 24px; }
@keyframes bounceIn { 0%{transform:scale(.3);opacity:0} 50%{transform:scale(1.05)} 70%{transform:scale(.95)} 100%{transform:scale(1);opacity:1} }

.topbar-back { font-size: 13px; color: #aaa; cursor: pointer; }
.topbar-back:hover { color: #66ccff; }
