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

:root {
  --cell-size: 50px;
  --cell-color: #fbf6ef;
  --cell-selected-bg: #690412;
  --cell-selected-color: #27ae60;
}

body {
  font-family: "Inter", sans-serif;
  /* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

button {
  font-family: "Open Sans", sans-serif;
}

.container {
  background: white;
  border-radius: 20px;
  padding: 10px;

  max-width: 600px;
  width: 100%;
}

h1 {
  text-align: center;
  color: #333;
  margin-bottom: 10px;
  font-size: 1.25rem;
  font-weight: bold;
}

.word-info {
  text-align: center;
  color: #666;
  margin-bottom: 15px;
  font-size: 0.9rem;
  font-weight: 500;
}

.game-info {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  font-size: 1.1rem;
  font-weight: normal;
}

.attempts {
  color: #e74c3c;
}

.score {
  color: #27ae60;
}

.timer {
  color: #333;
  font-weight: normal;
}

.grid-container {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  gap: 2px;
  padding: 10px;
  border-radius: 10px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  min-width: var(--cell-size);
  min-height: var(--cell-size);
  border: none;
  background: var(--cell-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 5px;
  color: #333;
  flex-shrink: 0;
}

.cell:hover {
  background: #f0f0f0;
  transform: scale(1.05);
}

.cell.word-cell {
  background: var(--cell-color);
  border: 2px solid var(--cell-color);
}

.cell.target-word {
  /* background: #e3f2fd;
  border: 2px solid #2196f3; */
}

.cell.selected {
  background: var(--cell-selected-bg);
  color: white;
  transform: scale(1.1);
}

.cell.revealed {
  background: #27ae60;
  color: white;
  animation: reveal 0.5s ease;
}

.cell.revealed.target-word {
  background: #52f195;
}

.cell.correct-swap {
  background: #ace9c6;
  color: white;
  animation: correctSwap 0.5s ease;
}

.cell.incorrect-swap {
  background: #e74c3c;
  color: white;
  animation: incorrectSwap 0.5s ease;
}

@keyframes reveal {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes correctSwap {
  0% {
    transform: scale(1);
    background: #27ae60;
  }
  50% {
    transform: scale(1.2);
    background: #2ecc71;
  }
  100% {
    transform: scale(1);
    background: #27ae60;
  }
}

@keyframes incorrectSwap {
  0% {
    transform: scale(1);
    background: #e74c3c;
  }
  50% {
    transform: scale(1.2);
    background: #c0392b;
  }
  100% {
    transform: scale(1);
    background: #e74c3c;
  }
}

.controls {
  display: flex;
  gap: 15px;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
}

.swap-btn,
.reset-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 120px;
}

.swap-btn {
  background: var(--cell-selected-bg);
  color: white;
}

.swap-btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.swap-btn:disabled {
  background: #bdc3c7;
  cursor: not-allowed;
  transform: none;
}

.reset-btn {
  background: #e74c3c;
  color: white;
}

.reset-btn:hover {
  background: #c0392b;
  transform: translateY(-2px);
}

.help-btn {
  padding: 8px 12px;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #dddddf;
  color: white;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message {
  text-align: center;
  min-height: 30px;
  font-weight: bold;
  font-size: 1.1rem;
}

.message.success {
  color: #27ae60;
}

.message.error {
  color: #e74c3c;
}

@media (max-width: 600px) {
  :root {
    --cell-size: 35px;
  }

  .cell {
    width: var(--cell-size);
    height: var(--cell-size);
    min-width: var(--cell-size);
    min-height: var(--cell-size);
    font-size: 0.8rem;
    position: relative;
  }

  .grid {
    grid-template-columns: repeat(8, var(--cell-size));
    gap: 1px;
    width: fit-content;
    margin: 0 auto;
    padding: 5px;
  }

  .grid-container {
    justify-content: center;
    width: 100%;
  }

  .game-info {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .container {
    padding: 5px;
  }

  h1 {
    font-size: 1.1rem;
  }

  .word-info {
    font-size: 0.8rem;
  }

  .game-info {
    font-size: 0.9rem;
  }

  .swap-btn,
  .reset-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
    min-width: 100px;
  }

  .help-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background-color: white;
  margin: 5% auto;
  padding: 0;
  border-radius: 15px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideIn 0.3s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 1px solid #e9ecef;
  background: #f8f9fa;
  border-radius: 15px 15px 0 0;
}

.modal-header h2 {
  margin: 0;
  color: #333;
  font-size: 1.5rem;
}

.close {
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s ease;
}

.close:hover {
  color: #333;
}

.modal-body {
  padding: 25px;
}

.modal-body h3 {
  color: #333;
  margin: 20px 0 10px 0;
  font-size: 1.2rem;
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body p {
  color: #666;
  line-height: 1.6;
  margin-bottom: 15px;
}

.modal-body ul {
  color: #666;
  line-height: 1.6;
  margin-bottom: 20px;
  padding-left: 20px;
}

.modal-body li {
  margin-bottom: 8px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
