/* ==========================================================================
   The Count — Blackjack
   Skin updated to match “The Count by Half Baked Idea” look and palette
   ========================================================================== */

/* Base -------------------------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

.thecount-app--blackjack {
  /* Half Baked Idea palette */
  --hbi-deep-teal: #013854;
  --hbi-mid-teal: #185f66;
  --hbi-light-teal: #9dd2d0;
  --hbi-gold: #f2c335;
  --hbi-orange: #d86604;

  /* Theme tokens (dark default) */
  --card-bg: rgba(1, 14, 22, 0.92);
  --card-border: rgba(11, 46, 60, 0.9);
  --card-shadow: 0 24px 70px rgba(0, 0, 0, 0.75);

  --text-main: #eaf7f7;
  --text-muted: #9ac3cf;
  --text-soft: #7fa4b0;

  --pill-bg: rgba(2, 24, 34, 0.96);
  --pill-border: rgba(33, 92, 108, 0.9);

  --button-bg: #f2c335;
  --button-border: #d86604;
  --button-text: #013854;

  --ghost-bg: transparent;
  --ghost-border: rgba(33, 92, 108, 0.9);
  --ghost-text: var(--text-main);

  --focus-ring: 0 0 0 3px rgba(216, 102, 4, 0.35);

  position: relative;
  padding: 0;
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  line-height: 1.5;
}

/* Remove the extra overlay layer behind the game.
   The Count page already provides the backdrop; this pseudo-element made the table
   look like it had a dark "sheet" behind it on some themes.
*/
.thecount-app--blackjack::before {
  content: none;
  display: none;
}

.thecount-app--blackjack .tcbj-wrap {
  position: relative;
  z-index: 1;
}

/* Light theme (driven by shortcode attr theme="light") -------------------- */

.tcbj-wrap[data-theme="light"] {
  --card-bg: rgba(255, 255, 255, 0.92);
  --card-border: #d3e6e5;
  --card-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);

  --text-main: #013854;
  --text-muted: #567883;
  --text-soft: #678893;

  --pill-bg: #e5f4f3;
  --pill-border: #bfdede;

  --ghost-border: rgba(1, 56, 84, 0.35);
  --ghost-text: #013854;
}

/* Layout ------------------------------------------------------------------ */

/* Match The Count container: 90% width, max 960, centered */
.tcbj-wrap {
  width: 90%;
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
  padding: 0;
}

.tcbj-card {
  border: 1px solid var(--card-border);
  border-radius: 20px;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  padding: 1.4rem 1.4rem 1.2rem;
}

.tcbj-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0;
  border-bottom: 0;
}

/* Header matches The Count app -------------------------------------------- */

.thecount-app--blackjack .tcbj-header{
  padding: 0 0 .85rem;
  margin-bottom: .9rem;
  border-bottom: 1px solid rgba(229, 195, 110, 0.22);
}

.thecount-app--blackjack .header-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:1.25rem;
}

.thecount-app--blackjack .header-left{
  display:flex;
  flex-direction:column;
  gap:.3rem;
}

.thecount-app--blackjack .logo-wrap{
  width:40px;
  height:40px;
}

.thecount-app--blackjack .hbi-logo{
  width:100%;
  height:100%;
  object-fit:contain;
}

.thecount-app--blackjack .header-left h1{
  margin:.15rem 0 0;
  font-size:1.7rem;
  line-height:1.1;
  color:var(--hbi-gold);
}

.thecount-app--blackjack .brand-row{
  font-size:.7rem;
  letter-spacing:.18em;
  text-transform:lowercase;
  font-variant:small-caps;
  color:var(--text-muted);
}

.thecount-app--blackjack .brand-link{
  color:var(--hbi-gold);
  text-decoration:none;
  border-bottom:1px solid rgba(229, 195, 110, 0.45);
  padding-bottom:.08rem;
}

.thecount-app--blackjack .brand-link:hover{
  border-bottom-color: rgba(229, 195, 110, 0.85);
}

.thecount-app--blackjack .brand-sub{
  opacity:.95;
}

.thecount-app--blackjack .tcbj-subtitle{
  margin-top:.25rem;
  font-size:.95rem;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--text-soft);
}


.tcbj-title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.15;
  color: var(--hbi-gold);
  letter-spacing: 0.01em;
}

.tcbj-wrap[data-theme="light"] .tcbj-title { color: var(--hbi-deep-teal); }

.tcbj-status {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.tcbj-table {
  padding: 0.95rem 0 0.2rem;
  display: grid;
  gap: 1rem;
}

.tcbj-hand {
  border: 1px solid rgba(33, 92, 108, 0.55);
  border-radius: 16px;
  padding: 0.85rem;
  background: radial-gradient(circle at top, rgba(2, 32, 51, 0.65) 0, rgba(1, 11, 20, 0.15) 80%);
}

.tcbj-wrap[data-theme="light"] .tcbj-hand {
  background: rgba(245, 251, 251, 0.9);
  border-color: rgba(1, 56, 84, 0.18);
}

.tcbj-hand__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.55rem;
}

