/* ───────────── Fila de estadísticas (stats-row) ───────────── */
/* Fila de estadísticas debajo de la tabla de jugadores */
.stats-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  margin: 8px 0 0 0;
  gap: 8px;
  min-height: 0;
}
.stats-graph-box {
  flex: 1 1 0;
  display: flex;
  align-items: stretch;
  min-width: 0;
  min-height: 0;
  position: relative;
}
.stats-graph-box canvas {
  background: rgba(0,0,0,0.35);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.08);
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.stats-qr-box {
  flex: 0 0 clamp(120px, 20vmin, 220px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 12px;
  box-shadow: 0 1px 6px #0001;
  border: 1px solid #eee;
  padding: clamp(4px, 1vmin, 10px);
  box-sizing: border-box;
  min-width: 0;
}
.stats-qr-box img,
.stats-qr-box canvas {
  display: block;
}
/* El QR (canvas/img generado por la librería a tamaño fijo) se reduce para
   caber siempre dentro del área de estadísticas, sin recortes ni scroll. */
.stats-qr-box .qr-host { min-width: 0; min-height: 0; overflow: hidden; }
.stats-qr-box .qr-host img,
.stats-qr-box .qr-host canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}
/* Pantalla completa */
.fullscreen-btn {
  background: none;
  border: none;
  cursor: pointer;
  margin-left: 12px;
  padding: 4px;
  vertical-align: middle;
  filter: brightness(0.9);
  transition: filter 0.2s;
}
.fullscreen-btn:hover {
  filter: brightness(1.2);
}
.player-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
/* ───────────── Panel de jugador — nuevo diseño visual ───────────── */
.player-panel {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
}
.player-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-surface);
  border-bottom: 2px solid var(--primary);
  flex-shrink: 0;
  gap: 10px;
}
.player-panel-title { flex: 1; min-width: 0; }
.player-panel-tournament {
  font-size: 0.82em;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-panel-name {
  font-size: 1.35em;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}
.player-section-label {
  text-align: center;
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text-secondary);
  padding: 6px 0 3px;
  text-transform: uppercase;
}
.player-chips-section {
  padding: 6px 10px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  box-sizing: border-box;
  width: 100%;
}
.player-chip-card {
  background: var(--bg-surface);
  border: 1px solid var(--tertiary-dark);
  border-radius: 10px;
  padding: 4px 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-sizing: border-box;
  min-width: 0;
  overflow: hidden;
}
.player-chip-card-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
}
.player-chip-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.player-chip-display svg {
  width: 100%;
  max-width: 44px;
  height: auto;
}
.player-chip-btn {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text-primary);
  transition: filter 0.12s, transform 0.1s;
  line-height: 1;
}
.player-chip-btn.plus {
  background: var(--secondary);
  box-shadow: 0 3px 10px rgba(31, 77, 58, 0.5);
}
.player-chip-btn.minus {
  background: var(--primary);
  box-shadow: 0 3px 10px rgba(90, 15, 29, 0.5);
}
.player-chip-btn:hover { filter: brightness(1.15); }
.player-chip-btn:active { filter: brightness(0.88); transform: scale(0.93); }

