*{
    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;
    max-width: 100dvw;
    padding-bottom: 64px;
}

#timer {
    margin-top: 1rem;
}

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

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

.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;
    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;
    box-sizing: border-box;
}

.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;
    color: black !important;
}

.btn:hover{
    background-color: lightyellow !important;
}

.btn#playBtn{
    width: 90%;
    font-size: 2rem !important;
    background-color: #ff2a00 !important;
    color: white !important;
    padding-bottom: 3.2rem !important;
}

.btn#playBtn:hover{
    background-color: #ff6e51 !important;
}

.btn#themeToggleBtn{
    font-size: 0.7rem !important;
}

.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;
}

body.dark-theme #acervoContainer {
    background: #181818;
    color: #fff;
}

body.dark-theme #acervoHeader h2 {
    color: #ff9800;
}

body.dark-theme .game-card {
    background: #222;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid #333;
}

body.dark-theme .game-card:hover {
    background: #2a2a2a;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

body.dark-theme .game-card-date {
    color: #ffa726;
}

body.dark-theme .game-card-status {
    color: #90be6d;
}

#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;
}

#acervoContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    max-width: 90dvw;
    padding: 20px;
    min-height: 80vh;
}

#acervoHeader {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 30px;
    position: relative;
}

#acervoHeader h2 {
    font-size: 2rem;
    margin: 0;
    color: #222;
}

#acervoHeader #acervoBackBtn {
    position: absolute;
    left: 20px;
    font-size: 1rem;
    padding: 8px 16px;
}

.acervo-games {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    padding: 0 20px;
}

.game-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: #222;
    min-height: 150px;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    background: #f5f5f5;
}

.game-card-date {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ff9800;
    margin-bottom: 10px;
}

.game-card-status {
    font-size: 0.9rem;
    color: #666;
}

.game-card-status.completed {
    color: #43aa8b;
    font-weight: bold;
}

.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;
    margin: 0.5rem 0;
}

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

#boardWrapper{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1;
    margin: none;
    padding: none;
}

#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: 100%;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
   }
   
   #acervoContainer {
      padding: 10px;
   }
   
   #acervoHeader {
      margin-bottom: 20px;
   }
   
   #acervoHeader h2 {
      font-size: 1.5rem;
   }
   
   #acervoHeader #acervoBackBtn {
      left: 10px;
      padding: 6px 12px;
      font-size: 0.9rem;
   }
   
   .acervo-games {
      grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
      gap: 15px;
      padding: 0 10px;
   }
   
   .game-card {
      padding: 20px;
      min-height: 120px;
   }

   #boardWrapper{
    max-width: 100dvw;
    max-height: 100dvw;
   }
}

