:root {
  --bg: #0b1020;
  --panel: #0f1724;
  --accent: #ffd166;
  --muted: #94a3b8;
}
html,
body {
  height: 100%;
  margin: 0;
  font-family: Inter, system-ui, Segoe UI, Roboto, "Helvetica Neue", Arial;
  box-sizing: border-box;
}
body {
  display: flex;
  flex-direction: column; /* mantém a pilha vertical */
  align-items: center; /* <— garante centralização HORIZONTAL */
  justify-content: flex-start; /* <— garante que NÃO fique verticalmente centrado */
  min-height: 100vh; /* opcional, garante altura mínima da viewport */
  padding-top: 18px;
  background: linear-gradient(180deg, #071024, #07142a);
  color: #e6eef6;

  width: 100%;
  overflow-x: hidden; /* DESLIGA a rolagem horizontal */
}

.wrap {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  width: 100%; /* Permite ocupar a largura total do body/screen */
  max-width: 800px; /* Limite visual opcional */
  padding: 0 18px; /* Adicionado padding para evitar que o conteúdo toque as bordas em telas estreitas */
  box-sizing: border-box;
}
.canvas-wrap {
  position: relative;
  flex: 3; /* Ocupa 75% do espaço livre (3 partes de 4) */
  min-width: 320px; /* Garante que o canvas não encolha menos que seu tamanho base */
  max-width: 75%; /* Limite para o canvas */
}
canvas {
  width: 100%; /* ← NOVO: Ocupa a largura total do .canvas-wrap (75%) */
  height: auto; /* Mantém a proporção (opcional) */
  background: linear-gradient(180deg, #07172b, #041022);
  border-radius: 8px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.6);
  display: block;
}
.panel {
  /* A largura do panel está atualmente em 360px. Vamos torná-lo flexível */
  flex: 1; /* Ocupa 25% do espaço livre (1 parte de 4) */
  min-width: 250px; /* Garante que o painel não encolha demais */
  padding: 18px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.6);
}

h1 {
  margin: 0 0 12px;
  font-size: 20px;
}
p {
  margin: 8px 0;
  color: var(--muted);
  font-size: 13px;
}
.hud {
  display: flex;
  gap: 12px;
  flex-direction: column;
}
.stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  align-items: center;
}
#next {
  flex-grow: 0;
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  /* O estilo original do canvas está sendo aplicado ao #next,
           então apenas garantimos que ele não será esticado */
}
.controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
button {
  padding: 8px 10px;
  border-radius: 6px;
  border: 0;
  background: #0b2334;
  color: #dff3ff;
  cursor: pointer;
}
footer {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}
.small {
  font-size: 12px;
  color: var(--muted);
}
#wordsList li {
  color: var(--accent);
  padding: 4px 0;
  font-weight: 600;
  letter-spacing: 0.6px;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.word-anim {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%) scale(1);
  font-size: 32px;
  color: #ffd166;
  font-weight: 800;
  opacity: 1;
  transition: transform 0.9s cubic-bezier(0.2, 0.9, 0.2, 1),
    opacity 0.9s ease-out;
  pointer-events: none;
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  z-index: 9999;
}
.float-plus {
  position: absolute;
  font-weight: 700;
  color: #b8ffb8;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1);
  transition: transform 700ms cubic-bezier(0.2, 0.9, 0.2, 1),
    opacity 700ms ease-out;
  z-index: 9999;
}
.particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9998;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  transition: transform 800ms cubic-bezier(0.2, 0.9, 0.2, 1),
    opacity 800ms linear;
}

/* --- Media Query para dispositivos menores (2) --- */
/* Quando a tela for menor que 768px, a direção muda para coluna (stack vertical) */
@media (max-width: 768px) {
  body {
    min-height: auto;
    height: auto;
  }
  body > img[alt="Letris"] {
    /* Sobrescreve o 500px para garantir que não ultrapasse a tela */
    max-width: 300px !important;
    width: auto !important;
  }
  .wrap {
    flex-direction: column; /* Coloca o canvas sobre o painel */
    gap: 18px;
    align-items: center; /* Centraliza ambos os elementos horizontalmente */
    /* max-width: 400px; Ajusta a largura máxima para centralizar */
  }
  .canvas-wrap,
  .panel {
    width: 100%; /* Ocupa a largura total dentro do wrap */
    max-width: none;
    box-sizing: border-box;
  }
}