.player-chip-count-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.player-chip-count-label {
  font-size: 0.8em;
  color: var(--text-secondary);
  white-space: nowrap;
}
.player-chip-count {
  width: 100%;
  max-width: 56px;
  text-align: center;
  background: var(--bg-main);
  border: 1.5px solid var(--tertiary-light);
  border-radius: 8px;
  padding: 3px 4px;
  font-size: 0.95em;
  font-weight: 700;
  color: var(--text-primary);
  -moz-appearance: textfield;
}
.player-chip-count::-webkit-outer-spin-button,
.player-chip-count::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.player-chip-count:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.player-stack-section {
  margin: 4px 12px;
  background: var(--bg-surface);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 2px 18px 8px;
  flex-shrink: 0;
}
.player-stack-row {
  display: flex;
  align-items: center;
  justify-content: center;
}
.player-stack-value {
  font-size: 1.8em;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 1px;
  min-width: 100px;
  text-align: center;
  cursor: pointer;
  border-bottom: 2px dashed transparent;
  transition: border-color 0.15s;
}
.player-stack-value:hover { border-bottom-color: var(--accent); }
.player-stack-inline-input {
  font-size: 1.8em;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 1px;
  width: 160px;
  text-align: center;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--accent);
  outline: none;
  -moz-appearance: textfield;
}
.player-stack-inline-input::-webkit-outer-spin-button,
.player-stack-inline-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.player-actions-row {
  display: flex;
  gap: 12px;
  padding: 8px 12px 12px;
  flex-shrink: 0;
}
.player-save-btn {
  flex: 2;
  background: var(--secondary);
  color: var(--text-primary);
  border-radius: 14px;
  padding: 11px 0;
  font-size: 1.05em;
  font-weight: 800;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(31, 77, 58, 0.4);
  letter-spacing: 0.5px;
  transition: filter 0.12s;
}
.player-save-btn:hover { filter: brightness(1.1); }
.player-save-btn:disabled { filter: brightness(0.8); cursor: default; }
.player-exit-btn {
  flex: 1;
  background: var(--tertiary-dark);
  color: var(--text-secondary);
  border-radius: 14px;
  padding: 11px 0;
  font-size: 0.95em;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: filter 0.12s;
}
.player-exit-btn:hover { filter: brightness(1.1); }

/* ── Evolución de stack (gráfica) en el panel del jugador ──
   Ocupa el espacio liberado al compactar fichas/stack y nunca provoca
   scroll: el canvas rellena la caja, que se adapta a la altura disponible. */
.player-graph-section {
  flex: 1 1 auto;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  padding: 0 12px;
  box-sizing: border-box;
}
.player-graph-box {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 6px;
  box-sizing: border-box;
}
.player-graph-box canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.player-graph-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  font-size: 0.85em;
  text-align: center;
  opacity: 0.8;
}

/* ───────────── Panel espectador ───────────── */
.spectator-player-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 1em;
}
.spectator-player-list li {
  padding: 6px 0;
  border-bottom: 1px solid #ffffff18;
}
.spectator-levels-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.98em;
}
.spectator-levels-table th, .spectator-levels-table td {
  border: 1px solid #ffffff18;
  padding: 4px 8px;
  text-align: center;
}
.spectator-levels-table th {
  background: var(--tertiary-dark);
  color: var(--accent);
}
/* ───────────── Panel de jugador ───────────── */
.player-chips-row, .player-points-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0 0 0;
  font-size: 1.2em;
  justify-content: center;
}
.chip-btn, .point-btn {
  background: var(--primary);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 1.2em;
  font-weight: 700;
  border: none;
  box-shadow: 0 1px 4px #0002;
  transition: background .15s;
}
.chip-btn:hover, .point-btn:hover {
  background: var(--primary-light);
}
.chip-value, .point-value {
  min-width: 40px;
  display: inline-block;
  text-align: center;
  font-weight: 600;
  font-size: 1.2em;
}
/* ───────────── Selector de modo y panel jugador ───────────── */
.mode-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 40px;
}
.mode-selector h2 {
  font-size: 2em;
  margin-bottom: 32px;
}
.mode-btns {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 320px;
}
.mode-btn {
  background: var(--primary);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 16px 0;
  font-size: 1.1em;
  font-weight: 600;
  margin: 0;
  border: none;
  box-shadow: 0 2px 8px #0002;
  transition: background .15s;
}
.mode-btn:hover {
  background: var(--primary-light);
}

/* ───────── Role selector (home) ───────── */
.role-selector {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 20px 60px;
}
.role-selector h2 {
  font-size: 1.6em;
  margin: 0 0 28px;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.role-btns {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 360px;
}
.role-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 2px solid var(--tertiary-light);
  border-radius: 14px;
  padding: 18px 22px;
  font-size: 1.15em;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  text-align: left;
}
.role-btn:hover {
  background: var(--tertiary-dark);
  border-color: var(--primary);
}
.role-btn:active { transform: scale(0.98); }
.role-icon {
  font-size: 1.6em;
  width: 1.6em;
  text-align: center;
  color: var(--primary);
}
.role-label { flex: 1; }

/* Home header con botón de volver y badge de rol */
.home-header.with-back {
  position: relative;
  align-items: center;
  gap: 12px;
}
.home-header.with-back .home-back {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
}
.role-badge {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--tertiary-dark);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 0.9em;
  font-weight: 600;
}