.tcbj-hand__label { font-weight: 650; color: var(--text-main); }

.tcbj-hand__score {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.tcbj-cards { display: flex; gap: 0.6rem; flex-wrap: wrap; min-height: 82px; }

/* Split hands ------------------------------------------------------------ */

/* When the player has multiple hands (after split), render each hand in its own
   clearly separated card-like panel. */
.tcbj-playerhands {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  align-items: start;
}

@media (min-width: 720px) {
  .tcbj-playerhands {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
}

.tcbj-handcard {
  border: 1px solid rgba(33, 92, 108, 0.6);
  border-radius: 16px;
  padding: 0.7rem;
  background:
    radial-gradient(220px 180px at 15% 0%, rgba(242, 195, 53, 0.14), transparent 55%),
    radial-gradient(circle at top, rgba(2, 32, 51, 0.58) 0, rgba(1, 11, 20, 0.18) 82%);
}

.tcbj-wrap[data-theme="light"] .tcbj-handcard {
  background:
    radial-gradient(240px 180px at 20% 0%, rgba(216, 102, 4, 0.08), transparent 60%),
    rgba(245, 251, 251, 0.92);
  border-color: rgba(1, 56, 84, 0.2);
}

.tcbj-handcard.is-active {
  box-shadow: 0 0 0 2px rgba(242, 195, 53, 0.75);
}

.tcbj-handcard.is-done {
  opacity: 0.8;
}

.tcbj-handcard__meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 0.6rem;
  margin-top: 0.55rem;
  align-items: baseline;
}

.tcbj-handcard__label {
  font-weight: 750;
  letter-spacing: 0.02em;
}

.tcbj-handcard__wager,
.tcbj-handcard__total {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.tcbj-handcard__wager {
  justify-self: end;
}

/* Playing cards ----------------------------------------------------------- */

.tcbj-playing-card {
  width: 56px;
  height: 84px;
  border-radius: 12px;
  border: 1px solid rgba(1, 56, 84, 0.25);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.4rem 0.45rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(243, 249, 252, 0.94));
  color: #013854;
  position: relative;
}

.tcbj-wrap[data-theme="light"] .tcbj-playing-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(243, 249, 252, 0.94));
  border-color: rgba(1, 56, 84, 0.22);
  color: #013854;
}

.tcbj-playing-card.is-red { color: #d63a3a; }
.tcbj-playing-card .tcbj-rank { font-weight: 900; font-size: 1.1rem; letter-spacing: -0.01em; }
.tcbj-playing-card .tcbj-suit { font-size: 1.2rem; align-self: flex-end; }

.tcbj-playing-card.is-facedown {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(220px 140px at 30% 25%, rgba(242, 195, 53, 0.22), transparent 60%),
    repeating-linear-gradient(45deg, rgba(1, 56, 84, 0.88) 0 8px, rgba(2, 24, 34, 0.9) 8px 16px);
  border-color: rgba(242, 195, 53, 0.55);
  color: rgba(255, 255, 255, 0.96);
}

.tcbj-wrap[data-theme="light"] .tcbj-playing-card.is-facedown {
  background:
    radial-gradient(220px 140px at 30% 25%, rgba(216, 102, 4, 0.18), transparent 60%),
    repeating-linear-gradient(45deg, rgba(1, 56, 84, 0.92) 0 8px, rgba(24, 95, 102, 0.9) 8px 16px);
  border-color: rgba(1, 56, 84, 0.35);
}

.tcbj-card-back { font-size: 1.55rem; opacity: 0.95; }

/* Controls ---------------------------------------------------------------- */

.tcbj-controls { padding: 0.9rem 0 0; display: grid; gap: 0.9rem; }

/* Controls layout: left 2/3 (bankroll/bet + buttons + feedback), right 1/3 (rules) */
.tcbj-controls-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  align-items: start;
}

.tcbj-controls-left {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
}

.tcbj-controls-rules {
  min-width: 0;
}

/* Bankroll + bet sit on the same row, equal width */
.tcbj-bankroll {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  align-items: start;
}

.tcbj-field { display: grid; gap: 0.35rem; min-width: 170px; }

.tcbj-field > span {
  font-size: 0.85rem;
  color: var(--text-soft);
}

.tcbj-field input {
  width: 100%;
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg);
  color: var(--text-main);
}

.tcbj-field input:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: rgba(216, 102, 4, 0.7);
}

/* Buttons ----------------------------------------------------------------- */

/* Match The Count controls: pill buttons, small-caps + stronger shadow */
/* Action buttons layout (matches card-counting tool style) */
.tcbj-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.tcbj-btn-row {
  display: flex;
  gap: 0.6rem;
}

