/* ========== 基础 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #123524 radial-gradient(ellipse at 50% -20%, #1d5c3c 0%, #0e2b1c 55%, #081b12 100%);
  color: #eef6ef;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ========== 大厅 ========== */
.hall-body { display: flex; align-items: center; justify-content: center; padding: 30px 16px; }
.hall-box { width: 640px; max-width: 100%; }
.hall-title { font-size: 34px; text-align: center; margin-bottom: 6px; letter-spacing: 2px; }
.hall-sub { text-align: center; color: #9fd8b8; margin-bottom: 26px; font-size: 14px; }

.name-row { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 14px 18px; margin-bottom: 12px; }
.name-row label { font-size: 15px; color: #c9e8d6; white-space: nowrap; }
.name-row input { flex: 1; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.18); color: #fff; border-radius: 8px; padding: 10px 12px; font-size: 15px; outline: none; }
.name-row input:focus { border-color: #34c98f; }

.room-list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.room-card { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14); border-radius: 14px; padding: 18px; text-align: center; }
.room-name { font-size: 20px; font-weight: bold; margin-bottom: 8px; }
.room-info { color: #9fd8b8; font-size: 13px; min-height: 20px; margin-bottom: 14px; }
.btn-enter {
  width: 100%; padding: 11px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, #27ae60, #1e8c4c); color: #fff; font-size: 15px; font-weight: bold; cursor: pointer;
}
.btn-enter:hover { filter: brightness(1.1); }
.my-coins { text-align: center; color: #ffd76a; font-size: 15px; margin: 0 0 14px; font-weight: bold; }
.coins-row { margin: 0 0 20px; }
.coins-row .btn-enter { width: 100%; }
.admin-link { text-align: center; margin-top: 8px; font-size: 13px; }
.admin-link a { color: #7fb9ff; text-decoration: none; }
.admin-link a:hover { text-decoration: underline; }

/* ========== 登录 / 注册 ========== */
.login-box { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 18px 20px; margin-bottom: 22px; }
.login-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.login-row label { width: 70px; font-size: 15px; color: #c9e8d6; white-space: nowrap; text-align: right; }
.login-row input { flex: 1; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.18); color: #fff; border-radius: 8px; padding: 10px 12px; font-size: 15px; outline: none; }
.login-row input:focus { border-color: #34c98f; }
.login-actions { display: flex; gap: 12px; margin-top: 16px; }
.login-actions .btn-enter { flex: 1; }
.btn-ghost {
  flex: 1; display: inline-flex; align-items: center; justify-content: center;
  padding: 11px; border: 1px solid rgba(255,255,255,.3); border-radius: 10px;
  background: transparent; color: #cfe9dc; font-size: 15px; cursor: pointer; text-decoration: none;
}
.btn-ghost:hover { background: rgba(255,255,255,.08); }
.login-msg { text-align: center; color: #ffb4a2; font-size: 14px; margin-top: 12px; }
.user-box { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 16px 20px; margin-bottom: 22px; text-align: center; }
.user-line { font-size: 16px; margin-bottom: 6px; }
.user-account { color: #9fd8b8; font-size: 13px; }
.user-coins { color: #ffd76a; }
.user-box .btn-ghost { width: 120px; margin-top: 8px; }
.register-box { padding-bottom: 30px; }
.reg-warn { text-align: center; color: #ffb4a2; font-size: 13px; margin: -14px 0 22px; }

.hall-rule { background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.1); border-radius: 14px; padding: 18px 22px; }
.hall-rule h3 { font-size: 16px; margin-bottom: 10px; color: #ffe9a8; }
.hall-rule ul { padding-left: 20px; font-size: 13.5px; line-height: 1.9; color: #cfe7da; }

/* ========== 对局 ========== */
.game-body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 10px 18px; background: rgba(0,0,0,.35); border-bottom: 1px solid rgba(255,255,255,.1);
}
.top-left { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.room-tag { background: #27ae60; padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: bold; }
#myName { font-size: 14px; color: #dfeee5; }

.scoreboard { display: flex; align-items: center; gap: 12px; }
.team { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.08); border-radius: 20px; padding: 5px 14px; font-size: 14px; }
.team-name { font-weight: bold; }
.team-a .team-name { color: #ff7b72; }
.team-b .team-name { color: #7cb3ff; }
.team-score { font-size: 18px; font-weight: bold; }
.vs { color: #888; font-size: 13px; }
.show-card-box { font-size: 13px; color: #ffe9a8; background: rgba(255,255,255,.08); border-radius: 20px; padding: 5px 12px; }
#showCard { font-weight: bold; font-size: 15px; }

.top-right { display: flex; align-items: center; gap: 10px; min-width: 150px; justify-content: flex-end; }
.status { font-size: 13px; color: #9fd8b8; }

.btn {
  border: none; border-radius: 8px; padding: 6px 16px; font-size: 13px; font-weight: bold; cursor: pointer; color: #fff;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-play { background: linear-gradient(135deg, #f39c12, #e67e22); }
.btn-pass { background: linear-gradient(135deg, #95a5a6, #7f8c8d); }
.btn-auto { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.btn-auto.auto-on { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.btn-leave { background: rgba(255,255,255,.12); font-size: 13px; padding: 8px 16px; }
.btn-four { background: linear-gradient(135deg, #e74c3c, #c0392b); font-size: 14px; padding: 8px 16px; }
.btn-fs { background: rgba(255,255,255,.15); font-size: 13px; padding: 6px 12px; }

/* ========== 对局桌面 ========== */
.table-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 12px; min-height: 0; }
.table-grid {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  grid-template-rows: 1fr 1.2fr 1fr;
  gap: 10px;
  width: 920px; max-width: 96vw; height: 100%;
}

.seat-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px; position: relative;
}
.seat-box.turn { box-shadow: 0 0 18px rgba(241,196,15,.4); }
.seat-box.me { box-shadow: 0 0 12px rgba(52,201,143,.3); }
.seat-name { font-size: 14px; font-weight: bold; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.seat-cards { font-size: 12px; color: #ffe9a8; background: rgba(0,0,0,.45); border-radius: 10px; padding: 1px 9px; margin-top: 2px; }
.seat-auto { font-size: 12px; color: #7fffc4; margin-top: 2px; }
.seat-cards.single-left { color: #ff5a5a; font-weight: bold; background: rgba(255,60,60,.25); border: 1px solid rgba(255,90,90,.7); border-radius: 10px; padding: 1px 9px; margin-top: 2px; animation: pulse 1s ease infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
.seat-role { font-size: 12px; font-weight: bold; color: #fff3c4; margin-top: 2px; }

.seat-top { grid-column: 2; grid-row: 1; }
.seat-left { grid-column: 1; grid-row: 2; }
.center-box { grid-column: 2; grid-row: 2; display: flex; align-items: center; justify-content: center; text-align: center; position: relative; }
.seat-right { grid-column: 3; grid-row: 2; }
.seat-bottom { grid-column: 2; grid-row: 3; }

.center-info { font-size: 16px; color: #ffe9a8; line-height: 1.6; padding: 8px; }

/* 出牌倒计时 */
.countdown {
  font-size: 42px; font-weight: bold; color: #f1c40f;
  text-shadow: 0 2px 10px rgba(0,0,0,.6); margin-top: 2px; line-height: 1;
}
.countdown.mine { color: #ff6b57; font-size: 52px; }

/* 中央轮次箭头：指向当前该出牌的玩家方向（上▲ 下▼ 左◀ 右▶） */
.turn-arrow { position: absolute; font-size: 44px; color: #f1c40f; font-weight: bold; line-height: 1; text-shadow: 0 0 16px rgba(241,196,15,.95); animation: pulse .7s ease infinite; z-index: 6; pointer-events: none; }
.turn-arrow.hidden { display: none; }
.turn-arrow.dir-0 { bottom: 6px; left: 50%; transform: translateX(-50%); }
.turn-arrow.dir-1 { left: 8px; top: 50%; transform: translateY(-50%); }
.turn-arrow.dir-2 { top: 6px; left: 50%; transform: translateX(-50%); }
.turn-arrow.dir-3 { right: 8px; top: 50%; transform: translateY(-50%); }

/* 座位出牌区：谁出的牌显示在谁座位处；多张牌重叠露出数字 */
.played-zone { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0; margin-top: 4px; min-height: 26px; }
/* 出牌区多张牌重叠：后一张盖住前一张（露出角标数字可识别） */
.played-zone .card.small + .card.small { margin-left: -26px; }
/* 只显示角标数字与花色，中央大花色不显示 */
.played-zone .card.small .card-center { display: none; }
.type-tag { flex-basis: 100%; text-align: center; font-size: 11px; color: #f1c40f; background: rgba(0,0,0,.35); border-radius: 6px; padding: 1px 7px; margin: 0 0 2px; }
.pass-tag { font-size: 14px; color: #aaa; font-style: italic; }

/* ========== 手牌区（扇形平铺，全部可见） ========== */
.action-bar {
  background: rgba(0,0,0,.4); border-top: 1px solid rgba(255,255,255,.1);
  padding: 8px 12px 10px; display: flex; flex-direction: column; gap: 4px;
}
.hand-wrap {
  position: relative;
  width: 100%;
  padding: 0 8px 0;
  min-height: 100px;
}
.hand-wrap .card {
  position: absolute;
  bottom: 4px;
  width: 62px;
  height: auto;
  aspect-ratio: 62 / 90;
  margin: 0;
  transform: translateY(0);
}
.hand-wrap .card:hover { transform: translateY(-10px); }
/* 选中的牌弹出半个头（层级由 JS 控制：左在下、右在上） */
.hand-wrap .card.selected { transform: translateY(-30px); box-shadow: 0 6px 14px rgba(241,196,15,.55); border-color: #f1c40f; }
.btn-row { display: flex; justify-content: center; gap: 12px; }

/* ========== 扑克牌（标准牌面：角标+中央花色） ========== */
.card {
  width: 62px; height: 90px; background: #fdfdf8; border-radius: 8px;
  font-weight: bold; cursor: pointer; user-select: none; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.5); border: 1px solid #d8d8cf;
  transition: transform .12s ease, box-shadow .12s ease;
  position: relative;
}
.card.red { color: #d03a3a; }
.card.black { color: #222; }
/* 王：角标 JOKER（横排，左上/右下镜像），中央竖排 JOKER */
.card > .card-rank { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: clamp(16px, 3vw, 28px); }
.card > .card-rank.joker { flex-direction: row; font-size: var(--card-joker, 24px); line-height: 1; letter-spacing: 1px; }
/* 角标：左上 与 右下（镜像），数字/花色按牌宽放大 */
.card .card-corner { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.card .card-corner .cr { font-size: var(--card-fs, 19px); font-weight: bold; }
.card .card-corner .cs { font-size: var(--card-cs, 15px); }
.card .card-corner.tl { top: 5px; left: 6px; }
.card .card-corner.br { bottom: 5px; right: 6px; transform: rotate(180deg); }
.card .card-corner.joker-corner { flex-direction: column; }
.card .card-corner .cr.joker-txt { font-size: calc(var(--card-fs, 19px) * 0.62); line-height: 1.02; }
/* 中央大花色 */
.card .card-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: var(--card-center, 34px); }
/* 王牌中央：四个花色竖排、居中、比中央大花色小一号 */
.card .card-center.joker-suits { flex-direction: column; font-size: calc(var(--card-center, 34px) * 0.55); line-height: 1.02; }
.card.small { width: 42px; height: 62px; cursor: default; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.card.small .card-corner.tl { top: 3px; left: 4px; }
.card.small .card-corner.br { bottom: 3px; right: 4px; }
.card.small .card-corner .cr { font-size: 12px; }
.card.small .card-corner .cs { font-size: 10px; }
.card.small .card-center { font-size: 17px; }
.card.small .card-rank.joker { font-size: 12px; line-height: 1.05; }
/* 发牌动画：一张张抓牌（新牌从上方落下） */
.hand-wrap .card.dealt { animation: dealIn .35s ease; }
@keyframes dealIn {
  from { transform: translateY(-46px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ========== 结算弹窗 ========== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.62); display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  background: #0e2b1c; border: 1px solid rgba(255,255,255,.18); border-radius: 18px;
  padding: 30px 40px; text-align: center; max-width: 420px; width: 92%;
}
.modal-box h2 { font-size: 24px; margin-bottom: 14px; }
.end-detail { font-size: 15px; line-height: 2; color: #d5e9dd; margin-bottom: 20px; }

/* ========== Toast ========== */
.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: rgba(20,20,20,.92); color: #fff; padding: 10px 22px; border-radius: 24px;
  font-size: 14px; z-index: 200; border: 1px solid rgba(255,255,255,.15);
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
