body { background: var(--bg-deep); }

/* ── Layout ── */
.bj-layout {
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  min-height: calc(100vh - 56px);
  gap: 1rem;
  padding: 1rem 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 1100px) {
  .bj-layout { grid-template-columns: 1fr; }
  .bj-sidebar-left, .bj-sidebar-right { display: none; }
}
.bj-sidebar-left  { grid-column: 1; grid-row: 1 / 4; }
.bj-center        { grid-column: 2; grid-row: 1 / 4; display: flex; flex-direction: column; gap: 0.75rem; }
.bj-sidebar-right { grid-column: 3; grid-row: 1 / 4; }

/* ── Table felt ── */
.bj-table {
  flex: 1;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1rem;
  position: relative;
}

/* ── Dealer ── */
.dealer-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}
.dealer-cards-area {
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dealer-score {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--amber);
  min-height: 2.2rem;
}

/* ── Players row ── */
.players-row {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
  margin-top: auto;
}

/* ── Bet zones row ── */
.bet-targets-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  flex-wrap: wrap;
  justify-content: center;
}
.bet-target {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.18s ease;
  min-width: 88px;
  background: rgba(0,0,0,0.3);
  gap: 0.12rem;
  user-select: none;
}
.bet-target:hover { border-color: var(--amber-dim); }
.bet-target.active {
  border-color: var(--amber);
  background: var(--amber-glow);
  box-shadow: 0 0 14px rgba(240,165,0,0.2);
}
.bet-target.has-bet { border-color: var(--amber-dim); }
.bt-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.52rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  text-align: center;
}
.bt-amount {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.95rem;
  color: var(--amber);
  font-weight: 700;
}
.bt-odds {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.48rem;
  color: var(--text-muted);
  text-align: center;
}
.bet-target.main-bet .bt-label { color: var(--text-secondary); }
.bet-target.main-bet.active .bt-label { color: var(--amber); }

/* ── Betting bar ── */
.betting-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0.85rem 1rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
}
.chips-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.bet-controls { display: flex; align-items: center; gap: 0.4rem; }

/* ── Hand log ── */
.hand-log { max-height: 200px; overflow-y: auto; }
.hand-log-entry {
  padding: 0.25rem 0;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.hand-log-entry.win  { color: var(--green-neon); }
.hand-log-entry.lose { color: var(--red-hot); }
.hand-log-entry.push { color: var(--silver); }
.hand-log-entry.total {
  font-weight: 700;
  font-size: 0.72rem;
  padding-bottom: 0.35rem;
  margin-bottom: 0.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.14) !important;
}
.hand-log-entry.total.win  { color: var(--green-neon); }
.hand-log-entry.total.lose { color: var(--red-hot); }
.hand-log-entry.total.push { color: var(--silver); }

/* ── Side bet payout reference ── */
.sb-ref-section { margin-bottom: 0.75rem; }
.sb-ref-title {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.58rem;
  color: var(--amber);
  letter-spacing: 0.12em;
  margin-bottom: 0.3rem;
}
.sb-ref-row {
  display: flex;
  justify-content: space-between;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.62rem;
  padding: 0.12rem 0;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255,255,255,0.025);
}
.sb-ref-row span:last-child { color: var(--amber); }

/* ── Split hand label ── */
.split-hand-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.58rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  margin-top: 0.2rem;
}
.split-hand-label.active-hand { color: var(--amber); }

/* ── Basic Strategy Hint ── */
.hint-btn {
  position: absolute;
  bottom: 8px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(240,165,0,0.15);
  border: 1px solid var(--amber-dim);
  color: var(--amber);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: background 0.15s, border-color 0.15s;
}
.hint-btn:hover { background: rgba(240,165,0,0.28); border-color: var(--amber); }
.hint-tooltip {
  position: absolute;
  bottom: 40px;
  right: 8px;
  background: rgba(10,15,10,0.96);
  border: 1px solid var(--amber);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.75rem;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.72rem;
  color: var(--amber);
  white-space: nowrap;
  z-index: 30;
  box-shadow: 0 0 12px rgba(240,165,0,0.2);
  pointer-events: none;
}
.hint-tooltip.hidden { display: none; }

