/* Sudoku — hoja de estilos unica.
   Identidad visual de brainybusiness.pro: oscuro siempre, acento verde.
   No hay tema claro: no existe [data-tema] ni @media (prefers-color-scheme). */

:root {
  color-scheme: dark;

  /* --- paleta de marca (brainybusiness.pro) --- */
  --green: #3fb950;
  --green-b: #7ee787;
  --green-glow: rgba(63, 185, 80, .18);
  --green-dim: rgba(63, 185, 80, .07);
  --green-line: rgba(63, 185, 80, .22);

  --bg: #060a0e;
  --bg-2: #080c12;
  --surface: #0d1117;
  --surf-2: #161b22;

  --border: #21262d;
  --bsoft: #161b22;

  --white: #f0f6fc;
  --body: #8b949e;
  --muted: #484f58;

  /* --- alias del juego (nombres que ya usaba la hoja) --- */
  --fondo: var(--bg);
  --papel: var(--surface);
  --tinta: var(--white);
  --tinta-suave: var(--body);
  --linea: var(--border);
  --linea-fuerte: #4a525c;      /* separadores de las nueve cajas 3x3 */
  --acento: var(--green);
  --acento-suave: var(--green-dim);
  --dado: var(--white);
  --puesto: var(--green);
  --error: #f85149;
  --error-fondo: rgba(248, 81, 73, .12);
  --resalte: #12171e;           /* fila / columna / caja de la seleccionada */
  --resalte-igual: #1d242e;     /* celdas con la misma cifra */

  --sombra: 0 20px 60px -12px rgba(0, 0, 0, .8);
  --sombra-corta: 0 2px 10px rgba(0, 0, 0, .5);
  --radio: 16px;

  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 20px 16px 32px;
  background:
    radial-gradient(900px 420px at 50% -140px, rgba(63, 185, 80, .07), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--white);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--green-glow); color: var(--white); }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* --- cabecera -------------------------------------------------------- */

.cabecera {
  width: min(560px, 100%);
  display: flex;
  align-items: center;
  gap: 12px;
}

.marca {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -1px;
  color: var(--white);
}

.marcadores {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.marcador {
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 8px;
  text-align: center;
  min-width: 58px;
  box-shadow: var(--sombra-corta);
}

.marcador .etiqueta {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--body);
  margin-bottom: 2px;
}

.marcador strong {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.icono {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--body);
  font-size: 17px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}

.icono:hover { border-color: var(--green-line); color: var(--green); }

/* --- tablero --------------------------------------------------------- */

.tablero-zona { position: relative; }

.tablero {
  --lado: min(560px, 92vw, 62vh);
  width: var(--lado);
  height: var(--lado);
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  background: var(--surface);
  border: 2px solid var(--linea-fuerte);
  border-radius: var(--radio);
  overflow: hidden;
  box-shadow: var(--sombra), 0 0 0 1px rgba(63, 185, 80, .06);
  touch-action: manipulation;
}

.celda {
  position: relative;
  border-right: 1px solid var(--linea);
  border-bottom: 1px solid var(--linea);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--lado) / 18);
  font-weight: 500;
  color: var(--puesto);
  cursor: pointer;
  user-select: none;
  background: var(--surface);
  transition: background-color .12s ease;
}

.celda:nth-child(9n) { border-right: none; }
.celda:nth-child(n+73) { border-bottom: none; }
.celda.borde-der { border-right: 2px solid var(--linea-fuerte); }
.celda.borde-abajo { border-bottom: 2px solid var(--linea-fuerte); }

.celda.dada { color: var(--dado); font-weight: 700; }
.celda.resaltada { background: var(--resalte); }
.celda.igual { background: var(--resalte-igual); }
.celda.seleccionada { background: var(--green-dim); box-shadow: inset 0 0 0 2px var(--green); }
.celda.error { color: var(--error); background: var(--error-fondo); }
.celda.pista { animation: destello .9s ease; }

@keyframes destello {
  0%, 100% { background: var(--surface); }
  40% { background: var(--green-glow); }
}

/* notas (candidatos) */
.notas {
  position: absolute;
  inset: 2px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  font-family: var(--mono);
  font-size: calc(var(--lado) / 46);
  font-weight: 500;
  color: var(--muted);
  line-height: 1;
}

.notas span { display: flex; align-items: center; justify-content: center; }

/* --- panel de control ------------------------------------------------ */

.panel {
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
}

.caja-num {
  position: relative;
  aspect-ratio: 1 / 1.15;
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--white);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--sombra-corta);
  transition: transform .08s ease, background-color .12s ease, border-color .15s ease, color .15s ease;
}

.caja-num:hover { border-color: var(--green-line); color: var(--green); background: var(--surf-2); }
.caja-num:active { transform: translateY(1px); }
.caja-num.completo { color: var(--muted); opacity: .45; }
.caja-num .restantes {
  position: absolute;
  bottom: 3px;
  left: 0;
  right: 0;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  color: var(--body);
}

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

.boton {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--white);
  padding: 13px 26px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.boton:hover { border-color: var(--green-line); color: var(--green); background: var(--green-dim); }
.boton .ico { font-size: 15px; }
.boton em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--body);
}
.boton:hover em { color: var(--green); }

.boton.activo {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}
.boton.activo em { color: var(--green); }

