/* 大怪路子 — 响应式样式 */

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --primary: #e94560;
  --accent: #0f3460;
  --gold: #f0a500;
  --text: #eee;
  --dim: #888;
  --card-w: 52px;
  --card-h: 74px;
  --team-a: #4fc3f7;
  --team-b: #ff8a65;
}

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

body {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.panel { flex: 1; display: flex; flex-direction: column; }

/* 登录 */
#login-panel { align-items: center; justify-content: center; gap: 0.75rem; }
#login-panel h1 { font-size: 2.5rem; color: var(--gold); letter-spacing: 0.1em; }
.login-form { display: flex; flex-direction: column; gap: 0.5rem; width: 260px; }
.login-form input, .login-form button {
  padding: 0.5rem 0.75rem; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--surface); color: var(--text); font-size: 1rem;
}
.login-form button { background: var(--primary); cursor: pointer; border: none; }
#login-msg { color: var(--primary); font-size: 0.85rem; min-height: 1.2em; }

/* 大厅 */
#lobby-panel { align-items: center; justify-content: center; gap: 1rem; }
.lobby-actions { display: flex; flex-direction: column; gap: 0.75rem; align-items: center; }
.lobby-actions button {
  padding: 0.75rem 2rem; border-radius: 8px; border: none; background: var(--primary);
  color: white; font-size: 1.1rem; cursor: pointer; min-width: 180px;
}
#lobby-msg { color: var(--dim); margin-top: 0.5rem; }

/* 游戏主布局 */
#game-panel {
  display: grid;
  grid-template-rows: 1fr auto auto;
  grid-template-columns: 1fr 260px;
  height: 100dvh;
  gap: 0;
}
#table-area {
  grid-column: 1; grid-row: 1;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
#chat-panel {
  grid-column: 2; grid-row: 1 / 3;
  border-left: 1px solid var(--accent);
  display: flex; flex-direction: column;
  background: var(--surface);
  min-height: 0;
}
#action-bar {
  grid-column: 1; grid-row: 2;
  display: flex; gap: 0.5rem; padding: 0.5rem 1rem;
  justify-content: center;
}
#hand-area {
  grid-column: 1; grid-row: 3;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 3px;
  padding: 0.5rem; min-height: 80px;
  overflow-x: auto;
}

/* 牌桌 + 多边形座位 */
#table-board {
  position: relative;
  width: min(90vw, 380px); height: min(90vw, 380px);
  max-width: 380px; max-height: 380px;
  border-radius: 50%;
  background: radial-gradient(circle, #1e3a5f 0%, var(--bg) 100%);
  border: 3px solid var(--accent);
}
#center-area {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; min-width: 120px;
}
#last-play-display { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.last-play-card {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 50px; border-radius: 4px; font-size: 0.75rem; font-weight: bold;
  background: white; color: #333; border: 1px solid #ccc; margin: 1px;
}
.last-play-card.joker { background: var(--gold); color: white; }
#round-info { font-size: 0.8rem; color: var(--dim); margin-top: 4px; }
#timer-display { font-size: 1.1rem; font-weight: bold; min-height: 1.5em; }
.turn-me { color: var(--gold); animation: pulse 1s infinite; }
.turn-other { color: var(--dim); }
@keyframes pulse { 50% { opacity: 0.4; } }

/* 座位 */
.seat-node {
  position: absolute;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 4px 8px;
  min-width: 68px; max-width: 85px;
  text-align: center; font-size: 0.75rem;
  cursor: default;
  transition: border-color 0.3s, background 0.3s;
}
.seat-node.team-a { border-color: var(--team-a); }
.seat-node.team-b { border-color: var(--team-b); }
.seat-node.active-turn { border-color: var(--gold); box-shadow: 0 0 12px var(--gold); }
.seat-node.finished { opacity: 0.4; }
.seat-node.is-me { background: #2a2e4a; }
.seat-nickname { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-card-count { color: var(--gold); font-size: 0.7rem; }
.seat-team-badge { font-size: 0.6rem; }
.seat-team-badge.a { color: var(--team-a); }
.seat-team-badge.b { color: var(--team-b); }

/* 聊天 */
#chat-messages {
  flex: 1; overflow-y: auto; padding: 0.5rem; display: flex; flex-direction: column; gap: 4px;
  min-height: 0;
}
.chat-msg {
  font-size: 0.8rem; padding: 3px 6px; border-radius: 6px;
  max-width: 100%; word-break: break-word;
}
.chat-msg.system {
  background: rgba(240,165,0,0.1); color: var(--gold); font-style: italic; font-size: 0.75rem;
}
.chat-msg.user-msg .chat-nick { font-weight: bold; margin-right: 4px; }
.chat-msg.user-msg .chat-nick.team-a { color: var(--team-a); }
.chat-msg.user-msg .chat-nick.team-b { color: var(--team-b); }
.chat-msg img {
  max-width: 100%; max-height: 120px; border-radius: 6px; margin-top: 2px; cursor: pointer;
}
#chat-input-bar {
  display: flex; gap: 4px; padding: 6px; border-top: 1px solid var(--accent); align-items: center;
}
#chat-input {
  flex: 1; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--bg); color: var(--text); font-size: 0.85rem; min-width: 0;
}
#img-upload-btn {
  cursor: pointer; font-size: 1.1rem; padding: 2px 4px;
  display: flex; align-items: center;
}
#chat-input-bar button {
  padding: 4px 10px; border-radius: 6px; border: none; background: var(--primary);
  color: white; font-size: 0.8rem; cursor: pointer; white-space: nowrap;
}

