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

/* Blackjack stacks the setup-brand vertically (chip, h1, game label)
   while shared/craps lays it out horizontally. */
.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; min-height: 100vh; }
.game-screen.active { display: flex; }

/* ===== Table Area ===== */

.table-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px 24px;
  background:
    radial-gradient(ellipse at 50% 60%, rgba(13,107,44,.2) 0%, transparent 70%),
    var(--bg);
  gap: 20px;
  min-height: 0;
}

/* Felt surface */
.felt-surface {
  width: 100%;
  max-width: 750px;
  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% 30%, var(--felt-light) 0%, var(--felt) 50%, var(--felt-dark) 100%);
  border-radius: 180px 180px 20px 20px;
  border: 10px solid #14341c;
  box-shadow:
    inset 0 2px 40px rgba(0,0,0,.35),
    inset 0 -2px 20px rgba(0,0,0,.15),
    0 6px 30px rgba(0,0,0,.5),
    0 2px 4px rgba(0,0,0,.3);
  padding: 60px 40px 40px;
  position: relative;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Padded rail/bumper */
.felt-surface::before {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 190px 190px 28px 28px;
  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 40px rgba(0,0,0,.6);
}

.felt-surface::after {
  content: 'BLACKJACK PAYS 3 TO 2  •  DEALER MUST STAND ON 17';
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,.22);
  white-space: nowrap;
}

/* Dealer avatar */
.dealer-avatar {
  position: absolute;
  top: -62px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.dealer-emoji {
  font-size: 2.2rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
}

.dealer-name {
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(255,255,255,.5);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Speech bubble */
.dealer-speech {
  background: rgba(0,0,0,.55);
  color: rgba(255,255,255,.85);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
  position: relative;
  margin-bottom: 4px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
}

.dealer-speech.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Speech bubble tail */
.dealer-speech::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid rgba(0,0,0,.55);
}

/* Shoe */
.shoe {
  position: absolute;
  top: 22px;
  right: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 5;
}

.shoe-cards {
  width: 48px;
  height: 34px;
  background:
    linear-gradient(135deg, #1a3a8a 0%, #0d2460 100%);
  border-radius: 4px;
  border: 1.5px solid #2a4a9a;
  position: relative;
  box-shadow: 2px 2px 6px rgba(0,0,0,.4);
}

/* Stacked card effect */
.shoe-cards::before,
.shoe-cards::after {
  content: '';
  position: absolute;
  border-radius: 4px;
  background: linear-gradient(135deg, #1e3e8e 0%, #112864 100%);
  border: 1px solid #2a4a9a;
}

.shoe-cards::before {
  width: 100%;
  height: 100%;
  top: -3px;
  left: -2px;
  z-index: -1;
}

.shoe-cards::after {
  width: 100%;
  height: 100%;
  top: -6px;
  left: -4px;
  z-index: -2;
  opacity: .7;
}

.shoe-label {
  font-size: 0.55rem;
  font-weight: 700;
  color: rgba(255,255,255,.35);
  letter-spacing: 0.04em;
}

/* Insurance arc */
.insurance-arc {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 40px;
  border: 2px dashed rgba(255,255,255,.12);
  border-bottom: none;
  border-radius: 200px 200px 0 0;
  z-index: 1;
}

.insurance-arc-text {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,.18);
  white-space: nowrap;
  background: var(--felt);
  padding: 0 8px;
}

/* Player zone: chips beside cards */
.player-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}


/* Betting circle */
.betting-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.betting-circle.has-bet {
  border-color: rgba(255,255,255,.25);
  box-shadow: 0 0 12px rgba(255,255,255,.06);
}

.betting-circle-chips {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.betting-circle-chips .felt-chip {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.45rem;
  font-weight: 800;
  color: #fff;
  border: 2px dashed rgba(255,255,255,.3);
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

.betting-circle-label {
  font-size: 0.55rem;
  font-weight: 700;
  color: rgba(255,255,255,.5);
  margin-top: 2px;
  position: absolute;
  bottom: -14px;
  white-space: nowrap;
}

/* Dealer area */
.dealer-area {
  text-align: center;
  margin-bottom: 16px;
}

.area-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,.4);
  margin-bottom: 8px;
}

.dealer-total {
  font-size: 0.85rem;
  font-weight: 700;
  color: rgba(255,255,255,.7);
  margin-top: 6px;
  min-height: 1.2em;
}

/* Player area */
.player-area {
  text-align: center;
}

.hands-container {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.hand-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hand-group.active-hand .hand-label {
  color: var(--gold-bright);
}

.hand-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255,255,255,.5);
}

.hand-total {
  font-size: 0.85rem;
  font-weight: 700;
  color: rgba(255,255,255,.8);
}

