/* thirteen — 十三支 */

.app {
  max-width: 820px;
  padding-bottom: 32px;
}

/* ── HUD ───────────────────────────────────────────────── */
.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}
.hud-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.hud-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.5px; }
.hud-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-value.win  { color: #2e7d32; }
.hud-value.lose { color: #d32f2f; }
body.dark .hud-value.win  { color: #69f0ae; }
body.dark .hud-value.lose { color: #ff8a80; }
.hud-value.hud-pulse { animation: hud-pulse 0.5s ease; }
@keyframes hud-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ── Table ─────────────────────────────────────────────── */
.table {
  background:
    radial-gradient(ellipse at center, rgba(255,255,255,0.08), transparent 70%),
    linear-gradient(180deg, #1e6b45, #14512f);
  border: 3px solid #8b5a2b;
  border-radius: var(--radius-lg);
  padding: 10px;
  box-shadow: inset 0 0 24px rgba(0,0,0,0.35), var(--shadow-sm);
  margin-bottom: 12px;
  color: #e8f5e9;
}

/* Opponents */
.opponents {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.opp {
  background: rgba(0,0,0,0.22);
  border-radius: var(--radius-md);
  padding: 6px;
  min-width: 0;
  transition: box-shadow 0.2s ease;
}
.opp.shot { box-shadow: 0 0 0 2px #ffd54f; }
.opp.shooter { box-shadow: 0 0 0 2px #ff8a80; }
.opp-head {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 4px;
  min-width: 0;
}
.opp-head .avatar { font-size: 16px; }
.opp-head .seat-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opp-score {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  border-radius: 999px;
  padding: 0 7px;
  font-size: 13px;
}
.opp-score:empty { display: none; }
.opp-score.pos, .row-tag.pos { background: #1b5e20; color: #fff; }
.opp-score.neg, .row-tag.neg { background: #b71c1c; color: #fff; }
.opp-score:not(.pos):not(.neg), .row-tag.zero { background: #455a64; color: #fff; }
.opp-special {
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  color: #3a2500;
  background: linear-gradient(135deg, #ffd700, #e0a800);
  border-radius: 6px;
  margin-bottom: 4px;
  padding: 1px 4px;
}
.opp-special[hidden] { display: none; }
.opp-special.foul { background: #c62828; color: #fff; }
.opp-rows { display: flex; flex-direction: column; gap: 3px; }
.opp-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 50px;
  border-radius: 6px;
  padding: 1px 2px;
  transition: background 0.2s ease;
}
.opp-row.active, .row-slot.active { background: rgba(255, 213, 79, 0.25); }
.mini-cards { display: flex; flex-shrink: 0; }
.mini-cards .card + .card { margin-left: -14px; }
.mini-name {
  font-size: 11px;
  color: #c8e6c9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.row-tag {
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  flex-shrink: 0;
}
.row-tag:empty { display: none; }
.row-tag.pop { animation: tag-pop 0.35s cubic-bezier(.2,1.4,.5,1); }
@keyframes tag-pop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Status + banner */
.status-line {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  min-height: 20px;
  margin: 8px 0 4px;
  color: #e8f5e9;
}
.status-line.flash { animation: info-shake 0.3s ease; color: #ffe082; }
@keyframes info-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.result-banner {
  text-align: center;
  margin: 8px auto 0;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: rgba(0,0,0,0.38);
  color: #fff;
  animation: banner-pop 0.35s cubic-bezier(.2,1.4,.5,1);
}
.result-banner[hidden] { display: none; }
.banner-head { font-size: 22px; font-weight: 900; }
.banner-sub  { font-size: 13px; margin-top: 2px; color: #e0f2f1; }
.result-banner.win  .banner-head { color: #ffd54f; }
.result-banner.lose .banner-head { color: #ff8a80; }
.result-banner.big { box-shadow: 0 0 18px rgba(255,215,0,0.6); }
@keyframes banner-pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Your rows */
.my-rows { display: flex; flex-direction: column; gap: 6px; }
.row-slot {
  background: rgba(0,0,0,0.2);
  border: 2px dashed rgba(255,255,255,0.28);
  border-radius: var(--radius-md);
  padding: 4px 8px 6px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.row-slot.editable { cursor: pointer; }
.row-slot.full { border-style: solid; }
.row-slot.target, .row-slot.drag-over { border-color: #ffd54f; }
.row-slot.drag-over, .hand-zone.drag-over { background: rgba(255,213,79,0.18); }
.row-slot:focus-visible, .hand-zone:focus-visible { outline: 3px solid #ffd54f; outline-offset: 2px; }
.row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  min-height: 20px;
  margin-bottom: 3px;
}
.row-hand {
  font-size: 12px;
  background: rgba(255,255,255,0.9);
  color: #263238;
  border-radius: 999px;
  padding: 0 8px;
}
.row-hand:empty { display: none; }
.row-cards { display: flex; gap: 5px; min-height: 80px; align-items: center; }
.slot {
  width: 54px;
  height: 78px;
  border-radius: 8px;
  border: 2px dashed rgba(255,255,255,0.22);
  flex-shrink: 0;
}

.validity {
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  margin: 8px 0;
  padding: 4px 8px;
  border-radius: 999px;
  color: #e8f5e9;
}
.validity.ok   { background: rgba(27,94,32,0.75); color: #fff; }
.validity.foul { background: #c62828; color: #fff; animation: info-shake 0.3s ease; }

.hand-zone {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  min-height: 88px;
  padding: 6px;
  border-radius: var(--radius-md);
  background: rgba(0,0,0,0.15);
  cursor: pointer;
}
.hand-zone[hidden] { display: none; }
.hand-zone.empty { align-items: center; }
.hand-zone.empty::before {
  content: attr(data-empty);
  font-size: 13px;
  color: #c8e6c9;
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
  width: 54px;
  height: 78px;
  border-radius: 7px;
  border: 1px solid #ccc;
  background: #fff;
  display: flex;
  flex-direction: column;
  padding: 4px;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  animation: card-deal 0.25s ease backwards;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card-face-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: inherit;
  pointer-events: none;
}
@keyframes card-deal {
  from { opacity: 0; transform: translateY(-14px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.card.flip-in { animation: card-flip 0.3s ease backwards; }
@keyframes card-flip { from { transform: rotateY(90deg); } to { transform: rotateY(0); } }
.card.red   { color: #d32f2f; }
.card.black { color: #1a1a1a; }
.card-rank-top { font-size: 15px; line-height: 1; }
.card-suit-center { font-size: 24px; line-height: 1; flex: 1; display: flex; align-items: center; justify-content: center; }
.card.face-down {
  background: repeating-linear-gradient(45deg, #1565c0, #1565c0 4px, #1976d2 4px, #1976d2 8px);
  border-color: #0d47a1;
  color: transparent;
}
.card.mini { width: 32px; height: 46px; padding: 2px; border-radius: 4px; animation: none; }
.card.mini.flip-in { animation: card-flip 0.3s ease backwards; }
.card.mini .card-rank-top { font-size: 11px; }
.card.mini .card-suit-center { font-size: 13px; }

.card.pickable { cursor: grab; }
.card.pickable:hover { transform: translateY(-3px); }
.card.pickable.selected {
  transform: translateY(-8px);
  box-shadow: 0 0 0 3px #ffb300, 0 6px 12px rgba(0,0,0,0.35);
}
.card.pickable:focus-visible { outline: 3px solid #ffd54f; outline-offset: 2px; }

/* ── Special prompt ────────────────────────────────────── */
.special-prompt {
  background: linear-gradient(135deg, #fff8e1, #ffecb3);
  border: 2px solid #ffb300;
  color: #3e2723;
  border-radius: var(--radius-md);
  padding: 10px 12px 2px;
  margin-bottom: 8px;
  text-align: center;
  font-weight: 700;
}
body.dark .special-prompt { background: #3e2f00; color: #ffecb3; border-color: #ffca28; }
.special-prompt[hidden] { display: none; }

/* ── Buttons ───────────────────────────────────────────── */
.action-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 14px;
}
.action-row[hidden] { display: none; }
.action-row .btn { min-width: 104px; }
.action-row .btn.primary {
  background: linear-gradient(180deg, #e74c3c, #c0392b);
  color: #fff;
  border: none;
  font-weight: 700;
}
.action-row .btn.primary.danger { background: linear-gradient(180deg, #8e24aa, #6a1b9a); }
.action-row .btn:disabled, .action-row .btn.primary:disabled {
  background: var(--btn-bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ── Points table ──────────────────────────────────────── */
.points-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  animation: banner-pop 0.35s ease;
}
.points-wrap[hidden] { display: none; }
.points-title { margin: 0 0 6px; font-size: 15px; color: var(--text-strong); }
.points-scroll { overflow-x: auto; }
.points {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--text-strong);
}
.points th, .points td {
  border: 1px solid var(--border);
  padding: 4px 4px;
  text-align: center;
  vertical-align: middle;
}
.points th small, .points td small { display: block; font-size: 10px; font-weight: 600; color: var(--text-muted); }
.points th small.foul { color: #c62828; }
.points tr.me th, .points tr.me td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.points td.self { color: var(--text-muted); }
.points td.pos b { color: #2e7d32; }
.points td.neg b { color: #c62828; }
body.dark .points td.pos b { color: #69f0ae; }
body.dark .points td.neg b { color: #ff8a80; }
body.dark .points th small.foul { color: #ff8a80; }
.points .mark {
  display: inline-block;
  font-size: 10px;
  margin-left: 2px;
  padding: 0 3px;
  border-radius: 3px;
  background: #f9a825;
  color: #2b1d00;
  vertical-align: 1px;
}
.points .mark.hr { background: #6a1b9a; color: #fff; }
.points-note { font-size: 11px; color: var(--text-muted); margin: 6px 0 0; }

.legend { font-size: 12px; color: var(--text-muted); text-align: center; line-height: 1.6; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 620px) {
  .mini-name { display: none; }
  .card.mini { width: 24px; height: 35px; padding: 1px 2px; }
  .mini-cards .card + .card { margin-left: -9px; }
  .card.mini .card-rank-top { font-size: 9px; }
  .card.mini .card-suit-center { font-size: 10px; }
  .opp-row { min-height: 37px; gap: 2px; }
  .opponents { gap: 5px; }
  .opp { padding: 4px; }
  .opp-head { font-size: 12px; }
  .opp-head .avatar { display: none; }
}
@media (max-width: 520px) {
  .table { padding: 7px; }
  .card { width: 44px; height: 63px; padding: 3px; }
  .card-rank-top { font-size: 13px; }
  .card-suit-center { font-size: 18px; }
  .slot { width: 44px; height: 63px; }
  .row-cards { gap: 4px; min-height: 64px; }
  .hand-zone { gap: 4px; padding: 4px; min-height: 72px; }
  .hud-value { font-size: 18px; }
  .banner-head { font-size: 18px; }
  .points { font-size: 12px; }
  .action-row .btn { min-width: 92px; }
}

:where(body:not(.dark)) .hud-value { color: color-mix(in srgb, var(--accent) 55%, #000); }
