/* ==========================================================================
   Blackjack — game shell styles
   Scoped with .blj-* (and #blj- ids) so the shared site stylesheet can't
   leak in and this can't leak out onto any other game. Mobile-first,
   single file, no image assets — every visual is CSS/emoji.
   ========================================================================== */

:root {
  --blj-bg-0:       #06140f;
  --blj-bg-1:       #0a2018;
  --blj-felt-1:     #0e4a34;
  --blj-felt-2:     #0a3527;
  --blj-felt-edge:  #041a12;
  --blj-panel:      rgba(6, 20, 15, 0.92);
  --blj-panel-line: rgba(232, 194, 94, 0.22);
  --blj-chip:       rgba(0, 0, 0, 0.32);
  --blj-ink:        #f2f7f4;
  --blj-ink-dim:    #a9c2b9;
  --blj-gold:       #e8c25e;
  --blj-gold-soft:  #ffe08a;
  --blj-red:        #ef5f5f;
  --blj-green-ok:   #55c98a;
  --blj-card-white: #f8f5ec;
  --blj-card-back-1:#7a1f2b;
  --blj-card-back-2:#4c1119;
  --blj-radius-lg:  18px;
  --blj-radius-md:  12px;
  --blj-radius-sm:  8px;
  --blj-font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --blj-safe-t:     env(safe-area-inset-top, 0px);
  --blj-safe-b:     env(safe-area-inset-bottom, 0px);
  --blj-safe-l:     env(safe-area-inset-left, 0px);
  --blj-safe-r:     env(safe-area-inset-right, 0px);
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

/* Playing state: hide the shared site chrome while a hand is in progress,
   same pattern as the rest of the platform. */
body:has(.blj-root.is-playing) .blj-site-header,
body:has(.blj-root.is-playing) #footer {
  display: none;
}

.blj-root {
  position: relative;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--blj-bg-1), var(--blj-bg-0) 70%);
  color: var(--blj-ink);
  font-family: var(--blj-font);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

.blj-root.is-playing {
  height: 100vh;
  overflow: hidden;
}

.blj-root *,
.blj-root *::before,
.blj-root *::after {
  box-sizing: border-box;
}

.blj-root button {
  font-family: inherit;
}

/* ---------- Generic dialog-style screens (loading / menu / help) ---------- */

.blj-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--blj-safe-t)) calc(16px + var(--blj-safe-r)) calc(20px + var(--blj-safe-b)) calc(16px + var(--blj-safe-l));
  opacity: 0;
  transform: scale(0.98);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 20;
  overflow-y: auto;
}

.blj-screen.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  z-index: 30;
}

/* ---------- Loading ---------- */

.blj-loading-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.blj-loading-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--blj-gold);
  margin-bottom: 20px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.blj-progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--blj-panel);
  border: 1px solid var(--blj-panel-line);
  overflow: hidden;
}

.blj-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blj-gold), var(--blj-gold-soft));
  transition: width 0.25s ease;
}

.blj-loading-hint {
  margin-top: 12px;
  font-size: 13px;
  color: var(--blj-ink-dim);
}

/* ---------- Menu ---------- */

.blj-menu-card {
  width: 100%;
  max-width: 480px;
  background: linear-gradient(180deg, rgba(14, 74, 52, 0.5), var(--blj-panel));
  border: 1px solid var(--blj-panel-line);
  border-radius: var(--blj-radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.blj-title {
  margin: 0 0 6px;
  font-size: 34px;
  font-weight: 800;
  color: var(--blj-gold);
  letter-spacing: 0.01em;
}

.blj-tagline {
  margin: 0 0 24px;
  color: var(--blj-ink-dim);
  font-size: 15px;
}

.blj-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.blj-fineprint {
  margin: 20px 0 0;
  font-size: 12px;
  color: var(--blj-ink-dim);
  opacity: 0.8;
}

/* ---------- Buttons ---------- */

.blj-btn {
  appearance: none;
  border: none;
  border-radius: var(--blj-radius-md);
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
  touch-action: manipulation;
}

.blj-btn:active {
  transform: scale(0.97);
}

.blj-btn-primary {
  background: linear-gradient(180deg, var(--blj-gold-soft), var(--blj-gold));
  color: #23180a;
  box-shadow: 0 8px 18px rgba(232, 194, 94, 0.25);
}

.blj-btn-primary:hover {
  filter: brightness(1.05);
}

.blj-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--blj-ink);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.blj-btn-disabled,
.blj-btn:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: var(--blj-ink-dim);
  cursor: not-allowed;
  opacity: 0.7;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.blj-btn:disabled:active {
  transform: none;
}

.blj-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.12);
  color: var(--blj-ink-dim);
  padding: 3px 8px;
  border-radius: 999px;
}

