@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  --background-color: #f0f0f0;
  --game-section-background: #202020;
  --overlay-color: rgba(0, 0, 0, 0.5);
  --game-over-screen-background: rgba(0, 0, 0, 0.8);
  --button-color: #ff6347;
  --button-hover-color: #ff4500;
  --pause-button-color: #008000;
  --pause-button-hover-color: #006400;
  --reset-button-color: #0000ff;
  --reset-button-hover-color: #00008b;
}

* {
  font-family: 'Press Start 2P', cursive;
}

body {
  background-color: var(--background-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  margin: 0;
  padding: 0;
}

/* CSS */
#highScoresModal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 1; /* Sit on top */
  left: 0;
  top: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: rgb(0, 0, 0); /* Fallback color */
  background-color: rgba(0, 0, 0, 0.4); /* Black w/ opacity */
}

/* Modal Content/Box */
#highScoresModal .modal-content {
  background-color: #fefefe;
  margin: 15% auto; /* 15% from the top and centered */
  padding: 20px;
  border: 1px solid #888;
  width: 80%; /* Could be more or less, depending on screen size */
}

/* The Close Button */
#highScoresModal .close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

#highScoresModal .close:hover,
#highScoresModal .close:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

#gameSection {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto;
  align-items: center;
  justify-content: center;
  background-color: var(--game-section-background);
  padding: 2vh;
  border: 2px solid #404040;
  border-radius: 10px;
  max-width: 90vw;
  margin: auto;
}

#gameCanvas {
  grid-row: 1;
  width: 100%;
  height: 60vh;
}

#rightColumn {
  grid-row: 2;
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  align-items: center;
  justify-items: center;
  color: white;
  height: 100%;
}

#rightColumn > div:last-child {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 8vh;
}

#nextPiece {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 60vw;
  height: 60vw;
}

#score {
  font-size: 1em;
}

#gameOverOverlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--overlay-color);
}

#gameOverScreen {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--game-over-screen-background);
  color: white;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  z-index: 1;
}

#buttonContainer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.button {
  font-size: 1.5em;
  padding: 10px 20px;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.startButton {
  background-color: var(--button-color);
}

.startButton:hover {
  background-color: var(--button-hover-color);
}

.pauseButton {
  background-color: var(--pause-button-color);
}

.pauseButton:hover {
  background-color: var(--pause-button-hover-color);
}

.resetButton {
  background-color: var(--reset-button-color);
}

.resetButton:hover {
  background-color: var(--reset-button-hover-color);
}

.speaker-icon {
  width: 1em;
  height: 1em;
  cursor: pointer;
}

@media (min-width: 767px) {
  body {
    overflow: hidden;
  }
  #nextPiece {
    width: 80%;
    height: 80%;
  }
  #gameSection {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: auto;
  }
  #gameCanvas {
    grid-row: 1 / span 2;
    height: 80vh;
  }
  #rightColumn {
    grid-row: 1;
    justify-content: center;
  }
  #score {
    font-size: 1em;
  }
}

@media (max-width: 767px) {
  header {
    font-size: 0.5em; /* Make the text smaller */
  }

  body {
    overflow: auto; /* Allow scrolling on small screens */
  }

  #gameSection {
    grid-template-columns: 1fr; /* Stack the game and the controls vertically */
    grid-template-rows: auto auto;
    font-size: 0.5em; /* Make the text smaller */
  }

  #gameCanvas {
    grid-row: 1; /* Put the game above the controls */
    height: 50vh; /* Adjust as needed */
  }

  #rightColumn {
    grid-row: 2; /* Put the controls below the game */
    height: 35vh; /* Adjust as needed */
  }

  #nextPiece {
    width: 100%; /* Adjust as needed */
    height: 100%; /* Adjust as needed */
    /* font-size: 0.5em; Make the text smaller */
  }

  #nextTetrominoCanvas {
    width: 50%; /* Adjust as needed */
    height: 80%; /* Adjust as needed */
  }

  #score {
    /* font-size: .75em; Make the text smaller */
  }

  #buttonContainer {
    width: 100%; /* Adjust as needed */
  }

  footer {
    font-size: 0.5em; /* Make the text smaller */
  }
}
