:root {
  --bg-dark: #07110c;
  --felt-primary: #0f3822;
  --felt-radial: #185434;
  --felt-border: #266b46;
  --panel-bg: rgba(10, 25, 17, 0.88);
  --panel-border: rgba(255, 255, 255, 0.12);
  --gold: #f5c542;
  --gold-hover: #ffd666;
  --gold-dim: rgba(245, 197, 66, 0.2);
  --text-main: #f0f6f2;
  --text-muted: #9cb3a5;
  --danger: #e5484d;
  --success: #30a46c;
  --info: #3b82f6;
  --card-white: #ffffff;
  --card-red: #d32f2f;
  --card-black: #1a1a1a;
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  max-width: 1680px;
  margin: 0 auto;
}

/* Keyboard badge styling */
kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  color: #111;
  background-color: #e2e8f0;
  border: 1px solid #94a3b8;
  border-bottom-width: 2px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}

/* Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(6, 15, 10, 0.95);
  border-bottom: 1px solid var(--panel-border);
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  background: linear-gradient(135deg, var(--gold), #b8860b);
  color: #0b1911;
  font-weight: 900;
  font-size: 0.95rem;
  padding: 8px 10px;
  border-radius: 8px;
  letter-spacing: 1px;
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Count HUD */
.hud-panel {
  display: flex;
  align-items: center;
  gap: 18px;
  background: rgba(18, 45, 30, 0.75);
  border: 1px solid rgba(245, 197, 66, 0.35);
  padding: 6px 18px;
  border-radius: 999px;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.4);
}

.hud-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
}

.hud-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.hud-value {
  font-size: 1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hud-value.highlight {
  color: var(--gold);
}

.hud-panel.masked .count-secret {
  filter: blur(7px);
  opacity: 0.5;
  transition: filter 0.2s ease;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Main Table Container */
.table-container {
  display: grid;
  grid-template-columns: 270px 1fr 270px;
  gap: 16px;
  padding: 14px 20px;
  background: radial-gradient(circle at center, var(--felt-radial) 0%, var(--felt-primary) 65%, #071f12 100%);
  overflow: hidden;
  position: relative;
}

/* Side Panels */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 2;
  overflow-y: auto;
}

.panel-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
  margin-bottom: 10px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--text-main);
}

/* Shoe Bar */
.shoe-bar-outer {
  position: relative;
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  overflow: hidden;
  margin-bottom: 8px;
}

.shoe-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #eab308);
  transition: width 0.3s ease;
}

.shoe-cut-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger);
}

.shoe-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Stats Rows */
.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-row:last-child {
  border-bottom: none;
}

/* Trainer Toggles */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  padding: 5px 0;
  cursor: pointer;
}

.toggle-row input {
  accent-color: var(--gold);
  width: 15px;
  height: 15px;
}

/* Card Values Grid */
.card-tags-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.tag-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 4px;
  font-size: 0.75rem;
}

.tag-pill .rank {
  font-weight: 700;
  color: var(--text-muted);
}

.tag-pill .val {
  font-weight: 800;
}

.tag-pill.pos .val { color: #4ade80; }
.tag-pill.zero .val { color: #94a3b8; }
.tag-pill.neg .val { color: #f87171; }

/* Shortcut List */
.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.77rem;
  color: var(--text-muted);
}

/* Center Felt Area */
.felt-area {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  border: 2px solid rgba(245, 197, 66, 0.22);
  border-radius: 28px;
  padding: 16px 24px;
  position: relative;
  background: radial-gradient(ellipse at top, rgba(255, 255, 255, 0.04), transparent 70%);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.35);
}

.table-arc-text {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: rgba(245, 197, 66, 0.45);
  font-weight: 700;
  text-align: center;
}

/* Dealer & Player Zones */
.dealer-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 155px;
}