/* Botón volver en la pantalla de selección de jugador */
.player-select { position: relative; }
.player-select-back {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
}
.player-select-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.player-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 40px;
}
.player-select h2 {
  font-size: 1.7em;
  margin-bottom: 24px;
}
.player-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
  width: 100%;
  max-width: 320px;
}
.player-list li {
  margin-bottom: 14px;
}
.player-btn {
  width: 100%;
  background: var(--secondary);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 14px 0;
  font-size: 1em;
  font-weight: 500;
  border: none;
  box-shadow: 0 1px 4px #0002;
  transition: background .15s;
}
.player-btn:hover {
  background: var(--secondary-light);
}
/* ──────────────────────────────────────────────────────────────
   Vinur Poker Timer — Web port (HTML+CSS+JS puro)
   Tema portado desde app/src/theme.js
   ────────────────────────────────────────────────────────────── */

:root {
  --primary: #5a0f1d;
  --primary-dark: #3f0a14;
  --primary-light: #7a2433;

  --secondary: #1f4d3a;
  --secondary-dark: #17382b;
  --secondary-light: #2f6b53;

  --tertiary: #5a3a29;
  --tertiary-dark: #3e281c;
  --tertiary-light: #8a6a52;

  --bg-main: #977f6b;
  --bg-surface: #494949;

  --text-primary: #f4efea;
  --text-secondary: #cfc7be;
  --text-dark: #111111;

  --accent: #c6a15b;

  --font: 'Outfit', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app, #screen-root {
  height: 100%;
}

/* Fullscreen: preservar fondo y color en cualquier elemento que entre a pantalla completa */
:fullscreen { background: var(--bg-main); color: var(--text-primary); }
:-webkit-full-screen { background: var(--bg-main); color: var(--text-primary); }
:-moz-full-screen { background: var(--bg-main); color: var(--text-primary); }

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
input { font-family: inherit; }

.loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  color: var(--text-secondary);
  font-weight: 500;
  z-index: 9999;
  transition: opacity .2s;
}
.loader.hidden { opacity: 0; pointer-events: none; }

/* ───────────── Common ───────────── */
.btn { display: inline-flex; align-items: center; justify-content: center;
       border-radius: 8px; padding: 6px 14px; font-weight: 600; font-size: 13px;
       color: var(--text-primary); transition: filter .15s; user-select: none; }
.btn:hover { filter: brightness(1.1); }
.btn.primary  { background: var(--primary); }
.btn.secondary{ background: var(--secondary); }
.btn.tertiary { background: var(--tertiary-dark); }
.btn.danger   { background: var(--primary-dark); color: #ff6b6b; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 18px;
  background: var(--tertiary-dark);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn img { width: 18px; height: 18px; filter: brightness(0) invert(1); }

input.text {
  background: var(--bg-surface);
  border: 1px solid var(--tertiary-dark);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 14px;
  color: var(--text-primary);
  width: 100%;
}
input.text.accent { border: 2px solid var(--primary); }
input.text.sm { padding: 5px 8px; font-size: 13px; border-radius: 6px; }
input.text.center { text-align: center; }
input.text:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ───────────── HOME ───────────── */
.home {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.home-header {
  display: flex;
  justify-content: center;
  padding: 30px 0 20px;
  flex-shrink: 0;
}
.home-header img.logo { width: 360px; max-width: 80vw; height: auto; }

.tournaments-list {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 20px;
  padding: 0 20px 40px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: flex-start;
}

.tournament-card {
  position: relative;
  width: 260px;
  flex: 0 0 auto;
  background: var(--bg-surface);
  border: 2px solid var(--tertiary-light);
  border-radius: 16px;
  padding: 18px;
  cursor: pointer;
  overflow-y: auto;
  max-height: 100%;
}
.tournament-card .card-title {
  font-weight: 700; font-size: 22px; margin: 0 0 12px;
  color: var(--text-primary);
}
.tournament-card .delete-btn {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; border-radius: 13px;
  background: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--text-primary);
  z-index: 5;
}
.chips-row {
  display: flex; flex-direction: row; gap: 8px; margin-bottom: 10px;
}
.info-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.info-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--tertiary-dark);
  padding: 3px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 500;
  color: var(--text-secondary);
}
.buyin-grid {
  background: var(--tertiary-dark);
  border-radius: 8px; padding: 8px; margin-bottom: 10px;
}
.buyin-row { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; padding: 2px 0; font-size: 11px; }
.buyin-row .label { color: var(--accent); font-weight: 500; }
.buyin-row .val { color: var(--text-secondary); text-align: center; }
.buyin-row .pts { color: var(--text-secondary); text-align: right; }

