/* doudizhu — 鬥地主 */

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

/* ── HUD ───────────────────────────────────────────────── */
.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 12px auto;
  max-width: 640px;
}
.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: #34a853; }
.hud-value.lose { color: #ef5350; }
.hud-value.small { font-size: 14px; line-height: 26px; }
.hud-value.hud-pulse { animation: hud-pulse 0.5s ease; }
@keyframes hud-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); color: gold; }
  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;
}
.table.shake { animation: table-shake 0.4s ease; }
@keyframes table-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 2px); }
  40% { transform: translate(6px, -2px); }
  60% { transform: translate(-4px, 1px); }
  80% { transform: translate(4px, 0); }
}

.table-top {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.kitty { display: flex; align-items: center; gap: 8px; }
.mini-label { font-size: 12px; font-weight: 800; opacity: 0.85; }
.round-info { display: flex; gap: 8px; }
.info-chip {
  background: rgba(0,0,0,0.28);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
}
.info-chip b { color: #ffd54f; font-size: 16px; font-variant-numeric: tabular-nums; }
.info-chip.bump { animation: hud-pulse 0.5s ease; }

.table-mid {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(0, 1.6fr) minmax(120px, 1fr);
  gap: 8px;
  margin: 10px 0 4px;
  min-height: 190px;
}

/* ── AI seats ──────────────────────────────────────────── */
.seat.ai-seat {
  background: rgba(0,0,0,0.18);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-width: 0;
}
.seat.active { border-color: #ffd54f; box-shadow: 0 0 14px rgba(255,213,79,0.45); }
.seat-head { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.seat-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.seat-name { font-size: 13px; font-weight: 800; letter-spacing: 0.5px; }
.role-badge {
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.role-badge[hidden] { display: none; }
.role-badge.landlord { background: linear-gradient(135deg, #ffd700, #b8860b); color: #3a2500; box-shadow: 0 0 8px rgba(255,215,0,0.6); }
.role-badge.farmer { background: #66bb6a; color: #fff; }

.card-count { display: flex; align-items: center; gap: 6px; font-size: 18px; }
.back-icon {
  width: 18px; height: 26px;
  border-radius: 3px;
  background: repeating-linear-gradient(45deg, #1565c0, #1565c0 3px, #1976d2 3px, #1976d2 6px);
  border: 1px solid #0d47a1;
}
.count-num { font-variant-numeric: tabular-nums; }
.warn {
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: #e53935;
  border-radius: 999px;
  padding: 1px 8px;
  animation: warn-pulse 0.9s ease-in-out infinite alternate;
}
.warn[hidden] { display: none; }
@keyframes warn-pulse { from { opacity: 0.65; } to { opacity: 1; transform: scale(1.06); } }

.action-area {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.action-inner { display: flex; flex-direction: column; align-items: center; gap: 3px; max-width: 100%; }
.action-inner.pop { animation: banner-pop 0.3s cubic-bezier(.2,1.4,.5,1); }
.action-tag {
  font-size: 15px;
  font-weight: 900;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,0.3);
}
.action-tag.pass { color: #cfd8dc; }
.action-tag.bid  { color: #ffd54f; }
.pattern-tag {
  font-size: 12px;
  font-weight: 800;
  color: #fff3c4;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.pattern-tag.bomb {
  font-size: 18px;
  color: #ff7043;
  text-shadow: 0 0 10px rgba(255,112,67,0.9);
  animation: bomb-pop 0.5s ease;
}
@keyframes bomb-pop { 0% { transform: scale(0.4); } 60% { transform: scale(1.4); } 100% { transform: scale(1); } }

/* ── Center ────────────────────────────────────────────── */
.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 6px;
}
.status-line {
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  min-height: 20px;
  opacity: 0.92;
}
.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 {
  text-align: center;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: rgba(0,0,0,0.4);
  color: #fff;
  animation: banner-pop 0.35s cubic-bezier(.2,1.4,.5,1);
}
.result-banner[hidden] { display: none; }
.banner-head { font-size: 20px; font-weight: 900; }
.banner-sub  { font-size: 12px; opacity: 0.9; margin-top: 2px; }
.banner-delta { font-size: 22px; font-weight: 900; margin-top: 4px; font-variant-numeric: tabular-nums; }
.banner-delta.win  { color: #ffd54f; }
.banner-delta.lose { 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; }
}

/* ── Me ────────────────────────────────────────────────── */
.me-seat {
  border-top: 1px dashed rgba(255,255,255,0.25);
  padding-top: 6px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
}
.me-seat.active { border-color: rgba(255,213,79,0.6); }
.me-head { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 13px; }
.me-count { opacity: 0.8; font-size: 12px; }
.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 26px 4px 8px;
  min-height: 130px;
}

/* ── Cards ─────────────────────────────────────────────── */
.card-row { display: flex; justify-content: center; align-items: center; }
.card-row.mini { gap: 3px; }
.card-row.mini.played, .reveal-row { flex-wrap: wrap; row-gap: 4px; max-width: 100%; padding-left: 18px; }
.card-row.mini.played .card, .reveal-row .card { margin-left: -18px; }
.reveal-row[hidden] { display: none; }

.card {
  --rot: 0deg;
  --arc: 0px;
  width: 64px;
  height: 92px;
  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;
  transform: translateY(var(--arc)) rotate(var(--rot));
  transform-origin: 50% 120%;
  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(-18px) scale(0.9); }
}
.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: 16px; line-height: 1; display: flex; flex-direction: column; align-items: center; width: 1.2em; }
.card-suit-top { font-size: 13px; }
.card-suit-center {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}
.card.face-down {
  background: repeating-linear-gradient(45deg, #1565c0, #1565c0 4px, #1976d2 4px, #1976d2 8px);
  border-color: #0d47a1;
}

/* Jokers — drawn with CSS (no images in the deck) */
.card.joker {
  background: linear-gradient(160deg, #fffdf5, #fff3d6);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.joker-text {
  align-self: flex-start;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 9px;
  line-height: 1;
  letter-spacing: -2px;
  font-weight: 900;
  font-family: Georgia, "Times New Roman", serif;
}
.joker-icon {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-35%, -40%);
  font-size: 28px;
}
.card.joker.small .joker-icon { filter: grayscale(1) contrast(1.3); }
.card.joker.big { box-shadow: inset 0 0 0 2px rgba(211,47,47,0.35), -1px 1px 4px rgba(0,0,0,0.25); }

.card.mini { width: 38px; height: 54px; padding: 2px; border-radius: 5px; animation: none; transform: none; }
.card.mini .card-rank-top { font-size: 12px; }
.card.mini .card-suit-top { font-size: 10px; }
.card.mini .card-suit-center { font-size: 16px; }
.card.mini .joker-text { font-size: 7px; letter-spacing: -2.5px; }
.card.mini .joker-icon { font-size: 16px; }
.card.mini.flip-in { animation: card-flip 0.35s ease backwards; }

.card.pickable { cursor: pointer; }
.card.pickable:hover { 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(calc(var(--arc) - 20px)) rotate(var(--rot));
  box-shadow: 0 0 0 3px #ffb300, 0 6px 12px rgba(0,0,0,0.35);
}
.card.pickable.from-kitty::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:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hand.shake { animation: info-shake 0.3s ease; }

/* ── Controls ──────────────────────────────────────────── */
.controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 14px;
}
.controls[hidden] { display: none; }
.controls .btn { min-width: 92px; }
.controls .btn.primary {
  background: linear-gradient(180deg, #e74c3c, #c0392b);
  color: #fff;
  border: none;
  font-weight: 700;
  animation: ddz-glow 1.6s ease-in-out infinite alternate;
}
@keyframes ddz-glow {
  0%   { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
  100% { box-shadow: 0 0 18px 4px rgba(255, 215, 0, 0.6); }
}
.controls .btn.primary:disabled {
  background: var(--btn-disabled);
  color: rgba(255,255,255,0.6);
  cursor: not-allowed;
  animation: none;
}
.bid-btn[data-bid="3"]:not(:disabled) { background: linear-gradient(180deg, #ffb300, #e65100); color: #fff; }
.btn.shake { animation: info-shake 0.3s ease; }
@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; }
  .table-mid { grid-template-columns: 92px minmax(0, 1fr) 92px; gap: 4px; min-height: 170px; }
  .seat.ai-seat { padding: 6px 4px; }
  .seat-head { flex-direction: column; gap: 2px; }
  .seat-meta { align-items: center; }
  .avatar { width: 34px; height: 34px; font-size: 20px; }
  .card { width: 50px; height: 72px; padding: 3px; }
  .card-rank-top { font-size: 13px; }
  .card-suit-top { font-size: 11px; }
  .card-suit-center { font-size: 20px; }
  .joker-text { font-size: 8px; letter-spacing: -2.5px; }
  .joker-icon { font-size: 20px; }
  .card.mini { width: 30px; height: 43px; }
  .card.mini .card-rank-top { font-size: 10px; }
  .card.mini .card-suit-center { font-size: 13px; }
  .card.mini .joker-icon { font-size: 13px; }
  .card.mini .joker-text { font-size: 6px; }
  .card-row.mini.played, .reveal-row { padding-left: 17px; }
  .card-row.mini.played .card, .reveal-row .card { margin-left: -17px; }
  .hand { min-height: 104px; padding-top: 22px; }
  .hud-value { font-size: 18px; }
  .controls .btn { min-width: 74px; }
  .info-chip { padding: 3px 9px; font-size: 12px; }
}
@media (max-width: 380px) {
  .table-mid { grid-template-columns: 80px minmax(0, 1fr) 80px; }
  .card { width: 44px; height: 64px; }
  .card.mini { width: 26px; height: 38px; }
}

/* Light mode: accent-gold HUD numbers on white were ~1.7:1 contrast. Darken the active accent
   (works with every profile accent colour); :where() keeps specificity at .hud-value so
   win/lose-coloured values still override it. Dark mode keeps the bright accent. */
:where(body:not(.dark)) .hud-value { color: color-mix(in srgb, var(--accent) 55%, #000); }
