/* blackjack — 21點 */

.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);
  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;
  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); }
}

/* ── 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: 10px 12px 24px;
  margin-bottom: 14px;
  box-shadow: inset 0 2px 12px rgba(0,0,0,0.35), var(--shadow-md);
  color: #fff;
  overflow: hidden;
}
.felt-rules {
  text-align: center;
  font-size: 11px;
  letter-spacing: 1px;
  color: rgba(255, 236, 170, 0.85);
  margin-bottom: 6px;
}
.dealer-area, .player-area { min-height: 132px; }
.hand-label, .hand-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 2px;
  margin-bottom: 6px;
  color: #e8f5e9;
  min-height: 24px;
}
.hand-no { font-size: 12px; letter-spacing: 1px; opacity: 0.9; }
.total-badge {
  min-width: 30px;
  text-align: center;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.total-badge[hidden] { display: none; }
.total-badge:empty { display: none; }
.total-badge.bust { background: #c62828; }
.total-badge.good { background: #1565c0; }
.total-badge.bj   { background: linear-gradient(135deg, #ffd700, #b8860b); color: #3a2500; box-shadow: 0 0 10px rgba(255,215,0,0.7); }

/* ── Cards (local images over a text fallback) ─────────── */
.card-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 98px;
}
.card {
  --w: 66px;
  width: var(--w);
  height: calc(var(--w) * 1.42);
  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: -2px 3px 8px rgba(0,0,0,0.35);
  user-select: none;
}
.card + .card { margin-left: calc(var(--w) * -0.5); }
.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; }
.card-back {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.18) 0 4px, transparent 4px 8px),
    linear-gradient(135deg, #8e1b1b, #5a0f0f);
  border: 3px solid #fff;
}
.card.face-down { padding: 0; border-color: #fff; }
.card.sideways { margin-top: 10px; outline: 2px solid gold; outline-offset: 1px; }

/* deal: slide in from the shoe (top right); flip: hole card turns over */
.card.deal-in { animation: card-deal 0.38s cubic-bezier(.2,.8,.3,1) var(--d, 0ms) backwards; }
@keyframes card-deal {
  from { opacity: 0; transform: translate(160px, -120px) rotate(18deg) scale(0.7); }
  to   { opacity: 1; transform: none; }
}
.card.flip-in { animation: card-flip 0.46s ease var(--d, 0ms) both; }
.card.flip-in > .card-back { animation: back-hide 0.46s linear var(--d, 0ms) both; }
@keyframes card-flip {
  0%   { transform: scaleX(1); }
  50%  { transform: scaleX(0.02); }
  100% { transform: scaleX(1); }
}
@keyframes back-hide {
  0%, 49%  { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ── Player hands ──────────────────────────────────────── */
.hands {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.hand-box {
  border-radius: var(--radius-md);
  padding: 6px 8px 8px;
  border: 2px solid transparent;
  transition: border-color 0.2s, background 0.2s, opacity 0.2s;
  min-width: 0;
}
.hands.multi .hand-box { border-color: rgba(255,255,255,0.15); flex: 0 1 160px; }
.hand-box.active { border-color: gold; background: rgba(255, 215, 0, 0.10); box-shadow: 0 0 14px rgba(255,215,0,0.35); }
.hands.multi .card { --w: 54px; padding: 4px; }
.hands.multi .card + .card { margin-left: calc(var(--w) * -0.62); }
.hands.multi .card-rank-top, .hands.multi .card-rank-bot { font-size: 13px; }
.hands.multi .card-suit-center { font-size: 20px; }
.hands.multi .card-row { min-height: 80px; }
.hand-box.res-lose .card-row { opacity: 0.6; }
.hand-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  min-height: 30px;
  flex-wrap: wrap;
}
.hand-bet, .bet-circle-amt, .fly-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: 999px;
  border: 3px dashed #fff;
  background: radial-gradient(circle at 30% 30%, #f39c12, #b9770e);
  color: #fff;
  font-weight: 900;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}
.hand-tag {
  font-size: 11px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 215, 0, 0.9);
  color: #3a2500;
}
.hand-result {
  font-size: 13px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(0,0,0,0.55);
  animation: float-in 0.45s cubic-bezier(.2,1.4,.5,1);
  white-space: nowrap;
}
.hand-result[hidden] { display: none; }
.hand-result.win  { color: gold; }
.hand-result.lose { color: #ffcdd2; }
.hand-result.push { color: #ecf0f1; }
@keyframes float-in {
  from { opacity: 0; transform: translateY(8px) scale(0.6); }
  to   { opacity: 1; transform: none; }
}

/* ── Bet spot ──────────────────────────────────────────── */
.bet-spot { display: flex; justify-content: center; padding: 14px 0 6px; }
.bet-spot[hidden] { display: none; }
.bet-circle {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px dashed rgba(255, 236, 170, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: box-shadow 0.2s;
}
.bet-circle.has-bet { box-shadow: 0 0 16px rgba(255,215,0,0.45); }
.bet-circle-label { font-size: 12px; font-weight: 900; letter-spacing: 2px; color: rgba(255, 236, 170, 0.9); }
.bet-circle-amt { height: 38px; min-width: 38px; font-size: 14px; }
.bet-circle-amt:empty { display: none; }
.fly-chip {
  position: fixed;
  z-index: 50;
  width: 36px;
  height: 36px;
  padding: 0;
  pointer-events: none;
  font-size: 10px;
}

/* ── Center strip: messages / insurance / banner ──────── */
.center-strip {
  min-height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 4px 0;
}
.table-msg {
  font-size: 13px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,0.45);
  color: #fff8d6;
  animation: float-in 0.3s ease;
  text-align: center;
}
.table-msg[hidden], .insurance-prompt[hidden], .result-banner[hidden] { display: none; }
.insurance-prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  background: rgba(0,0,0,0.5);
  box-shadow: 0 0 0 2px rgba(255,215,0,0.6) inset;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  animation: float-in 0.3s ease;
}
.ins-btns { display: inline-flex; gap: 6px; }
.ins-btn { min-height: 32px; padding: 6px 14px; }
.ins-btn[hidden] { display: none; }
.ins-btn.yes { background: #f9a825; color: #2b1d00; }
.ins-btn.no  { background: #546e7a; color: #fff; }
.result-banner {
  text-align: center;
  padding: 6px 16px;
  border-radius: 14px;
  background: rgba(0,0,0,0.5);
  animation: banner-in 0.35s cubic-bezier(.2,1.4,.5,1);
  max-width: 100%;
}
.banner-main { font-size: 20px; font-weight: 900; letter-spacing: 1px; }
.banner-sub { font-size: 12px; font-weight: 700; opacity: 0.9; margin-top: 2px; }
.result-banner.win  { color: #ffe082; box-shadow: 0 0 0 2px gold inset; }
.result-banner.lose { color: #ffcdd2; box-shadow: 0 0 0 2px #e74c3c inset; }
.result-banner.push { color: #eceff1; box-shadow: 0 0 0 2px #b0bec5 inset; }
.result-banner.bj .banner-main { text-shadow: 0 0 10px rgba(255,215,0,0.9); }
@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.8;
  font-variant-numeric: tabular-nums;
}

/* ── Action bar ────────────────────────────────────────── */
.action-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 14px;
  min-height: 52px;
}
.action-bar[hidden], .bet-controls[hidden] { display: none; }
.act-btn {
  min-width: 96px;
  min-height: 52px;
  font-size: 17px;
  font-weight: 900;
  border-radius: 14px;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.25);
}
.act-btn[hidden] { display: none; }
.act-btn kbd {
  font-size: 10px; font-weight: 700; line-height: 1; font-family: inherit;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.22);
}
.act-btn.hit       { background: #2e7d32; }
.act-btn.stand     { background: #c62828; }
.act-btn.double    { background: #ef6c00; }
.act-btn.split     { background: #1565c0; }
.act-btn.surrender { background: #546e7a; }
.act-btn:hover:not(:disabled) { filter: brightness(1.1); }

/* ── Chip selector + bet buttons ───────────────────────── */
.chip-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 12px;
}
.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: 15px;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0,0,0,0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s;
  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: 13px;
  border-style: solid;
  border-color: #fff5b8;
}
.chip-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 10px rgba(0,0,0,0.35); }
.chip-btn:disabled { filter: grayscale(0.8); opacity: 0.5; cursor: not-allowed; }
.action-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
}
.action-row .btn { min-width: 96px; min-height: 42px; font-size: 14px; }
.action-row .btn.primary {
  background: linear-gradient(180deg, #e74c3c, #c0392b);
  color: #fff;
  min-width: 132px;
  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-disabled);
  color: rgba(255,255,255,0.7);
  animation: none;
}
.legend {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 520px) {
  .table-felt { padding: 8px 6px 22px; }
  .card { --w: 48px; padding: 3px; border-radius: 6px; }
  .card-row { min-height: 70px; }
  .card-rank-top, .card-rank-bot { font-size: 11px; }
  .card-suit-center { font-size: 18px; }
  .hands { gap: 4px; }
  .hands.multi .hand-box { flex: 0 1 calc(50% - 4px); padding: 4px 4px 6px; }
  .hands.multi .card { --w: 42px; padding: 3px; }
  .hands.multi .card-rank-top, .hands.multi .card-rank-bot { font-size: 10px; }
  .hands.multi .card-suit-center { font-size: 15px; }
  .hands.multi .card-row { min-height: 62px; }
  .dealer-area, .player-area { min-height: 104px; }
  .banner-main { font-size: 17px; }
  .act-btn { min-width: 0; flex: 1 1 28%; font-size: 16px; min-height: 50px; padding: 6px 8px; }
  .action-bar { gap: 6px; }
  .chip-btn { width: 50px; height: 50px; font-size: 13px; }
  .chip-btn.allin { font-size: 11px; letter-spacing: 0; }
  .chip-row { gap: 6px; }
  .action-row .btn { min-width: 0; flex: 1 1 0; padding: 8px 8px; }
  .hud-value { font-size: 19px; }
}

.chip-btn:focus-visible, .act-btn:focus-visible, .ins-btn:focus-visible { outline: 3px solid #ffd54f; outline-offset: 2px; }

/* Light mode: accent-coloured HUD numbers on white are too faint; darken the active accent.
   :where() keeps specificity at .hud-value so win/lose colours still override it. */
:where(body:not(.dark)) .hud-value { color: color-mix(in srgb, var(--accent) 55%, #000); }
#last-result.win  { color: #2e9d57; }
#last-result.lose { color: #e53935; }
body.dark #last-result.win { color: #5fd38d; }
body.dark #last-result.lose { color: #ff7b72; }