.levels-table .table-title {
  font-size: 14px; font-weight: 600; margin: 0 0 6px;
}
.levels-table .thead, .levels-table .tr {
  display: grid; grid-template-columns: 0.5fr 1fr 1fr 1fr;
  padding: 4px 0; font-size: 11px; text-align: center;
}
.levels-table .thead {
  background: var(--tertiary-dark);
  border-radius: 4px;
  color: var(--accent); font-weight: 600;
}
.levels-table .tr {
  border-bottom: 1px solid var(--tertiary-dark);
  color: var(--text-secondary); font-size: 12px;
}

.edit-btn-card {
  margin-top: 14px; align-self: flex-end;
  background: var(--primary-light);
  padding: 6px 16px; border-radius: 8px;
  font-weight: 600; font-size: 13px; color: var(--text-primary);
  display: inline-block;
}

.add-card {
  width: 200px; min-height: 320px; flex: 0 0 auto;
  background: var(--bg-surface);
  border: 2px dashed var(--tertiary-light);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 64px; color: var(--tertiary-light);
}

/* ───────────── EDIT ───────────── */
.edit {
  height: 100%;
  overflow-y: auto;
  padding: 16px;
}
.edit-content { display: flex; flex-direction: column; gap: 10px; max-width: 1100px; margin: 0 auto; }
.edit .heading-row {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 8px; margin: 8px 0 4px;
  border-bottom: 2px solid var(--primary);
}
.edit .heading {
  flex: 1; text-align: center; font-weight: 700; font-size: 20px; margin: 0;
}
.field-row { display: flex; flex-direction: row; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 2px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.field label.accent { font-weight: 600; color: var(--accent); }

.section { margin-top: 6px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.section-title { font-size: 16px; font-weight: 700; margin: 0; }
.add-btn {
  background: var(--secondary); padding: 6px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-primary);
}

.players-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.player-row { display: flex; align-items: center; gap: 6px; }
.remove-sm {
  width: 24px; height: 24px; border-radius: 12px;
  background: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-primary); font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}

.levels-edit-header, .levels-edit-row {
  display: grid; grid-template-columns: 0.5fr 1fr 1fr 1fr 32px;
  gap: 4px; align-items: center;
}
.levels-edit-header {
  background: var(--tertiary-dark);
  border-radius: 6px; padding: 6px 0; margin-bottom: 4px;
  text-align: center; font-size: 12px; font-weight: 600; color: var(--accent);
}
.levels-edit-row { padding: 3px 0; }
.levels-edit-row .index-cell { text-align: center; color: var(--text-secondary); font-size: 13px; }
.remove-md {
  width: 28px; height: 28px; border-radius: 14px;
  background: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-primary); font-weight: 700; font-size: 14px;
}

.chips-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.chip-item { display: flex; flex-direction: row; align-items: center; gap: 4px; cursor: pointer; }
.chip-move {
  width: 22px; height: 16px;
  border: none; border-radius: 4px;
  background: var(--tertiary-dark);
  color: var(--text-primary);
  font-size: 10px; line-height: 1;
  cursor: pointer; padding: 0;
}
.chip-move:disabled { opacity: 0.3; cursor: not-allowed; }
.chip-move:hover:not(:disabled) { background: var(--primary); }
.chip-remove {
  width: 18px; height: 18px; border-radius: 9px;
  background: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-primary); font-weight: 700; font-size: 10px;
  margin-top: -4px;
}

.save-btn {
  background: var(--primary); border-radius: 12px;
  padding: 12px; text-align: center;
  font-weight: 700; font-size: 18px; color: var(--text-primary);
  margin-top: 8px; cursor: pointer;
}
.delete-btn-full {
  background: var(--primary-dark); border-radius: 14px;
  padding: 14px; text-align: center;
  font-weight: 600; font-size: 16px; color: #ff6b6b;
  margin-top: 8px; cursor: pointer;
}

