/* ==========================================================================
   El mejor ajedrecista — juego 8
   ==========================================================================
   Lo mismo de siempre: el lienzo manda y el HTML es el marco. El lienzo
   tiene el doble de píxeles que unidades de dibujo, así que hay que dejarlo
   escalar sin suavizado o se ve como una foto mojada.
   ========================================================================== */

.aj-intro { padding: clamp(2rem, 6vw, 4rem) 0 1.5rem; }
.aj-intro h1 { margin: .2rem 0 .6rem; }
.aj-intro .lead { max-width: 60ch; }

.aj-seccion { padding-bottom: clamp(2.5rem, 7vw, 5rem); }

.aj { position: relative; max-width: 860px; margin: 0 auto; }

/* ------------------------------------------------------------------ hud -- */
.hud {
  display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; align-items: baseline;
  padding: .55rem .8rem;
  border: 1px solid var(--border); border-bottom: 0;
  border-radius: var(--radius-m) var(--radius-m) 0 0;
  background: var(--fondo-2, #f6f4ef);
}
.hud small { display: block; font-size: .62rem; letter-spacing: .07em;
             text-transform: uppercase; color: var(--texto-2, var(--text-muted)); }
.hud b { font-size: .95rem; font-weight: 700; }
.hud-lugar { flex: 1 1 auto; min-width: 8rem; }

/* ---------------------------------------------------------------- lienzo -- */
.aj-vista {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-m) var(--radius-m);
  overflow: hidden;
  background: #0d1014;
  box-shadow: var(--shadow-s);
}
.aj.con-pantalla .aj-vista { overflow: visible; }
.aj.con-pantalla .aj-vista > canvas { display: none; }
.aj.con-pantalla .pant-ancha:not([hidden]) {
  position: relative; inset: auto; overflow: visible; border-radius: var(--radius-m);
}
.aj-vista canvas {
  display: block; width: 100%; height: auto;
  image-rendering: pixelated; image-rendering: crisp-edges;
  touch-action: none;
}

.flash {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  margin: 0; padding: .3rem .7rem;
  background: #2b3340; color: #f0ece0;
  border-radius: 6px; font-size: .78rem; font-weight: 600;
  pointer-events: none; z-index: 4;
}
.flash[hidden] { display: none; }

/* -------------------------------------------------------------- pantallas -- */
.pant {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-items: center;
  padding: 1rem;
  background: linear-gradient(180deg, rgba(14,17,22,.93), rgba(14,17,22,.97));
}
.pant[hidden] { display: none; }
.pant-caja {
  max-width: 52ch; text-align: center; color: #ece7db;
}
.pant-caja h2 { margin: .2rem 0 .7rem; color: #fff; }
.pant-caja p { margin: 0 0 .7rem; font-size: .92rem; line-height: 1.55; }
.pant-kicker {
  font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  color: #b0a88e; margin: 0 0 .3rem;
}
.pant-nota { font-size: .8rem !important; color: #b4ae9e; }
.pant-aviso {
  background: rgba(190,120,60,.16); border-left: 3px solid #c8874a;
  padding: .5rem .7rem; text-align: left;
}
.pant-botones { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center;
                margin-top: .8rem; }
.pant-cta {
  display: inline-block; margin: .2rem .2rem 0;
  padding: .55rem 1.1rem; border: 0; border-radius: 8px;
  background: #3f6f8a; color: #fff; font: inherit; font-weight: 600;
  font-size: .9rem; cursor: pointer;
}
.pant-cta:hover { background: #35607a; }
.pant-cta-2 { background: #39414e; }
.pant-cta-2:hover { background: #2f3641; }
.pant-pie { margin-top: .9rem !important; font-size: .82rem !important; }
.pant-pie a { color: #9fc0d4; }

/* ---------------------------------------------------------------- mandos -- */
.mandos {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-top: .7rem;
}
.mandos[hidden] { display: none; }
.mando-cruz { display: flex; align-items: center; gap: .3rem; }
.mando-col { display: flex; flex-direction: column; gap: .3rem; }
.mando {
  min-width: 3rem; min-height: 2.6rem;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--fondo-2, #f2efe8); color: inherit;
  font: inherit; font-size: 1rem; font-weight: 700;
  touch-action: manipulation; user-select: none; cursor: pointer;
}
.mando:active { background: #dfd9cc; }
.mando-acciones { display: flex; gap: .4rem; }
.mando-a { background: #3f6f8a; color: #fff; border-color: #35607a; }
.mando-b { background: #5a6270; color: #fff; border-color: #4a515d; }

.aj-pista { margin: .6rem 0 0; font-size: .8rem; color: var(--texto-2, var(--text-muted)); }
.aj-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* --------------------------------------------------------------- fichas -- */
.aj-fichas {
  display: grid; gap: 1.2rem; margin: 2.2rem auto 0; max-width: 860px;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
}
.aj-ficha {
  padding: 1rem 1.1rem;
  border: 1px solid var(--border); border-radius: var(--radius-m);
  background: var(--fondo-2, #f8f6f1);
}
.aj-ficha h2 { margin: 0 0 .4rem; font-size: 1.05rem; }
.aj-ficha > p { margin: 0 0 .8rem; font-size: .84rem; color: var(--texto-2, var(--text-muted)); }

.lista-pos { list-style: none; margin: 0; padding: 0; counter-reset: p; }
.lista-pos li {
  display: flex; justify-content: space-between; gap: .6rem;
  padding: .35rem 0; border-bottom: 1px solid var(--border);
  font-size: .86rem;
}
.lista-pos li:last-child { border-bottom: 0; }
.lista-pos li.vos { font-weight: 700; color: #3f6f8a; }
.lista-pos li span { color: var(--texto-2, var(--text-muted)); font-variant-numeric: tabular-nums; }

.lista-mej { list-style: none; margin: 0; padding: 0; }
.lista-mej li { padding: .4rem 0; border-bottom: 1px solid var(--border); }
.lista-mej li:last-child { border-bottom: 0; }
.lista-mej b { display: block; font-size: .85rem; }
.lista-mej span { display: block; font-size: .78rem; color: var(--texto-2, var(--text-muted)); }
.lista-mej li.sin b { color: var(--texto-2, var(--text-muted)); font-weight: 500; }
.lista-mej li.sin span { opacity: .8; }

.aj-como { max-width: 860px; margin: 2rem auto 0; }
.aj-como h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
.aj-como ul { margin: 0 0 1rem; padding-left: 1.1rem; }
.aj-como li { margin-bottom: .5rem; font-size: .88rem; line-height: 1.55; }
.aj-pie { font-size: .8rem; color: var(--texto-2, var(--text-muted)); max-width: 66ch; }
.borrar {
  border: 1px solid var(--border); border-radius: 7px;
  background: none; color: inherit; font: inherit; font-size: .8rem;
  padding: .35rem .8rem; cursor: pointer;
}
.borrar:hover { background: #f0e6e4; border-color: #c8a6a0; }

@media (max-width: 560px) {
  .hud { gap: .4rem .9rem; }
  .hud b { font-size: .85rem; }
  .mando { min-width: 2.7rem; }
}