.boton.primario {
  background: var(--green);
  border-color: var(--green);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 24px rgba(63, 185, 80, .35);
}
.boton.primario:hover {
  background: var(--green-b);
  border-color: var(--green-b);
  color: #000;
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(126, 231, 135, .4);
}

.boton:disabled { opacity: .4; cursor: not-allowed; }
.boton:disabled:hover { border-color: var(--border); color: var(--white); background: transparent; transform: none; }

/* las cuatro acciones bajo el tablero van apretadas: no caben 26px de aire */
.acciones .boton { padding: 12px 6px; gap: 5px; }

.barra-inferior {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.barra-inferior .boton { padding: 11px 18px; }

.selector, .check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--body);
}

.check input[type="checkbox"] {
  accent-color: var(--green);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

select {
  background: var(--surf-2);
  color: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

select:hover { border-color: var(--green-line); }

.ayuda {
  margin: 0;
  font-size: 12px;
  line-height: 2;
  color: var(--body);
}

kbd {
  background: var(--surf-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--white);
}

/* --- capas ----------------------------------------------------------- */

.capa {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 14, .82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}

.tablero-zona > .capa { position: absolute; border-radius: var(--radio); }
.capa.oculta { display: none; }

.cartel {
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radio);
  padding: 28px;
  text-align: center;
  box-shadow: var(--sombra);
  max-width: 340px;
}

.cartel h2 {
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -1px;
  color: var(--white);
}

.cartel p { margin: 0 0 18px; color: var(--body); font-size: 14px; line-height: 1.6; }

/* --- logo y pie ------------------------------------------------------ */

.logo { display: inline-flex; }
.logo img { height: 30px; width: auto; display: block; border-radius: 6px; }

.pie {
  width: min(560px, 100%);
  font-size: 12px;
  line-height: 1.7;
  color: var(--body);
  text-align: center;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.pie a { color: var(--green); text-decoration: none; font-weight: 700; }
.pie a:hover { color: var(--green-b); text-decoration: underline; }

.privacidad { display: inline-block; margin-top: 6px; font-size: 11px; color: var(--body); opacity: .85; }

/* --- instrucciones --------------------------------------------------- */

.cartel.ancho {
  max-width: 620px;
  width: min(620px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  text-align: left;
  position: relative;
  padding: 28px 30px 24px;
  background: var(--surface);
}

.cartel.ancho::-webkit-scrollbar { width: 10px; }
.cartel.ancho::-webkit-scrollbar-track { background: var(--bg-2); border-radius: 8px; }
.cartel.ancho::-webkit-scrollbar-thumb { background: var(--surf-2); border-radius: 8px; border: 2px solid var(--bg-2); }
.cartel.ancho::-webkit-scrollbar-thumb:hover { background: var(--border); }

.instrucciones h2 { text-align: center; }
.instrucciones h3 {
  margin: 22px 0 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--green);
}
.instrucciones p { margin: 0 0 8px; text-align: left; font-size: 14px; line-height: 1.7; color: var(--body); }
.instrucciones ul { margin: 0 0 8px; padding-left: 20px; }
.instrucciones li { font-size: 14px; line-height: 1.7; color: var(--body); margin-bottom: 6px; }
.instrucciones li::marker { color: var(--muted); }
.instrucciones li strong, .instrucciones p strong { color: var(--white); font-weight: 600; }
.instrucciones em { color: var(--body); font-style: italic; }
.instrucciones .ej-puesta { color: var(--green); }
.instrucciones .ej-error { color: var(--error); }
.instrucciones .nota { font-size: 13px; color: var(--body); }

.tabla { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 14px; }
.tabla th, .tabla td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.tabla th {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--body);
  border-bottom-color: var(--linea-fuerte);
}
.tabla td { color: var(--body); }
.tabla tbody tr:last-child td { border-bottom: none; }

.instrucciones .firma { text-align: center; margin: 22px 0 16px; }
.instrucciones .firma img { height: 34px; width: auto; border-radius: 6px; }

.instrucciones .boton.primario { display: block; margin: 0 auto; min-width: 170px; }

.cerrar {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--body);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  transition: color .15s ease;
}
.cerrar:hover { color: var(--green); }

/* --- movil ------------------------------------------------------------ */

@media (max-width: 560px) {
  .cabecera { flex-wrap: wrap; gap: 10px; }
  .marca { font-size: 19px; }
  .icono { margin-left: auto; }
  .marcadores {
    order: 3;
    margin-left: 0;
    width: 100%;
    gap: 5px;
    justify-content: space-between;
  }
  .marcador { min-width: 0; flex: 1 1 0; padding: 5px 6px; }
  .marcador .etiqueta { letter-spacing: 1px; }
}

@media (max-width: 480px) {
  body { padding: 14px 12px 28px; }
  .cabecera { width: 100%; }
  .acciones { grid-template-columns: repeat(2, 1fr); }
  .acciones .boton { padding: 12px 10px; }
  .boton span:not(.ico) { font-size: 13px; }
  .barra-inferior .boton { padding: 11px 14px; }
  .pad { gap: 4px; }
  .caja-num { font-size: 19px; }
  .cartel { padding: 24px 20px; }
  .cartel.ancho { padding: 24px 18px 20px; }
}

/* El enganche va donde la partida termina bien, no en la puerta de entrada. */
.gancho {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--linea, #21262d);
  font-size: 12px;
  line-height: 1.6;
}
.gancho a { color: var(--green, #3fb950); font-weight: 700; text-decoration: none; }
.gancho a:hover { text-decoration: underline; }