/* ───────────── Color picker modal ───────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--bg-surface);
  border: 2px solid var(--primary);
  border-radius: 16px;
  padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  max-width: 95vw; max-height: 95vh;
  overflow: auto;
}
.modal h3 { margin: 0; font-weight: 700; font-size: 16px; }

.color-grid {
  display: flex; flex-direction: column;
  border-radius: 8px; overflow: hidden;
}
.color-grid-row { display: flex; flex-direction: row; }
.color-cell { width: 14px; height: 14px; cursor: pointer; }

.cp-preview-row { display: flex; align-items: center; gap: 12px; }
.cp-preview {
  width: 48px; height: 48px; border-radius: 24px;
  border: 2px solid rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.cp-value-input {
  background: var(--bg-main);
  border: 1px solid var(--tertiary-dark);
  border-radius: 8px; padding: 8px 12px;
  font-weight: 600; font-size: 16px; color: var(--text-primary);
}
.cp-description-input {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--tertiary-dark);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-primary);
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.done-btn {
  background: var(--secondary); border-radius: 10px;
  padding: 8px 24px; font-weight: 600; font-size: 14px;
  color: var(--text-primary);
}

/* ───────────── PANEL ─────────────
   Todo el panel escala con la altura disponible (unidades vmin) para que
   NUNCA haga falta scroll: grande en TV, compacto en PC/tablet, sin que la
   parte inferior (tabla + gráfico) se recorte. */
.panel-screen {
  height: 100%;
  padding: clamp(4px, 1vmin, 10px);
  display: flex; flex-direction: row; gap: clamp(6px, 1.2vmin, 12px);
  overflow: hidden;
}
.chips-column {
  width: 20%;
  min-width: 60px;
  max-width: 150px;
  display: flex; flex-direction: column;
  align-items: center;
  padding-top: 4px;
  gap: 2px;
  transition: width .2s;
}
.chips-column.collapsed { width: 28px; }
.chips-column.collapsed > .chips-content { display: none; }
.chips-content {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  width: 100%; gap: 1px;
  overflow: hidden;
}
.chips-content img.logo { width: 100%; max-width: 220px; height: auto; max-height: 100px; object-fit: contain; cursor: pointer; margin-bottom: 2px; flex-shrink: 0; }
.chips-content img.logo { width: 100%; max-width: 80px; height: auto; max-height: 60px; object-fit: contain; cursor: pointer; margin-bottom: 2px; flex-shrink: 0; }
.chips-scroll { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; overflow-y: auto; overflow-x: hidden; padding: 2px 0; }
.chips-scroll { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 1px; overflow-y: auto; overflow-x: hidden; padding: 0; }
.chips-toggle {
  margin-top: auto;
  padding: 8px 4px;
  color: var(--text-secondary);
  font-size: 18px;
}

.right-column { flex: 1; display: flex; flex-direction: column; gap: clamp(3px, 0.8vmin, 6px); min-width: 0; min-height: 0; overflow: hidden; }