/* ── Side Bet Legend Illumination ── */
.sb-ref-row.illuminated {
  border-color: var(--green-neon) !important;
  color: var(--green-neon) !important;
  box-shadow: 0 0 8px var(--green-neon);
  animation: legendPulse 0.5s ease-in-out 2;
}
.sb-ref-row.illuminated span:last-child { color: var(--green-neon) !important; }
@keyframes legendPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Chat Panel ── */
.chat-panel {
  position: fixed;
  bottom: 0;
  right: 16px;
  width: 280px;
  background: var(--bg-primary, #0a0f0a);
  border: 1px solid var(--amber, #f0a500);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  z-index: 500;
  font-size: 0.8rem;
}
.chat-panel.collapsed .chat-messages,
.chat-panel.collapsed .chat-input-row,
.chat-panel.collapsed .chat-emotes { display: none; }
.chat-header {
  padding: 6px 10px;
  cursor: pointer;
  background: rgba(240,165,0,0.1);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  color: var(--amber);
  letter-spacing: 0.08em;
  border-radius: 8px 8px 0 0;
  user-select: none;
}
.chat-unread {
  background: var(--red-hot, #ff3a3a);
  color: white;
  border-radius: 10px;
  padding: 0 5px;
  font-size: 0.7rem;
  margin-left: auto;
}
.chat-toggle-icon { margin-left: auto; font-size: 0.65rem; }
.chat-unread + .chat-toggle-icon { margin-left: 0; }
.chat-messages {
  height: 160px;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text-primary);
}
.chat-msg { line-height: 1.3; word-break: break-word; }
.chat-emote { text-align: center; }
.emote-large { font-size: 1.5rem; }
.chat-user { font-weight: bold; font-size: 0.75rem; }
.chat-emotes {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px;
  border-top: 1px solid rgba(240,165,0,0.2);
}
.emote-btn {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.15s;
}
.emote-btn:hover { background: rgba(255,255,255,0.1); }
.chat-input-row {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-top: 1px solid rgba(240,165,0,0.2);
}
.chat-input-row input {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(240,165,0,0.3);
  color: var(--text-primary);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  outline: none;
}
.chat-input-row input:focus { border-color: var(--amber-dim); }
.chat-input-row button {
  padding: 4px 8px;
  background: var(--amber, #f0a500);
  color: black;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: bold;
  font-family: 'Share Tech Mono', monospace;
}

/* ── Mobile ── */
@media (max-width: 640px) {
  /*
   * Body flex-column approach: no hardcoded px offsets, no dvh units.
   * Header takes its natural height; bj-layout fills the remainder.
   */
  html { height: 100%; overflow: hidden; }
  body { height: 100%; overflow: hidden; display: flex; flex-direction: column; }
  .site-header { flex-shrink: 0; }

  .bj-layout {
    flex: 1;
    min-height: 0 !important;
    height: auto !important;
    position: relative !important;
    padding: 0; gap: 0;
    overflow: hidden;
  }

  .bj-center {
    min-height: 0;
    height: 100%;
    gap: 0; overflow: hidden;
    display: flex; flex-direction: column;
  }

  /* Table: min-height:0 is the iOS Safari flex-shrink fix */
  .bj-table {
    min-height: 0 !important;
    flex: 1; overflow: hidden;
    padding: 0.4rem 0.6rem;
    gap: 0.32rem;
    border-radius: 0; border-left: none; border-right: none;
  }

  .bj-center > .status-bar { flex-shrink: 0; margin: 0.28rem auto 0; }
  .dealer-cards-area { min-height: 62px; }

  /* All seats uniform size */
  .players-row {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 0.4rem; padding: 0.12rem 0.5rem 0.28rem;
    justify-content: flex-start !important; scrollbar-width: none;
  }
  .players-row::-webkit-scrollbar { display: none; }
  /* Other players: compact fixed-width tiles */
  .player-seat { min-width: 108px !important; max-width: 128px !important; flex-shrink: 0; scroll-snap-align: start; }
  /* My seat: fills the table width so cards aren't cramped */
  .player-seat.my-seat {
    min-width: 0 !important; max-width: 100% !important; width: 100% !important;
    margin-top: 0 !important; scroll-snap-align: start;
    flex-shrink: 1;
  }
  .player-seat.my-seat .seat-score { font-size: 1.2rem; }
  .player-seat.my-seat .seat-name  { font-size: 0.72rem; }

  /* Bet targets strip */
  #betArea { gap: 0 !important; flex-shrink: 0; }
  .bet-targets-row {
    gap: 0.26rem; overflow-x: auto; flex-wrap: nowrap;
    justify-content: flex-start; padding: 0.26rem 0.5rem;
    scrollbar-width: none; width: 100%; flex-shrink: 0;
  }
  .bet-targets-row::-webkit-scrollbar { display: none; }
  .bet-target { min-width: 64px; padding: 0.28rem 0.36rem; }

  /*
   * Betting bar: flex-direction:row overrides theme.css column.
   * chips-row (flex:0 0 100%) = own row.
   * bet-controls + DEAL share the second row.
   */
  .betting-bar {
    flex-direction: row !important; flex-wrap: wrap;
    gap: 0.26rem 0.38rem;
    padding: 0.35rem 0.6rem;
    padding-bottom: max(0.45rem, env(safe-area-inset-bottom));
    background: rgba(6,10,6,0.97);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-radius: 0; border-left: none; border-right: none; border-bottom: none;
    border-top: 1px solid var(--border-dim);
    flex-shrink: 0;
  }
  .chips-row {
    flex: 0 0 100%; order: 0;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    justify-content: flex-start !important;
  }
  .chips-row::-webkit-scrollbar { display: none; }
  .bet-controls { flex: 1; order: 1; width: auto !important; display: flex; gap: 0.3rem; align-items: center; }
  #confirmBetBtn { flex: 0 0 auto; order: 2; min-width: 80px; min-height: 38px; font-size: 0.88rem; }
  .chip { width: 42px; height: 42px; font-size: 0.62rem; flex-shrink: 0; }

  /* Action bar: 2-col grid for HIT/STAND, spans full width for insurance */
  .action-bar {
    display: grid !important;
    grid-template-columns: 1fr 1fr; gap: 0.28rem;
    padding: 0.32rem 0.6rem;
    padding-bottom: max(0.45rem, env(safe-area-inset-bottom));
    background: rgba(6,10,6,0.97);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-dim);
    flex-shrink: 0;
  }
  #btnHit, #btnStand { min-height: 50px !important; font-size: 0.95rem; }
  #btnDouble, #btnSplit { min-height: 40px !important; font-size: 0.78rem; }
  #btnInsurance, #btnNoInsurance { min-height: 44px !important; font-size: 0.85rem; }

  #toast-container { top: auto; bottom: max(82px, calc(72px + env(safe-area-inset-bottom))); right: 0.75rem; left: 0.75rem; }
  .toast { max-width: 100%; text-align: center; }

  /* theme.css has .action-bar{display:grid!important} at higher cascade position than
     .hidden{display:none!important} — two-class selector wins the !important tie */
  .action-bar.hidden { display: none !important; }
  .betting-bar.hidden { display: none !important; }

  /* Keep content packed at top; felt shows below */
  .bj-table { justify-content: flex-start; }

  /* Chat: full-width bar at bottom so it doesn't clip betting buttons.
     bj-center gets matching padding-bottom so the betting/action bars
     always sit above the collapsed chat header (~38px). */
  .chat-panel {
    left: 0;
    right: 0;
    width: 100%;
    border-left: none;
    border-right: none;
    border-radius: 0;
  }
  .bj-center {
    padding-bottom: 38px;
  }
}
@supports (padding: max(0px)) {
  .site-header { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
}
.seat-collectible {
  display: block;
  margin: 4px auto 0;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
}
.emote-btn.collectible-emote svg { vertical-align: middle; }
