.tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.palette button,
.palette button:hover:not(:disabled) {
  width: 44px;
  padding: 0;
  background: var(--swatch);
  border: 2px solid var(--line);
}

.palette button[aria-pressed='true'] {
  border-color: #fff;
  box-shadow: 0 0 0 3px #fff;
}

.picker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 0.8rem;
}

.picker input {
  width: 52px;
  height: 44px;
  padding: 2px;
  background: var(--panel);
  border: 1px solid var(--bright);
  cursor: pointer;
}

button[aria-pressed='true']#erase {
  color: #000;
  background: #fff;
}

.board {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 1px;
  width: min(100%, 62vh);
  padding: 1px;
  background: var(--line);
  touch-action: none;
}

/* Las 256 casillas no pueden medir 44 px: se pinta arrastrando o con las flechas. */
.board button {
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  padding: 0;
  background: var(--panel);
  border: 0;
  cursor: crosshair;
}

.board button:focus-visible {
  position: relative;
  z-index: 1;
  outline-offset: 0;
}

/* Móvil pequeño: el tablero cede para que quepan las herramientas. */
@media (max-height: 560px) and (orientation: portrait) {
  .board {
    width: min(100%, 46vh);
  }

  .help {
    display: none;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  main {
    flex-direction: row;
    width: 100%;
  }

  .tools {
    flex: 1;
    max-width: 260px;
  }

  .board {
    width: min(55%, calc(100vh - 80px));
  }

  .help {
    display: none;
  }
}
