:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #7a7872;
  --line: #e2e0da;
  --felt: #2f5d4a;
  --felt-edge: #24493a;
  --accent: #1f6f5a;
  --good: #2e7d4f;
  --warn: #b7791f;
  --bad: #c0392b;
  --card: #ffffff;
  --red: #c0392b;
  --black: #1d1d1b;
  --radius: 10px;
  --fs: 15px; /* tamaño de texto del coach y los ejercicios (A− / A+) */
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161716;
    --surface: #1f2120;
    --text: #e9e7e2;
    --muted: #9a978f;
    --line: #333634;
    --felt: #24473a;
    --felt-edge: #1b362c;
    --accent: #4fb393;
    --card: #f4f2ec;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, select, input { font: inherit; color: inherit; }
button {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 14px; cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
select { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.muted { color: var(--muted); }

/* Cabecera */
.top {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand img { display: block; flex: none; }
.brand .name { font-size: 16px; }
.brand .sub { font-weight: 400; color: var(--muted); font-size: 13px; }
@media (max-width: 600px) { .brand .sub { display: none; } }
.tabs { display: flex; gap: 4px; }
.tabs button { background: transparent; color: var(--muted); padding: 6px 12px; }
.tabs button.active { color: var(--text); background: var(--bg); }
main { max-width: 1380px; margin: 0 auto; padding: 16px; }
.tab { display: none; }
.tab.active { display: block; }

/* Mesa */
.mesa-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  grid-template-areas: "mesa side" "hist side"; grid-template-rows: auto 1fr;
  column-gap: 24px; align-items: start;
}
.mesa-col { grid-area: mesa; }
.side { grid-area: side; }
.history { grid-area: hist; }
@media (max-width: 1080px) {
  .mesa-layout { grid-template-columns: 1fr; grid-template-areas: "mesa" "side" "hist"; grid-template-rows: auto; row-gap: 14px; }
  .side { position: static; max-height: none; }
  .side .feed { max-height: 70vh; }
}
.toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-bottom: 10px; font-size: 14px; }
.toolbar .check { display: flex; gap: 6px; align-items: center; }
.toolbar #btn-new { margin-left: auto; }

.table { position: relative; height: 470px; margin-top: 8px; }
.felt {
  position: absolute; inset: 78px 100px; border-radius: 200px;
  background: var(--felt); border: 10px solid var(--felt-edge);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.board { display: flex; gap: 6px; min-height: 64px; }
.pot { color: #e8f2ec; font-size: 14px; }

.seat {
  position: absolute; transform: translate(-50%, -50%);
  width: 132px; padding: 6px 8px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); text-align: center; font-size: 13px;
}
.seat.hero { border-color: var(--accent); }
.seat.to-act { box-shadow: 0 0 0 2px var(--accent); }
.seat.folded > * { opacity: .4; }
.seat .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .style { color: var(--muted); font-size: 11px; }
.seat .stack { font-variant-numeric: tabular-nums; }
.seat .hole { display: flex; gap: 3px; justify-content: center; margin: 4px 0; min-height: 40px; }
.seat .bet {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: -22px;
  font-size: 12px; background: #e2b93b; color: #1d1d1b; font-weight: 600; border-radius: 10px; padding: 0 8px; white-space: nowrap;
}
.seat.lower .bet { bottom: auto; top: -22px; }
.seat .last { font-size: 11px; color: var(--muted); min-height: 15px; }
.dealer {
  display: inline-block; width: 18px; height: 18px; line-height: 18px; border-radius: 50%;
  background: var(--text); color: var(--bg); font-size: 11px; font-weight: 700; margin-left: 4px;
}

/* Cartas */
.card {
  width: 30px; height: 40px; border-radius: 5px; background: var(--card);
  border: 1px solid #cfccc4; display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center; line-height: 1; font-weight: 700; font-size: 14px;
  color: var(--black);
}
.card small { font-size: 13px; }
.card.r { color: var(--red); }
.card.back { background: repeating-linear-gradient(45deg, #5b7c6e, #5b7c6e 4px, #4c6b5e 4px, #4c6b5e 8px); border-color: #3f5b4f; }
.board .card { width: 42px; height: 58px; font-size: 18px; }
.board .card small { font-size: 18px; }
.card.hl { outline: 2px solid #e2b93b; }

/* Acciones */
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 48px; margin: 18px 0 8px; }
.actions .sizes { display: flex; gap: 4px; }
.actions .sizes button { padding: 4px 8px; font-size: 12px; }
.actions input[type=range] { width: 160px; }
.actions .amount { width: 80px; border: 1px solid var(--line); border-radius: 6px; padding: 6px; background: var(--surface); }
.actions .info { color: var(--muted); font-size: 13px; }
.stats { font-size: 13px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }

/* Panel del coach */
.side {
  position: sticky; top: 12px;
  display: flex; flex-direction: column; max-height: calc(100vh - 24px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.side-head h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.fs { display: flex; gap: 4px; }
.fs button { padding: 2px 10px; font-size: 13px; }
.feed {
  flex: 1; overflow-y: auto; padding: 14px 16px 18px;
  display: flex; flex-direction: column; gap: 18px;
  font-size: var(--fs); line-height: 1.55;
}
.feed > p { margin: 0; }
.decision { display: flex; flex-direction: column; gap: 10px; }
.decision + .decision { border-top: 1px solid var(--line); padding-top: 18px; }
.dtitle { font-size: calc(var(--fs) - 2px); color: var(--muted); font-weight: 600; }
.decision.latest .dtitle { color: var(--text); }
.decision.latest .dtitle::before { content: 'Última · '; color: var(--accent); }
.ic { color: var(--text); white-space: nowrap; }
.ic.r { color: var(--red); }
.tip { background: var(--bg); border-left: 4px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.tip.bien { border-left-color: var(--good); }
.tip.ojo { border-left-color: var(--warn); }
.tip.error { border-left-color: var(--bad); }
.tip .head { font-weight: 650; margin-bottom: 4px; }
.tip.bien .head { color: var(--good); }
.tip.ojo .head { color: var(--warn); }
.tip.error .head { color: var(--bad); }
.tip .ctxline { color: var(--muted); font-size: calc(var(--fs) - 1px); margin-bottom: 4px; }
.ref { display: inline-block; margin-top: 6px; color: var(--accent); font-size: calc(var(--fs) - 2px); cursor: pointer; text-decoration: underline; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.fact { background: var(--bg); border-radius: 8px; padding: 8px 12px; }
.fact .k { font-size: calc(var(--fs) - 3px); color: var(--muted); }
.fact .v { font-weight: 650; }
.freq { margin-top: 10px; }
.freq .bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--line); }
.freq .bar span { display: block; height: 100%; }
.freq .f, .dot.f { background: #a19e96; }
.freq .c, .dot.c { background: #5b8fb9; }
.freq .r, .dot.r { background: var(--accent); }
.freq .legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: calc(var(--fs) - 2px); margin-top: 6px; color: var(--muted); }
.freq .legend b { color: var(--text); }
.freq .legend .chosen { color: var(--text); font-weight: 600; }
.freq .legend .chosen::after { content: ' ← tú'; color: var(--accent); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* Historial (bajo la mesa) */
.history { margin-top: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; }
.history summary { cursor: pointer; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.log { max-height: 190px; overflow-y: auto; margin-top: 6px; font-size: 13px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; }
.log div { padding: 1px 0; }
.log .street { color: var(--text); font-weight: 600; margin-top: 4px; }

/* Ejercicios */
.ex-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 24px; align-items: start; max-width: 1120px; margin: 0 auto; }
.ex-menu { display: flex; flex-direction: column; gap: 6px; position: sticky; top: 12px; }
.ex-menu button {
  display: block; text-align: left; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}
.ex-menu button:hover { filter: none; border-color: var(--accent); }
.ex-menu button.active { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.ex-menu .t { font-weight: 600; font-size: 15px; }
.ex-menu .d { color: var(--muted); font-size: 13px; margin-top: 1px; }
.ex-menu .sc { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 12px; color: var(--muted); }
.ex-menu .sc .bar { flex: 1; height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.ex-menu .sc .bar span { display: block; height: 100%; background: var(--good); }

.ex-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px 26px;
  font-size: var(--fs); line-height: 1.55; display: flex; flex-direction: column; gap: 18px;
}
.ex-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ex-kind { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.ex-progress { font-size: calc(var(--fs) - 2px); color: var(--muted); }
.ex-cards { display: flex; gap: 32px; flex-wrap: wrap; }
.hand .lbl, .ex-outs .lbl { font-size: calc(var(--fs) - 2px); color: var(--muted); margin-bottom: 6px; }
.ex-card .cards { display: flex; gap: 6px; flex-wrap: wrap; }
.ex-cards .card { width: 56px; height: 78px; font-size: 23px; border-radius: 8px; }
.ex-cards .card small { font-size: 23px; }
.ex-outs .card { width: 34px; height: 46px; font-size: 15px; }
.ex-q { font-size: calc(var(--fs) + 4px); font-weight: 600; line-height: 1.4; }
.ex-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.ex-opts button {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 16px; font-size: calc(var(--fs) + 1px); line-height: 1.35;
}
.ex-opts button:hover:not(:disabled) { filter: none; border-color: var(--accent); }
.ex-opts button:disabled { cursor: default; opacity: 1; }
.ex-opts button.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--bg)); }
.ex-opts button.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--bg)); }
.ex-opts button.dim { opacity: .5; }
kbd {
  font: 12px/1.6 ui-monospace, Consolas, monospace; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 6px; color: var(--muted); background: var(--surface);
}
.ex-result { display: flex; flex-direction: column; gap: 14px; border-top: 1px solid var(--line); padding-top: 18px; }
.ex-result[hidden] { display: none; }
.ex-verdict { border-radius: 10px; padding: 12px 16px; border-left: 4px solid; }
.ex-verdict.ok { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--surface)); }
.ex-verdict.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.ex-verdict .v-head { font-weight: 700; font-size: calc(var(--fs) + 2px); }
.ex-verdict.ok .v-head { color: var(--good); }
.ex-verdict.bad .v-head { color: var(--bad); }
.ex-expl { margin: 0; }
.ex-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.ex-foot .ref { margin-top: 0; }
.ex-foot .next { padding: 10px 18px; font-size: var(--fs); margin-left: auto; }
.ex-foot .next kbd { color: #fff; background: transparent; border-color: rgba(255, 255, 255, .5); margin-left: 6px; }
.ex-total { margin-top: 12px; color: var(--muted); font-size: 13px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.ex-total button { font-size: 12px; padding: 3px 10px; }
@media (max-width: 860px) {
  .ex-layout { grid-template-columns: 1fr; }
  .ex-menu { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .ex-menu button { flex: 0 0 auto; min-width: 180px; }
  .ex-card { padding: 16px; }
  .ex-cards .card { width: 46px; height: 64px; font-size: 19px; }
  .ex-cards .card small { font-size: 19px; }
}

/* Lecciones */
.lessons { max-width: 820px; }
.lessons h2 { font-size: 18px; margin: 26px 0 8px; }
.lesson { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; }
.lesson h4 { margin: 0 0 6px; }
.lesson.flash { box-shadow: 0 0 0 2px var(--accent); }
.lesson ul { margin: 6px 0 0; padding-left: 20px; }
.lesson .src { color: var(--muted); font-size: 12px; }

@media (max-width: 600px) {
  main { padding: 10px; }
  .table { height: 420px; }
  .felt { inset: 70px 40px; }
  .seat { width: 98px; font-size: 11px; padding: 4px; }
  .seat .card { width: 24px; height: 32px; font-size: 12px; }
}
