:root {
  --primary: #6200ee;
  --primary-dark: #3700b3;
  --secondary: #03dac6;
  --background: #121212;
  --surface: #1e1e1e;
  --error: #cf6679;
  --on-primary: #ffffff;
  --on-background: #ffffff;
  --on-surface: #ffffff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: var(--background);
  color: var(--on-background);
  line-height: 1.6;
}

header {
  background-color: var(--primary);
  color: var(--on-primary);
  padding: 1rem;
  text-align: center;
}

nav {
  background-color: var(--primary-dark);
  display: flex;
  justify-content: center;
  padding: 0.5rem;
}

nav a {
  color: var(--on-primary);
  text-decoration: none;
  padding: 0.5rem 1rem;
  margin: 0 0.5rem;
  border-radius: 4px;
  transition: background-color 0.3s;
}

nav a:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.section-title {
  margin-bottom: 2rem;
  text-align: center;
  color: var(--secondary);
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
}

.game-card {
  background-color: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.game-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.game-image {
  width: 100%;
  height: 200px;
  background-color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-primary);
  font-size: 3rem;
}

.game-content {
  padding: 1.5rem;
}

.game-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--secondary);
}

.game-description {
  margin-bottom: 1rem;
  color: rgba(255, 255, 255, 0.8);
}

.play-button {
  display: inline-block;
  background-color: var(--secondary);
  color: #000;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  text-decoration: none;
  font-weight: bold;
  transition: background-color 0.3s;
}

.play-button:hover {
  background-color: #02b3a4;
}

.game-container {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 1000;
}

.game-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  max-width: 800px;
  height: 80vh;
  background-color: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.game-header {
  background-color: var(--primary);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-button {
  background: none;
  border: none;
  color: var(--on-primary);
  font-size: 1.5rem;
  cursor: pointer;
}

.game-area {
  flex: 1;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000;
}

footer {
  background-color: var(--primary-dark);
  color: var(--on-primary);
  text-align: center;
  padding: 1rem;
  margin-top: 2rem;
}

/* Juego específico: Snake */
#snake-game-canvas {
  border: 2px solid var(--secondary);
  background-color: #000;
}

/* Juego específico: Tic Tac Toe */
.tictactoe-board {
  display: grid;
  grid-template-columns: repeat(3, 100px);
  grid-template-rows: repeat(3, 100px);
  gap: 5px;
}

.tictactoe-cell {
  background-color: #f0f0f0;
  border: 2px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
}

.tictactoe-cell.x {
  color: #ff4444; /* Color para el jugador X */
}

.tictactoe-cell.o {
  color: #4444ff; /* Color para el jugador O */
}

/* Juego específico: Tetris */
#tetris-canvas {
  border: 2px solid var(--secondary);
  background-color: #000;
}

/* Juego específico: Breakout */
#breakout-canvas {
  border: 2px solid var(--secondary);
  background-color: #000;
}

/* Juego específico: Hangman */
.hangman-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.hangman-drawing {
  width: 200px;
  height: 250px;
  border: 2px solid var(--secondary);
  margin-bottom: 1rem;
  position: relative;
}

.hangman-word {
  display: flex;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.hangman-letter {
  width: 30px;
  height: 40px;
  border-bottom: 2px solid var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.hangman-keyboard {
  display: grid;
  grid-template-columns: repeat(7, 40px);
  gap: 0.5rem;
  margin-top: 1rem;
}

.hangman-key {
  width: 40px;
  height: 40px;
  background-color: var(--surface);
  border: 1px solid var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
}

.hangman-key:hover {
  background-color: rgba(3, 218, 198, 0.1);
}

.hangman-key.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Juego específico: Memory */
.memory-board {
  display: grid;
  grid-template-columns: repeat(4, 80px);
  grid-template-rows: repeat(4, 80px);
  gap: 10px;
  margin: 0 auto;
}

.memory-card {
  width: 80px;
  height: 80px;
  background-color: var(--primary);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.3s, background-color 0.3s;
  font-size: 2rem;
  color: transparent;
}

.memory-card:hover {
  background-color: var(--primary-dark);
}

.memory-card.flipped {
  transform: rotateY(180deg);
  background-color: var(--secondary);
  color: #000;
}

.memory-card.matched {
  background-color: var(--secondary);
  cursor: default;
  color: #000;
}

/* Estilos para el contenedor del crucigrama */
#crossword-container {
  display: none; /* Oculto por defecto */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #1e1e1e;
  border: 2px solid #ffffff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.game-frame {
  text-align: center;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.game-header h3 {
  font-size: 1.5rem;
  margin: 0;
}

.close-button {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s;
}

.close-button:hover {
  color: #ff0266;
}


/* Juego específico: Buscaminas */
.minesweeper-container {
  text-align: center;
}

.minesweeper-grid {
  display: grid;
  grid-template-columns: repeat(8, 40px);
  grid-template-rows: repeat(8, 40px);
  gap: 2px;
  margin: 20px auto;
  justify-content: center;
}

.minesweeper-cell {
  width: 40px;
  height: 40px;
  background-color: #bdbdbd;
  border: 2px solid #8b8b8b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
}

.minesweeper-cell.revealed {
  background-color: #000000;
  border: 1px solid #8b8b8b;
}

.minesweeper-cell.mine {
  background-color: #ff4444;
}

.minesweeper-cell.flag {
  background-color: #ffcc00;
}

/* Juego específico: Sudoku */
.sudoku-container {
  text-align: center;
}

.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(9, 40px);
  grid-template-rows: repeat(9, 40px);
  gap: 2px;
  margin: 20px auto;
  justify-content: center;
}

.sudoku-cell {
  width: 40px;
  height: 40px;
  background-color: #f0f0f0;
  border: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
}

.sudoku-cell.fixed {
  background-color: #000000;
  cursor: default;
}

.sudoku-cell input {
  width: 100%;
  height: 100%;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  border: none;
  background: none;
}

.sudoku-cell input:focus {
  outline: none;
  background-color: #e0e0e0;
}

.sudoku-controls {
  margin-top: 20px;
}

.sudoku-controls button {
  margin: 5px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}

.sudoku-status {
  margin-top: 20px;
  font-size: 18px;
  font-weight: bold;
}


/* Juego Especifico: Pac-Man */
.pacman-container {
  text-align: center;
}

#pacman-canvas {
  background-color: #000;
  display: block;
  margin: 0 auto;
  border: 2px solid #fff;
}

.pacman-stats {
  margin-top: 10px;
  font-size: 18px;
  color: #fff;
}

.pacman-stats span {
  margin: 0 10px;
}

.tictactoe-reset {
  margin-top: 10px;
  padding: 8px 16px;
  font-size: 16px;
  cursor: pointer;
  background-color: #6200ee;
  color: #fff;
  border: none;
  border-radius: 5px;
}

.tictactoe-reset:hover {
  background-color: #3700b3;
}


/* Responsive design */

@media (max-width: 768px) {
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }

  .game-frame {
    width: 95%;
    height: 90vh;
  }

  .tictactoe-board {
    grid-template-columns: repeat(3, 80px);
    grid-template-rows: repeat(3, 80px);
  }

  .tictactoe-cell {
    width: 80px;
    height: 80px;
  }

  .memory-board {
    grid-template-columns: repeat(4, 60px);
    grid-template-rows: repeat(4, 60px);
  }

  .memory-card {
    width: 60px;
    height: 60px;
  }
}