/* ==========================================================================
   Sudoku — cores do tabuleiro do Sudoku Master (ui/tema/Cores.kt), escuras e claras
   ========================================================================== */

.sudoku {
  --sd-fundo: #191d22;
  --sd-regiao: #212c3a;
  --sd-mesmo: #2b4767;
  --sd-selecionada: #3a6699;
  --sd-conflito: #5a2328;
  --sd-linha-fina: #39414b;
  --sd-linha-grossa: #8fb6e3;
  --sd-fixo: #e6e8ec;
  --sd-jogador: #90caf9;
  --sd-errado: #ff8a80;
  --sd-nota: #aab4c0;
  --sd-nota-destacada: #90caf9;
  max-width: 560px;
  margin: 0 auto;
}
:root[data-theme="light"] .sudoku {
  --sd-fundo: #ffffff;
  --sd-regiao: #e9f1fb;
  --sd-mesmo: #c9ddf5;
  --sd-selecionada: #a3c6ef;
  --sd-conflito: #ffdcdc;
  --sd-linha-fina: #c4cdd8;
  --sd-linha-grossa: #1b4f7e;
  --sd-fixo: #1a1c20;
  --sd-jogador: #1565c0;
  --sd-errado: #c62828;
  --sd-nota: #55606c;
  --sd-nota-destacada: #1565c0;
}

.sd-topo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.sd-topo .button {
  min-height: 44px;
  padding: 10px 18px;
}

.sd-info {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 12px;
}
.sd-dado {
  padding: 6px 8px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.sd-dado span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sd-dado strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.sd-dado strong.com-erros {
  color: var(--sd-errado);
}
.sd-pausa {
  min-width: 96px;
  padding: 0 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.sd-pausa:hover:not(:disabled) {
  border-color: var(--violet-2);
}
.sd-pausa:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ---------- Grade ---------- */
.sd-area {
  position: relative;
  width: min(100%, 520px, max(300px, calc(100vh - 300px)));
  margin: 0 auto;
}
@supports (height: 100svh) {
  .sd-area {
    width: min(100%, 520px, max(300px, calc(100svh - 300px)));
  }
}
.sd-grade {
  container-type: inline-size;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  gap: 2px;
  aspect-ratio: 1;
  padding: 2px;
  background: var(--sd-linha-grossa);
  border-radius: 12px;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.sd-grade.oculta {
  visibility: hidden;
}
.sd-bloco {
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  gap: 1px;
  background: var(--sd-linha-fina);
}
.sd-casa {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  font: inherit;
  font-size: calc(100cqi / 9 * 0.58);
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--sd-jogador);
  background: var(--sd-fundo);
  border: 0;
  cursor: pointer;
  transition: background-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.sd-casa:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid var(--ring);
  outline-offset: -3px;
}
.sd-casa.regiao {
  background: var(--sd-regiao);
}
.sd-casa.mesmo {
  background: var(--sd-mesmo);
}
.sd-casa.conflito {
  background: var(--sd-conflito);
}
.sd-casa.selecionada {
  background: var(--sd-selecionada);
}
.sd-casa.fixa {
  font-weight: 750;
  color: var(--sd-fixo);
}
.sd-casa.errada {
  color: var(--sd-errado);
}
.sd-notas {
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: calc(100cqi / 9 * 0.27);
  font-weight: 600;
  color: var(--sd-nota);
}
.sd-notas .destacada {
  font-weight: 800;
  color: var(--sd-nota-destacada);
}

.sd-pausado {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 16px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 12px;
}
.sd-pausado p {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

/* ---------- Ações e teclado numérico ---------- */
.sd-acoes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px auto 10px;
  max-width: 520px;
}
.sd-acao {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  min-height: 60px;
  padding: 8px 4px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.sd-acao svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sd-acao:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--violet-2);
}
.sd-acao.ativo {
  color: #fff;
  background: var(--grad);
  border-color: transparent;
}
.sd-acao:disabled {
  opacity: 0.4;
  cursor: default;
}
.sd-contagem {
  position: absolute;
  top: 6px;
  right: calc(50% - 26px);
  min-width: 18px;
  padding: 1px 5px;
  font-size: 11px;
  font-weight: 800;
  line-height: 16px;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: var(--r-pill);
}

.sd-teclado {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 520px;
  margin: 0 auto;
}
.sd-teclado button {
  flex: 1 1 calc((100% - 8 * 6px) / 9);
  max-width: 64px;
  min-height: 52px;
  padding: 0;
  font: inherit;
  font-size: 24px;
  font-weight: 650;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  cursor: pointer;
  touch-action: manipulation;
}
.sd-teclado button:hover:not(:disabled) {
  border-color: var(--violet-2);
}
.sd-teclado button:disabled {
  opacity: 0.35;
  cursor: default;
}
.sudoku.notas-ativas .sd-teclado button {
  color: var(--accent);
  background: var(--surface-2);
  border-style: dashed;
}
:root[data-theme="light"] .sudoku.notas-ativas .sd-teclado button {
  color: #92400e;
}

.sd-ajuda {
  margin: 14px 0 0;
  font-size: 13.5px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Diálogo ---------- */
.sd-dialogo {
  width: min(92vw, 380px);
  padding: 24px;
  color: var(--text);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.sd-dialogo::backdrop {
  background: rgba(5, 10, 30, 0.6);
}
.sd-dialogo h2 {
  margin: 0 0 8px;
  font-size: 24px;
}
.sd-dialogo p {
  margin: 0 0 16px;
  color: var(--text-2);
}
.sd-dialogo-dados {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  text-align: left;
}
.sd-dialogo-dados div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.sd-dialogo-dados dt {
  color: var(--muted);
}
.sd-dialogo-dados dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sd-dialogo-dados .destaque dt {
  font-weight: 800;
  color: var(--accent);
}
:root[data-theme="light"] .sd-dialogo-dados .destaque dt {
  color: #92400e;
}
.sd-dialogo-botoes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.sd-dialogo.travado .sd-dialogo-botoes {
  pointer-events: none;
}

@media (max-width: 480px) {
  .sd-info {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .sd-pausa {
    grid-column: 1 / -1;
    min-height: 40px;
  }
  /* Duas fileiras de teclas (1–5 e 6–9), cada tecla com pelo menos 48 px */
  .sd-teclado button {
    flex: 0 1 calc((100% - 4 * 6px) / 5);
  }
  .sd-topo {
    justify-content: center;
  }
}
