:root {
  --bg: #0a1410;
  --panel: #102019;
  --panel2: #15291f;
  --line: #20392c;
  --felt: #0f5132;
  --green: #10b981;
  --green-glow: #34d399;
  --gold: #d4af37;
  --red: #e0455e;
  --black: #313a44;
  --text: #e9f1ec;
  --muted: #8aa399;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(16, 185, 129, 0.10), transparent 60%),
    radial-gradient(900px 400px at 0% 0%, rgba(212, 175, 55, 0.06), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 20, 16, 0.7);
  position: sticky;
  top: 0;
  backdrop-filter: blur(8px);
  z-index: 10;
}
.brand { font-size: 1.15rem; letter-spacing: 0.2px; }
.brand b { color: var(--green-glow); }
.chip-wheel { font-size: 1.3rem; }
.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: rgba(16, 185, 129, 0.15); color: var(--green-glow); border-color: rgba(16, 185, 129, 0.4); }

.disclaimer {
  margin: 12px 22px 0;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: #f3d9a6;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 10px;
}
.disclaimer b { color: var(--gold); }

main { max-width: 1080px; margin: 0 auto; padding: 18px 22px 40px; }
.hidden { display: none !important; }
.view-title { font-size: 1.5rem; margin: 6px 0 2px; }
.view-sub { color: var(--muted); margin: 0 0 18px; font-size: 0.92rem; }
.muted { color: var(--muted); font-weight: 400; }

