#app {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.board-wrap {
  width: 100%;
  max-width: 560px;
}

.board-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.clue-current {
  font-size: 0.95rem;
  font-weight: bold;
  background: var(--panel);
  border: 1px solid var(--cell-border);
  border-radius: 8px;
  padding: 8px 12px;
  flex: 1 1 200px;
  min-height: 1.2em;
}

.board-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.board-actions button {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--cell-border);
  background: var(--panel);
  cursor: pointer;
}

.board-actions button:hover { background: #efe9d8; }

.level-tabs { padding-bottom: 4px; }
.level-tabs button { font-weight: bold; font-size: 0.9rem; }

.chess-board {
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 3px solid var(--ink);
}

.sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.sq.light { background: #efe9d8; }
.sq.dark { background: #a9895f; }
.sq.selected { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }

.piece {
  width: 82%;
  height: 82%;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.35));
}

.coord {
  position: absolute;
  font-size: 0.62rem;
  font-family: sans-serif;
  font-weight: bold;
  color: var(--muted);
  pointer-events: none;
}
.rank-label { top: 2px; left: 3px; }
.file-label { bottom: 1px; right: 3px; }

.status { min-height: 1.4em; font-size: 0.9rem; color: var(--muted); text-align: center; }
.status.ok { color: #1d7a3c; font-weight: bold; }

.explanation {
  max-width: 560px;
  margin: 8px auto 0;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--cell-border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: sans-serif;
  color: var(--ink);
  text-align: center;
}

@media (max-width: 720px) {
  #app { padding: 12px; }
}

/* --- Mejoras 2026-10-13: casillas legales, último movimiento, jaque, arrastre --- */
.chess-board { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; border-radius: 4px; overflow: hidden; }
.sq.last.light { background: #f3e48c; }
.sq.last.dark { background: #c9b45a; }
.sq.selected.light, .sq.selected.dark { background: #8fbf6a; outline: none; }
.sq.target::after {
  content: ""; position: absolute; width: 30%; height: 30%; border-radius: 50%;
  background: rgba(20, 60, 20, 0.35); pointer-events: none;
}
.sq.capture::after {
  content: ""; position: absolute; inset: 4%; border-radius: 50%;
  border: 5px solid rgba(20, 60, 20, 0.35); pointer-events: none;
}
.sq.check { background: radial-gradient(circle, #ff3b30 0%, rgba(231, 76, 60, 0.75) 35%, rgba(169, 0, 0, 0) 75%) !important; }
.sq.bad { animation: mal 0.9s ease; }
@keyframes mal { 0%, 60% { box-shadow: inset 0 0 0 100px rgba(214, 48, 49, 0.55); } 100% { box-shadow: none; } }
.piece.ghost {
  position: fixed; z-index: 50; pointer-events: none; transform: translate(-50%, -60%) scale(1.15);
  filter: drop-shadow(0 6px 6px rgba(0,0,0,0.35));
}
.status.bad { color: #b3261e; font-weight: bold; }
.board-actions button:disabled { opacity: 0.45; cursor: default; }
.board-actions button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: bold; }
.coord { font-size: clamp(0.55rem, 2.2vw, 0.7rem); }
.sq.light .coord { color: #a9895f; }
.sq.dark .coord { color: #efe9d8; }
.explanation { line-height: 1.45; }
.credits { font-size: 0.75rem; opacity: 0.75; margin-top: 4px; }
.credits a { color: inherit; }
@media (max-width: 720px) {
  .board-actions button { font-size: 0.85rem; padding: 8px 12px; }
}
