/* 武道家扑克 · FC 红白机风格 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0a12;
  --panel: #14141f;
  --line: #3a3a55;
  --gold: #e8c46a;
  --cyan: #5ad0e6;
  --red: #e65a5a;
  --green: #7ce87c;
  --text: #e8e8f0;
  --dim: #9a9ab0;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', 'PingFang SC', 'Microsoft YaHei', monospace;
  image-rendering: pixelated;
  min-height: 100vh;
}

/* ===== 顶栏 ===== */
#topBar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  border-bottom: 3px solid var(--line);
  background: linear-gradient(#17172a, #0e0e1a);
  position: sticky; top: 0; z-index: 50;
}
.logo { font-size: 20px; font-weight: 700; color: var(--gold); text-shadow: 2px 2px 0 #000; }
.logo .sub { font-size: 11px; color: var(--dim); margin-left: 6px; letter-spacing: 1px; }
.room-tag { font-size: 12px; color: var(--cyan); border: 1px solid var(--line); padding: 2px 8px; margin-right: 8px; }

.pix-btn {
  background: #23233a; color: var(--text);
  border: 2px solid var(--line); border-radius: 4px;
  padding: 8px 16px; font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer; letter-spacing: 2px;
  box-shadow: 2px 2px 0 rgba(0,0,0,.6);
}
.pix-btn:hover { border-color: var(--gold); color: var(--gold); }
.pix-btn.big { font-size: 18px; padding: 12px 28px; background: #2b2b4a; }
.pix-btn.small { font-size: 12px; padding: 5px 10px; }
.pix-btn.danger { border-color: var(--red); color: var(--red); }
.pix-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== 视图面板 ===== */
.view { max-width: 720px; margin: 0 auto; padding: 16px 12px 24px; }
.panel {
  background: var(--panel); border: 3px solid var(--line);
  border-radius: 8px; padding: 20px; margin-top: 12px;
}
.panel h2 { color: var(--gold); text-align: center; font-size: 20px; letter-spacing: 4px; margin-bottom: 10px; }
.slogan { text-align: center; color: var(--cyan); font-size: 13px; margin-bottom: 16px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 4px; letter-spacing: 2px; }
.field input, .field select, .join-row input {
  width: 100%; background: #0d0d18; color: var(--text);
  border: 2px solid var(--line); border-radius: 4px;
  padding: 10px 12px; font-family: inherit; font-size: 16px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--gold); }

.or { text-align: center; color: var(--dim); margin: 14px 0 10px; font-size: 12px; letter-spacing: 4px; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; text-align: center; letter-spacing: 8px; font-size: 20px; }

.rule-note {
  margin-top: 16px; font-size: 12px; color: var(--dim);
  border-top: 1px dashed var(--line); padding-top: 12px; line-height: 1.7;
}
.rule-note b { color: var(--gold); }

/* ===== 房间等待 ===== */
.room-no { color: var(--cyan); font-size: 26px; }
.wait-msg { text-align: center; color: var(--dim); font-size: 13px; margin-bottom: 12px; }
.player-list { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 14px; }
.p-chip {
  background: #1c1c30; border: 2px solid var(--line); border-radius: 6px;
  padding: 8px 14px; text-align: center; min-width: 110px;
}
.p-chip .nm { font-size: 14px; color: var(--text); font-weight: 700; }
.p-chip .st { font-size: 11px; color: var(--dim); margin-top: 2px; }
.p-chip.host { border-color: var(--gold); }
.p-chip .ai { color: var(--green); }
.qr-wrap { display: flex; justify-content: center; margin: 10px 0; }

/* ===== 对局 ===== */
.status-bar {
  background: #10101e; border: 2px solid var(--line); border-radius: 6px;
  padding: 8px 12px; font-size: 13px; color: var(--cyan);
  text-align: center; margin-bottom: 12px; min-height: 38px;
  display: flex; align-items: center; justify-content: center;
}

.table {
  display: grid;
  grid-template-columns: 1fr 96px 1fr;
  grid-template-rows: auto auto auto;
  grid-template-areas:
    ". s0 ."
    "s3 mid s1"
    ". s2 .";
  gap: 8px;
  background: #10101e; border: 3px solid var(--line); border-radius: 8px;
  padding: 12px; margin-bottom: 12px;
}
.seat { text-align: center; padding: 6px; }
#seat-0 { grid-area: s0; }
#seat-1 { grid-area: s1; }
#seat-2 { grid-area: s2; }
#seat-3 { grid-area: s3; }
.table-center { grid-area: mid; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.cycle { font-size: 10px; color: var(--cyan); letter-spacing: 1px; text-align: center; line-height: 1.5; }
.dir { font-size: 10px; color: var(--dim); text-align: center; }
.seat-name { font-size: 12px; color: var(--dim); margin-bottom: 6px; min-height: 16px; }
.seat-no { display: inline-block; min-width: 18px; color: var(--dim); font-size: 11px; }
.seat.active .seat-name { color: var(--gold); font-weight: 700; }
.seat.active .seat-no { color: var(--gold); }
.seat.leader .seat-name { color: var(--cyan); }
.seat.leader .seat-no { color: var(--cyan); }
.seat.winner .seat-name { color: var(--green); }
.seat-left { font-size: 11px; color: var(--dim); margin-top: 4px; min-height: 14px; }
.seat-card { min-height: 108px; display: flex; align-items: center; justify-content: center; }
.seat-card img { image-rendering: pixelated; width: 63px; height: 96px; display: block; }

/* 像素牌 */
.px-card {
  background-repeat: no-repeat;
  image-rendering: pixelated;
  width: 63px; height: 96px;
  background-size: 63px 96px;
}
.px-card.empty {
  width: 63px; height: 96px;
  border: 2px dashed #2a2a44; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #3a3a55; font-size: 22px;
}
.px-card.back {
  background: #1a1a2e;
  border: 2px solid var(--gold); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-size: 14px; font-weight: 700; letter-spacing: 2px;
}

/* 掷骰区 */
.dice-area {
  background: #10101e; border: 3px solid var(--line); border-radius: 8px;
  padding: 16px; text-align: center; margin-bottom: 12px;
}
.dice-msg { font-size: 14px; color: var(--text); margin-bottom: 10px; }
.dice-result { margin-top: 10px; font-size: 16px; color: var(--gold); min-height: 24px; letter-spacing: 2px; }

/* 骰子面 */
.dice-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: flex-end; }
.dice-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dice-cell .d-name { font-size: 11px; color: var(--dim); max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dice-cell .d-pts { font-size: 12px; color: var(--gold); font-weight: 700; }
.dice-cell.rolling .d-name { color: var(--cyan); }
.dice-cell.top .d-pts { color: var(--green); }
.dice-cell.top .die { border-color: var(--green); }
.die {
  width: 44px; height: 44px; background: #f4f1e8; border: 2px solid #888; border-radius: 6px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: 5px; gap: 2px; box-sizing: border-box;
}
.die i { border-radius: 50%; background: transparent; }
.die i.on { background: #20242c; }
.die.rolling { animation: die-shake .4s linear infinite; }
@keyframes die-shake {
  0% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
  100% { transform: rotate(0deg); }
}
.dice-wait { font-size: 12px; color: var(--dim); }

/* 手牌 */
.hand-area { margin-bottom: 12px; }
.hand-title { font-size: 12px; color: var(--dim); margin-bottom: 6px; letter-spacing: 2px; }
.hand { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.hand-card {
  cursor: default; text-align: center; position: relative;
  border: 2px solid transparent; border-radius: 8px; padding: 4px;
}
.hand-card .weapon-name { font-size: 12px; color: var(--dim); margin-top: 2px; }
.hand-card.playable { cursor: pointer; border-color: var(--gold); }
.hand-card.playable:hover { transform: translateY(-6px); background: #1d1d33; }
.hand-card.locked { opacity: .45; cursor: not-allowed; }
.hand-card.played { opacity: .3; }
.hand-card.selected { border-color: var(--cyan); background: #162433; }

/* 积分榜 */
.score-bar {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 10px; justify-content: center;
}
.score-chip {
  background: #1c1c30; border: 2px solid var(--line); border-radius: 6px;
  padding: 5px 10px; font-size: 12px; color: var(--dim);
}
.score-chip b { color: var(--gold); font-size: 15px; margin-left: 4px; }
.score-chip.me { border-color: var(--cyan); color: var(--text); }
.score-chip.top { border-color: var(--green); }

/* 聊天窗口（打牌记录上方） */
.chat-box {
  background: #0a0a14; border: 2px solid var(--line); border-radius: 6px;
  padding: 8px 10px; margin-bottom: 10px;
}
.chat-title { font-size: 11px; color: var(--dim); letter-spacing: 3px; text-align: center; margin-bottom: 6px; }
.chat-msg {
  max-height: 90px; overflow-y: auto; font-size: 12px; line-height: 1.6;
  margin-bottom: 6px; color: var(--dim);
}
.chat-line { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-line b { color: var(--gold); font-weight: 700; flex-shrink: 0; }
.chat-line span { color: #c7c9e0; word-break: break-all; }
.chat-line.mine b { color: var(--cyan); }
.chat-input-row { display: flex; gap: 6px; }
.chat-input-row input {
  flex: 1; min-width: 0; background: #12121f; color: #e7e9ff;
  border: 2px solid #2a2a44; border-radius: 4px; padding: 6px 8px; font-size: 13px; outline: none;
}
.chat-input-row input:focus { border-color: var(--gold); }

/* 消息 */
.msg-log {
  background: #0c0c16; border: 2px solid var(--line); border-radius: 6px;
  padding: 8px 10px; font-size: 12px; color: var(--dim);
  max-height: 120px; overflow-y: auto; margin-bottom: 10px; line-height: 1.6;
}
.msg-log .sys { color: var(--cyan); }
.msg-log .gold { color: var(--gold); }
.msg-log .red { color: var(--red); }

/* 对局结束 */
.game-end {
  background: #241f10; border: 3px solid var(--gold); border-radius: 8px;
  padding: 16px; text-align: center; margin-bottom: 12px;
}
.game-end #winnerText { font-size: 18px; color: var(--gold); font-weight: 700; margin-bottom: 12px; }
.end-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.game-foot { display: flex; gap: 8px; justify-content: flex-end; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--panel); border: 3px solid var(--gold); border-radius: 8px;
  padding: 24px; max-width: 320px; width: 90%; text-align: center;
}
.modal-box h3 { color: var(--gold); letter-spacing: 4px; margin-bottom: 10px; }
.modal-box p { font-size: 14px; margin-bottom: 12px; }
.reset-votes { font-size: 12px; color: var(--dim); margin-bottom: 14px; min-height: 20px; line-height: 1.7; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* ===== 二维码区 ===== */
.qr-section {
  max-width: 720px; margin: 0 auto; padding: 12px;
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
  border-top: 2px solid var(--line);
}
.qr-col { text-align: center; }
.qr-title { font-size: 11px; color: var(--dim); margin-bottom: 6px; letter-spacing: 2px; }
.qr-img { width: 96px; height: 96px; image-rendering: auto; border: 2px solid var(--line); border-radius: 6px; background: #fff; }

/* ===== 页脚备案 ===== */
#footer {
  text-align: center; padding: 14px 12px 22px;
  font-size: 11px; color: #55556e; border-top: 1px solid #1c1c30; margin-top: 8px;
}
#footer a { color: #55556e; text-decoration: none; }
#footer .notice { font-size: 10px; color: #3f3f58; margin-top: 6px; line-height: 1.6; max-width: 720px; margin-left: auto; margin-right: auto; }

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  .logo { font-size: 17px; }
  .px-card { width: 52px; height: 80px; background-size: 52px 80px; }
  .px-card.empty, .px-card.back { width: 52px; height: 80px; font-size: 12px; }
  .seat-card { min-height: 92px; }
  .seat-card img { width: 52px; height: 80px; }
  .table { grid-template-columns: 1fr 64px 1fr; }
  .die { width: 38px; height: 38px; }
}