.blj-icon-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--blj-ink);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Help / Rules / Paytable ---------- */

.blj-help-card {
  width: 100%;
  max-width: 480px;
  background: linear-gradient(180deg, rgba(14, 74, 52, 0.5), var(--blj-panel));
  border: 1px solid var(--blj-panel-line);
  border-radius: var(--blj-radius-lg);
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.blj-help-title {
  margin: 0 0 10px;
  color: var(--blj-gold);
  font-size: 22px;
  font-weight: 800;
}

.blj-help-copy {
  margin: 0 0 16px;
  color: var(--blj-ink-dim);
  font-size: 14px;
  line-height: 1.5;
}

.blj-help-copy-small {
  font-size: 12px;
  margin-top: 4px;
}

.blj-help-list {
  margin: 0 0 16px;
  padding-left: 20px;
  color: var(--blj-ink-dim);
  font-size: 13px;
  line-height: 1.6;
}

.blj-help-list strong {
  color: var(--blj-ink);
}

.blj-table-wrap {
  overflow-x: auto;
  border-radius: var(--blj-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
}

.blj-paytable {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 260px;
}

.blj-paytable th,
.blj-paytable td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.blj-paytable th {
  color: var(--blj-gold);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.2);
}

.blj-paytable td:last-child,
.blj-paytable th:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--blj-gold-soft);
  font-weight: 700;
}

.blj-paytable tbody tr:last-child td {
  border-bottom: none;
}

/* ---------- Play screen ---------- */

#blj-screen-play.blj-screen {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  display: none;
  background: transparent;
}

#blj-screen-play.blj-screen.is-open {
  display: flex;
  opacity: 1;
  transform: none;
}

.blj-screen-play {
  width: 100%;
}

.blj-play-inner {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(10px + var(--blj-safe-t)) calc(12px + var(--blj-safe-r)) calc(14px + var(--blj-safe-b)) calc(12px + var(--blj-safe-l));
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  overflow-y: auto;
}

.blj-play-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.blj-balance-chip {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  background: var(--blj-chip);
  border: 1px solid var(--blj-panel-line);
  border-radius: 999px;
  padding: 8px 16px;
}

.blj-balance-label {
  font-size: 11px;
  color: var(--blj-ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.blj-balance-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--blj-gold-soft);
  font-variant-numeric: tabular-nums;
}

.blj-balance-currency {
  font-size: 11px;
  color: var(--blj-ink-dim);
}

.blj-table-felt {
  position: relative;
  border-radius: var(--blj-radius-lg);
  background:
    radial-gradient(120% 140% at 50% 0%, var(--blj-felt-1) 0%, var(--blj-felt-2) 60%, var(--blj-felt-edge) 100%);
  border: 6px solid #3a2211;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45), 0 12px 30px rgba(0, 0, 0, 0.4);
  padding: 14px 10px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.blj-dealer-area,
.blj-hand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.blj-seat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--blj-ink-dim);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.blj-seat-value {
  font-size: 14px;
  font-weight: 800;
  color: var(--blj-gold-soft);
  font-variant-numeric: tabular-nums;
}

.blj-cards-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 74px;
}

/* ---------- Cards ---------- */

.blj-card {
  width: 48px;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  background: var(--blj-card-white);
  color: #1a1a1a;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px 5px;
  position: relative;
  animation: blj-card-deal 0.22s ease both;
}

