/* ============================================================
   Felt Trainer — Baccarat game-specific styles
   Tokens, resets, setup screen, header bar, modals, toasts,
   tooltips, and the tutorial card live in shared/styles.css.
   ============================================================ */

/* Baccarat stacks the setup-brand vertically like blackjack/roulette. */
.setup-brand {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  margin-bottom: 8px;
}

/* ===== Game screen ===== */

.game-screen { display: none; flex-direction: column; height: 100vh; height: 100dvh; }
.game-screen.active { display: flex; }

.game-main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.table-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 18px 14px;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(13,107,44,.18) 0%, transparent 70%),
    var(--bg);
  overflow-y: auto;
}

/* ===== Felt ===== */

.felt-surface {
  width: 100%;
  max-width: 860px;
  position: relative;
  padding: 30px 22px 20px;
  border-radius: 16px;
  border: 8px solid #14341c;
  background:
    repeating-linear-gradient(
      0deg, transparent, transparent 2px,
      rgba(0,0,0,.015) 2px, rgba(0,0,0,.015) 4px),
    radial-gradient(ellipse at 50% 35%, var(--felt-light) 0%, var(--felt) 55%, var(--felt-dark) 100%);
  box-shadow:
    inset 0 2px 32px rgba(0,0,0,.32),
    0 6px 24px rgba(0,0,0,.5);
}
.felt-surface::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 22px;
  background: linear-gradient(180deg, #1e4528 0%, #14341c 50%, #0f2a16 100%);
  z-index: -1;
  box-shadow:
    inset 0 2px 6px rgba(255,255,255,.08),
    inset 0 -2px 6px rgba(0,0,0,.3),
    0 8px 30px rgba(0,0,0,.55);
}

.felt-edge-label {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: rgba(255,255,255,0.22);
  white-space: nowrap;
}

/* ===== Printed commission boxes (dealer's edge) ===== */

.commission-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 2px 0 10px;
  flex-wrap: wrap;
}
.commission-row .comm-title {
  font-size: 0.56rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(212,175,55,0.5);
  margin-right: 4px;
}
.commission-row .comm-box {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(212,175,55,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  font-variant-numeric: tabular-nums;
}

/* ===== The two hands, dressed as printed bet boxes ===== */

.baccarat-table {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 20px;
  width: 100%;
  padding: 14px 0 6px;
}
/* Faint printed "BACCARAT" watermark behind the boxes */
.baccarat-table::before {
  content: 'BACCARAT';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 2.4rem;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.04);
  pointer-events: none;
  white-space: nowrap;
  z-index: 0;
}

.hand-area {
  flex: 1;
  max-width: 320px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  border-radius: 16px;
  border: 2px solid rgba(212,175,55,0.45);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.05) 0%, transparent 70%),
    rgba(0,0,0,0.16);
  box-shadow: inset 0 0 0 4px rgba(0,0,0,0.18), inset 0 0 0 5px rgba(212,175,55,0.18);
  transition: border-color .25s, box-shadow .25s, background .25s;
}
.player-area { border-color: rgba(91,142,201,0.55); }
.banker-area { border-color: rgba(224,82,82,0.55); }

.hand-area.winner.player-area {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 4px rgba(0,0,0,0.18), 0 0 0 1px var(--blue), 0 0 24px rgba(91,142,201,0.45);
}
.hand-area.winner.banker-area {
  border-color: var(--red-bright);
  box-shadow: inset 0 0 0 4px rgba(0,0,0,0.18), 0 0 0 1px var(--red-bright), 0 0 24px rgba(224,82,82,0.45);
}

.hand-label {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.player-area .hand-label { color: #8fb6e3; }
.banker-area .hand-label { color: #ef8a8a; }

.hand-payout {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(212,175,55,0.7);
  margin-top: 2px;
}

/* ===== Printed TIE betting band ===== */

.tie-band {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 12px auto 2px;
  max-width: 420px;
}
.tie-band .tie-rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212,175,55,0.5), transparent);
}
.tie-band .tie-text {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(70,183,106,0.85);
  white-space: nowrap;
}
.tie-band .tie-text strong { color: var(--gold); }

.hand-cards {
  display: flex;
  gap: 6px;
  min-height: 96px;
  align-items: center;
  justify-content: center;
}

