* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body, #container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  body {
    background: #08080c;
    color: #ededf5;
  }
}

@media (prefers-color-scheme: light) {
  body {
    background: #f5f5f7;
    color: #1a1a1f;
  }
}

#container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* TELAS */
.tela {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;

  background: linear-gradient(135deg, #08080c 0%, #101018 100%);
}

.tela.ativa {
  opacity: 1;
  pointer-events: auto;
}

.painel {
  background: rgba(16, 16, 24, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid #26263a;
  border-radius: 12px;
  padding: 2rem;
  max-width: 540px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.painel h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #2563eb;
  text-align: center;
}

.painel h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 1.5rem 0 1rem;
  color: #ededf5;
}

.lema {
  font-size: 0.95rem;
  color: #9a9ab0;
  text-align: center;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.secaoControles {
  margin: 1.5rem 0;
}

.controles {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
  background: rgba(37, 99, 235, 0.05);
  padding: 1rem;
  border-radius: 8px;
  border-left: 3px solid #2563eb;
}

.controle {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
}

.controle strong {
  color: #ededf5;
}

.controle span {
  color: #2563eb;
  font-weight: 600;
  font-family: 'Courier New', monospace;
}

.dica {
  font-size: 0.875rem;
  color: #9a9ab0;
  line-height: 1.6;
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(37, 99, 235, 0.05);
  border-radius: 6px;
  border-left: 2px solid #2563eb;
}

.seletor-fase {
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.seletor-fase label {
  font-size: 0.875rem;
  color: #9a9ab0;
  font-weight: 600;
}

.seletor-fase select {
  padding: 0.75rem;
  background: rgba(16, 16, 24, 0.6);
  border: 1px solid #26263a;
  border-radius: 6px;
  color: #ededf5;
  font-family: inherit;
  cursor: pointer;
}

.seletor-fase select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.resultado {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  margin: 2rem 0;
  padding: 1.5rem;
  background: rgba(37, 99, 235, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(37, 99, 235, 0.1);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.stat .label {
  font-size: 0.75rem;
  color: #9a9ab0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat .valor {
  font-size: 1.75rem;
  font-weight: 700;
  color: #2563eb;
  font-family: 'Courier New', monospace;
}

.licao {
  font-size: 0.875rem;
  color: #9a9ab0;
  line-height: 1.6;
  margin: 1.5rem 0;
  padding: 1rem;
  background: rgba(16, 185, 129, 0.05);
  border-radius: 6px;
  border-left: 2px solid #10b981;
}

/* BOTÕES */
button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: inline-block;
  text-align: center;
}

.botao-primario {
  width: 100%;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ededf5;
  margin-top: 1rem;
  padding: 1rem;
  font-size: 1.125rem;
}

.botao-primario:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.botao-primario:active {
  transform: translateY(0);
}

.botao-secundario {
  width: 100%;
  background: rgba(154, 154, 176, 0.1);
  color: #ededf5;
  border: 1px solid #26263a;
  margin-top: 0.5rem;
  padding: 0.75rem;
}

.botao-secundario:hover {
  background: rgba(154, 154, 176, 0.2);
  border-color: #9a9ab0;
}

/* JOGO */
.jogo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 1rem;
  gap: 1rem;
  position: relative;
}

.hud {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  z-index: 50;
  font-size: 0.875rem;
}

.hud-esq,
.hud-dir {
  display: flex;
  gap: 1rem;
}

.hud-item {
  background: rgba(16, 16, 24, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid #26263a;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  min-width: fit-content;
}

.hud-item .label {
  display: block;
  font-size: 0.75rem;
  color: #9a9ab0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.hud-item .valor {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: #2563eb;
  font-family: 'Courier New', monospace;
}

.tabuleiro-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 3rem;
}

.tabuleiro {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 0;
  background: #26263a;
  padding: 0;
  border: 3px solid #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.celula {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a26;
  border: 1px solid #26263a;
  color: #ededf5;
  font-size: clamp(1rem, 4vw, 1.5rem);
  font-weight: 700;
  cursor: pointer;
  position: relative;
  transition: background-color 0.15s ease;
  padding: 0;
  min-height: 44px;
  min-width: 44px;
}

.celula:hover {
  background: #252533;
}

.celula.selecionada {
  background: rgba(37, 99, 235, 0.3);
  border-color: #2563eb;
}

.celula.mesmo-linha {
  background: rgba(37, 99, 235, 0.1);
}

.celula.mesmo-coluna {
  background: rgba(37, 99, 235, 0.1);
}

.celula.mesmo-bloco {
  background: rgba(37, 99, 235, 0.1);
}

.celula.fixo {
  background: #101018;
  color: #ededf5;
}

.celula.conflito {
  background: rgba(239, 68, 68, 0.3);
  border-color: #ef4444;
}

.celula.correto {
  background: rgba(16, 185, 129, 0.2);
}

/* Bordas grossas para blocos de 3x3 */
.celula:nth-child(3n)::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 0;
  height: 100%;
  width: 2px;
  background: #2563eb;
}

.celula:nth-child(27n)::after,
.celula:nth-child(27n+1)::after,
.celula:nth-child(27n+2)::after {
  width: 2px;
}

.celula:nth-child(-3n+27)::after {
  bottom: -1px;
  right: 0;
  height: 2px;
  width: 100%;
}

/* Anotações */
.anotacoes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  width: 100%;
  height: 100%;
  padding: 2px;
  font-size: 0.5rem;
  align-content: center;
  justify-content: center;
}

.anotacao {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9a9ab0;
  opacity: 0.6;
}

.anotacao.ativa {
  opacity: 1;
  color: #2563eb;
}

/* CONTROLES */
.controles-jogo {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  max-width: 600px;
}

.botao-acao {
  flex: 1;
  min-width: 80px;
  padding: 0.75rem;
  font-size: 0.875rem;
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid #26263a;
  color: #2563eb;
}

.botao-acao:hover {
  background: rgba(37, 99, 235, 0.2);
  border-color: #2563eb;
}

.botao-acao:active {
  background: rgba(37, 99, 235, 0.3);
}

.teclado-numeros {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 0.5rem;
  width: 100%;
  max-width: 600px;
}

.botao-numero {
  aspect-ratio: 1;
  padding: 0;
  min-height: 44px;
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid #26263a;
  color: #2563eb;
  font-weight: 700;
  font-size: 1.125rem;
}

.botao-numero:hover {
  background: rgba(37, 99, 235, 0.2);
  border-color: #2563eb;
}

.botao-numero:active {
  background: rgba(37, 99, 235, 0.3);
}

.info-modo {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.botao-modo {
  padding: 0.75rem 1.5rem;
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid #26263a;
  color: #7c3aed;
}

.botao-modo:hover {
  background: rgba(124, 58, 237, 0.2);
  border-color: #7c3aed;
}

.botao-modo.ativo {
  background: rgba(124, 58, 237, 0.3);
  border-color: #7c3aed;
}

/* RESPONSIVIDADE */
@media (max-width: 768px) {
  .painel {
    padding: 1.5rem;
  }

  .painel h1 {
    font-size: 1.5rem;
  }

  .controles {
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .tabuleiro-container {
    margin-top: 5rem;
  }

  .tabuleiro {
    max-width: 90vw;
    max-height: 90vw;
  }

  .hud {
    top: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    font-size: 0.75rem;
  }

  .hud-item {
    padding: 0.5rem 0.75rem;
  }

  .hud-item .valor {
    font-size: 1.25rem;
  }

  .controles-jogo {
    gap: 0.25rem;
  }

  .botao-acao {
    min-width: 60px;
    padding: 0.5rem;
    font-size: 0.75rem;
  }

  .teclado-numeros {
    gap: 0.25rem;
  }

  .botao-numero {
    min-height: 36px;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .jogo-container {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .tabuleiro-container {
    margin-top: 4rem;
    flex: 0 1 auto;
    max-height: 70vh;
  }

  .tabuleiro {
    max-width: 85vw;
    max-height: 85vw;
  }

  .celula {
    font-size: clamp(0.75rem, 2.5vw, 1rem);
    min-height: 36px;
    min-width: 36px;
  }

  .anotacoes {
    font-size: 0.35rem;
  }

  .hud {
    top: 0.25rem;
    left: 0.25rem;
    right: 0.25rem;
    gap: 0.5rem;
    font-size: 0.625rem;
  }

  .hud-item {
    padding: 0.4rem 0.6rem;
  }

  .hud-item .valor {
    font-size: 1rem;
  }

  .controles-jogo {
    gap: 0.2rem;
  }

  .botao-acao {
    min-width: 45px;
    padding: 0.4rem;
    font-size: 0.65rem;
  }

  .teclado-numeros {
    gap: 0.2rem;
  }

  .botao-numero {
    min-height: 32px;
    font-size: 0.875rem;
  }
}

/* ANIMAÇÕES */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.painel {
  animation: fadeIn 0.3s ease;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.celula.conflito {
  animation: pulse 0.4s ease-in-out;
}

/* PREFERÊNCIA DE MOVIMENTO REDUZIDO */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
