/* baccarat — 百家樂 */

.app {
  max-width: 720px;
  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.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); }
}
#last-result.win  { color: #2ecc71; }
#last-result.lose { color: #e74c3c; }

/* ── Table felt ────────────────────────────────────────── */
.table-felt {
  position: relative;
  background:
    radial-gradient(ellipse at center top, rgba(255,255,255,0.10), transparent 65%),
    linear-gradient(180deg, #1f7a46, #145a32);
  border: 3px solid #0e3f23;
  border-radius: var(--radius-lg);
  padding: 12px 12px 26px;
  margin-bottom: 14px;
  box-shadow: inset 0 2px 12px rgba(0,0,0,0.35), var(--shadow-md);
  color: #fff;
}
.hands {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.hand-area {
  border-radius: var(--radius-md);
  padding: 8px;
  min-height: 140px;
  border: 2px solid rgba(255,255,255,0.18);
}
.player-side { background: rgba(41, 128, 185, 0.22); border-color: rgba(93, 173, 226, 0.55); }
.banker-side { background: rgba(192, 57, 43, 0.22); border-color: rgba(236, 112, 99, 0.55); }
.hand-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.player-side .hand-label { color: #aed6f1; }
.banker-side .hand-label { color: #f5b7b1; }
.total-badge {
  min-width: 30px;
  text-align: center;
  background: rgba(0,0,0,0.45);
  color: #fff;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.total-badge.hud-pulse { animation: hud-pulse 0.4s ease; }
.total-badge.winner { background: gold; color: #3a2a00; box-shadow: 0 0 10px gold; }

/* ── Cards (blackjack-style: text fallback under local image) ── */
.card-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  min-height: 98px;
  align-items: flex-start;
}
.card {
  width: 66px;
  height: 94px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px;
  font-weight: 800;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(0,0,0,0.35);
  animation: card-deal 0.28s ease;
  user-select: none;
}
.card.third { margin-top: 10px; outline: 2px solid gold; outline-offset: 1px; }
.card.red   { color: #d32f2f; }
.card.black { color: #1a1a1a; }
.card-face-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: inherit;
  pointer-events: none;
}
.card-rank-top, .card-rank-bot { font-size: 15px; line-height: 1; }
.card-rank-bot { text-align: right; transform: rotate(180deg); }
.card-suit-center {
  font-size: 26px;
  line-height: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
@keyframes card-deal {
  from { opacity: 0; transform: translate(0, -24px) rotate(-8deg) scale(0.85); }
  to   { opacity: 1; transform: none; }
}

/* ── Result banner / shuffle notice / shoe info ─────────── */
.result-banner {
  margin: 10px auto 0;
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,0.45);
  animation: banner-in 0.35s cubic-bezier(.2,1.4,.5,1);
}
.result-banner[hidden] { display: none; }
.result-banner.banker { color: #ff8a80; box-shadow: 0 0 0 2px #e74c3c inset; }
.result-banner.player { color: #82b1ff; box-shadow: 0 0 0 2px #3498db inset; }
.result-banner.tie    { color: #b9f6ca; box-shadow: 0 0 0 2px #27ae60 inset; }
@keyframes banner-in {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}
.shuffle-notice {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 3px;
  background: rgba(0,0,0,0.6);
  border-radius: inherit;
  z-index: 5;
  animation: shuffle-blink 0.55s ease-in-out infinite alternate;
}
.shuffle-notice[hidden] { display: none; }
@keyframes shuffle-blink { from { opacity: 0.7; } to { opacity: 1; } }
.shoe-info {
  position: absolute;
  right: 12px;
  bottom: 5px;
  font-size: 11px;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

/* ── Chip selector (sicbo style) ───────────────────────── */
.chip-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 12px;
}
.chip-row.disabled { opacity: 0.55; pointer-events: none; }
.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[data-chip="1000"] { background: radial-gradient(circle at 30% 30%, #c0392b, #78281f); font-size: 14px; }
.chip-btn.allin {
  background: linear-gradient(135deg, #ffd700, #b8860b);
  color: #1a1a1a;
  font-size: 14px;
  letter-spacing: 1px;
  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;
}

/* ── Bet table ─────────────────────────────────────────── */
.bet-table { display: flex; flex-direction: column; gap: 6px; }
.bet-row { display: grid; gap: 6px; }
.bet-row.grid-2 { grid-template-columns: 1fr 1fr; }
.bet-row.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.bet-cell {
  position: relative;
  background: linear-gradient(180deg, #2e7d32, #1b5e20);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s ease, opacity 0.2s;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.bet-cell:hover { transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,0,0,0.25); }
.bet-cell.disabled { cursor: default; pointer-events: none; }
.bet-cell.main { min-height: 86px; }
.bet-cell.player { background: linear-gradient(180deg, #2471a3, #1a5276); }
.bet-cell.banker { background: linear-gradient(180deg, #c0392b, #922b21); }
.bet-cell.player-pair { background: linear-gradient(180deg, #1f618d, #154360); }
.bet-cell.banker-pair { background: linear-gradient(180deg, #a93226, #78281f); }
.bet-cell.tie { background: linear-gradient(180deg, #229954, #196f3d); }
.bet-cell.has-bet { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,255,255,0.2) inset; }
.bet-cell.win { border-color: gold; animation: win-pulse 0.7s ease-out; }
.bet-cell.lose { opacity: 0.5; }
.bet-cell.push { border-color: #bdc3c7; }
@keyframes win-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.8); }
  100% { box-shadow: 0 0 0 18px rgba(255, 215, 0, 0); }
}
.bet-label { font-size: 26px; font-weight: 900; letter-spacing: 4px; }
.bet-label.small { font-size: 17px; letter-spacing: 2px; }
.bet-pay { font-size: 11px; opacity: 0.85; margin-top: 2px; }
.bet-amt {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 11px;
  font-weight: 800;
  color: gold;
  background: rgba(0,0,0,0.55);
  border-radius: 8px;
  padding: 1px 6px;
  display: none;
  font-variant-numeric: tabular-nums;
}
.bet-amt.show { display: inline-block; }

/* Settlement label per bet (stays until the next bet/deal) */
.bet-float {
  position: absolute;
  left: 4px;
  bottom: 3px;
  font-size: 13px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(0,0,0,0.55);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  animation: float-in 0.45s cubic-bezier(.2,1.4,.5,1);
}
.bet-float.win  { color: gold; text-shadow: 0 0 6px rgba(255,215,0,0.7); }
.bet-float.lose { color: #ffcdd2; }
.bet-float.push { color: #ecf0f1; }
@keyframes float-in {
  from { opacity: 0; transform: translateY(8px) scale(0.6); }
  to   { opacity: 1; transform: none; }
}

/* ── Actions ───────────────────────────────────────────── */
.action-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 16px;
}
.action-row .btn { min-width: 104px; }
.action-row .btn.primary {
  background: linear-gradient(180deg, #e74c3c, #c0392b);
  color: #fff;
  border: none;
  font-weight: 700;
  animation: deal-glow 1.6s ease-in-out infinite alternate;
}
@keyframes deal-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;
  filter: grayscale(0.4);
  animation: none;
}

/* ── Big Road ──────────────────────────────────────────── */
.road-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 8px 10px 10px;
}
.road-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-strong);
}
.road-title { font-weight: 800; letter-spacing: 1px; }
.road-stats { display: flex; gap: 12px; font-variant-numeric: tabular-nums; }
.stat { display: inline-flex; align-items: center; gap: 4px; }
.stat i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 2px solid; }
.stat-b i { border-color: #e74c3c; }
.stat-p i { border-color: #2e86de; }
.stat-t i { border-color: #27ae60; background: #27ae60; }
.road-scroll { overflow-x: auto; overflow-y: hidden; }
.big-road {
  --cell: 20px;
  display: grid;
  grid-template-columns: repeat(var(--cols, 24), var(--cell));
  grid-template-rows: repeat(6, var(--cell));
  width: max-content;
  background-color: #fff;
  background-image:
    linear-gradient(to right, #d9d9d9 1px, transparent 1px),
    linear-gradient(to bottom, #d9d9d9 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  border-right: 1px solid #d9d9d9;
  border-bottom: 1px solid #d9d9d9;
}
.road-cell {
  position: relative;
  margin: 2px;
  border-radius: 50%;
  border: 3px solid transparent;
}
.road-cell.b { border-color: #e74c3c; }
.road-cell.p { border-color: #2e86de; }
.road-cell.has-tie::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: #27ae60;
  transform: translateX(-50%) rotate(45deg);
}
.tie-n {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 900;
  color: #1e8449;
}

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

/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 520px) {
  .card { width: 46px; height: 66px; padding: 3px; border-radius: 6px; }
  .card-row { gap: 3px; min-height: 70px; }
  .card-rank-top, .card-rank-bot { font-size: 11px; }
  .card-suit-center { font-size: 18px; }
  .hand-area { min-height: 112px; padding: 6px; }
  .result-banner { font-size: 16px; }
  .bet-label { font-size: 22px; }
  .bet-label.small { font-size: 15px; letter-spacing: 1px; }
  .chip-btn { width: 48px; height: 48px; font-size: 14px; }
  .big-road { --cell: 18px; }
}

/* keyboard focus for bet areas */
.bet-cell:focus-visible { outline: 3px solid #ffd54f; outline-offset: 2px; }

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

/* Big Road in dark mode: dark paper + subtle grid instead of a bright white block */
body.dark .big-road {
  background-color: #1e1a17;
  background-image:
    linear-gradient(to right, #3a332d 1px, transparent 1px),
    linear-gradient(to bottom, #3a332d 1px, transparent 1px);
  border-right-color: #3a332d;
  border-bottom-color: #3a332d;
}
body.dark .road-cell.b { border-color: #ff6b5e; }
body.dark .road-cell.p { border-color: #5aa9ff; }
