* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: #0f172a; color: #e2e8f0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}
.app { max-width: 1240px; margin: 0 auto; padding: 12px 16px 40px; }

header h1 { font-size: 22px; }
.subtitle { color: #94a3b8; font-size: 13px; margin-top: 2px; }

.controls-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 12px 0; font-size: 13px;
}
.controls-bar select {
  background: #1e293b; color: #e2e8f0; border: 1px solid #334155;
  border-radius: 4px; padding: 3px 6px; font-size: 13px;
}
.start-btn {
  background: #2563eb; color: #fff; border: none; border-radius: 6px;
  padding: 6px 16px; font-size: 14px; cursor: pointer;
}
.start-btn:hover { background: #1d4ed8; }
.ghost-btn {
  background: #1e293b; color: #cbd5e1; border: 1px solid #475569;
  border-radius: 6px; padding: 6px 14px; font-size: 14px; cursor: pointer;
}
.ghost-btn:hover { background: #334155; }
.laya-warning { color: #fbbf24; font-size: 13px; }

.level-bar {
  display: flex; gap: 18px; align-items: center;
  background: #1e293b; border: 1px solid #334155; border-radius: 8px;
  padding: 8px 14px; font-size: 14px; margin-bottom: 10px;
}
.wild-tag { color: #f87171; font-weight: 600; }
#team-levels { color: #94a3b8; margin-left: auto; }

/* ---------- 4-seat table ---------- */
.table-gd { display: flex; flex-direction: column; gap: 8px; }
.mid-row { display: flex; gap: 8px; align-items: stretch; }
.seat-gd {
  background: #16203a; border: 1px solid #2b3a55; border-radius: 10px;
  padding: 8px 12px;
}
.seat-top-gd { min-height: 96px; }
.seat-bottom-gd { min-height: 130px; }
.seat-side { width: 240px; flex-shrink: 0; }
.center-zone-gd {
  flex: 1; background: #132341; border: 1px dashed #2b3a55;
  border-radius: 10px; padding: 10px; min-height: 220px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}

.seat-head {
  display: flex; gap: 10px; align-items: center; font-size: 13px;
  margin-bottom: 6px; flex-wrap: wrap;
}
.seat-name { font-weight: 600; }
.badge { color: #a78bfa; font-size: 12px; }
.team-tag { font-size: 11px; font-weight: 600; }
.count-tag { color: #94a3b8; font-size: 12px; }
.fin-tag { color: #4ade80; font-size: 12px; font-weight: 700; }

/* ---------- cards ---------- */
.card {
  display: inline-flex; flex-direction: column; align-items: center;
  justify-content: center;
  width: 44px; height: 60px; background: #f8fafc; color: #0f172a;
  border: 1px solid #94a3b8; border-radius: 6px;
  font-weight: 700; user-select: none; cursor: default;
  margin-right: -14px; transition: transform .08s, margin-bottom .08s;
  position: relative; flex-shrink: 0;
}
.card:last-child { margin-right: 0; }
.card .rk { font-size: 15px; line-height: 1; }
.card .st { font-size: 14px; line-height: 1; }
.card.red { color: #dc2626; }
.card.joker { color: #7c3aed; font-size: 12px; }
.card.joker .rk { font-size: 12px; }
.card.back { background: repeating-linear-gradient(45deg, #1e40af, #1e40af 4px, #3b82f6 4px, #3b82f6 8px); border-color: #1d4ed8; }
.card.card-sm { width: 34px; height: 46px; margin-right: -16px; }
.card.card-sm .rk { font-size: 12px; }
.card.card-sm .st { font-size: 11px; }
.card-sm.joker .rk { font-size: 10px; }

.my-hand { display: flex; flex-wrap: wrap; padding: 4px 20px 4px 4px; min-height: 66px; }
.my-hand .card { cursor: pointer; margin-right: -10px; }
.my-hand .card:hover { transform: translateY(-4px); }
.my-hand .card.sel { transform: translateY(-12px); box-shadow: 0 4px 12px rgba(59,130,246,.5); border-color: #3b82f6; }

.opp-hand { display: flex; flex-wrap: wrap; padding-left: 4px; min-height: 48px; }
.side-hand { max-width: 220px; }

/* ---------- center played area ---------- */
.played-area-gd {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  width: 100%; flex: 1;
}
.played-slot {
  background: #0f1b33; border: 1px solid #24334d; border-radius: 8px;
  padding: 6px 8px; min-height: 64px;
}
.played-slot.active { border-color: #38bdf8; box-shadow: 0 0 8px rgba(56,189,248,.3); }
.played-label { font-size: 11px; color: #7dd3fc; min-height: 15px; }
.played-cards { display: flex; flex-wrap: wrap; padding-left: 4px; margin-top: 2px; }

.turn-hint { font-size: 13px; color: #fbbf24; min-height: 18px; text-align: center; }

.tribute-panel {
  background: #2a1a3a; border: 1px solid #7c3aed; border-radius: 8px;
  padding: 10px 14px; font-size: 13px; width: 100%; text-align: center;
}
.tribute-panel .action-bar { justify-content: center; margin-top: 8px; }

/* ---------- ai panel ---------- */
.ai-panel { font-size: 12px; color: #a5b4fc; min-height: 18px; }
.ai-thinking { color: #fbbf24; }
.ai-decision { color: #a5b4fc; }
.io-details summary { cursor: pointer; color: #7dd3fc; font-size: 11px; }
.io-pre {
  background: #0a1120; border: 1px solid #24334d; border-radius: 6px;
  padding: 8px; font-size: 10px; max-height: 260px; overflow: auto;
  white-space: pre-wrap; word-break: break-all; color: #94a3b8;
}

/* ---------- action bar ---------- */
.action-bar { margin-top: 8px; }
.action-bar > div { display: flex; gap: 8px; }
.action-bar button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- winner overlay ---------- */
.winner-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.winner-card {
  background: #1e293b; border: 1px solid #475569; border-radius: 12px;
  padding: 28px 36px; text-align: center; max-width: 520px;
}
#winner-text { font-size: 20px; font-weight: 700; }
.winner-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: center; }
.winner-actions a { text-decoration: none; display: inline-flex; align-items: center; }

footer .help { color: #64748b; font-size: 12px; margin-top: 14px; }

/* ---------- replay ---------- */
.replay-layout { display: flex; gap: 14px; margin-top: 12px; }
.file-list {
  width: 260px; flex-shrink: 0; max-height: 70vh; overflow-y: auto;
  background: #16203a; border: 1px solid #2b3a55; border-radius: 10px; padding: 6px;
}
.replay-item {
  padding: 8px 10px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.replay-item:hover { background: #1e293b; }
.replay-item.active { background: #1d3557; }
.replay-item .sub { color: #64748b; font-size: 11px; margin-top: 2px; }
.replay-main { flex: 1; }
.rp-controls { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.rp-controls input[type=range] { flex: 1; }
.rp-label { text-align: center; font-size: 13px; color: #fbbf24; min-height: 18px; margin-bottom: 8px; }
.rp-hands-gd { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rp-seat { background: #16203a; border: 1px solid #2b3a55; border-radius: 8px; padding: 8px; }
.rp-hand { display: flex; flex-wrap: wrap; padding-left: 4px; min-height: 46px; }