.blj-card-rank {
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.blj-card-suit {
  font-size: 18px;
  line-height: 1;
  align-self: center;
}

.blj-card.blj-suit-red {
  color: var(--blj-red);
}

.blj-card.blj-card-back {
  background:
    repeating-linear-gradient(45deg, var(--blj-card-back-1) 0 6px, var(--blj-card-back-2) 6px 12px);
  border: 2px solid rgba(255, 255, 255, 0.25);
  align-items: center;
  justify-content: center;
}

.blj-card-back-glyph {
  width: 55%;
  height: 55%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
}

.blj-card.blj-card-reveal {
  animation: blj-card-reveal 0.4s ease both;
}

@keyframes blj-card-deal {
  from { transform: translateY(-14px) scale(0.9); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes blj-card-reveal {
  0% { transform: rotateY(90deg) scale(0.9); opacity: 0.4; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}

.blj-card.blj-card-bust {
  outline: 2px solid var(--blj-red);
}

.blj-card.blj-card-win-glow {
  outline: 2px solid var(--blj-green-ok);
}

/* ---------- Player hands ---------- */

.blj-player-hands {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.blj-hand {
  flex: 1 1 220px;
  max-width: 260px;
  padding: 6px 8px 8px;
  border-radius: var(--blj-radius-md);
  border: 1px solid transparent;
}

.blj-hand.is-active {
  border-color: rgba(232, 194, 94, 0.55);
  background: rgba(232, 194, 94, 0.06);
}

.blj-hand-outcome {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-height: 14px;
}

.blj-hand-outcome.blj-outcome-win,
.blj-hand-outcome.blj-outcome-blackjack {
  color: var(--blj-green-ok);
}

.blj-hand-outcome.blj-outcome-push {
  color: var(--blj-ink-dim);
}

.blj-hand-outcome.blj-outcome-loss {
  color: var(--blj-red);
}

.blj-hand-wager {
  font-size: 10px;
  color: var(--blj-ink-dim);
}

/* ---------- Result ---------- */

.blj-result {
  min-height: 24px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--blj-ink-dim);
}

.blj-result.blj-result-win {
  color: var(--blj-green-ok);
}

.blj-result.blj-result-lose {
  color: var(--blj-ink-dim);
}

.blj-result.blj-result-push {
  color: var(--blj-gold-soft);
}

/* ---------- Stats row ---------- */

.blj-stats-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.blj-stat {
  flex: 1;
  max-width: 200px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--blj-radius-sm);
  padding: 8px 10px;
  text-align: center;
}

.blj-stat-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--blj-ink-dim);
}

.blj-stat-value {
  display: block;
  font-size: 15px;
  font-weight: 800;
  color: var(--blj-ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- Controls ---------- */

.blj-bet-controls,
.blj-action-controls,
.blj-next-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 4px;
}

/* Guard against the native [hidden] default losing to the flex rules
   above — without this, an element carrying the "hidden" attribute would
   still render (and still intercept clicks) because display:flex here
   would otherwise beat the UA's default [hidden]{display:none}. */
.blj-action-controls[hidden],
.blj-next-controls[hidden],
.blj-bet-controls[hidden] {
  display: none;
}

.blj-bet-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--blj-chip);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 6px 10px;
}

.blj-bet-label {
  font-size: 11px;
  color: var(--blj-ink-dim);
  text-transform: uppercase;
  padding-left: 4px;
}

.blj-bet-btn {
  appearance: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--blj-ink);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.blj-bet-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.blj-bet-value {
  min-width: 56px;
  text-align: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.blj-btn-deal {
  flex: 1;
  font-size: 18px;
  letter-spacing: 0.04em;
  padding: 16px 20px;
}

.blj-btn-deal:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.blj-action-controls {
  flex-wrap: wrap;
}

.blj-action-btn {
  flex: 1 1 calc(50% - 5px);
  min-width: 110px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--blj-ink);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 15px;
  padding: 13px 14px;
}

.blj-action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#blj-btn-hit,
#blj-btn-stand {
  background: linear-gradient(180deg, var(--blj-gold-soft), var(--blj-gold));
  color: #23180a;
  border: none;
}

.blj-next-controls .blj-btn {
  flex: 1;
  font-size: 16px;
  padding: 15px 20px;
}

/* ---------- Small screens ---------- */

@media (max-width: 380px) {
  .blj-title {
    font-size: 28px;
  }
  .blj-card {
    width: 40px;
  }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .blj-card,
  .blj-progress-bar {
    animation: none !important;
    transition: none !important;
  }
}
