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

html, body {
  overflow-x: hidden;
}

body {
    font-family: 'Roboto', sans-serif;
    background: #fafafa;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
}

header {
    background: #ff9800;
    color: white;
    padding: 1rem;
    text-align: center;
    width: 100%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

main{
    text-align: center;
}

#timer {
    margin-top: 1rem;
}

#mainLayout {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    gap: 0;
}

#controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-right: 24px;
    min-width: 160px;
}

#boardWrapper {
    /* já está quadrado e centralizado */
}

.board {
    /* margin: 0 auto; */
    display: grid;
    grid-template-columns: repeat(var(--size, 8), 40px);
    grid-template-rows: repeat(var(--size, 8), 40px);
    gap: 2px;
    margin-top: 20px;
    position: relative;
    border-radius: 16px;
}

.controls {
    margin-top: 20px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    max-width: 400px;
    justify-content: center;
}

.controls .btn {
    width: 160px;
    height: 40px;
    box-sizing: border-box;
    font-size: 1rem;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.words-list {
    margin-top: 8px; /* Diminua o espaçamento */
    /* margin-left: 24px; */
    list-style: none;
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    flex-direction: column;
    min-width: 160px;
    gap: 0.25rem 0.5rem;
    max-width: 600px;
}

.flex-row {
    flex-direction: row;
}

.words-list li {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background: #fff3e0;
    border-radius: 5px;
    color: #222;
}

.words-list li.resolved {
    opacity: 0.5;
}

.btn {
    background: #ff9800;
    color: white;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.3s;
}

.btn:hover {
    background: #e68900;
}

.delete-btn {
    background: red;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px 6px;
}

.popup {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.popup-content {
    position: absolute;
    top:180px;
    background: #fff;
    color: #222;
    padding: 2em 2.5em;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 400px;
}

.popup-content p{
    margin:0.4rem 0;
    text-align: justify;
}

.popup-content button {
    margin: 0.5em;
    margin-top:2rem;
}

.overlay-rect {
  position: absolute;
  pointer-events: none;
  border: 2px solid rgba(33, 150, 243, 0.5); /* azul, 50% opacidade */
  background: rgba(33, 150, 243, 0.2);       /* azul, 20% opacidade */
  border-radius: 8px;
  z-index: 10;
}
#overlayContainer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

#overlayContainer {
  /* position: absolute; */
  /* top: 0; left: 0; */
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}

.overlay-rect {
  position: absolute;
  border: 2px solid rgba(33,150,243,0.5);
  background: rgba(33,150,243,0.2);
  border-radius: 8px;
  pointer-events: none;
  z-index: 11;
  transform-origin: left top;
}

.overlay-line {
  position: absolute;
  background: rgba(33,150,243,0.3); /* azul, 30% opacidade */
  border-radius: 32px;
  pointer-events: none;
  z-index: -30;
  box-shadow: 0 0 16px rgba(33,150,243,0.2);
  border: 2px solid rgba(33,150,243,0.5);
  transform-origin: left center;
  height: 32px; /* Espessura mínima da linha */
  padding: 0 16px;
  opacity: 0.3;
}

/* Tema claro (default) */
body {
    background: #fafafa;
    color: #222;
}

a {
    color: #181818;
}

body.dark-theme a{
    color: #fff;
}



header {
    background: #ff9800;
    color: white;
    padding: 1rem;
    text-align: center;
    width: 100%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.words-list li {
    background: #fff3e0;
    color: #222;
}

/* Tema escuro */
body.dark-theme {
    background: #181818;
    color: #eee;
}

.cell {
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #222;
    font-size: 1.8rem;
    cursor: pointer;
    user-select: none;
    border: none;
    background: transparent;
}
body.dark-theme .cell {
    
    color: #ddd;
    /* border: none; */
    /* font-weight: bold; */
    /* text-shadow: 0 1px 4px #000, 0 0 2px #333; */
}

header.dark-theme {
    background: #333;
    color: #ff9800;
}
.controls.dark-theme {
    background: #222;
}
.words-list.dark-theme li {
    background: #333;
    color: #eee;
}



#themeToggleBtn {
  margin: 1rem 0;
  font-size: 1rem;
}

/* Popup padrão (modo claro) */
.popup {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.popup-content {
    background: #fff;
    color: #222;
    padding: 2em 2.5em;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    text-align: center;
}

/* Popup modo escuro */
body.dark-theme .popup {
    background: rgba(24,24,24,0.95);
}
body.dark-theme .popup-content {
    background: #222;
    color: #ff9800;
    box-shadow: 0 4px 24px rgba(0,0,0,0.7);
}

body.dark-theme .btn {
    background: #ff9800;
    color: #fff;
}

#wordInput {
    height: 40px;
    font-size: 1rem;
    box-sizing: border-box;
    padding: 0 16px;
    border-radius: 5px;
    border: 1px solid #ccc;
    width: 160px;
    margin-right: 8px;
    vertical-align: middle;
}

#homeContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    width: 100%;
}

#homeContainer img {
    max-height:400px; 
    width: auto;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    object-fit: contain;
    display: block;
}

#homeContainer .btn {
    min-width: 180px;
    height: 44px;
    font-size: 1.1rem;
    margin: 0.2rem 0;
    border-radius: 5px;
    background: #ff9800;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
#homeContainer .btn:hover {
    background: #e68900;
}

/* Esconde o homeContainer quando não estiver no modo home */
body:not(.home-mode) #homeContainer {
    display: none !important;
}

.adfig {
    margin: 0.5rem 0;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.adfig #adImg {
    width: 95%;
    height: 95%;
    margin: auto;
}


figcaption{
    margin: 0.2rem 0 0 0;
    font-size: 0.7rem;
    width: 100%;
    margin-left: 2rem;
}

#gridControls{
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    width: 100%;
    justify-content: center;
}

#gridControls .btn{
    font-size: 2rem;
    width: 50px;
    height: 50px;
    text-align: center;
    padding: 0;
}

#acervoList li{
    list-style: none;
}

footer {
    width: 100%;
    text-align: center;
}

#boardWrapper .words-list {
    margin-top: 16px;
    margin-left: 0;
    align-items: center;
    /* width: 100%; */
    display: flex;
    flex-direction: column;
}

/* Media Query para dispositivos móveis */
@media (max-width: 1000px) {
   #mainLayout {
    flex-direction: column;
   }
   #wordsList{
    width: 100dvw;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0 5dvw;
   }
}