.zone-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zone-label {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.hand-total-badge {
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 2px 9px;
  border-radius: 999px;
}

.hand-total-badge.bust {
  background: var(--danger);
  border-color: #ff8b8e;
}

.hand-total-badge.bj {
  background: var(--gold);
  color: #111;
}

/* Cards Row */
.cards-row {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 116px;
}

.playing-card {
  width: 82px;
  height: 116px;
  background: var(--card-white);
  border-radius: 8px;
  box-shadow: -4px 4px 12px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px 8px;
  position: relative;
  margin-left: -22px;
  transition: transform 0.2s ease;
  animation: dealCard 0.18s ease-out;
}

.playing-card:first-child {
  margin-left: 0;
}

@keyframes dealCard {
  from {
    opacity: 0;
    transform: translate(80px, -90px) rotate(12deg) scale(0.75);
  }
  to {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

@keyframes flipReveal {
  0% {
    transform: perspective(600px) rotateY(90deg) scale(1.06);
  }
  100% {
    transform: perspective(600px) rotateY(0deg) scale(1);
  }
}

.playing-card.flip-reveal {
  animation: flipReveal 0.28s ease-out;
}

.playing-card.red {
  color: var(--card-red);
}

.playing-card.black {
  color: var(--card-black);
}

.playing-card.hole-card {
  background: repeating-linear-gradient(
    45deg,
    #1e3a8a,
    #1e3a8a 6px,
    #172554 6px,
    #172554 12px
  );
  border: 3px solid #f8fafc;
}

.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card-corner.bottom {
  align-self: flex-end;
  transform: rotate(180deg);
}

.card-rank {
  font-size: 1.05rem;
  font-weight: 800;
}

.card-suit-sm {
  font-size: 0.85rem;
}

.card-center-suit {
  font-size: 2.1rem;
  align-self: center;
  line-height: 1;
}

.card-count-tag {
  position: absolute;
  top: -8px;
  right: -6px;
  background: #0f172a;
  color: var(--gold);
  border: 1px solid var(--gold);
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 99px;
  animation: popTag 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-count-tag.pos {
  color: #4ade80;
  border-color: #4ade80;
}

.card-count-tag.neg {
  color: #f87171;
  border-color: #f87171;
}

@keyframes popTag {
  from {
    transform: scale(0.3) translateY(6px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.hud-panel.masked ~ .table-container .card-count-tag {
  display: none;
}

/* Center Prompts / Status Banner */
.center-banner-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 5;
  max-width: 560px;
  width: 100%;
}

.status-banner {
  background: rgba(7, 17, 12, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 8px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.prompt-box {
  background: rgba(10, 22, 16, 0.96);
  border: 2px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.prompt-box.warning-box {
  border-color: #f97316;
}

.prompt-title {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--gold);
  margin-bottom: 4px;
}

.prompt-Sub, .prompt-desc {
  font-size: 0.82rem;
  color: var(--text-main);
  margin-bottom: 10px;
}

.prompt-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.quiz-form {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.quiz-form input {
  width: 130px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: #0f1f16;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
}

.quiz-feedback {
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 700;
}

/* Player Hands Container */
.player-zone {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 28px;
  min-height: 175px;
  width: 100%;
}

.player-hand-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  transition: all 0.2s ease;
  position: relative;
}

.player-hand-box.active-hand {
  border-color: var(--gold);
  background: rgba(245, 197, 66, 0.08);
  box-shadow: 0 0 20px rgba(245, 197, 66, 0.2);
}

.hand-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hand-bet-chip {
  background: rgba(245, 197, 66, 0.2);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
}

.hand-outcome-pill {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 6px;
}

.outcome-win { background: var(--success); color: #fff; }
.outcome-loss { background: var(--danger); color: #fff; }
.outcome-push { background: #64748b; color: #fff; }
.outcome-bj { background: var(--gold); color: #111; }

/* Bottom Control Deck */
.control-deck {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(6, 15, 10, 0.96);
  border-top: 1px solid var(--panel-border);
  gap: 20px;
  flex-wrap: wrap;
}

.bankroll-box {
  display: flex;
  gap: 20px;
}

.bank-item {
  display: flex;
  flex-direction: column;
}

.bank-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 700;
}

.bank-val {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.bank-val.gold {
  color: var(--gold);
}

.bank-val-wrap,
.bet-stack-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.payout-float {
  font-size: 0.9rem;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 99px;
  animation: floatUpFade 1.5s ease-out forwards;
}

.payout-float.win {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.16);
}

.payout-float.loss {
  color: #f87171;
  background: rgba(248, 113, 113, 0.16);
}

@keyframes floatUpFade {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.85);
  }
  20% {
    opacity: 1;
    transform: translateY(0) scale(1.05);
  }
  80% {
    opacity: 1;
    transform: translateY(-4px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
}

.mini-chip-stack {
  display: flex;
  align-items: center;
  margin-left: 4px;
}

.mini-chip {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.85);
  margin-left: -7px;
  box-shadow: -1px 2px 4px rgba(0, 0, 0, 0.5);
  animation: chipBounce 0.2s ease-out;
}

.mini-chip:first-child {
  margin-left: 0;
}

@keyframes chipBounce {
  from {
    transform: translateY(-12px) scale(0.7);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes warnShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.prompt-box.warning-box {
  border-color: #f97316;
  animation: warnShake 0.35s ease-in-out;
}

/* Chips Rack */
.chips-rack {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chip {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 4px dashed rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease, opacity 0.2s;
  position: relative;
}

.chip:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.05);
}

.chip:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.chip-amount {
  font-size: 0.78rem;
  line-height: 1;
}

.chip kbd {
  margin: 2px 0 0 0;
  font-size: 0.62rem;
  padding: 1px 4px;
}

.chip-5 { background: #dc2626; }
.chip-25 { background: #16a34a; }
.chip-100 { background: #1e293b; border-color: var(--gold); }
.chip-500 { background: #7e22ce; }
.chip-1000 { background: #ca8a04; color: #111; }

.bet-utility-btns {
  display: flex;
  gap: 6px;
  margin-left: 6px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.86rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-main);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.78rem;
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.18);
}

.btn-outline:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--gold);
}

.btn-secondary {
  background: #1e293b;
  border-color: #334155;
}

.btn-secondary:hover:not(:disabled) {
  background: #334155;
}

.btn-gold {
  background: var(--gold);
  color: #111;
}

.btn-gold:hover:not(:disabled) {
  background: var(--gold-hover);
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-deal {
  background: linear-gradient(135deg, var(--gold), #eab308);
  color: #0b1911;
  font-size: 0.95rem;
  font-weight: 900;
  padding: 11px 22px;
  box-shadow: 0 4px 14px rgba(245, 197, 66, 0.35);
}

.btn-deal:hover:not(:disabled) {
  transform: translateY(-2px);
  background: var(--gold-hover);
}

.btn-action {
  padding: 11px 16px;
  font-weight: 800;
}

.btn-hit { background: #16a34a; }
.btn-hit:hover:not(:disabled) { background: #22c55e; }

.btn-stand { background: #dc2626; }
.btn-stand:hover:not(:disabled) { background: #ef4444; }

.btn-double { background: #2563eb; }
.btn-double:hover:not(:disabled) { background: #3b82f6; }

.btn-split { background: #7c3aed; }
.btn-split:hover:not(:disabled) { background: #8b5cf6; }

.btn-surrender { background: #475569; }
.btn-surrender:hover:not(:disabled) { background: #64748b; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  background: #0d1f16;
  border: 1px solid rgba(245, 197, 66, 0.4);
  border-radius: var(--radius-lg);
  max-width: 780px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--panel-border);
}

.modal-header h2 {
  font-size: 1.1rem;
  color: var(--gold);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.modal-section h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
}

.form-group select,
.form-group input[type="number"] {
  padding: 8px 10px;
  background: #07120c;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: #fff;
  font-size: 0.85rem;
}

.system-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 12px;
}

.custom-tags-editor {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.tag-input-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px;
  border-radius: 6px;
}

.tag-input-box label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 3px;
}

.tag-input-box input {
  width: 100%;
  text-align: center;
  background: #07120c;
  border: 1px solid var(--panel-border);
  color: #fff;
  border-radius: 4px;
  padding: 4px;
  font-size: 0.8rem;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--panel-border);
  display: flex;
  justify-content: flex-end;
}

/* Analyzer Table inside Modal */
.analyzer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.analyzer-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 14px;
}

.analyzer-card h4 {
  color: var(--gold);
  font-size: 0.85rem;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.analyzer-stat-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 4px 0;
}

.rec-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 6px;
  background: var(--gold);
  color: #111;
  font-weight: 900;
}