.hand-total {
  font-family: var(--font-display);
  font-size: 1.7rem;
  line-height: 1;
  min-height: 1.7rem;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* ===== Result badge ===== */

.result-badge {
  align-self: center;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  padding: 12px 18px;
  border-radius: 10px;
  color: #fff;
  white-space: nowrap;
  text-align: center;
  box-shadow: 0 4px 18px rgba(0,0,0,.45);
  animation: badgePop .4s cubic-bezier(.34,1.56,.64,1);
}
.result-badge.badge-player { background: linear-gradient(180deg, #6fa0d8 0%, #3f6da8 100%); }
.result-badge.badge-banker { background: linear-gradient(180deg, #e16363 0%, #b22828 100%); }
.result-badge.badge-tie    { background: linear-gradient(180deg, #46b76a 0%, #0d6b2c 100%); }
@keyframes badgePop {
  from { transform: scale(0.2); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ===== Cards (face-up only) ===== */

.card {
  width: 64px;
  height: 92px;
  border-radius: 6px;
  background: #fffef8;
  box-shadow:
    0 1px 3px rgba(0,0,0,.25),
    0 4px 10px rgba(0,0,0,.15),
    inset 0 0 0 1px rgba(0,0,0,.08);
  position: relative;
  font-family: 'Plus Jakarta Sans', Georgia, serif;
  flex-shrink: 0;
}
.card.red { color: #c0392b; }
.card.black { color: #1a1a1a; }

.card .card-corner-tl {
  position: absolute;
  top: 4px;
  left: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.card .card-corner-br {
  position: absolute;
  bottom: 4px;
  right: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  transform: rotate(180deg);
}
.card .card-rank { font-size: 0.8rem; font-weight: 800; }
.card .card-suit { font-size: 0.6rem; margin-top: -1px; }

.card .card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.7rem;
  opacity: 0.82;
}
.card.face-card .card-center {
  font-size: 1.35rem;
  font-weight: 800;
  opacity: 0.6;
}

.card-dealing { will-change: transform, opacity; }

/* Third-card indicator — subtle "3rd" tag on a drawn third card */
.card.card-third::after {
  content: '3rd';
  position: absolute;
  top: -8px;
  right: -7px;
  background: var(--gold);
  color: #1a1a1a;
  font-family: var(--font-body);
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 1px 4px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,.45);
}

/* ===== Scoreboard (history dots) ===== */

.history-strip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 26px;
  margin-top: 8px;
}
.history-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 800;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.18);
  box-shadow: 0 2px 4px rgba(0,0,0,.35);
  font-family: var(--font-body);
}
.history-dot.dot-player { background: var(--blue); }
.history-dot.dot-banker { background: var(--chip-red); }
.history-dot.dot-tie    { background: var(--green); }

/* ===== Card-value cheat sheet ===== */

.values-legend {
  width: 100%;
  max-width: 860px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text-muted);
}
.values-legend .vl-title {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  flex-shrink: 0;
}
.values-legend .vl-item {
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface-3);
}
.values-legend .vl-item b { color: var(--text); font-weight: 700; }
.values-legend .vl-note {
  color: var(--text-dim);
  font-size: 0.76rem;
  flex: 1;
  min-width: 200px;
}

/* ===== Coach panel ===== */

.coach-panel {
  width: 100%;
  max-width: 860px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}
.coach-panel .coach-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan);
  flex-shrink: 0;
}
.coach-panel .coach-text { color: var(--text-muted); flex: 1; line-height: 1.5; }
.coach-panel .coach-text strong { color: var(--text); }
.coach-panel .coach-text .pos { color: var(--green-bright); font-weight: 700; }
.coach-panel .coach-text .neg { color: var(--red-bright); font-weight: 700; }

/* ===== Controls ===== */

.controls-area {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px 20px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.chip-rack {
  display: flex;
  gap: 8px;
  align-items: center;
}
.chip-rack.disabled { opacity: 0.5; pointer-events: none; }

.chip-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 3px dashed rgba(255,255,255,0.4);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.76rem;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0,0,0,.45), inset 0 -2px 4px rgba(0,0,0,.3);
  transition: transform .1s, filter .12s;
  flex-shrink: 0;
}
.chip-btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.chip-btn:active { transform: translateY(0); }
.chip-btn.selected {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  transform: translateY(-2px);
}
.chip-btn[data-denom="1"]   { background: radial-gradient(circle at 35% 30%, #fff 0%, #d2d2d2 80%); color: #222; }
.chip-btn[data-denom="5"]   { background: radial-gradient(circle at 35% 30%, #e05252 0%, var(--chip-red) 80%); }
.chip-btn[data-denom="25"]  { background: radial-gradient(circle at 35% 30%, #3bb46f 0%, var(--chip-green) 80%); }
.chip-btn[data-denom="100"] { background: radial-gradient(circle at 35% 30%, #2a2a2a 0%, var(--chip-black) 80%); }

/* ===== Bet buttons (Player / Tie / Banker) ===== */

.bet-buttons {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.bet-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 116px;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  color: #fff;
  cursor: pointer;
  font-family: var(--font-body);
  transition: transform .1s, box-shadow .15s, filter .12s, border-color .15s;
}
.bet-btn:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.bet-btn:active:not(:disabled) { transform: translateY(0); }
.bet-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.bet-btn-name {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.bet-btn-payout { font-size: 0.68rem; font-weight: 700; opacity: 0.85; }

.bet-btn-amount {
  position: absolute;
  top: -11px;
  right: -9px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: radial-gradient(circle at 35% 30%, var(--gold-bright) 0%, var(--gold) 80%);
  border: 2px dashed rgba(0,0,0,.4);
  color: #1a1a1a;
  font-size: 0.62rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 5px rgba(0,0,0,.5);
}

.bet-player { background: linear-gradient(180deg, #5b8ec9 0%, #3a6298 100%); }
.bet-banker { background: linear-gradient(180deg, #d84f4f 0%, #a32222 100%); }
.bet-tie    { background: linear-gradient(180deg, #2d9f5f 0%, #0d6b2c 100%); min-width: 92px; }

.bet-btn.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold), 0 4px 16px rgba(0,0,0,.45);
  transform: translateY(-2px);
}

/* ===== Action buttons ===== */

.action-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn-action {
  padding: 11px 18px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s;
  min-width: 84px;
}
.btn-action:hover:not(:disabled) { background: var(--surface-3); border-color: var(--text-dim); }
.btn-action:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-action.btn-deal {
  background: var(--green);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(45,159,95,.3);
}
.btn-action.btn-deal:hover:not(:disabled) {
  background: var(--green-bright);
  box-shadow: 0 4px 14px rgba(45,159,95,.4);
}
.btn-action.btn-deal:disabled { background: var(--surface-2); color: var(--text-dim); box-shadow: none; }
.btn-action.btn-new { background: var(--gold); color: #1a1a1a; border-color: transparent; }
.btn-action.btn-new:hover { background: var(--gold-bright); }
.btn-action.btn-rebet { border-color: var(--gold-dim); color: var(--gold); }
.btn-action.btn-rebet:hover { border-color: var(--gold); background: var(--gold-dim); }

/* ===== Tutorial =====
   Base card/progress/spotlight styles live in shared/styles.css. Baccarat's
   controls row is wide (chip rack + three bet buttons + actions), so a
   floating bottom-right card would cover the Deal button. Instead we dock the
   card into its own column inside .game-main (the roulette pattern): the felt
   reflows and the full-width controls row below stays clear. Card overrides
   are scoped under .game-main so they beat the shared single-class rules
   (including media queries) by specificity. */
.tut-step-counter { margin-left: auto; }

.game-main .tutorial-card {
  position: static;
  z-index: 2;
  inset: auto;
  flex-shrink: 0;
  width: 340px;
  max-width: none;
  overflow-x: visible;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: none;
  border-left: 1px solid var(--green);
  border-radius: 0;
  box-shadow: -8px 0 30px rgba(0, 0, 0, .35);
  animation: bacTutSlideIn .3s ease;
}
@keyframes bacTutSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.tut-progress-bar { flex-shrink: 0; }
.tut-step-count { flex-shrink: 0; }
.tut-skip { margin-top: auto; flex-shrink: 0; }

/* Narrow screens: dock below the felt (in flow), controls stay pinned below. */
@media (max-width: 820px) {
  .game-main { flex-direction: column; }
  .game-main .tutorial-card {
    width: auto;
    max-height: 42vh;
    border-left: none;
    border-top: 1px solid var(--green);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .35);
  }
}

/* ===== Responsive ===== */

@media (max-width: 720px) {
  .table-area { padding: 18px 10px 12px; gap: 12px; }
  .felt-surface { padding: 24px 12px 14px; border-width: 6px; }

  /* Stack Player above Banker on narrow screens */
  .baccarat-table {
    flex-direction: column;
    gap: 12px;
  }
  .hand-area { max-width: 100%; width: 100%; }
  .result-badge { order: 0; font-size: 0.95rem; padding: 8px 16px; }

  .card { width: 54px; height: 78px; }
  .card .card-center { font-size: 1.4rem; }
  .card.face-card .card-center { font-size: 1.1rem; }
  .card .card-rank { font-size: 0.7rem; }
  .card .card-suit { font-size: 0.52rem; }
  .hand-total { font-size: 1.4rem; }

  .controls-area { gap: 10px; padding: 12px; }
  .bet-btn { min-width: 92px; padding: 8px 12px; }
  .bet-tie { min-width: 74px; }
  .bet-btn-name { font-size: 0.85rem; }
  .chip-btn { width: 44px; height: 44px; font-size: 0.66rem; }
  .btn-action { padding: 9px 12px; font-size: 0.78rem; min-width: 70px; }
}

@media (max-width: 460px) {
  .felt-edge-label { display: none; }
  .bet-buttons { gap: 6px; }
  .bet-btn { min-width: 80px; padding: 7px 8px; }
  .card { width: 48px; height: 70px; }
}