.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: clamp(2px, 1vmin, 14px);
  flex-shrink: 0;
}
.tournament-name {
  font-weight: 700; font-size: clamp(15px, 2.6vmin, 24px); letter-spacing: 1px;
  flex: 1; margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-bar-right { display: flex; align-items: center; gap: 12px; }
.reset-icon img { width: 22px; height: 22px; filter: brightness(0) invert(0.85); }
.settings-icon { font-size: 24px; color: var(--text-secondary); }

.timer-row { display: flex; flex-direction: row; gap: clamp(6px, 1.2vmin, 12px); align-items: stretch; flex: 0 0 auto; min-height: 0; }
.timer-section { flex: 2; min-width: 0; }
.blinds-section { flex: 1; min-width: 0; }

.timer-card {
  background: var(--bg-surface);
  border: 2px solid var(--tertiary-dark);
  border-radius: clamp(16px, 3.5vmin, 36px);
  padding: clamp(8px, 1.8vmin, 20px) clamp(8px, 1.6vmin, 18px);
  display: flex; flex-direction: column; align-items: center; gap: clamp(4px, 1.2vmin, 10px);
  height: 100%;
}
.level-label { font-size: clamp(11px, 2.2vmin, 18px); font-weight: 600; color: var(--text-secondary); }
.timer-digits { display: flex; align-items: center; gap: clamp(2px, 0.6vmin, 5px); }
.digit-box {
  background: var(--bg-main);
  border: 2px solid var(--secondary);
  border-radius: clamp(5px, 1.2vmin, 10px);
  width: clamp(36px, 11vmin, 96px); height: clamp(48px, 14.8vmin, 129px);
  display: flex; align-items: center; justify-content: center;
}
.digit-text { font-weight: 700; font-size: clamp(28px, 9.3vmin, 81px); }
.digit-colon { font-weight: 700; font-size: clamp(28px, 9.3vmin, 81px); margin: 0 2px; }
.controls-row { display: flex; gap: clamp(10px, 3.2vmin, 28px); align-items: center; }
.control-btn {
  width: clamp(30px, 4.6vmin, 40px); height: clamp(30px, 4.6vmin, 40px); border-radius: 50%;
  background: var(--tertiary-dark);
  display: inline-flex; align-items: center; justify-content: center;
}
.control-btn img { width: clamp(16px, 2.6vmin, 22px); height: clamp(16px, 2.6vmin, 22px); filter: brightness(0) invert(1); }
.control-btn.main { width: clamp(36px, 5.5vmin, 48px); height: clamp(36px, 5.5vmin, 48px); background: var(--secondary); }
.control-btn.main img { width: clamp(20px, 3vmin, 26px); height: clamp(20px, 3vmin, 26px); }
.control-btn.main.pause { background: var(--primary); }

.blinds-card {
  background: var(--bg-surface);
  border: 2px solid var(--tertiary-dark);
  border-radius: clamp(16px, 3.5vmin, 36px);
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 clamp(8px, 1.4vmin, 14px);
  overflow: hidden;
}
.blinds-top {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(5px, 1vmin, 10px); width: 100%;
}
.blind-big { font-weight: 700; color: var(--text-primary); flex-shrink: 1; line-height: 1; white-space: nowrap; }
.blind-pipe { color: var(--text-secondary); line-height: 1; }
.blind-hr { width: 70%; height: 2px; background: var(--text-secondary); margin: clamp(3px, 1vmin, 6px) 0; }
.blind-small { font-weight: 700; color: var(--text-primary); line-height: 1; white-space: nowrap; }

.rebuy-bar {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--tertiary-dark);
  border-radius: 8px;
  padding: clamp(3px, 0.8vmin, 5px) 12px;
  gap: 8px;
  font-size: clamp(9px, 1.5vmin, 11px); font-weight: 600; color: var(--text-secondary);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.rebuy-divider { color: var(--tertiary-light); font-weight: 400; }

.bottom-half {
  flex: 1 1 0; display: flex; flex-direction: row; gap: 10px; min-height: 0; overflow: hidden;
}
.panel-box {
  background: var(--bg-surface);
  border: 1px solid var(--tertiary-dark);
  border-radius: 12px;
  padding: 10px;
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-box.players { flex: 5; min-height: 0; }
.panel-box.levels { flex: 4; }
/* La tabla de jugadores hace scroll interno (no la página) cuando hay muchos
   jugadores, dejando siempre visible el gráfico de abajo. */
.panel-box.players .table-scroll { flex: 1 1 0; min-height: 0; }


.players-thead, .players-tr {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 28px 28px;
  align-items: center;
  gap: 4px;
  /* font-size removed to allow inline font-size (vw) to take effect */
  padding: 3px 0;
  text-align: center;
}
.players-thead { color: var(--accent); font-weight: 600; border-bottom: 1px solid var(--tertiary-dark); padding-bottom: 4px; }
.players-tr { border-bottom: 1px solid var(--tertiary-dark); color: var(--text-secondary); }
.players-tr .name { text-align: left; }


.players-total {
  display: flex;
  align-items: center;
  border-top: 2px solid var(--accent);
  font-weight: 900;
  color: #222;
  padding-top: 6px;
  background: #ffe9b3;
  margin-top: 2px;
  font-size: 1.25em;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 0 #fff, 0 0 2px #ffd70099;
}
.players-total .name,
.players-total span {
  color: #222 !important;
  font-weight: 900 !important;
  text-shadow: 0 1px 0 #fff, 0 0 2px #ffd70099;
}

.table-scroll { overflow-y: auto; }
.buy-btn-pos, .buy-btn-neg {
  width: 24px; height: 24px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: var(--text-primary);
}
.buy-btn-pos { background: var(--secondary); }
.buy-btn-neg { background: var(--primary); }

.levels-thead, .levels-tr {
  display: grid;
  grid-template-columns: 0.5fr 1fr 1fr 1fr;
  padding: 3px 0;
  font-size: 12px; text-align: center;
  border-bottom: 1px solid var(--tertiary-dark);
}
.levels-thead {
  background: var(--tertiary-dark);
  border-radius: 4px;
  color: var(--accent); font-weight: 600; font-size: 11px;
  margin-bottom: 2px;
  padding: 4px 0;
  border-bottom: none;
}
.levels-tr { color: var(--text-secondary); }
.levels-tr.active {
  background: var(--primary-dark);
  border-radius: 4px;
  color: var(--text-primary); font-weight: 700;
}
.levels-tr.break {
  background: var(--tertiary-dark);
  border-radius: 4px;
  color: var(--accent); font-weight: 700;
  grid-template-columns: 0.5fr 3fr;
}
.levels-tr.break.active { background: var(--accent); color: var(--text-dark); }

/* ───────────── Buy menu modal ───────────── */
.buy-menu {
  background: var(--bg-surface);
  border: 2px solid var(--primary);
  border-radius: 16px;
  padding: 20px;
  min-width: 280px;
  max-width: 90vw;
  display: flex; flex-direction: column; gap: 10px;
}
.buy-menu .title { text-align: center; font-weight: 700; font-size: 16px; margin: 0 0 4px; }
.buy-menu-btn {
  background: var(--tertiary-dark);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: center;
  font-weight: 600; font-size: 13px; color: var(--text-primary);
  cursor: pointer;
}
.buy-menu-btn.remove {
  background: rgba(148, 33, 33, 0.3);
  border: 1px solid var(--primary);
}
.chip-edit-row {
  display: flex; align-items: center; gap: 6px;
  background: var(--tertiary-dark);
  border-radius: 10px;
  padding: 6px 8px;
}
.chip-edit-btn {
  width: 28px; height: 28px;
  border: none; border-radius: 6px;
  background: var(--primary-dark);
  color: var(--text-primary);
  font-weight: 700; font-size: 16px; line-height: 1;
  cursor: pointer;
}
.chip-edit-btn:hover { background: var(--primary); }
.chip-edit-input {
  width: 50px; min-width: 0;
  text-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--tertiary-dark);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 4px 2px;
  font-weight: 600;
}
.chip-edit-actions { display: flex; justify-content: center; margin-top: 6px; }
.buy-menu[data-wide] { min-width: 480px; }
.reset-confirm-text { font-size: 13px; color: var(--text-secondary); text-align: center; margin: 0; }
.reset-confirm-row { display: flex; gap: 10px; }
.reset-confirm-row .buy-menu-btn { flex: 1; }
.reset-confirm-row .buy-menu-btn.confirm { background: var(--primary); }

/* ───────────── Break overlay ───────────── */
.break-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.break-card {
  background: var(--bg-surface);
  border: 3px solid var(--accent);
  border-radius: 24px;
  padding: 40px;
  min-width: 320px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.break-emoji { font-size: 64px; }
.break-title { font-weight: 700; font-size: 36px; color: var(--accent); margin: 0; }
.break-subtitle { font-weight: 600; font-size: 18px; color: var(--text-secondary); margin: 0; }
.break-btn {
  background: var(--secondary); border-radius: 14px;
  padding: 14px 28px; margin-top: 10px;
  font-weight: 700; font-size: 16px; color: var(--text-primary);
  cursor: pointer;
}

/* ───────────── Small responsive tweaks ─────────────
   El tamaño de timer/blinds ya escala con vmin (clamp), así que aquí solo
   reestructuramos el layout en pantallas muy estrechas (móvil en vertical). */
@media (max-width: 600px) {
  .panel-screen { flex-direction: column; }
  .chips-column { width: 100% !important; max-width: none; flex-direction: row; }
  .chips-content { flex-direction: row; }
  .chips-scroll { flex-direction: row; }
  .timer-row { flex-direction: column; }
  .bottom-half { flex-direction: column; }
}

/* Scrollbar discreto */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--tertiary-dark); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--tertiary-light); }

