/* Tetris Game Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  background-color: #141414;
  font-family: "IBM Plex Mono", monospace;
  padding: 10px;
  overflow: hidden;
  position: relative;
}

/* Static Grid Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 50px 50px;
  z-index: -1;
  pointer-events: none;
}

.game-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}

.main-game {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.game-info {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
  color: white;
  font-size: 16px;
  font-family: "IBM Plex Mono", monospace;
  flex-wrap: wrap;
  justify-content: center;
}

canvas {
  border: 1px solid white;
  background-color: #141414;
  max-width: 100%;
  height: auto;
}

#tetrisCanvas {
  width: 300px;
  height: 600px;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.preview-box,
.hold-box,
.combo-box {
  border: none;
  background-color: #141414;
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

.preview-title,
.hold-title {
  color: white;
  font-size: 16px;
  font-family: "IBM Plex Mono", monospace;
  margin-bottom: 10px;
}

.combo-display,
.level-display {
  color: white;
  font-size: 16px;
  font-family: "IBM Plex Mono", monospace;
  text-align: left;
  margin-bottom: 5px;
}

.score-previews {
  margin-top: 10px;
  width: 100%;
}

.score-previews .preview-title {
  color: white;
  font-size: 16px;
  font-family: "IBM Plex Mono", monospace;
  margin-bottom: 3px;
}

.score-preview {
  color: darkgray;
  font-size: 10px;
  font-family: "IBM Plex Mono", monospace;
  text-align: left;
  margin-bottom: 3px;
}

.time-preview {
  color: darkgray;
}

.preview-canvas,
.hold-canvas {
  background-color: #141414;
}

.highscore-panel {
  color: white;
  width: 200px;
  display: flex;
  flex-direction: column;
}

.highscore-title {
  font-size: 16px;
  font-family: "IBM Plex Mono", monospace;
  margin-bottom: 10px;
}

.highscore-list {
  font-size: 10px;
  font-family: "IBM Plex Mono", monospace;
  overflow-y: auto;
  border: 1px solid white;
  padding: 5px 10px 5px 10px;
  background-color: #141414;
  width: 100%;
  height: 599px;
  margin-bottom: 20px;
}

.highscore-entry {
  display: flex;
  flex-direction: column;
  padding: 11px 6px;
  border-bottom: 1px solid white;
}

.highscore-entry:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.highscore-entry.current {
  font-family: "IBM Plex Mono", monospace;
  background-color: #141414;
  border-left: 1px solid white;
}

.score-main {
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.rank {
  font-family: "IBM Plex Mono", monospace;
  min-width: 20px;
}

.score {
  font-family: "IBM Plex Mono", monospace;
  flex-grow: 1;
  text-align: right;
}

.lines {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  background-color: white;
  padding: 1px 4px;
}

.score-details {
  display: flex;
  justify-content: space-between;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  color: darkgray;
}

.player-name {
  font-family: "IBM Plex Mono", monospace;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.date-time {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
}

#gameControls {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

#restartButton {
  padding: 10px 20px;
  font-size: 16px;
  font-family: "IBM Plex Mono", monospace;
  background-color: #141414;
  color: white;
  border: 1px solid white;
  cursor: pointer;
  transition: 0.5s;
  display: none;
  width: 100%;
}

#restartButton:hover {
  background-color: white;
  color: #141414;
}

.back-button {
  padding: 10px 20px;
  font-size: 16px;
  font-family: "IBM Plex Mono", monospace;
  background-color: #141414;
  color: white;
  border: 1px solid white;
  text-decoration: none;
  transition: 0.5s;
  display: inline-block;
  text-align: center;
  width: 100%;
}

.back-button:hover {
  background-color: white;
  color: #141414;
}

.controls-info {
  color: white;
  font-size: 10px;
  font-family: "IBM Plex Mono", monospace;
  text-align: center;
  margin-top: 10px;
  max-width: 500px;
}

/* Achievement Animations */
.achievement {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  color: #141414;
  padding: 15px 30px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 16px;
  z-index: 1000;
  box-shadow: 0 5px 15px rgba(255, 255, 255, 0.5);
  animation: slideInBounce 0.5s ease-out;
}

.achievement.fadeOut {
  animation: slideOutBounce 0.5s ease-in;
}

@keyframes slideInBounce {
  0% {
    transform: translateX(-50%) translateY(-100px);
    opacity: 0;
  }
  60% {
    transform: translateX(-50%) translateY(10px);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@keyframes slideOutBounce {
  0% {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
  40% {
    transform: translateX(-50%) translateY(-10px);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) translateY(-100px);
    opacity: 0;
  }
}

/* Modal Styles */
.modal {
  display: none !important;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
}

.modal.show {
  display: flex !important;
  justify-content: center;
  align-items: center;
  animation: modalFadeIn 0.3s ease-out;
}

.modal-content {
  background-color: #141414;
  border: 1px solid white;
  padding: 25px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8);
  text-align: center;
  color: white;
  min-width: 300px;
  max-width: 90vw;
  animation: modalSlideIn 0.3s ease-out;
}

.modal-content h2 {
  margin: 0 0 15px 0;
  font-size: 16px;
  font-family: "IBM Plex Mono", monospace;
  color: white;
}

.modal-content p {
  margin: 10px 0;
  font-size: 16px;
  font-family: "IBM Plex Mono", monospace;
  color: white;
}

.modal-content input {
  width: 100%;
  padding: 12px;
  margin: 15px 0;
  border: 1px solid white;
  font-family: "IBM Plex Mono", monospace;
  font-size: 16px;
  text-align: center;
  background-color: #141414;
  color: white;
}

.modal-content input:focus {
  outline: none;
  border-color: white;
  background-color: #141414;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

.btn-primary,
.btn-secondary {
  padding: 10px 20px;
  border: 1px solid white;
  font-size: 16px;
  font-family: "IBM Plex Mono", monospace;
  cursor: pointer;
  transition: 0.5s;
  background-color: #141414;
  color: white;
}

.btn-primary:hover,
.btn-secondary:hover {
  background-color: white;
  color: #141414;
}

.btn-primary:active,
.btn-secondary:active {
  transform: translateY(0);
}

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

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

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .game-layout {
    flex-direction: column;
    align-items: center;
  }

  .side-panel {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    min-width: auto;
  }

  .highscore-panel {
    order: -1;
    max-width: 250px;
    min-width: 200px;
  }
}