/* ---------- Panels ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: 0.15s;
}
.btn:hover { border-color: rgba(16, 185, 129, 0.5); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--green); color: #052015; border-color: transparent; }
.btn-primary:hover { background: var(--green-glow); }
.btn-ghost { background: var(--panel2); }
.btn-win { background: rgba(16, 185, 129, 0.18); border-color: rgba(16, 185, 129, 0.5); color: var(--green-glow); flex: 1; }
.btn-loss { background: rgba(224, 69, 94, 0.16); border-color: rgba(224, 69, 94, 0.5); color: #ff8aa0; flex: 1; }
.btn-win:hover { background: rgba(16, 185, 129, 0.28); }
.btn-loss:hover { background: rgba(224, 69, 94, 0.26); }

/* ---------- Strategy grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.scard {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: 0.15s;
}
.scard:hover { border-color: rgba(16, 185, 129, 0.5); transform: translateY(-2px); }
.scard h3 { margin: 0 0 6px; font-size: 1.05rem; }
.scard p { margin: 8px 0 12px; font-size: 0.85rem; color: var(--muted); line-height: 1.4; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 0.7rem; padding: 3px 9px; border-radius: 999px; font-weight: 700; border: 1px solid transparent; }
.badge.family { background: rgba(56, 189, 248, 0.14); color: #7dd3fc; }
.badge.coverage { background: rgba(212, 175, 55, 0.16); color: #f0d27a; }
.risk-bajo { background: rgba(16, 185, 129, 0.16); color: var(--green-glow); }
.risk-medio { background: rgba(212, 175, 55, 0.16); color: #f0d27a; }
.risk-alto { background: rgba(249, 115, 22, 0.16); color: #fdba74; }
.risk-muy-alto { background: rgba(224, 69, 94, 0.18); color: #ff8aa0; }
.risk-negativa-suave, .risk-cobertura { background: rgba(56,189,248,0.14); color:#7dd3fc; }

/* ---------- Strategy detail ---------- */
.detail-cols { display: grid; grid-template-columns: 1.2fr 1fr; gap: 22px; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: 8px 0 8px 36px;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 7px;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  background: rgba(16, 185, 129, 0.15);
  color: var(--green-glow);
  border-radius: 50%; font-size: 0.78rem; font-weight: 700;
}
.pc-list { list-style: none; padding: 0; margin: 6px 0 16px; }
.pc-list li { font-size: 0.86rem; padding: 4px 0 4px 22px; position: relative; color: #cfe0d6; }
.pc-list.pros li::before { content: "✔"; position: absolute; left: 0; color: var(--green-glow); }
.pc-list.cons li::before { content: "✗"; position: absolute; left: 0; color: #ff8aa0; }
.detail-actions { margin-top: 14px; display: flex; gap: 10px; }

/* ---------- Coach form ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.form-grid input, .form-grid select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 0.92rem;
  font-family: inherit;
}
.form-grid input:focus, .form-grid select:focus { outline: none; border-color: var(--green); }

/* ---------- Live session ---------- */
.live-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.live-actions { display: flex; gap: 8px; }
.status-pill { display: inline-block; margin-top: 4px; font-size: 0.82rem; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat span { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.pos { color: var(--green-glow); }
.neg { color: #ff8aa0; }

.live-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.bet-head { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 10px; }
.bet-amount { font-size: 2rem; font-weight: 800; color: var(--gold); }
.bet-progress { color: var(--muted); font-size: 0.85rem; margin-top: 4px; min-height: 18px; }
.bet-warning { margin-top: 10px; padding: 8px 12px; border-radius: 9px; font-size: 0.82rem; background: rgba(224, 69, 94, 0.14); color: #ff8aa0; border: 1px solid rgba(224, 69, 94, 0.4); }
.controls { display: flex; gap: 10px; margin: 16px 0 12px; }
.controls-spin { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.num-entry { display: flex; gap: 6px; }
.num-entry input { width: 120px; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 9px 11px; }
.spin-result { margin-top: 14px; display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.num-badge { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; font-weight: 800; color: #fff; }
.num-badge.red { background: var(--red); }
.num-badge.black { background: var(--black); }
.num-badge.green { background: var(--felt); }

.honest-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.honest-row b { font-variant-numeric: tabular-nums; }
.honest-note { font-size: 0.78rem; color: var(--muted); margin: 12px 0 0; line-height: 1.4; }

canvas#pnl-chart { width: 100%; display: block; }

.table-wrap { overflow-x: auto; }
.history { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.history th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); font-size: 0.74rem; text-transform: uppercase; }
.history td { padding: 8px; border-bottom: 1px solid rgba(32, 57, 44, 0.5); font-variant-numeric: tabular-nums; }
.res-win { color: var(--green-glow); font-weight: 700; }
.res-loss { color: #ff8aa0; font-weight: 700; }

.foot { text-align: center; color: var(--muted); font-size: 0.78rem; padding: 20px; border-top: 1px solid var(--line); }

@media (max-width: 760px) {
  .live-grid, .detail-cols { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  main { padding: 16px 16px 36px; }
}

@media (max-width: 560px) {
  .topbar { flex-direction: column; gap: 10px; align-items: stretch; padding: 12px 14px; }
  .brand { text-align: center; }
  .tabs { width: 100%; }
  .tab { flex: 1; text-align: center; }
  .disclaimer { margin: 10px 14px 0; font-size: 0.78rem; }
  main { padding: 14px 14px 32px; }
  .view-title { font-size: 1.25rem; }
  .grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat b { font-size: 1.05rem; }
  .bet-amount { font-size: 1.5rem; }
  .btn { padding: 12px 16px; min-height: 44px; }            /* objetivos táctiles */
  .live-head { flex-direction: column; gap: 10px; }
  .live-actions { width: 100%; }
  .live-actions .btn { flex: 1; }
  .controls-spin { flex-direction: column; align-items: stretch; }
  .num-entry { width: 100%; }
  .num-entry input { flex: 1; width: auto; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Respeta el área segura en móviles con notch */
@supports (padding: max(0px)) {
  .topbar { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
}

/* ══════════════════════════════════════════════════
   BIBLIOTECA — mejoras de tarjetas
══════════════════════════════════════════════════ */
.card-summary { margin: 6px 0 8px; font-size: 0.88rem; color: var(--muted); line-height: 1.4; }
.card-rule {
  background: rgba(212,175,55,0.08);
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  padding: 7px 12px;
  font-size: 0.82rem;
  color: #e8d78a;
  margin: 8px 0;
}
.prog-row { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin: 8px 0 12px; }
.prog-step {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 0.76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--green-glow);
}
.prog-step.lg { font-size: 0.88rem; padding: 5px 10px; }
.prog-arr { color: var(--muted); font-size: 0.75rem; }

/* ══════════════════════════════════════════════════
   DETALLE DE ESTRATEGIA
══════════════════════════════════════════════════ */
.detail-keyrule {
  background: rgba(212,175,55,0.08);
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: #e8d78a;
  margin: 10px 0 18px;
}
.detail-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 18px;
}
.detail-fact {
  margin-top: 12px;
  font-size: 0.82rem;
  color: #7dd3fc;
  background: rgba(125,211,252,0.07);
  border-radius: 8px;
  padding: 8px 12px;
}
.detail-worst {
  margin-top: 8px;
  font-size: 0.82rem;
  color: #fca5a5;
  background: rgba(224,69,94,0.08);
  border-radius: 8px;
  padding: 8px 12px;
}
.jb-dist-table { margin-top: 10px; font-size: 0.83rem; }
.jbd-head {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 6px;
  padding: 6px 8px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
}
.jbd-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 6px;
  padding: 8px 8px;
  border-bottom: 1px solid rgba(32,57,44,0.4);
  align-items: center;
  font-size: 0.83rem;
}
.jbd-win { background: rgba(52,211,153,0.04); }
.jbd-loss { background: rgba(224,69,94,0.06); }

/* ══════════════════════════════════════════════════
   FICHAS DE CASINO
══════════════════════════════════════════════════ */
.chip-tk {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 2px solid rgba(255,255,255,0.15);
  white-space: nowrap;
  line-height: 1.3;
}
.chip-tk b { font-size: 0.82rem; }

/* ══════════════════════════════════════════════════
   PANEL GUÍA DE APUESTA
══════════════════════════════════════════════════ */
.bet-guide {
  background: rgba(52,211,153,0.05);
  border: 1px solid rgba(52,211,153,0.2);
  border-radius: 12px;
  padding: 14px;
  margin-top: 14px;
}
.bet-guide.jb { background: rgba(96,165,250,0.05); border-color: rgba(96,165,250,0.25); }
.bg-title { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 8px; }
.bg-action { font-size: 1.2rem; font-weight: 800; margin-bottom: 4px; }
.bg-money { color: var(--gold); }
.bg-target.tgt-red  { color: #f87171; }
.bg-target.tgt-blk  { color: #94a3b8; }
.bg-target.tgt-oth  { color: var(--gold); }
.bg-sub { font-size: 0.8rem; color: var(--muted); margin-bottom: 10px; }
.bg-chips-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 10px; }
.bg-chips-lbl { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-right: 2px; }
.bg-cov { font-size: 0.78rem; color: var(--muted); margin: 6px 0 10px; }
.jb-rows { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.jbr { display: flex; align-items: center; gap: 10px; border-radius: 8px; padding: 8px 12px; }
.jbr-h { background: rgba(96,165,250,0.12); border: 1px solid rgba(96,165,250,0.3); }
.jbr-m { background: rgba(251,191,36,0.10);  border: 1px solid rgba(251,191,36,0.3); }
.jbr-z { background: rgba(52,211,153,0.10);  border: 1px solid rgba(52,211,153,0.3); }
.jbr-zone { font-size: 0.83rem; font-weight: 600; min-width: 110px; }
.jbr-amt  { font-size: 1rem; font-weight: 800; color: var(--gold); min-width: 42px; }
.jbr-chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* ══════════════════════════════════════════════════
   MESA DE RULETA MINI
══════════════════════════════════════════════════ */
.rtable { margin-top: 10px; font-size: 0.6rem; user-select: none; overflow-x: auto; }
.rt-zeros { display: flex; gap: 3px; margin-bottom: 2px; }
.rt-z { background: var(--felt); color: #fff; font-weight: 800; border-radius: 4px; padding: 3px 10px; font-size: 0.7rem; border: 1.5px solid transparent; }
.rt-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; min-width: 240px; }
.rt-n { aspect-ratio: 1; display: grid; place-items: center; border-radius: 3px; font-weight: 700; font-size: 0.6rem; border: 1.5px solid transparent; transition: filter 0.12s; }
.rt-n.r { background: #7f1d1d; color: #fca5a5; }
.rt-n.k { background: #1e293b; color: #94a3b8; }
.rt-n.cv, .rt-z.cv { border-color: #34d399; box-shadow: 0 0 5px rgba(52,211,153,0.5); filter: brightness(1.5); }
.rt-n.jh { border-color: #60a5fa; box-shadow: 0 0 4px rgba(96,165,250,0.5); filter: brightness(1.4); }
.rt-n.jm { border-color: #fbbf24; box-shadow: 0 0 4px rgba(251,191,36,0.5); filter: brightness(1.4); }
.rt-n.jz, .rt-z.jz { border-color: #34d399; box-shadow: 0 0 4px rgba(52,211,153,0.5); filter: brightness(1.3); }
.rt-n.jx { opacity: 0.25; filter: none; }
.rt-dz { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin-top: 2px; }
.rt-d { background: var(--panel2); border: 1px solid var(--line); border-radius: 3px; padding: 3px 4px; text-align: center; font-size: 0.6rem; color: var(--muted); line-height: 1.2; }
.rt-d.cv  { border-color: #34d399; color: #34d399; background: rgba(52,211,153,0.1); }
.rt-d.jh  { border-color: #60a5fa; color: #60a5fa; background: rgba(96,165,250,0.1); }
.rt-d.jm  { border-color: #fbbf24; color: #fbbf24; background: rgba(251,191,36,0.1); }
.rt-d.jx  { opacity: 0.3; }
.rt-em { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; margin-top: 2px; }
.rt-e { background: var(--panel2); border: 1px solid var(--line); border-radius: 3px; padding: 3px 2px; text-align: center; font-size: 0.58rem; color: var(--muted); }
.rt-e.re { background: rgba(224,69,94,0.25); color: #f87171; }
.rt-e.bk { background: rgba(30,41,59,0.8); color: #94a3b8; }
.rt-e.cv { border-color: #34d399; color: #34d399; background: rgba(52,211,153,0.15); font-weight: 700; }
.rt-e.re.cv { border-color: #f87171; color: #f87171; background: rgba(224,69,94,0.35); }
.rt-e.bk.cv { border-color: #94a3b8; color: #e2e8f0; background: rgba(148,163,184,0.2); }
.rt-jbl { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.jbl { font-size: 0.68rem; padding: 2px 8px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.jbl.jh { background: rgba(96,165,250,0.15); color: #93c5fd; border: 1px solid rgba(96,165,250,0.3); }
.jbl.jm { background: rgba(251,191,36,0.12); color: #fde68a; border: 1px solid rgba(251,191,36,0.3); }
.jbl.jz { background: rgba(52,211,153,0.12); color: #6ee7b7; border: 1px solid rgba(52,211,153,0.3); }
.jbl.jx { background: rgba(224,69,94,0.10); color: #fca5a5; border: 1px solid rgba(224,69,94,0.25); }

@media (max-width: 560px) {
  .jbr { flex-wrap: wrap; gap: 6px; }
  .jbr-zone { min-width: unset; width: 100%; }
  .bg-action { font-size: 1rem; }
  .jbd-head, .jbd-row { font-size: 0.7rem; }
}