/* ───────────── Chip Scan: botón de cámara ───────────── */
.player-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.chip-scan-btn {
  font-size: 1.6em;
  background: var(--tertiary-dark);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.chip-scan-btn:hover  { filter: brightness(1.2); }
.chip-scan-btn:active { transform: scale(0.9); }

/* ───────────── Chip Scan: overlay y modal ───────────── */
.chip-scan-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
}
.chip-scan-modal {
  background: var(--bg-surface);
  border-radius: 18px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  border: 1px solid var(--tertiary-light);
}
.chip-scan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  font-size: 1.1em;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--tertiary-dark);
  flex-shrink: 0;
}
.chip-scan-close {
  font-size: 1.2em;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.chip-scan-close:hover { background: var(--tertiary-dark); }

.chip-scan-body {
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chip-scan-hint {
  font-size: 0.92em;
  color: var(--text-secondary);
  margin: 0;
  text-align: center;
}
.chip-scan-source-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.chip-scan-source-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--tertiary-dark);
  border-radius: 14px;
  padding: 20px 28px;
  font-size: 2em;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, filter 0.15s;
  flex: 1;
}
.chip-scan-source-btn span {
  font-size: 0.5em;
  color: var(--text-secondary);
  font-weight: 600;
}
.chip-scan-source-btn:hover  { border-color: var(--accent); filter: brightness(1.1); }

