/* ============================================================
 * Baduy Academy — Estilos del Coach de Dominó GTO
 * Paleta: azul marino / cian / dorado (identidad de la marca)
 * ============================================================ */
:root {
  --ink: #0d1b2a;
  --navy: #1b263b;
  --blue: #1e6091;
  --cyan: #48cae4;
  --gold: #c9a227;
  --cream: #faf6ef;
  --white: #ffffff;
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: linear-gradient(160deg, var(--ink) 0%, var(--navy) 100%);
  color: var(--white);
  min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: rgba(13, 27, 42, 0.9);
  border-bottom: 2px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo-mark { font-size: 2rem; }
.brand b { display: block; font-size: 1.05rem; letter-spacing: 1px; }
.brand small { color: var(--cyan); font-size: 0.75rem; }
.lang button {
  background: transparent; border: 1px solid var(--cyan); color: var(--cyan);
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-weight: 700;
}
.lang button.active { background: var(--cyan); color: var(--ink); }

/* ---- Main ---- */
main { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }

/* ---- Toolbar de estudio ---- */
.toolbar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.btn-tool {
  background: rgba(255,255,255,0.1); color: var(--white);
  border: 1px solid var(--cyan); padding: 10px 16px;
  border-radius: 10px; cursor: pointer; font-weight: 700;
}
.btn-tool:hover { background: rgba(72,202,228,0.15); }

/* ---- Editor de manos ---- */
.hand-editor {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.editor-header h2 { color: var(--cyan); font-size: 1.1rem; margin-bottom: 6px; }
.editor-sub { font-size: 0.85rem; opacity: 0.8; margin-bottom: 14px; }
.editor-players {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 700px) { .editor-players { grid-template-columns: repeat(4, 1fr); } }
.editor-player {
  background: rgba(0,0,0,0.25); border-radius: 10px; padding: 10px;
  cursor: pointer; border: 2px solid transparent;
}
.editor-player.active { border-color: var(--cyan); background: rgba(72,202,228,0.08); }
.editor-player .ep-name { font-weight: 800; font-size: 0.9rem; color: var(--cyan); margin-bottom: 6px; }
.editor-player .ep-tiles { display: flex; flex-wrap: wrap; gap: 4px; min-height: 40px; }
.editor-player .ep-slot {
  width: 30px; height: 46px; border-radius: 5px;
  background: rgba(255,255,255,0.08);
  border: 1px dashed rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; color: rgba(255,255,255,0.4);
  cursor: pointer; position: relative;
}
.editor-player .ep-slot.filled {
  background: var(--white); border: 1px solid var(--ink);
  color: var(--ink); font-weight: 800; font-size: 0.75rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  width: 34px; height: 52px;
}
.ep-pips {
  display: grid;
  grid-template-columns: repeat(3, 5px);
  grid-template-rows: repeat(3, 5px);
  gap: 1px;
}
.ep-pips .pips { display: contents; }
.ep-pips .pip { width: 4px; height: 4px; }
.ep-divider { width: 100%; height: 1.5px; background: var(--ink); }
.editor-player .ep-count { font-size: 0.7rem; opacity: 0.6; margin-top: 5px; text-align: center; }
.editor-bank h3 { color: var(--cyan); font-size: 0.95rem; margin-bottom: 8px; }
.bank-count {
  background: var(--gold); color: var(--ink); padding: 2px 8px;
  border-radius: 10px; font-size: 0.8rem; font-weight: 800;
}
.bank-tiles {
  display: flex; flex-wrap: wrap; gap: 6px;
  background: rgba(0,0,0,0.2); border-radius: 10px; padding: 10px;
  min-height: 60px;
}
.bank-tile {
  width: 42px; height: 64px; border-radius: 7px;
  background: var(--white); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; cursor: pointer; border: 2px solid transparent;
  transition: transform 0.12s;
}
.bank-tile:hover { transform: scale(1.1); border-color: var(--cyan); }
.bank-tile.used { opacity: 0.25; cursor: not-allowed; }
.bt-pips {
  display: grid;
  grid-template-columns: repeat(3, 6px);
  grid-template-rows: repeat(3, 6px);
  gap: 1px;
}
.bt-pips .pips { display: contents; }
.bt-pips .pip { width: 5px; height: 5px; }
.bt-divider { width: 100%; height: 2px; background: var(--ink); }
.editor-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ---- Status ---- */
.status {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 16px;
  background: rgba(255,255,255,0.06); padding: 12px 16px; border-radius: var(--radius);
}
.turn { font-size: 1rem; color: var(--cyan); font-weight: 700; }
.round { font-size: 0.9rem; opacity: 0.8; }

/* ---- Botones ---- */
.btn-primary {
  background: var(--gold); color: var(--ink); border: none; padding: 10px 18px;
  border-radius: 10px; font-weight: 800; cursor: pointer; font-size: 0.95rem;
  transition: transform 0.15s;
}
.btn-primary:hover { transform: scale(1.04); }
.btn-secondary {
  background: rgba(255,255,255,0.12); color: var(--white); border: 1px solid rgba(255,255,255,0.3);
  padding: 10px 18px; border-radius: 10px; cursor: pointer; font-weight: 700;
}
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-accent {
  background: var(--cyan); color: var(--ink); border: none; padding: 10px 18px;
  border-radius: 10px; font-weight: 800; cursor: pointer; font-size: 0.95rem;
  transition: transform 0.15s;
}
.btn-accent:hover { transform: scale(1.04); }

/* ---- Mesa de juego ---- */
.table-wrap {
  background:
    radial-gradient(ellipse at center, rgba(255,255,255,0.06) 0%, transparent 70%),
    repeating-linear-gradient(45deg, #174531 0px, #174531 2px, #15402d 2px, #15402d 4px),
    linear-gradient(160deg, #1d5139 0%, #123a29 50%, #0c2b1f 100%);
  border: 8px solid #6b4226;
  border-radius: 28px;
  padding: 14px;
  margin-bottom: 16px;
  box-shadow:
    inset 0 0 60px rgba(0,0,0,0.6),
    inset 0 0 4px rgba(255,255,255,0.1),
    0 10px 30px rgba(0,0,0,0.5);
  position: relative;
}
/* Bisel de la mesa (madera) */
.table-wrap::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 2px solid rgba(139,90,43,0.4);
  border-radius: 22px;
  pointer-events: none;
}
.table-middle {
  display: flex; align-items: stretch; gap: 6px;
}
.board-felt {
  flex: 1; min-width: 0;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255,255,255,0.08) 0%, transparent 60%),
    rgba(0,0,0,0.35);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 10px;
  box-shadow: inset 0 2px 12px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
}
.board-felt-inner {
  width: 100%;
}
.board-felt-inner h2 {
  color: var(--gold); font-size: 0.7rem; letter-spacing: 3px;
  text-align: center; margin-bottom: 8px; text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.board-empty {
  color: rgba(255,255,255,0.45); font-size: 0.8rem;
  text-align: center; padding: 15px 8px;
}

/* Secuencia de la mano (notación en vivo) */
.sequence {
  margin: 10px 0;
  padding: 10px 12px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--gold);
  text-align: left;
  line-height: 1.5;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  min-height: 20px;
}
.sequence-label {
  display: block;
  font-size: 0.6rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  margin-bottom: 4px;
}
.sequence-empty {
  color: rgba(255,255,255,0.35);
  text-align: center;
}

/* ---- Jugadores con atril ---- */
.player-top, .player-bottom, .player-side {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 8px 10px;
  box-shadow:
    0 4px 12px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.08);
}
.player-top { margin-bottom: 10px; text-align: center; }
.player-bottom { margin-top: 10px; }
.player-side {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  min-width: 62px;
  gap: 6px;
}
.player-name {
  font-weight: 900; font-size: 1rem; color: var(--cyan);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
}
.player-name .p-letter {
  background: var(--gold); color: var(--ink);
  border-radius: 50%; width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 900;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.player-name.me { color: #fff; }
.player-name.me .p-letter { background: var(--cyan); }
/* Equipo A = azul/cian, Equipo B = naranja/rojo */
.player-name.team1 { color: #4fc3f7; text-shadow: 0 0 8px rgba(79,195,247,0.5); }
.player-name.team2 { color: #ff8a65; text-shadow: 0 0 8px rgba(255,138,101,0.5); }
.player-name.team1 .p-letter { background: #4fc3f7; color: #0a2e23; }
.player-name.team2 .p-letter { background: #ff8a65; color: #0a2e23; }
.player-sub { font-size: 0.62rem; opacity: 0.6; margin-top: 1px; }

/* Atril: base donde descansan las fichas boca abajo */
.player-top .player-cards, .player-bottom .player-cards {
  display: flex; gap: 3px; justify-content: center; margin-top: 6px;
  flex-wrap: wrap;
  padding: 5px 8px;
  background: linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.15));
  border-radius: 8px;
  border-bottom: 3px solid rgba(139,90,43,0.5);
}
.card-back {
  width: 16px; height: 26px; border-radius: 3px;
  background:
    repeating-linear-gradient(45deg, #2a4a8a, #2a4a8a 2px, #1e3a6a 2px, #1e3a6a 4px);
  border: 1px solid #0d1b2a;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* Atril lateral (vertical) */
.player-side .player-cards {
  display: flex; flex-direction: column; gap: 3px;
  margin-top: 2px;
  align-items: center;
  padding: 6px 5px;
  background: linear-gradient(90deg, rgba(0,0,0,0.35), rgba(0,0,0,0.15));
  border-radius: 8px;
  border-right: 3px solid rgba(139,90,43,0.5);
}
.player-side .card-back {
  width: 14px; height: 22px;
}
/* Mano visible del jugador de perspectiva */
.player-bottom .hand { margin-top: 8px; }

/* Tablero: UNA línea continua que escala (nunca se rompe) */
.board-chain {
  display: flex; gap: 2px; align-items: center;
  justify-content: center;
  width: 100%;
  flex-wrap: nowrap;
}
.board {
  display: flex; align-items: center; justify-content: center;
  min-height: 90px;
  padding: 6px;
  max-width: 100%;
  overflow-x: hidden;
}
.board .tile-h, .board .tile-v { flex-shrink: 1; }

/* Fichas del tablero: tamaño controlado por --halfw (JS) */
.board .tile-h {
  padding: 2px 3px;
  height: calc(var(--halfw, 26px) + 10px);
}
.board .tile-h .half {
  width: var(--halfw, 26px);
  height: 100%;
}
.board .tile-h .pip { width: calc(var(--halfw, 26px) * 0.24); height: calc(var(--halfw, 26px) * 0.24); }
.board .tile-v {
  width: calc(var(--halfw, 26px) + 8px);
  padding: 3px 2px;
}
.board .tile-v .half {
  width: 100%;
  height: var(--halfw, 26px);
}
.board .tile-v .pip { width: calc(var(--halfw, 26px) * 0.24); height: calc(var(--halfw, 26px) * 0.24); }

/* ---- Fichas ---- */
.tile {
  background: var(--white); color: var(--ink);
  border-radius: 6px; padding: 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
  position: relative;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
  gap: 1px;
  width: 40px;
}
.tile:hover { transform: translateY(-4px); }
.tile.selected { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,39,0.4); }
.tile.best-tile { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(72,202,228,0.45); }
.tile .half {
  display: flex; justify-content: center; align-items: center;
  width: 100%; height: 22px;
}
.tile .divider { width: 100%; height: 2px; background: var(--ink); }
.tile .pips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 1px;
  width: 100%;
  height: 100%;
}
.pip {
  width: 5px; height: 5px; border-radius: 50%; background: var(--ink);
  justify-self: center; align-self: center;
}
/* Ficha horizontal en el tablero (cadena) */
.tile-h {
  flex-direction: row;
  width: auto;
  padding: 2px 3px;
}
.tile-h .half { width: 19px; height: 100%; }
.tile-h .divider { width: 2px; height: 100%; }
.tile-h .pip { width: 4px; height: 4px; }

/* Ficha VERTICAL (doble perpendicular en el tablero) */
.tile-v {
  flex-direction: column;
  width: 34px;
  padding: 2px;
  align-self: center;
  box-shadow: 0 3px 8px rgba(0,0,0,0.5);
}
.tile-v .half { width: 100%; height: 20px; }
.tile-v .divider { width: 100%; height: 2px; }
.tile-v .pip { width: 4px; height: 4px; }
.tile-board { cursor: default; }
.tile-board:hover { transform: none; }
.tile-sm { width: 32px; }
.tile-sm .half { height: 18px; }
.tile-sm .pip { width: 4px; height: 4px; }
.tile-xs { width: 26px; }
.tile-xs .half { height: 15px; }
.tile-xs .pip { width: 3px; height: 3px; }

/* ---- Selector de perspectiva ---- */
.perspective-wrap {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.perspective-wrap h3 { color: var(--cyan); font-size: 0.95rem; margin-bottom: 10px; }
.perspective-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.perspective-btn {
  background: rgba(255,255,255,0.08); color: var(--white);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 10px; padding: 8px 14px;
  cursor: pointer; font-weight: 800; font-size: 0.9rem;
  transition: all 0.15s;
}
.perspective-btn:hover { border-color: var(--cyan); }
.perspective-btn.active {
  background: var(--cyan); color: var(--ink); border-color: var(--cyan);
}
.perspective-hint { font-size: 0.75rem; opacity: 0.6; margin-top: 8px; }

/* ---- Tiempo de pensada (señal al compañero) ---- */
.think-wrap {
  display: flex; align-items: center; gap: 6px;
  justify-content: center; margin-top: 8px;
  flex-wrap: wrap;
}
.think-label { font-size: 0.8rem; opacity: 0.75; font-weight: 700; }
.think-btn {
  background: rgba(255,255,255,0.08); color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px; padding: 5px 12px;
  font-size: 0.78rem; font-weight: 700; cursor: pointer;
  transition: all 0.15s;
}
.think-btn:hover { border-color: var(--cyan); }
.think-btn.active {
  background: var(--cyan); color: var(--ink);
  border-color: var(--cyan); font-weight: 900;
}
.think-btn[data-think="breve"].active { background: var(--gold); border-color: var(--gold); }
.think-btn[data-think="larga"].active { background: #e67e22; border-color: #e67e22; color: #fff; }

/* ---- Mano ---- */
.hand { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 70px; }
.hand-actions { display: flex; gap: 10px; margin-top: 12px; justify-content: center; flex-wrap: wrap; }

/* ---- Métodos de comunicación (Federación Mundial Paralela) ---- */
.comms-wrap {
  margin-top: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.comms-wrap h3 { font-size: 0.95rem; margin-bottom: 10px; color: var(--gold); }
.comms-grid { display: flex; flex-direction: column; gap: 10px; }
.comms-pair {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.comms-label { font-size: 0.82rem; font-weight: 700; min-width: 90px; }
.comms-select {
  flex: 1; min-width: 200px;
  background: rgba(255,255,255,0.1); color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px; padding: 7px 10px; font-size: 0.8rem;
  cursor: pointer;
}
.comms-select option { background: #1a1a2e; color: #fff; }
.comms-hint { font-size: 0.72rem; opacity: 0.55; margin-top: 8px; font-style: italic; }

/* ---- Coach ---- */
.modalidad-wrap {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.modalidad-label { font-size: 0.85rem; opacity: 0.8; }
.modalidad-select {
  background: rgba(255,255,255,0.1); color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px; padding: 6px 10px; font-size: 0.85rem;
  cursor: pointer; flex: 1;
}
.modalidad-select option { background: #1a1a2e; color: #fff; }
.coach-progress { margin-bottom: 12px; }
.progress-bar {
  width: 100%; height: 10px; background: rgba(255,255,255,0.12);
  border-radius: 6px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  border-radius: 6px;
  transition: width 0.15s;
}
.progress-text {
  text-align: center; font-size: 0.85rem; color: var(--cyan);
  margin-top: 5px; font-weight: 700;
}
.coach-results { display: flex; flex-direction: column; gap: 8px; }
.coach-row {
  display: flex; align-items: center; gap: 12px;
  background: rgba(0,0,0,0.25); border-radius: 10px; padding: 8px 14px;
  border-left: 4px solid var(--blue);
}
.coach-row.best { border-left-color: var(--gold); background: rgba(201,162,39,0.12); }
.coach-row .rank { font-weight: 900; font-size: 1.1rem; color: var(--cyan); min-width: 30px; }
.coach-row .tile-mini { display: flex; align-items: center; }
.coach-row .tile-mini .tile { width: 34px; cursor: default; box-shadow: none; }
.coach-row .tile-mini .tile:hover { transform: none; }
.coach-row .tile-mini .pip { width: 5px; height: 5px; }
.coach-row .ev { margin-left: auto; font-weight: 800; color: var(--gold); font-size: 0.95rem; }
.coach-row .ev.neg { color: #e74c3c; }
.coach-row .ev.best-ev { color: #2ecc71; }
.coach-hint { color: rgba(255,255,255,0.5); font-size: 0.85rem; margin-top: 8px; font-style: italic; }

/* ---- Lesson ---- */
.lesson p { font-size: 0.95rem; line-height: 1.7; opacity: 0.9; }

/* ---- Responsive ---- */
@media (max-width: 520px) {
  /* Laterales compactos: solo avatar y conteo, sin fichas visibles */
  .player-side {
    min-width: 44px;
    padding: 6px 4px;
  }
  .player-side .player-cards { display: none; }
  .player-side .player-sub { font-size: 0.55rem; }
  .player-name { font-size: 0.7rem; }
  .player-name .p-letter { width: 18px; height: 18px; font-size: 0.65rem; }

  /* Tablero ocupa todo el ancho disponible */
  .table-wrap { padding: 10px; border-width: 6px; border-radius: 20px; }
  .table-middle { gap: 4px; }
  .board-felt { padding: 8px; min-height: 120px; }

  /* Fichas del tablero más pequeñas en móvil */
  .board .tile-h .half { width: 20px; }
  .board .tile-h .pip { width: 4.5px; height: 4.5px; }
  .board .tile-v { width: 34px; }
  .board .tile-v .half { height: 20px; }
  .board .tile-v .pip { width: 4.5px; height: 4.5px; }

  /* Mano más compacta */
  .tile { width: 34px; }
  .tile .half { height: 18px; }
  .pip { width: 4px; height: 4px; }

  .status { flex-direction: column; align-items: stretch; }
  .hand-actions { flex-direction: column; }
  .btn-accent, .btn-primary, .btn-secondary { width: 100%; }
}
