:root {
  --bg: #171b20;
  --panel: #222830;
  --panel-2: #2b323b;
  --felt: #08775a;
  --felt-dark: #056348;
  --cream: #fff8e9;
  --yellow: #ffd84a;
  --red: #f05a55;
  --blue: #69b7ff;
  --text: #f7f4ea;
  --muted: #9da6ae;
  --line: rgba(255, 255, 255, .1);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(53, 80, 102, .32), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: ui-rounded, "Arial Rounded MT Bold", Inter, system-ui, sans-serif;
}
button, select, input { font: inherit; }
button { color: inherit; }

.app-shell { width: min(1240px, calc(100% - 32px)); margin: 0 auto; padding: 20px 0 32px; }
.topbar { height: 62px; display: flex; align-items: center; justify-content: space-between; }
.logo { font-weight: 900; letter-spacing: .04em; }
.logo span { display: inline-grid; place-items: center; width: 34px; height: 34px; margin-right: 8px; border-radius: 10px; background: var(--yellow); color: #1b2025; transform: rotate(-6deg); }
.bankroll { display: flex; align-items: center; gap: 10px; padding: 8px 13px; border-radius: 12px; background: var(--panel); }
.bankroll small { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.bankroll strong { color: var(--yellow); font-size: 18px; }

.playground { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, .8fr); gap: 16px; }
.game-panel, .simulator { overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: 0 16px 40px rgba(0, 0, 0, .22); }

.felt { position: relative; min-height: 620px; display: grid; grid-template-rows: 1fr auto 1fr; gap: 16px; padding: 30px 9%; overflow: hidden; background: radial-gradient(circle at 50% 40%, #11906e, var(--felt) 52%, var(--felt-dark)); }
.felt::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .12; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.25'/%3E%3C/svg%3E"); }
.table-arc { position: absolute; width: 78%; height: 44%; left: 11%; top: 27%; border: 2px solid rgba(255,255,255,.16); border-radius: 50%; pointer-events: none; }
.hand-area { z-index: 1; min-height: 180px; display: flex; flex-direction: column; }
.dealer-area { align-self: start; }
.player-area { align-self: end; justify-content: end; }
.hand-label { display: flex; justify-content: center; align-items: center; gap: 8px; margin-bottom: 16px; font-weight: 800; }
.hand-label strong { display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 7px; border-radius: 9px; background: rgba(0,0,0,.22); color: var(--yellow); font-size: 13px; }
.cards { display: flex; justify-content: center; min-height: 140px; }
.card { position: relative; width: 94px; height: 136px; margin-left: -20px; padding: 10px; border-radius: 11px; background: var(--cream); color: #20242a; border: 2px solid rgba(255,255,255,.8); box-shadow: 0 8px 0 rgba(0,0,0,.18), 0 13px 24px rgba(0,0,0,.16); font-family: Georgia, serif; font-size: 27px; font-weight: 800; transform: rotate(-2deg); }
.card:nth-child(even) { transform: rotate(2deg) translateY(2px); }
.card:first-child { margin-left: 0; }
.card.red { color: #dd3e43; }
.card.back { background: repeating-linear-gradient(45deg, #ffd84a 0 7px, #e4b923 7px 10px); border: 7px solid var(--cream); color: transparent; }
.card-suit { display: block; font-size: 19px; }
.table-message { z-index: 2; justify-self: center; align-self: center; padding: 9px 15px; border-radius: 999px; background: rgba(0,0,0,.28); backdrop-filter: blur(5px); font-size: 13px; font-weight: 800; }

.game-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; }
.bet-control { display: flex; align-items: center; gap: 8px; padding-left: 4px; }
.bet-control > span { margin-right: 4px; color: var(--muted); font-size: 12px; font-weight: 800; }
.bet-control button { width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--panel-2); cursor: pointer; font-size: 19px; }
.bet-control button:hover { background: #39424d; }
.bet-control strong { min-width: 50px; text-align: center; color: var(--yellow); }
.action-buttons { display: flex; gap: 8px; }
.btn { min-width: 76px; height: 42px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--panel-2); cursor: pointer; font-weight: 900; }
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .3; cursor: not-allowed; }
.btn.deal { background: var(--yellow); color: #20242a; }

.simulator { padding: 20px; }
.sim-head { display: flex; align-items: center; gap: 13px; margin-bottom: 20px; }
.bot-face { display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 auto; border-radius: 15px; background: var(--blue); color: #152331; font-family: monospace; font-size: 15px; font-weight: 900; box-shadow: inset 0 -4px rgba(0,0,0,.12); }
.sim-head h1 { margin: 0 0 3px; font-size: 19px; }
.sim-head p { margin: 0; color: var(--muted); font: 12px/1.4 system-ui, sans-serif; }
#sim-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row, .range-row { padding: 11px 12px; border-radius: 12px; background: var(--panel-2); }
.form-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.form-row label, .range-row label { color: var(--muted); font: 700 11px system-ui, sans-serif; }
.form-row select { max-width: 100px; padding: 5px 6px; border: 0; border-radius: 7px; background: #20262d; color: var(--text); font: 700 11px system-ui, sans-serif; }
.range-row { grid-column: 1 / -1; }
.range-row label { display: flex; justify-content: space-between; margin-bottom: 8px; }
.range-row label strong { color: var(--text); }
.label-with-help { position: relative; display: inline-flex; align-items: center; gap: 5px; }
.help-tip { display: inline-grid; place-items: center; width: 17px; height: 17px; padding: 0; border: 1px solid #69747e; border-radius: 50%; background: transparent; color: var(--muted); cursor: help; font: 800 10px/1 system-ui, sans-serif; }
.help-tip:hover, .help-tip:focus-visible { border-color: var(--blue); color: var(--blue); outline: none; }
.tooltip { position: absolute; z-index: 10; left: 0; bottom: calc(100% + 9px); width: 230px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: #11161b; color: var(--text); box-shadow: 0 8px 24px rgba(0,0,0,.3); font: 11px/1.45 system-ui, sans-serif; opacity: 0; visibility: hidden; transform: translateY(4px); transition: opacity .15s, transform .15s, visibility .15s; pointer-events: none; }
.label-with-help:hover .tooltip, .label-with-help:focus-within .tooltip { opacity: 1; visibility: visible; transform: translateY(0); }
input[type=range] { width: 100%; accent-color: var(--yellow); }
.run-button { grid-column: 1 / -1; height: 44px; border: 0; border-radius: 12px; background: var(--blue); color: #142433; cursor: pointer; font-weight: 900; box-shadow: inset 0 -4px rgba(0,0,0,.12); }
.run-button:hover:not(:disabled) { filter: brightness(1.08); }
.run-button:disabled { opacity: .6; }
.run-button span { margin-right: 5px; font-size: 11px; }

.results-panel { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.result-main { text-align: center; }
.result-main > span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; }
.result-main > strong { display: block; margin: 3px 0; font-size: 38px; letter-spacing: -.04em; }
.result-main > strong.positive { color: #64dfa9; }
.result-main > strong.negative { color: var(--red); }
.result-main small { color: var(--muted); font: 10px system-ui, sans-serif; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 15px; }
.metrics div { padding: 10px; border-radius: 11px; background: var(--panel-2); }
.metrics span { display: block; color: var(--muted); font: 10px system-ui, sans-serif; }
.metrics strong { display: block; margin-top: 3px; font-size: 16px; }
.chart-wrap { margin-top: 15px; padding: 12px; border-radius: 12px; background: #1b2127; }
.chart-label { display: flex; justify-content: space-between; color: var(--muted); font: 700 10px system-ui, sans-serif; }
#bankroll-chart { display: block; width: 100%; height: 140px; margin-top: 8px; }

@media (max-width: 880px) {
  .playground { grid-template-columns: 1fr; }
  .felt { min-height: 560px; }
}

@media (max-width: 540px) {
  .app-shell { width: 100%; padding: 8px; }
  .topbar { padding: 0 7px; }
  .game-panel, .simulator { border-radius: 17px; }
  .felt { min-height: 500px; padding: 22px 5%; }
  .hand-area { min-height: 145px; }
  .card { width: 76px; height: 112px; font-size: 23px; }
  .cards { min-height: 115px; }
  .game-controls { align-items: stretch; flex-direction: column; }
  .bet-control { justify-content: center; }
  .action-buttons .btn { flex: 1; min-width: 0; }
  .logo { font-size: 13px; }
}
