:root {
  /* Paleta de cores do tema escuro */
  --bg-color: #1e1f29;
  --text-color: #ffffff;
  --sidebar-bg: #242636;
  --main-bg: #2a2a2a;
  --border-color: #444;
  --button-bg: #6272a4;
  --button-bg-hover: #7082b4;
  --card-bg: #242636;
  /* Atribuímos a color-scheme para que, nos navegadores modernos,
     a scrollbar e componentes sigam a cor do tema automaticamente. */
  color-scheme: light dark; 
}

/* Tema escuro */
body.dark-theme {
  --bg-color: #1e1f29;
  --text-color: #ffffff;
  --sidebar-bg: #242636;
  --main-bg: #2a2a2a;
  --border-color: #444;
  --button-bg: #6272a4;
  --button-bg-hover: #7082b4;
  --card-bg: #242636;
}

/* Tema claro */
body.light-theme {
  --bg-color: #f0f0f0;
  --text-color: #333333;
  --sidebar-bg: #cccccc;
  --main-bg: #ffffff;
  --border-color: #888888;
  --button-bg: #6272a4;
  --button-bg-hover: #7082b4;
  --card-bg: #ffffff;
}

/* Reset básico e body */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  display: flex; /* exibe sidebar-esquerda, main e sidebar-direita lado a lado */
  flex-direction: row;
  min-height: 100vh;
  background: var(--bg-color);
  color: var(--text-color);
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden; /* evita scroll horizontal global */
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.6); 
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--card-bg);
  margin: auto;
  padding: 20px;
  border: 2px solid var(--border-color);
  width: 300px;
  border-radius: 8px;
  position: relative;
  text-align: center;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* Botão X menor no canto */
.close-modal {
  position: absolute;
  right: 10px;
  top: 10px;
  cursor: pointer;
  font-size: 1.2rem;
  background: none;
  border: none;
  color: var(--text-color);
  width: 30px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  border-radius: 50%;
  transition: background 0.2s;
}
.close-modal:hover {
  background: rgba(255,255,255,0.1);
}

/* Sidebar esquerda */
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  border-right: 2px solid var(--border-color);
  box-sizing: border-box;
  transition: background 0.3s;
}

.site-title {
  text-align: center;
  font-size: 1.4rem;
  margin: 0 0 20px 0;
}

.menu-section {
  margin-bottom: 20px;
  width: 100%;
  text-align: center;
}

.difficulty-label {
  display: block;
  margin-bottom: 10px;
}

/* Botões e selects */
select,
button {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: var(--button-bg);
  color: white;
  margin: 5px 0;
  width: 100%;
  box-sizing: border-box;
  transition: background 0.3s;
  font-size: 0.9rem;
}

select:hover,
button:hover {
  background: var(--button-bg-hover);
}

/* Compartilhar - share-button */
.share-button {
  margin: 5px 0;
  width: 100%;
  text-align: center;
  border-radius: 4px;
  background: var(--button-bg);
  color: #fff;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.3s;
  display: block;
}
.share-button:hover {
  background: var(--button-bg-hover);
}

/* Carrossel */
.carousel {
  display: flex;
  align-items: center;
  justify-content: center;
}

.carousel-btn {
  background: var(--border-color);
  color: var(--text-color);
  font-size: 1.5rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  padding: 0;
  margin: 0 5px;
  cursor: pointer;
  border: none;
  transition: background 0.3s;
}
.carousel-btn:hover {
  background: var(--button-bg);
}

.carousel-image-container {
  width: 120px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 4px;
  transition: border-color 0.3s;
}
.carousel-image-container:hover {
  border-color: var(--button-bg);
}

.preview {
  object-fit: cover;
  width: 120px;
  height: 80px;
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.primary-button {
  /* sem bold, mas pode estilizar se quiser */
}
.secondary-button {
  text-decoration: none;
  display: block;
  text-align: center;
  font-size: 0.9rem;
}

/* Rodapé da sidebar */
.menu-footer {
  margin-top: auto;
  width: 100%;
  display: flex;
  justify-content: space-evenly;
  gap: 10px;
}
.menu-footer button {
  width: 40px;
  height: 40px;
  background: var(--button-bg);
  border-radius: 50%;
  font-size: 1.2rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Conteúdo principal (central) */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
  height: 100vh;
  box-sizing: border-box;
}

/* Ajuste do container do puzzle para evitar scroll horizontal */
.puzzle-container {
  position: relative;
  width: min(1200px, calc(100vw - 250px - 250px)); 
  /*
     220px (sidebar esquerda) + ~30px e 220px (sidebar direita) + ~30px 
     ajustado para acomodar as duas sidebars 
  */
  height: min(800px, calc(100vh - 40px));
  margin: 20px auto;
  border: 2px solid var(--border-color);
  background: var(--main-bg);
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  transition: background 0.3s;
}

/* Peças do puzzle */
.puzzle-piece {
  position: absolute;
  border: 1px solid #fff;
  cursor: move;
  transition: box-shadow 0.3s;
  border-radius: 4px;
  touch-action: none; /* desabilita scroll em mobile ao tocar */
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
.puzzle-piece:hover {
  box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

/* Barra lateral direita para anúncios */
.right-sidebar {
  width: 220px; /* espaço suficiente para o banner 160x600 e margens */
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  border-left: 2px solid var(--border-color);
  box-sizing: border-box;
}

/* Container para o anúncio especificamente */
.ad-container {
  width: 160px;
  min-height: 600px; /* para caber um banner 160x600 fixo */
  margin-top: 20px;
}

/* Scrollbar customizado */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
  background: var(--button-bg);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--button-bg-hover);
}

/* Ajustes para telas menores */
@media screen and (max-width: 1024px) {
  body {
    flex-direction: column;
    height: auto;
    overflow-y: auto;
  }
  .sidebar, .right-sidebar {
    width: 100%;
    height: auto;
    padding: 10px;
    box-sizing: border-box;
    border-right: none;
    border-left: none;
  }
  .main-content {
    height: auto;
    min-height: 50vh;
  }
  .puzzle-container {
    margin: 10px auto;
    width: 95vw; 
    height: 63vw; 
  }
}

@media screen and (max-width: 768px) {
  .menu-section {
    width: 100%;
    padding: 0 10px;
  }
  select,
  button {
    font-size: 16px;
    padding: 12px 16px;
  }
  .carousel-image-container {
    width: 100px;
    height: 67px;
  }
  .site-title {
    font-size: 1.2rem;
  }
  .icon-button {
    width: 35px !important;
    height: 35px !important;
    font-size: 1rem;
  }
}

/* Ajuste para telas Retina (borda mais fina) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .puzzle-piece {
    border-width: 0.5px;
  }
}

