:root {
  --bg: #0b1512;
  --panel: #13231d;
  --panel-2: #1b3129;
  --line: #2a4539;
  --text: #eef3f0;
  --muted: #9db3a8;
  --accent: #3ddc97;
  --accent-ink: #062117;
  --good: #3ddc97;
  --bad: #ff6b6b;
  --warn: #ffc857;
  --info: #7cc4ff;
  --card: #fbfaf6;
  --s: #15171a;
  --h: #d62839;
  --d: #1d6fd1;
  --c: #178a4b;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px 96px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 12px;
}

h1 { font-size: 22px; margin: 0; }

h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}

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

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.ghost {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--muted);
}

/* Huecos de cartas */
.slots-row { display: flex; gap: 14px; }
.grow { flex: 1; min-width: 0; }
.slots { display: flex; gap: 6px; }

.slot {
  width: 40px;
  height: 56px;
  flex: 0 0 auto;
  border-radius: 7px;
  border: 1.5px dashed var(--line);
  background: var(--panel-2);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
  line-height: 1;
  padding: 0;
}

.slot.filled {
  border: 1px solid #d8d3c4;
  background: var(--card);
  flex-direction: column;
}

.slot.active { outline: 2.5px solid var(--accent); outline-offset: 1px; }
.slot .suit { font-size: 16px; }

/* Selector de cartas: 4 filas de palos x 13 rangos */
.picker {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 3px;
  margin-top: 12px;
}

.pick {
  height: 44px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: var(--card);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.05;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.pick .suit { font-size: 12px; }
.pick:disabled { opacity: .18; cursor: default; }
.pick:not(:disabled):active { transform: scale(.94); }

.s { color: var(--s); }
.h { color: var(--h); }
.d { color: var(--d); }
.c { color: var(--c); }

/* Campos */
.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row + .field-row, .field + .field-row, .field-row + .field { margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 90px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 44px;
  padding: 0 10px;
  width: 100%;
  min-width: 0;
}

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }

.stepper {
  display: flex;
  align-items: center;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  overflow: hidden;
}

.stepper button {
  width: 44px;
  height: 100%;
  border: 0;
  background: none;
  font-size: 22px;
}

.stepper output { min-width: 24px; text-align: center; font-weight: 700; font-size: 18px; }

/* Resultado */
.verdict {
  font-size: 30px;
  font-weight: 800;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 12px;
  letter-spacing: .02em;
}

.verdict small { display: block; font-size: 14px; font-weight: 600; opacity: .85; }
.v-call, .v-bet { background: color-mix(in srgb, var(--good) 22%, transparent); color: var(--good); }
.v-fold { background: color-mix(in srgb, var(--bad) 22%, transparent); color: var(--bad); }
.v-close { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.verdict.doubtful { outline: 2px dashed var(--warn); outline-offset: -2px; }
.verdict small.doubt { color: var(--warn); }
.v-check { background: color-mix(in srgb, var(--info) 22%, transparent); color: var(--info); }

.bar {
  position: relative;
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--bad) 45%, var(--panel-2));
}

.bar .win { background: var(--good); }
.bar .tie { background: var(--warn); }

.bar .need {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 3px;
  background: var(--text);
  transform: translateX(-1.5px);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0 8px;
}

.stats div { min-width: 0; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }

.reasons { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.reasons li + li { margin-top: 4px; }

.error {
  background: color-mix(in srgb, var(--bad) 18%, transparent);
  color: var(--bad);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 12px;
}

.actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
}

.primary {
  display: block;
  width: 100%;
  max-width: 528px;
  margin: 0 auto;
  height: 52px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 18px;
}

.primary:disabled { opacity: .6; }

