:root {
  --bg: #0b1d14;
  --bg-elev: #112a1f;
  --bg-elev-2: #173a2b;
  --line: #1f4632;
  --text: #e8f3ec;
  --text-dim: #8aa89a;
  --accent: #d4af37;
  --green: #3ecf6b;
  --red: #ef4d4d;
  --yellow: #f5c542;
  --blue: #4ea3ff;
  --player: #4ea3ff;
  --banker: #ef4d4d;
  --tie: #3ecf6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

.app {
  max-width: 540px;
  margin: 0 auto;
  padding: 12px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 4px 8px;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-size: 18px;
}

.topbar-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.deck-toggle {
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.deck-btn {
  background: transparent;
  color: var(--text-dim);
  border: 0;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.deck-btn.active {
  background: var(--accent);
  color: #1a1408;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.tally {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.tally-cell {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tally-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  font-weight: 600;
}

.tally-val {
  font-size: 32px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.tally-cell.banker .tally-val { color: var(--banker); }
.tally-cell.player .tally-val { color: var(--player); }
.tally-cell.tie    .tally-val { color: var(--tie);    }

.panel-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pred-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pred-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-elev-2);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.pred-row.side {
  font-size: 14px;
  padding: 6px 10px;
}

.pred-label {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

[data-bet="banker"] .pred-label { color: var(--banker); }
[data-bet="player"] .pred-label { color: var(--player); }
[data-bet="tie"] .pred-label { color: var(--tie); }

.pred-prob {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 56px;
  text-align: right;
}

.pred-ev {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  min-width: 72px;
  text-align: right;
  color: var(--text-dim);
  padding: 2px 6px;
  border-radius: 4px;
}

.pred-ev.positive {
  color: #0a1a10;
  background: var(--green);
  font-weight: 700;
}

.pred-ev.bad {
  color: var(--red);
}

.pred-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: rgba(255,255,255,0.04);
}

.pred-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 250ms ease;
}

[data-bet="banker"] .pred-bar-fill { background: var(--banker); }
[data-bet="player"] .pred-bar-fill { background: var(--player); }
[data-bet="tie"] .pred-bar-fill { background: var(--tie); }

.tie-alert {
  background: var(--yellow);
  color: #1a1408;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.pred-meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.hand-num {
  color: var(--accent);
  font-weight: 700;
}

.hand-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hand-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-elev-2);
  border-radius: 8px;
}

.hand-side {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.hand-cards {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
}

.hand-score {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: center;
}

.hand-prompt {
  margin-top: 10px;
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
  padding: 6px;
  border-top: 1px dashed var(--line);
}

.hand-prompt.done {
  color: var(--green);
  font-weight: 700;
}

.hand-prompt.empty {
  color: var(--red);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.card-btn {
  position: relative;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 0 6px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform 80ms ease, background 120ms ease;
}

.card-btn:active {
  transform: scale(0.93);
  background: var(--accent);
  color: #1a1408;
}

.card-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.card-btn .count {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.card-btn:active .count {
  color: #1a1408;
}

.card-btn.low .count {
  color: var(--yellow);
}

.actions {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 8px;
}

.primary-btn, .ghost-btn {
  border: 0;
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
}

.primary-btn {
  background: var(--green);
  color: #0a1a10;
}

.primary-btn:disabled {
  background: var(--bg-elev-2);
  color: var(--text-dim);
  cursor: not-allowed;
}

.primary-btn:not(:disabled) {
  animation: glow 1.6s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 rgba(62,207,107,0); }
  50% { box-shadow: 0 0 16px rgba(62,207,107,0.45); }
}

.ghost-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 14px;
  padding: 10px 14px;
}

.ghost-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ghost-btn.warn {
  border-color: rgba(239, 77, 77, 0.4);
  color: var(--red);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.stats-grid > div {
  background: var(--bg-elev-2);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.stat-val {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.recent {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.recent-chip {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.recent-chip.B { background: var(--banker); }
.recent-chip.P { background: var(--player); }
.recent-chip.T { background: var(--tie); color: #0a1a10; }

.footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  padding: 8px;
}

@media (min-width: 720px) {
  .app {
    max-width: 920px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "topbar   topbar"
      "tally    tally"
      "pred     hand"
      "pred     cards"
      "stats    actions"
      "footer   footer";
    gap: 12px;
  }
  .topbar { grid-area: topbar; }
  .tally { grid-area: tally; }
  .prediction { grid-area: pred; }
  .hand { grid-area: hand; }
  .cards { grid-area: cards; }
  .actions { grid-area: actions; align-self: start; }
  .stats { grid-area: stats; }
  .footer { grid-area: footer; }
}