/* Cámara */
.chip-scan-video {
  width: 100%;
  border-radius: 10px;
  background: #000;
  max-height: 260px;
  object-fit: cover;
}
.chip-scan-camera-actions {
  display: flex;
  gap: 10px;
}
.chip-scan-capture-btn {
  flex: 2;
  background: var(--secondary);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 13px 0;
  font-size: 1em;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: filter 0.12s;
}
.chip-scan-capture-btn:hover { filter: brightness(1.15); }
.chip-scan-capture-btn:active { filter: brightness(0.9); }
.chip-scan-back-btn {
  flex: 1;
  background: var(--tertiary-dark);
  color: var(--text-secondary);
  border-radius: 12px;
  padding: 13px 0;
  font-size: 0.9em;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: filter 0.12s;
}
.chip-scan-back-btn:hover { filter: brightness(1.1); }

/* Preview */
.chip-scan-preview {
  width: 100%;
  border-radius: 10px;
  max-height: 260px;
  object-fit: cover;
  border: 2px solid var(--tertiary-light);
}

/* Loading */
.chip-scan-loading {
  align-items: center;
  text-align: center;
}
.chip-scan-spinner {
  width: 48px;
  height: 48px;
  border: 5px solid var(--tertiary-dark);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: chip-scan-spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes chip-scan-spin {
  to { transform: rotate(360deg); }
}

/* Resultado */
.chip-result-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9em;
  color: var(--text-secondary);
}
.chip-result-notes {
  font-size: 0.88em;
  color: var(--text-secondary);
  font-style: italic;
  margin: 0;
}
.chip-result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}
.chip-result-table th {
  background: var(--tertiary-dark);
  color: var(--accent);
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 6px 8px;
  text-align: center;
}
.chip-result-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--tertiary-dark);
  text-align: center;
  color: var(--text-primary);
}
.chip-result-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}
.chip-result-chip svg { flex-shrink: 0; }
.chip-result-count {
  font-weight: 800;
  font-size: 1.15em;
  color: var(--accent);
}
.chip-result-subtotal {
  font-weight: 600;
  color: var(--text-secondary);
}
.chip-result-total-row td {
  border-bottom: none;
  padding-top: 10px;
  font-weight: 800;
  font-size: 1em;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.chip-result-total {
  font-size: 1.4em;
  font-weight: 900;
  color: var(--accent) !important;
  letter-spacing: 1px;
}

/* Error */
.chip-scan-error {
  color: #ff7575;
  font-size: 0.95em;
  text-align: center;
  margin: 0;
}

