/* paigow — 牌九 */

.app {
  max-width: 640px;
  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: #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: 12px;
  box-shadow: inset 0 0 24px rgba(0,0,0,0.35), var(--shadow-sm);
  margin-bottom: 12px;
}
.seat { padding: 6px 4px; }
.seat-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: #e8f5e9;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}
.hand-badge {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 800;
  background: rgba(255,255,255,0.9);
  color: #333;
}
.hand-badge[hidden] { display: none; }
.hand-badge.c2, .hand-badge.c3, .hand-badge.c4, .hand-badge.c5 { background: #1976d2; color: #fff; }
.hand-badge.c6 { background: linear-gradient(135deg, #ff7043, #e53935); color: #fff; }
.hand-badge.c7 { background: linear-gradient(135deg, #ffd700, #b8860b); color: #3a2500; box-shadow: 0 0 10px rgba(255,215,0,0.7); }

/* ── Dominoes (CSS pips) ───────────────────────────────── */
.tile-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  min-height: 150px;
  align-items: flex-end;
}
.tile-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; animation: tile-deal 0.3s ease backwards; }
.tile-name { font-size: 12px; font-weight: 700; color: #e8f5e9; white-space: nowrap; }
.tile {
  width: 62px;
  height: 124px;
  border-radius: 9px;
  background: linear-gradient(160deg, #fffdf5, #efe6cf);
  border: 1px solid #b9a77f;
  box-shadow: 0 3px 0 #c9b88f, 0 5px 10px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  position: relative;
  flex-shrink: 0;
  animation: tile-deal 0.3s ease backwards;
}
.tile-wrap .tile { animation: none; }
.tile::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; top: 50%;
  height: 2px;
  margin-top: -1px;
  background: #8b7a55;
  border-radius: 1px;
}
.tile-half {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 8px;
  place-items: center;
}
.tile-half .pip {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #1a1a1a;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.6);
}
.tile-half.red .pip { background: #d32f2f; }
.tile-half.p1 .pip { width: 17px; height: 17px; }
.tile.face-down {
  background: repeating-linear-gradient(45deg, #2e7d32, #2e7d32 5px, #1b5e20 5px, #1b5e20 10px);
  border-color: #0d3b12;
  box-shadow: 0 3px 0 #0d3b12, 0 5px 10px rgba(0,0,0,0.35);
}
.tile.face-down::after { display: none; }
.tile.ghost { opacity: 0.3; animation: none; }
.tile-wrap.flip-in { animation: tile-flip 0.3s ease backwards; }
@keyframes tile-deal {
  from { opacity: 0; transform: translateY(-18px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes tile-flip {
  from { transform: rotateY(90deg); }
  to   { transform: rotateY(0); }
}

/* ── Ranking reference ────────────────────────────────── */
.rank-ref {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  color: var(--text-strong);
  font-size: 13px;
}
.rank-ref summary { cursor: pointer; font-weight: 700; }
.rank-ref ol { margin: 8px 0 4px; padding-left: 26px; columns: 2; column-gap: 24px; }
.rank-ref li { break-inside: avoid; line-height: 1.7; }
.rank-ref li span { color: var(--text-muted); font-size: 12px; }

/* ── Result banner ─────────────────────────────────────── */
.result-banner {
  text-align: center;
  margin: 8px auto;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: rgba(0,0,0,0.35);
  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; opacity: 0.9; margin-top: 2px; }
.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; }
}

/* ── Betting ───────────────────────────────────────────── */
.bet-info {
  text-align: center;
  font-size: 15px;
  color: var(--text-strong);
  margin: 4px 0 8px;
}
.bet-info b { color: var(--accent); font-variant-numeric: tabular-nums; }
.bet-info.shake { animation: info-shake 0.3s ease; }
@keyframes info-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.chip-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 10px;
}
.chip-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px dashed #fff;
  background: radial-gradient(circle at 30% 30%, #f39c12, #b9770e);
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0,0,0,0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
}
.chip-btn[data-chip="50"]  { background: radial-gradient(circle at 30% 30%, #16a085, #0e6655); }
.chip-btn[data-chip="100"] { background: radial-gradient(circle at 30% 30%, #2980b9, #1b4f72); }
.chip-btn[data-chip="500"] { background: radial-gradient(circle at 30% 30%, #8e44ad, #5b2c6f); }
.chip-btn.allin {
  background: linear-gradient(135deg, #ffd700, #b8860b);
  color: #1a1a1a;
  font-size: 14px;
  border-style: solid;
  border-color: #fff5b8;
}
.chip-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 10px rgba(0,0,0,0.35); }
.chip-btn.active {
  transform: translateY(-3px) scale(1.08);
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ── Action buttons ────────────────────────────────────── */
.action-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 10px 0 14px;
}
.action-row .btn { min-width: 110px; }
.action-row .btn.primary {
  background: linear-gradient(180deg, #e74c3c, #c0392b);
  color: #fff;
  border: none;
  font-weight: 700;
  animation: pg-glow 1.6s ease-in-out infinite alternate;
}
@keyframes pg-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); }
}
.action-row .btn.primary:disabled {
  background: var(--btn-bg);
  color: var(--text-muted);
  cursor: not-allowed;
  animation: none;
}

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

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 520px) {
  .tile { width: 52px; height: 104px; }
  .tile-half { padding: 6px; }
  .tile-half .pip { width: 9px; height: 9px; }
  .tile-half.p1 .pip { width: 14px; height: 14px; }
  .tile-row { min-height: 128px; gap: 10px; }
  .chip-btn { width: 48px; height: 48px; font-size: 13px; }
  .hud-value { font-size: 18px; }
  .rank-ref ol { columns: 1; }
}

/* 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); }