/* 手牌 */
.hand-card {
  width: var(--card-w); height: var(--card-h);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  background: white; border: 2px solid #ccc; border-radius: 6px;
  font-size: 0.85rem; font-weight: bold; cursor: pointer; user-select: none;
  flex-shrink: 0;
  transition: transform 0.15s, border-color 0.15s;
}
.hand-card:hover { transform: translateY(-8px); }
.hand-card.selected { transform: translateY(-12px); border-color: var(--gold); }
.hand-card.suit-red { color: #c62828; }
.hand-card.suit-black { color: #222; }
.hand-card.joker { background: var(--gold); color: white; }

/* 操作按钮 */
#action-bar button {
  padding: 0.4rem 1.2rem; border-radius: 6px; border: none;
  font-size: 0.95rem; cursor: pointer;
}
#play-btn { background: var(--primary); color: white; }
#pass-btn { background: var(--accent); color: white; }
#hint-btn { background: var(--surface); color: var(--dim); border: 1px solid var(--accent); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

/* 等待界面 */
.waiting-info { text-align: center; padding: 2rem 1rem; }
.waiting-info h3 { color: var(--gold); margin-bottom: 1rem; font-size: 1.3rem; }
.waiting-info .seat-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin: 1rem 0; }
.waiting-info .seat-item { background: var(--surface); border: 1px solid var(--accent); border-radius: 8px; padding: 0.5rem 1rem; min-width: 100px; }
.waiting-info .seat-num { color: var(--gold); font-weight: bold; margin-right: 0.5rem; }
.waiting-info .hint { color: var(--dim); font-size: 0.85rem; margin-top: 1rem; }

/* 弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-content {
  background: var(--surface); border-radius: 12px; padding: 1.5rem; max-width: 360px; width: 90%;
  text-align: center;
}
.modal-content h3 { color: var(--gold); margin-bottom: 1rem; }
.modal-content button {
  padding: 0.5rem 1rem; border-radius: 6px; border: none; background: var(--primary);
  color: white; cursor: pointer; margin: 0.25rem;
}
.modal-actions { display: flex; gap: 0.5rem; justify-content: center; margin-top: 1rem; }
.tribute-hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 1rem 0; }
#team-target-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 1rem 0; align-items: center; }
.team-target-option {
  display: flex; align-items: center; gap: 0.5rem; cursor: pointer;
  padding: 0.4rem 0.75rem; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--bg);
}
.team-target-option:hover { border-color: var(--gold); }
.team-target-option input { accent-color: var(--gold); }

/* 响应式 - 手机端 */
@media (max-width: 640px) {
  #game-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto auto;
    height: 100dvh;
  }
  #table-area { grid-column: 1; grid-row: 1; min-height: 200px; padding: 0.5rem; }
  #table-board { width: 240px; height: 240px; max-width: 240px; max-height: 240px; }
  #chat-panel {
    grid-column: 1; grid-row: 2;
    border-left: none; border-top: 1px solid var(--accent);
    max-height: 160px;
  }
  #action-bar { grid-column: 1; grid-row: 3; padding: 0.25rem; }
  #hand-area { grid-column: 1; grid-row: 4; padding: 0.25rem; min-height: 70px; }
  .seat-node { min-width: 54px; max-width: 68px; font-size: 0.65rem; padding: 3px 5px; }
  .hand-card { width: 40px; height: 58px; font-size: 0.7rem; }
}