.tcbj-btn-row .tcbj-btn {
  flex: 1 1 0;
}

.tcbj-btn-row--full .tcbj-btn {
  width: 100%;
}

/* On very small screens, allow rows to stack */
@media (max-width: 420px) {
  .tcbj-btn-row {
    flex-direction: column;
  }
}


.tcbj-btn {
  border-radius: 999px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: var(--button-text);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  font-variant: small-caps;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}

.tcbj-btn:hover { transform: translateY(-1px); }

.tcbj-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), 0 10px 18px rgba(0, 0, 0, 0.22);
}

.tcbj-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
/* Reserve space for context-only buttons (e.g., Insurance) without layout shift */
.tcbj-btn.tcbj-hidden {
  visibility: hidden;
  pointer-events: none;
}


.tcbj-btn--ghost {
  background: var(--ghost-bg);
  border: 1px solid var(--ghost-border);
  color: var(--ghost-text);
  box-shadow: none;
}

/* Bankroll + bet bar ------------------------------------------------------ */

/* Allow the bet field to shrink to share space equally with bankroll */
.tcbj-field--bet { min-width: 0; }

.tcbj-betbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg);
}

.tcbj-bet-display {
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  letter-spacing: 0.02em;
  display: flex;
  align-items: baseline;
  gap: 0.2rem;
}

.tcbj-money { opacity: 0.9; color: var(--text-muted); }

.tcbj-bet-actions { display: flex; gap: 0.4rem; }

.tcbj-mini {
  border-radius: 999px;
  padding: 0.42rem 0.7rem;
  border: 1px solid rgba(33, 92, 108, 0.9);
  background: rgba(157, 210, 208, 0.10);
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 650;
}

.tcbj-wrap[data-theme="light"] .tcbj-mini {
  background: rgba(1, 56, 84, 0.05);
  color: var(--text-main);
}

.tcbj-mini:disabled { opacity: 0.45; cursor: not-allowed; }

/* Chip rack --------------------------------------------------------------- */

/* Chips should span the full width of bankroll + bet combined */
.tcbj-bankroll .tcbj-chip-rack {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}

.tcbj-chip {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: 2px solid rgba(242, 195, 53, 0.35);
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.22), rgba(0, 0, 0, 0.25) 65%),
    linear-gradient(180deg, rgba(1, 56, 84, 0.9), rgba(1, 24, 36, 0.95));
  color: var(--text-main);
  cursor: pointer;
  position: relative;
  display: grid;
  place-items: center;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28), inset 0 0 0 3px rgba(0, 0, 0, 0.24);
  user-select: none;
}

.tcbj-chip span { font-size: 0.9rem; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35); }

.tcbj-chip::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 999px;
  border: 2px dashed rgba(242, 195, 53, 0.55);
  opacity: 0.75;
}

.tcbj-chip::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.22), rgba(0, 0, 0, 0.20) 60%);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

/* Denomination accents (subtle) */
.tcbj-chip.denom-1   { border-color: rgba(157, 210, 208, 0.45); }
.tcbj-chip.denom-5   { border-color: rgba(242, 195, 53, 0.45); }
.tcbj-chip.denom-25  { border-color: rgba(216, 102, 4, 0.50); }
.tcbj-chip.denom-100 { border-color: rgba(157, 210, 208, 0.55); }
.tcbj-chip.denom-500 { border-color: rgba(242, 195, 53, 0.60); }

/* Feedback + rules -------------------------------------------------------- */

.tcbj-feedback { min-height: 1.25rem; color: var(--text-muted); }

.tcbj-rules-inline {
  margin-top: 0.75rem;
  border-radius: 16px;
  border: 1px solid rgba(33, 92, 108, 0.45);
  background: rgba(2, 24, 34, 0.55);
  padding: 0.85rem;
}

.tcbj-wrap[data-theme="light"] .tcbj-rules-inline {
  background: rgba(229, 244, 243, 0.85);
  border-color: rgba(1, 56, 84, 0.18);
}

.tcbj-rules-inline__title {
  font-size: 0.95rem;
  font-weight: 750;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.tcbj-rules-inline__list { display: grid; gap: 0.35rem; color: var(--text-muted); font-size: 0.92rem; }

/* Small screens ----------------------------------------------------------- */



/* Mobile layout ----------------------------------------------------------- */
@media (max-width: 540px) {
  .tcbj-card { padding: 1.15rem 1.0rem 1rem; }
}

@media (max-width: 860px) {
  .tcbj-controls-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .tcbj-bankroll {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .tcbj-header { align-items: flex-start; flex-direction: column; }
  .tcbj-title { font-size: 1.25rem; }
  .tcbj-chip { width: 50px; height: 50px; }
}

/* Stack controls on smaller screens */
@media (max-width: 780px) {
  .tcbj-controls-grid { grid-template-columns: 1fr; }
  .tcbj-bankroll { grid-template-columns: 1fr; }
}
