/* pickred — 撿紅點 */

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

/* ── HUD ───────────────────────────────────────────────── */
.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 12px auto;
  max-width: 600px;
}
.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);
  min-width: 0;
}
.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;
}

/* ── 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;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.seat {
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 6px;
  background: rgba(0,0,0,0.16);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.seat.active { border-color: #ffd54f; box-shadow: 0 0 14px rgba(255,213,79,0.4); }
.seat-head { display: flex; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.seat-name { font-size: 14px; font-weight: 800; }
.pts-chip {
  background: rgba(0,0,0,0.3);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
}
.pts-chip b { color: #ffd54f; font-size: 16px; font-variant-numeric: tabular-nums; }

.card-row { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px; }
.cpu-hand { gap: 3px; min-height: 54px; }

/* captured piles */
.pile { display: flex; align-items: center; gap: 8px; min-height: 46px; flex-wrap: wrap; justify-content: center; }
.pile-info { font-size: 12px; font-weight: 700; color: #c8e6c9; white-space: nowrap; }
.pile-row { display: flex; flex-wrap: wrap; padding-left: 16px; row-gap: 4px; max-width: 100%; }
.pile-row .card { margin-left: -16px; }

/* ── Center ────────────────────────────────────────────── */
.center {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "stock tablec" "status status" "banner banner";
  align-items: center;
  gap: 8px 12px;
  padding: 6px 0;
}
.stock-area { grid-area: stock; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.table-cards {
  grid-area: tablec;
  display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 8px;
  min-height: 100px;
  padding: 8px;
  border: 2px dashed rgba(255,255,255,0.18);
  border-radius: var(--radius-md);
}
.table-cards.shake { animation: info-shake 0.3s ease; }
.table-empty { font-size: 13px; color: #c8e6c9; align-self: center; }
.stock { position: relative; }
.stock .card { box-shadow: 2px 2px 0 #0d47a1, 4px 4px 0 #0b3c87, -1px 1px 4px rgba(0,0,0,0.3); animation: none; }
.stock.empty .card { visibility: hidden; }
.stock-count {
  position: absolute; right: -8px; bottom: -8px;
  min-width: 26px; height: 26px; padding: 0 4px;
  border-radius: 13px;
  background: #ffd54f; color: #3a2500;
  font-size: 13px; line-height: 26px; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.flip-slot { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 20px; }
.flip-tag { font-size: 11px; font-weight: 800; color: #fff3c4; white-space: nowrap; }

.status-line { grid-area: status; font-size: 14px; font-weight: 700; text-align: center; min-height: 20px; }
.status-line.mine { color: #ffd54f; }
.dots i { font-style: normal; animation: dot-blink 1.2s infinite; opacity: 0.2; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-blink { 30% { opacity: 1; } }

.result-banner {
  grid-area: banner;
  text-align: center;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: rgba(0,0,0,0.42);
  color: #fff;
  animation: banner-pop 0.35s cubic-bezier(.2,1.4,.5,1);
}
.result-banner[hidden] { display: none; }
.result-banner.win { box-shadow: 0 0 18px rgba(255,215,0,0.55); }
.banner-head { font-size: 20px; font-weight: 900; }
.banner-sub { font-size: 14px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.banner-delta { font-size: 20px; font-weight: 900; margin-top: 4px; }
.banner-delta.win { color: #ffd54f; }
.banner-delta.lose { color: #ff8a80; }
@keyframes banner-pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.hand { min-height: 96px; padding: 10px 4px 4px; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  width: 58px;
  height: 84px;
  border-radius: 7px;
  border: 1px solid #bbb;
  background: #fff;
  padding: 4px;
  font-weight: 800;
  box-shadow: -1px 1px 4px rgba(0,0,0,0.25);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: card-deal 0.25s ease backwards;
}
.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.92); } }
.card.flip-in { animation: card-flip 0.35s 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; display: flex; flex-direction: column; align-items: center; width: 1.2em; }
.card-suit-top { font-size: 12px; }
.card-suit-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 24px; }
.card.face-down {
  background: repeating-linear-gradient(45deg, #1565c0, #1565c0 4px, #1976d2 4px, #1976d2 8px);
  border-color: #0d47a1;
}
.card.mini { width: 34px; height: 49px; padding: 2px; border-radius: 5px; animation: none; }
.card.mini .card-rank-top { font-size: 11px; }
.card.mini .card-suit-top { font-size: 9px; }
.card.mini .card-suit-center { font-size: 14px; }

.card.pickable { cursor: pointer; }
.card.pickable.waiting { filter: brightness(0.82); cursor: default; }
.card.pickable.can-take::after {
  content: "";
  position: absolute; right: 3px; bottom: 3px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #ffb300; box-shadow: 0 0 4px #ffb300;
}
.card.pickable:hover:not(.waiting) { box-shadow: -1px 1px 4px rgba(0,0,0,0.25), 0 0 0 2px rgba(255,213,79,0.6); }
.card.pickable.selected { transform: translateY(-14px); box-shadow: 0 0 0 3px #ffb300, 0 6px 12px rgba(0,0,0,0.35); }
.table-cards .card.legal {
  cursor: pointer;
  box-shadow: 0 0 0 3px #ffeb3b, 0 0 16px 4px rgba(255,235,59,0.75);
  animation: legal-pulse 1s ease-in-out infinite alternate;
}
@keyframes legal-pulse { to { transform: translateY(-4px); } }
.card.just-placed { box-shadow: 0 0 0 2px rgba(255,255,255,0.75), -1px 1px 4px rgba(0,0,0,0.25); }
.card:focus-visible { outline: 3px solid #ffeb3b; outline-offset: 2px; }

/* ── Controls ──────────────────────────────────────────── */
.controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 10px 0 14px; }
.controls[hidden] { display: none; }
.controls .btn { min-width: 110px; }
.controls .btn.primary { background: linear-gradient(180deg, #e74c3c, #c0392b); color: #fff; border: none; font-weight: 700; }
@keyframes info-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.legend { font-size: 12px; color: var(--text-muted); text-align: center; line-height: 1.6; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 640px) {
  .table { padding: 8px 6px; }
  .card { width: 46px; height: 66px; padding: 3px; }
  .card-rank-top { font-size: 12px; }
  .card-suit-top { font-size: 10px; }
  .card-suit-center { font-size: 18px; }
  .card.mini { width: 28px; height: 40px; }
  .card.mini .card-rank-top { font-size: 9px; }
  .card.mini .card-suit-center { font-size: 12px; }
  .pile-row { padding-left: 14px; }
  .pile-row .card { margin-left: -14px; }
  .table-cards { gap: 5px; padding: 5px; min-height: 80px; }
  .center { gap: 6px 8px; }
  .hud-value { font-size: 18px; }
  .card-row { gap: 4px; }
  .hand { min-height: 80px; }
}

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

/* the hand box only takes (script) focus while it is momentarily empty */
.hand:focus { outline: none; }