@media (max-width: 380px) {
  .slot { width: 36px; height: 50px; font-size: 15px; }
  .slots { gap: 4px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .pick { font-size: 13px; }
}

/* Navegación entre calculadora y mano */
.tabs { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tabs a { color: var(--muted); text-decoration: none; padding: 5px 12px; border-radius: 999px; font-size: 14px; }
.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
@media (max-width: 420px) { .tabs a { padding: 5px 7px; font-size: 13px; } }

.muted { color: var(--muted); }
.small { font-size: 13px; margin: 4px 0 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
h2.sub { margin-top: 14px; }

/* Mano: configuración de la mesa */
.setup summary { cursor: pointer; font-weight: 700; }
.setup summary .muted { font-weight: 400; font-size: 14px; }
.setup[open] summary { margin-bottom: 12px; }
.seats { display: flex; flex-direction: column; gap: 6px; }
.seat-row { display: grid; grid-template-columns: 52px 1fr 1.3fr 70px; gap: 6px; align-items: center; }
.seat-row .pos, .range .pos { font-weight: 700; }
.seat-row input, .seat-row select { height: 40px; padding: 0 8px; font-size: 14px; }

/* Mano: turno y acciones */
.status { font-size: 14px; color: var(--muted); }
.status strong { display: block; color: var(--text); font-size: 20px; margin-top: 2px; }
.status small { display: block; font-size: 13px; }
#act-box { margin-top: 12px; }
.act-buttons, .raise-row { display: flex; gap: 8px; }
.raise-row { margin-top: 8px; }
.act {
  flex: 1;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  font-weight: 700;
}
.act.fold { color: var(--bad); }
.act.raise { flex: 0 0 38%; background: color-mix(in srgb, var(--accent) 22%, var(--panel-2)); color: var(--accent); }
.raise-row input { height: 48px; }
.chips { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; }
.chip {
  flex: 1 0 auto;
  min-width: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 4px 6px;
  font-size: 13px;
  line-height: 1.2;
}
.chip small { display: block; color: var(--muted); }

/* Mano: opciones con EV */
#advice { margin-top: 12px; }
.options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.option {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 8px 10px;
}
.option small { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.option .o-label { font-weight: 700; }
.option .o-ev { font-weight: 800; font-variant-numeric: tabular-nums; }
.option.best { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--panel-2)); }
.option.best .o-ev { color: var(--accent); }
.preflop { font-size: 14px; margin: 10px 0 0; }

/* Mano: rangos y registro */
.range { border-top: 1px solid var(--line); padding: 8px 0; }
.range:first-child { border-top: 0; }
.range summary { cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.range .pct { font-weight: 800; }
.range .top { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix { max-width: 280px; display: grid; grid-template-columns: repeat(13, 1fr); gap: 1px; margin: 6px 0; }
.matrix span {
  aspect-ratio: 1;
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent) calc(var(--w) * 100%), var(--panel-2));
}
.steps, .log { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.steps small { color: var(--muted); }
#history h3 { font-size: 14px; margin: 10px 0 2px; }
#history h3:first-child { margin-top: 0; }

.actions.two { display: flex; gap: 8px; justify-content: center; }
.actions.two .primary { margin: 0; max-width: 260px; }
.secondary {
  flex: 1;
  max-width: 260px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font-weight: 700;
}
.secondary:disabled { opacity: .5; }
#save-fields .field { margin-bottom: 12px; }

/* Repaso post-sesión */
.pos { color: var(--good); }
.neg { color: var(--bad); }
.progress { margin-top: 12px; }
.progress .bar { background: var(--panel-2); }
#files { height: auto; padding: 10px; }
.curve { width: 100%; height: auto; display: block; }
.curve polyline { fill: none; stroke-width: 2; stroke-linejoin: round; }
.curve .net { stroke: var(--accent); }
.curve .ev { stroke: var(--warn); stroke-dasharray: 5 4; }
.curve .zero { stroke: var(--line); stroke-width: 1; }
.axis { display: flex; justify-content: space-between; }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); }
.legend .key { display: inline-block; width: 18px; height: 3px; border-radius: 2px; }
.legend .key.net { background: var(--accent); }
.legend .key.ev { background: var(--warn); margin-left: 8px; }
.leaks, .mistakes { list-style: none; margin: 0; padding: 0; }
.leak, .mistake { border-top: 1px solid var(--line); padding: 8px 0; }
.leak:first-child, .mistake:first-child { border-top: 0; }
#minor-wrap { margin-top: 8px; }
#minor-wrap summary { cursor: pointer; }
.hud { width: 100%; border-collapse: collapse; font-size: 14px; }
.hud th { text-align: left; font-weight: 600; }
.hud th, .hud td { padding: 5px 4px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.hud tr.tip td { border-top: 0; padding-top: 0; color: var(--muted); font-size: 13px; }
.mistake summary { cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; list-style: none; }
.mistake summary::-webkit-details-marker { display: none; }
.m-what { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }
.m-loss { font-weight: 800; font-variant-numeric: tabular-nums; }
.mini {
  display: inline-block;
  min-width: 26px;
  padding: 1px 3px;
  margin-right: 2px;
  border-radius: 4px;
  background: var(--card);
  font-weight: 700;
  font-size: 13px;
  text-align: center;
}
.board { margin-left: 4px; white-space: nowrap; }
header { flex-wrap: wrap; gap: 8px; }
.hud td { white-space: nowrap; }
.hud td:last-child { white-space: normal; }

/* Entrenador */
.spot-cards { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 6px 0 10px; }
.spot-hand, .spot-board { display: flex; gap: 4px; }
.card {
  width: 38px; height: 52px; border-radius: 6px; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; line-height: 1;
}
.card small { font-size: 15px; }
.spot-line { font-size: 17px; margin: 0 0 4px; }
.answers { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.answer { width: 100%; flex: 0 0 auto; height: 48px; }
.answer.best-answer { border-color: var(--accent); color: var(--accent); }
.answer.wrong-answer { border-color: var(--bad); color: var(--bad); }
#feedback-best { margin: 0; }

#login .field + .field { margin-top: 12px; }
#login .error { margin: 12px 0 0; }
#login .primary { margin-top: 16px; }

/* Calculadora de fichero */
.nav-row { align-items: center; margin-top: 8px; }
.nav-row button { height: 44px; min-width: 48px; }
.nav-row output { text-align: center; font-weight: 700; font-size: 18px; }

.v-raise { background: color-mix(in srgb, var(--good) 22%, transparent); color: var(--good); }
.sizes { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.sizes th, .sizes td { padding: 5px 6px; text-align: right; border-bottom: 1px solid var(--line); }
.sizes th:first-child { text-align: left; font-weight: 600; }
.sizes thead th { color: var(--muted); font-size: 12px; font-weight: 600; }
.sizes tr.best { color: var(--good); font-weight: 700; }
.warn-note { color: var(--warn); font-size: 13px; margin: 4px 0 8px; }

/* Caja */
#levels td:last-child { font-weight: 800; }
#check { margin: 0 0 8px; }
#levels th small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