.hand-result {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 10px;
  border-radius: 99px;
  animation: badge-pop 350ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes badge-pop {
  0% { opacity: 0; transform: scale(0.3); }
  100% { opacity: 1; transform: scale(1); }
}

.hand-result.win { background: var(--green-dim); color: var(--green-bright); }
.hand-result.lose { background: var(--red-dim); color: var(--red-bright); }
.hand-result.push { background: var(--surface-3); color: var(--text-muted); }
.hand-result.blackjack { background: var(--gold-dim); color: var(--gold-bright); }
.hand-result.bust { background: var(--red-dim); color: var(--red-bright); }
.hand-result.surrender { background: var(--surface-3); color: var(--text-dim); }

/* Cards */
.cards-row {
  display: flex;
  justify-content: center;
  padding-left: 14px;
}

/* Overlap cards like a real hand */
.cards-row .card {
  margin-left: -14px;
}

.card {
  width: 66px;
  height: 94px;
  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;
  transition: transform .2s ease;
  flex-shrink: 0;
}

.card.red { color: #c0392b; }
.card.black { color: #1a1a1a; }

/* Corner pip: top-left */
.card .card-corner-tl {
  position: absolute;
  top: 4px;
  left: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card .card-corner-tl .card-rank {
  font-size: 0.85rem;
  font-weight: 800;
}

.card .card-corner-tl .card-suit {
  font-size: 0.65rem;
  margin-top: -1px;
}

/* Corner pip: bottom-right (rotated 180) */
.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-corner-br .card-rank {
  font-size: 0.85rem;
  font-weight: 800;
}

.card .card-corner-br .card-suit {
  font-size: 0.65rem;
  margin-top: -1px;
}

/* Center suit (big) */
.card .card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.8rem;
  opacity: 0.8;
}

/* Face cards get a special center */
.card.face-card .card-center {
  font-size: 1.4rem;
  font-weight: 800;
  opacity: 0.6;
}

/* Face-down card (back design) */
.card.face-down {
  background:
    repeating-conic-gradient(
      #1a3a8a 0% 25%, #152e70 0% 50%
    ) 50% / 8px 8px,
    linear-gradient(135deg, #1a3a8a 0%, #0d2460 100%);
  border: 2.5px solid #2a4a9a;
  box-shadow:
    0 1px 3px rgba(0,0,0,.25),
    0 4px 10px rgba(0,0,0,.15),
    inset 0 0 0 3px rgba(255,255,255,.06);
}

/* Inner border pattern on card back */
.card.face-down::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1.5px solid rgba(255,255,255,.1);
  border-radius: 3px;
}

.card.face-down::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.12);
  background: radial-gradient(circle, rgba(255,255,255,.06) 0%, transparent 70%);
}

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

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

.controls-area {
  padding: 16px 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* Betting controls */
.bet-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.bet-display {
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 80px;
  text-align: center;
}

.chip-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px dashed rgba(255,255,255,.3);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s;
  font-family: var(--font-body);
}

.chip-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}

.chip-btn:active { transform: scale(0.95); }

.chip-1   { background: var(--chip-white); color: #333; border-color: rgba(0,0,0,.15); }
.chip-5   { background: var(--chip-red); }
.chip-25  { background: var(--chip-green); }
.chip-100 { background: var(--chip-black); color: #ccc; border-color: rgba(255,255,255,.2); }
.chip-500 { background: #6a2db8; }

.btn-deal {
  padding: 12px 40px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background .15s;
}

.btn-deal:hover { background: var(--green-bright); }
.btn-deal:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-clear-bet {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-body);
}

.btn-clear-bet:hover { color: var(--text-muted); border-color: var(--text-dim); }

/* Action buttons */
.action-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-action {
  padding: 12px 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
  transition: border-color .15s, background .15s;
  min-width: 90px;
}

.btn-action:hover {
  border-color: var(--green);
  background: var(--surface-2);
}

.btn-action.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.btn-action.primary:hover {
  background: var(--green-bright);
  border-color: var(--green-bright);
}

.btn-action.danger {
  border-color: var(--red);
  color: var(--red-bright);
}

.btn-action.danger:hover {
  background: var(--red-dim);
}

.btn-action:disabled,
.btn-action[disabled] {
  opacity: 0.38;
  cursor: not-allowed;
  color: var(--text-dim);
  border-color: var(--border);
}
.btn-action:disabled:hover,
.btn-action[disabled]:hover {
  background: transparent;
  transform: none;
}
.btn-action:disabled .tooltip-hint,
.btn-action[disabled] .tooltip-hint {
  background: rgba(255,255,255,0.08);
  color: var(--text-dim);
}

/* Insurance prompt */
.insurance-prompt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--gold-dim);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.insurance-prompt span {
  color: var(--gold-bright);
  font-weight: 600;
}

/* Coach panel */
.coach-panel {
  width: 100%;
  max-width: 720px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.5;
  min-height: 44px;
}

.coach-panel .coach-label {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  white-space: nowrap;
}

.coach-panel .coach-text {
  color: var(--text-muted);
  flex: 1;
}

.coach-correct { color: var(--green-bright) !important; }
.coach-wrong { color: var(--red-bright) !important; }

/* Strategy chart badge */
.strategy-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--blue-dim);
  color: var(--blue);
  cursor: pointer;
  border: none;
  font-family: var(--font-body);
}

