/* Üldised stiilid */
body {
  font-family: Arial, sans-serif;
  background-color: #f0f0f0;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  flex-direction: column;
}

h1 {
  text-align: center;
  margin-bottom: 10px;
  font-size: 1.5em;
  margin-top: 0;
}

/* Mängu konteiner */
#game-container {
  max-width: 500px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
}

/* Mängulaud */
#game-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin-bottom: 20px;
}

.cell {
  width: 100%;
  padding-top: 100%;
  position: relative;
  border: 2px solid #ccc;
  background-color: white;
}

.cell span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2em;
  font-weight: bold;
}

.cell.correct {
  background-color: #6aaa64;
  border-color: #6aaa64;
  color: white;
}

.cell.present {
  background-color: #c9b458;
  border-color: #c9b458;
  color: white;
}

.cell.absent {
  background-color: #787c7e;
  border-color: #787c7e;
  color: white;
}

/* Klaviatuur */
#keyboard {
  width: 100%;
  margin-top: 20px;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  margin-bottom: 5px;
}

.key {
  flex: 1;
  margin: 2px;
  padding: 10px 0;
  border: none;
  font-size: 1em;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.1s ease, box-shadow 0.3s ease;
  border-radius: 5px;
  text-align: center;
  background-color: #eee;
  box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.2);
}

.key:active {
  box-shadow: inset 3px 3px 5px rgba(0, 0, 0, 0.2);
}

.key:hover {
  transform: scale(1.05);
  box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.3);
}

.key.large {
  flex: 1.5;
}

/* Värvid funktsiooninupudele */
#enter {
  background-color: #6aaa64;
  color: white;
  font-weight: bold;
}

#delete {
  background-color: #c9b458;
  color: white;
  font-weight: bold;
}

#new-game-btn {
  background-color: #d9534f;
  color: white;
  font-weight: bold;
}

/* Klaviatuuri tähed */
.key.correct {
  background-color: #6aaa64;
  color: white;
}

.key.present {
  background-color: #c9b458;
  color: white;
}

.key.absent {
  background-color: #787c7e;
  color: white;
}

/* Ruutude stiil valesõna korral */
.cell.invalid {
  background-color: #d9534f;
  border-color: #d9534f;
  color: white;
}

/* Värisemisefekt */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  20%, 60% {
    transform: translateX(-10px);
  }
  40%, 80% {
    transform: translateX(10px);
  }
}

.cell.shake {
  animation: shake 0.5s;
}

/* Modaalakna stiilid */

/* Üldised modaalakna stiilid */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.7);
}

.modal-content {
  background-color: #fefefe;
  margin: 10% auto;
  padding: 30px 40px;
  border: 1px solid #888;
  width: 80%;
  max-width: 500px;
  border-radius: 10px;
  position: relative;
  animation: fadeIn 0.5s;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  text-align: center;
}

.close {
  position: absolute;
  top: 15px;
  right: 20px;
  color: #aaaaaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover,
.close:focus {
  color: #000000;
  text-decoration: none;
}

@keyframes fadeIn {
  from {opacity: 0;}
  to {opacity: 1;}
}

/* Mängu lõpu modaalaken */
.game-over-content h2 {
  margin-top: 0;
  font-size: 2em;
  color: #333;
}

.game-over-content p {
  margin: 15px 0;
  font-size: 1.2em;
  line-height: 1.5;
  color: #333;
}

.game-over-content strong {
  color: #6aaa64;
}

.game-over-content hr {
  border: none;
  border-top: 1px solid #ccc;
  margin: 20px 0;
}

#modal-new-game-btn {
  margin-top: 20px;
  padding: 10px 20px;
  font-size: 1em;
  background-color: #6aaa64;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

#modal-new-game-btn:hover {
  background-color: #5a9955;
}

/* Õpetuse modaalaken */
.instructions-content h2 {
  text-align: center;
  margin-bottom: 20px;
}

.instructions-content p {
  text-align: center;
  font-size: 1.1em;
  margin-bottom: 20px;
}

.instructions-list {
  list-style: none;
  padding: 0;
}

.instructions-list li {
  margin-bottom: 15px;
  font-size: 1em;
  line-height: 1.4;
}

.instructions-list li ul {
  margin-top: 10px;
  margin-left: 20px;
  list-style: none;
}

.instructions-content .example {
  display: inline-block;
  width: 25px;
  height: 25px;
  margin-right: 8px;
  border-radius: 4px;
  vertical-align: middle;
}

.instructions-content .example.correct {
  background-color: #6aaa64;
}

.instructions-content .example.present {
  background-color: #c9b458;
}

.instructions-content .example.absent {
  background-color: #787c7e;
}

/* Nupp modaalakna avamiseks */
#open-instructions {
  margin-top: 20px;
  padding: 10px 20px;
  font-size: 1em;
  background-color: #00796b;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#open-instructions:hover {
  background-color: #00695c;
}

/* Tume teema */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #121212;
    color: #e0e0e0;
  }
  h1 {
    color: #ffffff;
  }
  #game-container {
    background-color: #1e1e1e;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    padding: 20px;
    box-sizing: border-box;
  }
  .cell {
    border: 2px solid #3a3a3a;
    background-color: #2b2b2b;
  }
  .cell.correct {
    background-color: #6aaa64;
    border-color: #6aaa64;
  }
  .cell.present {
    background-color: #c9b458;
    border-color: #c9b458;
  }
  .cell.absent {
    background-color: #787c7e;
    border-color: #787c7e;
  }
  .key {
    background-color: #3a3a3a;
    color: #e0e0e0;
    box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.5);
  }
  .key:active {
    box-shadow: inset 3px 3px 5px rgba(0, 0, 0, 0.5);
  }
  .key:hover {
    background-color: #4a4a4a;
    transform: scale(1.05);
    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.7);
  }
  #enter {
    background-color: #6aaa64;
  }
  #delete {
    background-color: #c9b458;
  }
  #new-game-btn {
    background-color: #d9534f;
  }
  .key.correct {
    background-color: #6aaa64;
  }
  .key.present {
    background-color: #c9b458;
  }
  .key.absent {
    background-color: #787c7e;
    color: white;
  }
  .modal-content {
    background-color: #2b2b2b;
    color: #e0e0e0;
  }
  .modal-content h2 {
    color: #e0e0e0;
  }
  .modal-content p {
    color: #e0e0e0;
  }
  .close {
    color: #cccccc;
  }
  .close:hover,
  .close:focus {
    color: #ffffff;
  }
  .instructions-content {
    background: #2b2b2b;
  }
  .game-over-content strong {
    color: #6aaa64;
  }
}
