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

:root {
  --felt:       #1a5c2a;
  --felt-dark:  #123d1d;
  --felt-light: #217334;
  --gold:       #c9993a;
  --gold-light: #f0c060;
  --red:        #c0392b;
  --chip-shadow: 0 4px 12px rgba(0,0,0,0.5);
  --card-w: 80px;
  --card-h: 112px;
}

body {
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0d0d1a 100%);
  min-height: 100vh;
  font-family: 'Inter', sans-serif;
  color: #fff;
  overflow-x: hidden;
}

/* ─── HEADER ──────────────────────────────────────────── */
header {
  text-align: center;
  padding: 20px 16px 10px;
}
header h1 {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 900;
  letter-spacing: .12em;
  background: linear-gradient(135deg, #c9993a, #f0c060, #c9993a);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 2px 6px rgba(201,153,58,.6));
}
header p { color: rgba(255,255,255,0.45); font-size: .8rem; letter-spacing: .15em; text-transform: uppercase; margin-top: 4px; }

/* ─── STATS BAR ──────────────────────────────────────── */
.stats-bar {
  display: flex; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 0 16px 12px;
}
.stat-pill {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50px;
  padding: 6px 18px;
  font-size: .78rem;
  font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.stat-pill .label { color: rgba(255,255,255,0.45); }
.stat-pill .val { color: var(--gold-light); }
#stat-streak .val { color: #22c55e; }
.btn-lang {
  background: rgba(201,153,58,0.15);
  border: 1px solid rgba(201,153,58,0.5);
  color: var(--gold-light);
  border-radius: 50px;
  padding: 6px 14px;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Cinzel', serif;
}
.btn-lang:hover { background: rgba(201,153,58,0.3); }

/* ─── MAIN LAYOUT ────────────────────────────────────── */
.main-container {
  display: flex;
  gap: 20px;
  max-width: 900px;
  margin: 0 auto 30px;
  padding: 0 16px;
  align-items: stretch;
  justify-content: center;
}

/* ─── LEFT PANEL (CHIPS & BET) ───────────────────────── */
.left-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 24px;
  padding: 24px 20px;
  min-width: 130px;
}
.chips-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chip {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 3px dashed rgba(255,255,255,0.3);
  outline: 4px solid rgba(0,0,0,0.4);
  cursor: pointer;
  font-weight: 700; font-size: .75rem;
  font-family: 'Cinzel', serif;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--chip-shadow);
  position: relative;
  user-select: none;
}
.chip:hover  { transform: scale(1.12) translateY(-3px); }
.chip:active { transform: scale(0.95); }
.chip[data-val="10"]  { background: radial-gradient(circle, #3b82f6, #1d4ed8); }
.chip[data-val="25"]  { background: radial-gradient(circle, #22c55e, #15803d); }
.chip[data-val="50"]  { background: radial-gradient(circle, #ec4899, #be185d); }
.chip[data-val="100"] { background: radial-gradient(circle, #f59e0b, #b45309); }
.chip[data-val="500"] { background: radial-gradient(circle, #8b5cf6, #6d28d9); }

.bet-display {
  text-align: center;
  font-family: 'Cinzel', serif;
}
.bet-display .bl { font-size: .65rem; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: .15em; margin-bottom: 2px; }
.bet-display .bv { font-size: 1.6rem; font-weight: 700; color: var(--gold-light); line-height: 1; }

.btn-clear {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: #ef4444;
  padding: 8px 16px;
  border-radius: 50px;
  font-size: .75rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-clear:hover { background: rgba(239,68,68,0.25); }
.btn-clear:disabled { opacity: 0.35; cursor: not-allowed; }

/* ─── RIGHT PANEL (TABLE & BUTTONS) ──────────────────── */
.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ─── TABLE ──────────────────────────────────────────── */
.table {
  background: radial-gradient(ellipse at center, var(--felt-light) 0%, var(--felt) 50%, var(--felt-dark) 100%);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border: 6px solid #5a3e1b;
  border-bottom: none;
  box-shadow:
    0 0 0 2px rgba(201,153,58,.4),
    inset 0 2px 40px rgba(0,0,0,0.3);
  padding: 24px 20px;
  position: relative;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.table::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 20px,
    rgba(255,255,255,0.015) 20px, rgba(255,255,255,0.015) 21px
  );
  pointer-events: none;
}

.balance-top-right {
  position: absolute;
  top: 16px;
  right: 20px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(201,153,58,.3);
  border-radius: 50px;
  padding: 6px 16px;
  display: flex; align-items: center; gap: 8px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.balance-top-right .ml { font-size: .65rem; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: .1em; }
.balance-top-right .mv { font-family: 'Cinzel', serif; font-size: 1.1rem; font-weight: 700; color: var(--gold-light); }

/* ─── PLAYER ZONES ──────────────────────────────────── */
.zone-label {
  font-family: 'Cinzel', serif;
  font-size: .7rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  margin-bottom: 8px;
}
.score-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50px;
  padding: 4px 16px;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 10px;
  position: relative; z-index: 2;
}
.score-badge .name { font-size: .75rem; color: rgba(255,255,255,0.5); font-weight: 400; }
.score-badge .pts { color: var(--gold-light); }
.score-badge.bust .pts { color: #ef4444; }
.score-badge.win21 .pts { color: #22c55e; }

.cards-area {
  min-height: var(--card-h);
  display: flex;
  align-items: center;
  gap: -10px;
  flex-wrap: wrap;
  padding: 4px 0 8px;
  position: relative;
}

/* ─── CARDS ─────────────────────────────────────────── */
.carta {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  box-shadow: 3px 4px 12px rgba(0,0,0,0.5);
  object-fit: cover;
  margin-right: -18px;
  transition: transform 0.15s;
  animation: dealCard 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  position: relative;
}
.carta:hover { transform: translateY(-8px) scale(1.05); z-index: 10; }
@keyframes dealCard {
  from { opacity: 0; transform: translateY(-40px) rotate(-8deg) scale(0.8); }
  to   { opacity: 1; transform: translateY(0)    rotate(0deg)  scale(1); }
}

.divider {
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.15), transparent);
  margin: 12px 0;
}

/* ─── BUTTONS ────────────────────────────────────────── */
.btns-row-attached {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  background: rgba(20, 20, 30, 0.95);
  padding: 14px 20px;
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  border: 1px solid rgba(255,255,255,0.05);
  border-top: none;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.btn {
  padding: 10px 24px; border-radius: 50px;
  font-weight: 700; font-size: .85rem;
  border: none; cursor: pointer;
  transition: all 0.2s;
  font-family: 'Cinzel', serif;
  letter-spacing: .05em;
  display: flex; align-items: center; gap: 8px;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; }
.btn:not(:disabled):hover { transform: translateY(-2px); }
.btn:not(:disabled):active { transform: translateY(0) scale(0.97); }

.btn-deal {
  background: linear-gradient(135deg, #c9993a, #f0c060);
  color: #1a0e00;
  box-shadow: 0 6px 24px rgba(201,153,58,.45);
}
.btn-hit {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  box-shadow: 0 6px 24px rgba(34,197,94,.35);
}
.btn-stand {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  box-shadow: 0 6px 24px rgba(59,130,246,.35);
}
.btn-new {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: #ccc;
}

/* ─── RESULT MODAL ───────────────────────────────────── */
#result-modal {
  display: none; position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
}
#result-modal.show { display: flex; }
.modal-card {
  background: linear-gradient(145deg, #1e2235, #12151f);
  border-radius: 24px;
  padding: 48px 40px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 40px 80px rgba(0,0,0,0.7);
  max-width: 380px; width: 90%;
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.modal-emoji { font-size: 4rem; margin-bottom: 12px; }
.modal-title { font-family: 'Cinzel', serif; font-size: 1.8rem; font-weight: 900; margin-bottom: 8px; }
.modal-title.win  { color: var(--gold-light); }
.modal-title.lose { color: #ef4444; }
.modal-title.push { color: #94a3b8; }
.modal-detail { color: rgba(255,255,255,0.5); font-size: .9rem; margin-bottom: 24px; }
.modal-earn { font-family: 'Cinzel', serif; font-size: 1.3rem; font-weight: 700; margin-bottom: 24px; }
.modal-earn.positive { color: #22c55e; }
.modal-earn.negative { color: #ef4444; }
.modal-earn.neutral  { color: #94a3b8; }

/* ─── HISTORY ────────────────────────────────────────── */
.history-wrap {
  max-width: 860px; margin: 0 auto 30px;
  padding: 0 12px;
}
.history-title {
  font-family: 'Cinzel', serif;
  font-size: .75rem; letter-spacing: .15em;
  color: rgba(255,255,255,0.3);
  text-align: center; margin-bottom: 10px;
}
#history-list {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
}
.hist-pill {
  font-size: .75rem; padding: 4px 12px; border-radius: 50px;
  font-weight: 600;
}
.hist-pill.W { background: rgba(34,197,94,.15); color: #22c55e; border: 1px solid rgba(34,197,94,.3); }
.hist-pill.L { background: rgba(239,68,68,.15);  color: #ef4444; border: 1px solid rgba(239,68,68,.3); }
.hist-pill.P { background: rgba(148,163,184,.1); color: #94a3b8; border: 1px solid rgba(148,163,184,.2); }

/* ─── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 768px) {
  .main-container { flex-direction: column; }
  .left-panel { flex-direction: row; flex-wrap: wrap; padding: 16px; }
  .chips-col { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .balance-top-right { top: 10px; right: 10px; padding: 4px 12px; }
}
@media (max-width: 480px) {
  :root { --card-w: 58px; --card-h: 82px; }
  .chip { width: 44px; height: 44px; font-size: .65rem; }
  .btn { padding: 10px 16px; font-size: .75rem; }
  .balance-top-right .mv { font-size: .95rem; }
}