.strategy-badge:hover { background: #223a55; }

/* Accuracy bar */
.accuracy-bar {
  width: 100%;
  max-width: 700px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
}

.accuracy-label { color: var(--text-dim); white-space: nowrap; }
.accuracy-value { font-weight: 700; min-width: 40px; }
.accuracy-value.good { color: var(--green-bright); }
.accuracy-value.ok { color: var(--gold-bright); }
.accuracy-value.bad { color: var(--red-bright); }

.accuracy-track {
  flex: 1;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
}

.accuracy-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width .3s ease;
}

/* ===== Strategy Chart Modal ===== */
/* Base .modal-overlay/.modal-card/.modal-header/.btn-close in shared/styles.css.
   Override the card width — the strategy chart needs more room. */

.modal-card {
  max-width: 800px;
}

/* Strategy table */
.strategy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
  margin-bottom: 16px;
}

.strategy-table th,
.strategy-table td {
  padding: 4px 6px;
  text-align: center;
  border: 1px solid var(--border);
}

.strategy-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 700;
}

.strategy-table .cell-H { background: var(--green-dim); color: var(--green-bright); }
.strategy-table .cell-S { background: var(--red-dim); color: var(--red-bright); }
.strategy-table .cell-D { background: var(--gold-dim); color: var(--gold-bright); }
.strategy-table .cell-P { background: var(--blue-dim); color: var(--blue); }
.strategy-table .cell-Rh { background: #2a1520; color: #b06080; }
.strategy-table .cell-Ds { background: var(--gold-dim); color: var(--gold); }

.chart-section-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin: 12px 0 6px;
  color: var(--text-muted);
}

.chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

/* ===== Hint Panel ===== */

.hint-panel {
  width: 100%;
  max-width: 700px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  animation: hintSlideIn .25s ease-out;
}

@keyframes hintSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hint-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.hint-table {
  font-size: 0.65rem;
}

.hint-table th,
.hint-table td {
  padding: 3px 5px;
}

/* Highlight the dealer's column */
.hint-col-highlight {
  background: rgba(229, 184, 74, .25) !important;
  color: var(--gold-bright) !important;
}

/* Highlight the player's row */
.hint-row-highlight td,
.hint-row-highlight th {
  border-top: 2px solid var(--gold) !important;
  border-bottom: 2px solid var(--gold) !important;
}

.hint-row-label-highlight {
  background: rgba(229, 184, 74, .15) !important;
  color: var(--gold-bright) !important;
}

/* Pulse the exact cell */
.hint-cell-active {
  animation: hintPulse 1s ease-in-out infinite;
  outline: 2px solid var(--gold-bright);
  outline-offset: -1px;
  font-weight: 900 !important;
  font-size: 0.85rem !important;
  position: relative;
  z-index: 2;
}

@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 184, 74, .4); }
  50% { box-shadow: 0 0 12px 4px rgba(229, 184, 74, .3); }
}

.hint-legend {
  margin-top: 8px;
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.8;
}

.hint-legend span {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 0.65rem;
}

/* Hint button styling */
.btn-action.hint-btn {
  border-color: var(--gold-dim);
  color: var(--gold);
  background: transparent;
  min-width: 70px;
  font-size: 0.85rem;
}

.btn-action.hint-btn:hover {
  border-color: var(--gold);
  background: var(--gold-dim);
}

.btn-action.hint-active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold-bright);
}


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

@media (max-width: 600px) {
  .felt-surface {
    border-radius: 80px 80px 16px 16px;
    padding: 50px 20px 30px;
    min-height: 300px;
  }

  .card {
    width: 52px;
    height: 74px;
  }

  .card .card-corner-tl .card-rank,
  .card .card-corner-br .card-rank { font-size: 0.7rem; }

  .card .card-corner-tl .card-suit,
  .card .card-corner-br .card-suit { font-size: 0.55rem; }

  .card .card-center { font-size: 1.3rem; }

  .cards-row { padding-left: 10px; }
  .cards-row .card { margin-left: -10px; }

  .dealer-avatar { top: -50px; }
  .dealer-emoji { font-size: 1.6rem; }
  .dealer-speech { font-size: 0.55rem; padding: 2px 8px; }

  .shoe { top: 14px; right: 16px; }
  .shoe-cards { width: 36px; height: 26px; }

  .betting-circle { width: 42px; height: 42px; }
  .betting-circle-chips .felt-chip { width: 22px; height: 22px; font-size: 0.35rem; }
  .player-zone { gap: 10px; }

  .insurance-arc { display: none; }

  .chip-btn { width: 44px; height: 44px; font-size: 0.65rem; }

  .header-stats { gap: 12px; }
  .header-bar { padding: 8px 12px; }

  .btn-action {
    padding: 10px 16px;
    font-size: 0.85rem;
    min-width: 70px;
  }
}

/* ============================================================
   Tutorial — base card/progress/spotlight styles live in
   shared/styles.css. Blackjack uses the shared fixed-position
   card as-is; it only right-aligns the step counter so it sits
   opposite the Back link in the step-count row.
   ============================================================ */
.tut-step-counter { margin-left: auto; }
