:root {
  --bg: #0c0f12;
  --panel: #151a21;
  --text: #dbe3ec;
  --muted: #9aa6b2;
  --accent: #3aa675;
  --warn: #e6b800;
  --danger: #e05d5d;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}
.app-header { padding: 16px 20px; border-bottom: 1px solid #222933; }
.app-header h1 { margin: 0; font-weight: 700; font-size: 20px; }
.app-header .sub { color: var(--muted); margin-top: 4px; font-size: 12px; }

.controls { padding: 16px 20px; }
.control-group { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.control-group label { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid #1e2530; border-radius: 8px; padding: 8px 10px; }
.control-group select, .control-group input { background: #0f1318; color: var(--text); border: 1px solid #2a3442; border-radius: 6px; padding: 6px 8px; }
.control-group button { background: #233041; color: var(--text); border: 1px solid #2f3e52; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.control-group button:hover { background: #2a3a4e; }
.control-group button, .action-bar button { min-height: 44px; }
.game { padding: 0 20px 16px; }
.section-title { margin: 0 0 8px 0; font-size: 16px; color: var(--muted); }
.game-controls { margin-bottom: 8px; }
.seat-picker { gap: 8px; }
.seat-picker label { padding: 4px 8px; }
.seat-picker input[type="checkbox"] { transform: translateY(1px); }
.status-bar { display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #142230; border: 1px solid #213146; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.banner .banner-text { color: #cfe9da; font-weight: 600; }
.banner .banner-actions button { background: #233041; color: var(--text); border: 1px solid #2f3e52; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.banner .banner-actions button:hover { background: #2a3a4e; }
.banner-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#ins-seat-list { display: flex; gap: 8px; flex-wrap: wrap; }
#ins-seat-list label { background: #0f161c; border: 1px solid #223041; padding: 4px 8px; border-radius: 6px; }
.visually-hidden { position: absolute !important; height: 1px; width: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap; }
.table { border: 1px solid #1e2530; border-radius: 10px; background: #10151b; padding: 10px; }
.dealer { border-bottom: 1px dashed #1e2530; padding-bottom: 8px; margin-bottom: 8px; }
.dealer .label { color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.players { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.player-hand { background: #0e1318; border: 1px solid #1e2530; border-radius: 8px; padding: 8px; position: relative; }
.player-hand.active-hand { border-color: #ffd36e; box-shadow: 0 0 0 2px rgba(255, 211, 110, 0.25); }
.player-hand.blackjack-win { border-color: #3aa675; box-shadow: 0 0 0 2px rgba(58, 166, 117, 0.35), 0 0 18px rgba(58,166,117,0.6); animation: bj-pulse 800ms ease-in-out 3; }
.bj-badge { position: absolute; top: 6px; right: 6px; background: #173224; color: #cfe9da; border: 1px solid #25533e; border-radius: 999px; padding: 2px 8px; font-weight: 800; letter-spacing: 0.5px; }
@keyframes bj-pulse { 0% { transform: scale(1); } 50% { transform: scale(1.03); } 100% { transform: scale(1); } }
.player-title { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.player-title .active { color: #cfe9da; }
.bet-tag { background: #1a2430; padding: 2px 6px; border-radius: 6px; border: 1px solid #2f3e52; color: #cbd5e1; }
.cards .card { width: 36px; height: 52px; border-radius: 6px; border: 1px solid #2a3442; background: #0f1318; display: inline-flex; align-items: center; justify-content: center; color: #e6edf5; font-weight: 700; }
.cards .card + .card { margin-left: 6px; }
.action-bar { display: flex; gap: 8px; align-items: center; padding: 10px 0; }
.action-bar button { background: #233041; color: var(--text); border: 1px solid #2f3e52; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.action-bar button[disabled] { opacity: 0.5; cursor: not-allowed; }
.hint-suggest { outline: 2px solid #ffd36e; }

/* Focus visibility for accessibility */
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

.betting, .insurance { margin: 8px 0; padding: 8px 10px; border-left: 3px solid var(--accent); background: #122019; border-radius: 6px; color: #cbe7d8; }
.insurance { border-left-color: var(--warn); background: #211f12; color: #f2e6b3; }

.hands { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; padding: 0 20px 24px; }
.hand { background: var(--panel); border: 1px solid #1e2530; border-radius: 10px; overflow: hidden; }
.hand-header { padding: 10px 12px; font-weight: 600; border-bottom: 1px solid #1e2530; background: #11161c; }
.cards { padding: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.card-select { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; background: #10151b; border: 1px solid #273041; border-radius: 8px; }
.card-select .rank { background: #0f1318; color: var(--text); border: 1px solid #2a3442; border-radius: 6px; padding: 6px 8px; }
.card-select button { background: transparent; color: var(--muted); border: none; cursor: pointer; padding: 0 4px; font-size: 16px; }
.card-select button:hover { color: #d66; }
.hand-actions { padding: 0 12px 12px; display: flex; gap: 10px; align-items: center; }
.result { padding: 10px 12px; border-top: 1px solid #1e2530; font-size: 14px; }

.round-summary { background: #0e1318; border: 1px solid #1e2530; border-radius: 8px; padding: 10px; margin-top: 10px; }
.round-summary .title { font-weight: 700; color: #cbd5e1; margin-bottom: 6px; }
.summary-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; }
.summary-item { background: #0f161c; border: 1px solid #223041; border-radius: 6px; padding: 8px; }
.summary-item.win { border-color: #2e6f4e; }
.summary-item.lose { border-color: #6f2e2e; }
.summary-item.push { border-color: #5f5f5f; }
.summary-item .delta { font-weight: 700; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 1000; }
.toast { background: #142230; color: #cbd5e1; border: 1px solid #213146; border-radius: 8px; padding: 8px 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.35); opacity: 0.96; }

.action {
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #2f3e52;
  background: #0f1318;
}
.action.HIT { color: #f1f1f1; }
.action.STAND { color: #7fd1a0; }
.action.DOUBLE { color: #80bfff; }
.action.SPLIT { color: #f7b267; }
.action.SURRENDER { color: #e05d5d; }

.hint { color: var(--muted); }
.deviation { color: #ffd36e; font-weight: 600; }
.why { color: #c3d4e3; }
.small { font-size: 12px; color: var(--muted); }
.app-footer { padding: 12px 20px; border-top: 1px solid #222933; color: var(--muted); font-size: 12px; }
