* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  min-height: 100vh;
  background: var(
    --body-background-color,
    linear-gradient(135deg, #667eea 0%, #764ba2 100%)
  );
  font-family: "Rajdhani", "Orbitron", "Arial", sans-serif;
}

/* Rotate Device Message */
.rotate-message {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(
    --body-background-color,
    linear-gradient(135deg, #667eea 0%, #764ba2 100%)
  );
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  text-align: center;
  animation: fadeIn 0.3s ease-in;
}

.rotate-message.show {
  display: flex;
}

.rotate-icon {
  font-size: 4rem;
  animation: rotateAnimation 2s ease-in-out infinite;
  margin-bottom: 20px;
}

.rotate-message h2 {
  color: var(--text-color, white);
  font-size: 2rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  font-family: "Orbitron", "Rajdhani", sans-serif;
  font-weight: 700;
  letter-spacing: 2px;
}

.rotate-message p {
  color: var(--text-color, white);
  font-size: 1.2rem;
  opacity: 0.9;
  font-family: "Rajdhani", "Orbitron", sans-serif;
  font-weight: 500;
}

@keyframes rotateAnimation {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(90deg);
  }
}

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

/* Show rotate message only in landscape on mobile */
@media (max-width: 768px) and (orientation: landscape),
  (max-width: 1024px) and (max-height: 600px) and (orientation: landscape) {
  .rotate-message {
    display: flex !important;
  }

  .modal-backdrop,
  #game-screen,
  .screen:not(.rotate-message) {
    display: none !important;
  }
}

.screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
}

.screen.hidden {
  display: none;
}

/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--modal-backdrop-color, rgba(0, 0, 0, 0.7));
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-backdrop.hidden {
  display: none;
}

/* Modal Popup */
.modal-popup {
  background: linear-gradient(
    135deg,
    var(--primary-color, #667eea) 0%,
    var(--secondary-color, #764ba2) 100%
  );
  border-radius: 20px;
  padding: 40px 50px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: modalSlideIn 0.3s ease-out;
}

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

h1 {
  color: var(--title-color, white);
  margin-bottom: 20px;
  font-size: 3rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  font-family: "Orbitron", "Rajdhani", sans-serif;
  font-weight: 700;
  letter-spacing: 2px;
}

#statistics-container {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--stat-card-background-color, rgba(255, 255, 255, 0.1));
  border: 1.5px solid var(--stat-card-border-color, white);
  border-radius: 8px;
  padding: 12px 18px;
  text-align: center;
  flex: 1;
  max-width: 120px;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  backdrop-filter: blur(10px);
}

.stat-label {
  color: var(--stat-label-color, white);
  font-size: 0.7rem;
  font-weight: bold;
  margin-bottom: 4px;
  opacity: 0.9;
  font-family: "Rajdhani", "Orbitron", sans-serif;
  font-weight: 600;
}

.stat-value {
  color: var(--stat-value-color, white);
  font-size: 1.3rem;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  font-family: "Orbitron", "Rajdhani", sans-serif;
  font-weight: 700;
}

.mode-selection {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.mode-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.mode-controls > * {
  flex-shrink: 0;
}

.mode-selection label {
  color: var(--text-color, white);
  font-size: 1.2rem;
  font-weight: bold;
  white-space: nowrap;
  font-family: "Rajdhani", "Orbitron", sans-serif;
  font-weight: 600;
}

.mode-selection select {
  padding: 10px 20px;
  font-size: 1.1rem;
  border-radius: 8px;
  border: 2px solid var(--light-color, white);
  background: var(--light-color, white);
  color: var(--button-text-color, #333);
  cursor: pointer;
  min-width: 200px;
  font-family: "Rajdhani", "Orbitron", sans-serif;
  font-weight: 500;
}

.mode-selection select:hover {
  background: #f0f0f0;
}

#start-btn,
#restart-btn {
  padding: 15px 40px;
  font-size: 1.2rem;
  font-weight: bold;
  border: none;
  border-radius: 10px;
  background: linear-gradient(
    135deg,
    var(--button-background-color, #ffd700) 0%,
    var(--accent-color, #ffc107) 100%
  );
  color: var(--button-text-color, #333);
  cursor: pointer;
  box-shadow: 0 4px 15px var(--drop-shadow-color, rgba(0, 0, 0, 0.3));
  transition: transform 0.2s, box-shadow 0.2s;
  font-family: "Rajdhani", "Orbitron", sans-serif;
  font-weight: 600;
  letter-spacing: 1px;
}

#start-btn:hover,
#restart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

#start-btn:active,
#restart-btn:active {
  transform: translateY(0);
}

#game-screen h1 {
  font-size: 2rem;
  margin-bottom: 5px;
}

#game-over-screen {
  gap: 30px;
}

#game-over-message {
  color: var(--text-color, white);
  font-size: 1.5rem;
  font-weight: bold;
  text-align: center;
  font-family: "Orbitron", "Rajdhani", sans-serif;
  font-weight: 700;
  letter-spacing: 1px;
}

#game-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

#game-info {
  text-align: center;
  margin-bottom: 10px;
  color: var(--text-color, white);
  font-family: "Rajdhani", "Orbitron", sans-serif;
}

#current-player {
  font-size: 1rem;
  font-weight: bold;
  margin-bottom: 10px;
  font-family: "Rajdhani", "Orbitron", sans-serif;
  font-weight: 600;
}

#status-message {
  font-size: 0.9rem;
  min-height: 25px;
  font-family: "Rajdhani", "Orbitron", sans-serif;
}

#game-board-wrapper {
  background: var(--board-background-color, #1e88e5);
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 8px 20px var(--drop-shadow-color, rgba(0, 0, 0, 0.3));
  position: relative;
}

#game-board {
  display: grid;
  grid-template-columns: repeat(7, 75px);
  grid-template-rows: repeat(6, 75px);
  gap: 8px;
  background: var(--board-border-color, #1565c0);
  padding: 8px;
  border-radius: 10px;
}

.cell {
  width: 75px;
  height: 75px;
  background: var(--cell-background-color, white);
  border-radius: 50%;
  border: 3px solid var(--cell-border-color, #0d47a1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  position: relative;
  box-shadow: inset 0 3px 6px var(--drop-shadow-color, rgba(0, 0, 0, 0.2));
  transition: background-color 0.2s ease;
}

.cell:hover {
  background: #e3f2fd;
  cursor: not-allowed;
}

.cell.red {
  background: var(--player1-color, #e53935);
}

.cell.green {
  background: var(--player2-color, #4caf50);
}

.cell.dropping {
  animation: dropWithGravity 0.6s cubic-bezier(0.5, 0, 0.3, 1);
}

.cell.shake {
  animation: shake 0.3s ease-in-out;
}

.cell.red.winner {
  background: linear-gradient(
    135deg,
    var(--player1-color, #ff6b6b) 0%,
    var(--winning-glow-color, #ffd700) 100%
  );
  box-shadow: inset 0 3px 6px var(--drop-shadow-color, rgba(0, 0, 0, 0.2)),
    0 0 20px rgba(255, 215, 0, 0.9), 0 0 40px rgba(255, 215, 0, 0.7),
    0 0 60px rgba(255, 215, 0, 0.5);
  animation: goldenBlink 0.6s ease-in-out infinite;
  border-color: var(--accent-color, #ffc107);
}

.cell.green.winner {
  background: linear-gradient(
    135deg,
    var(--player2-color, #6bcf7f) 0%,
    var(--winning-glow-color, #ffd700) 100%
  );
  box-shadow: inset 0 3px 6px var(--drop-shadow-color, rgba(0, 0, 0, 0.2)),
    0 0 20px rgba(255, 215, 0, 0.9), 0 0 40px rgba(255, 215, 0, 0.7),
    0 0 60px rgba(255, 215, 0, 0.5);
  animation: goldenBlink 0.6s ease-in-out infinite;
  border-color: var(--accent-color, #ffc107);
}

@keyframes dropWithGravity {
  0% {
    transform: translateY(-400px);
    opacity: 0;
  }
  60% {
    transform: translateY(5px);
    opacity: 1;
  }
  70% {
    transform: translateY(-3px);
  }
  80% {
    transform: translateY(2px);
  }
  90% {
    transform: translateY(-1px);
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  10% {
    transform: translateX(-2px);
  }
  20% {
    transform: translateX(2px);
  }
  30% {
    transform: translateX(-2px);
  }
  40% {
    transform: translateX(2px);
  }
  50% {
    transform: translateX(-1px);
  }
  60% {
    transform: translateX(1px);
  }
  70% {
    transform: translateX(-1px);
  }
  80% {
    transform: translateX(1px);
  }
  90% {
    transform: translateX(-0.5px);
  }
  100% {
    transform: translateX(0);
  }
}

#column-indicators {
  display: grid;
  grid-template-columns: repeat(7, 75px);
  gap: 8px;
  padding: 0 8px;
  margin-bottom: 6px;
}

.column-indicator {
  width: 75px;
  height: 75px;
  background: var(--indicator-background-color, white);
  border-radius: 50%;
  border: 3px solid var(--indicator-border-color, #ffc107);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 3px 6px var(--drop-shadow-color, rgba(0, 0, 0, 0.2));
  transition: all 0.2s ease;
  color: var(--indicator-text-color, #ffc107);
  font-weight: bold;
  font-size: 1.8rem;
  font-family: "Rajdhani", "Orbitron", sans-serif;
  font-weight: 700;
}

.column-indicator:hover {
  background: #fff9c4;
  transform: scale(1.1);
  box-shadow: inset 0 3px 6px var(--drop-shadow-color, rgba(0, 0, 0, 0.2)),
    0 0 15px rgba(255, 193, 7, 0.5);
}

@keyframes goldenBlink {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  h1 {
    font-size: 2rem;
  }

  #game-screen h1 {
    font-size: 1.5rem;
  }

  .modal-popup {
    padding: 30px 25px;
    max-width: 95%;
  }

  .mode-controls {
    flex-direction: column;
    gap: 15px;
  }

  #statistics-container {
    gap: 10px;
    margin-bottom: 15px;
  }

  .stat-card {
    padding: 10px 15px;
    min-width: 80px;
    max-width: 110px;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  #game-board {
    grid-template-columns: repeat(7, 45px);
    grid-template-rows: repeat(6, 45px);
    gap: 4px;
    padding: 4px;
  }

  #column-indicators {
    grid-template-columns: repeat(7, 45px);
    gap: 4px;
    padding: 0 4px;
    margin-bottom: 4px;
  }

  .cell,
  .column-indicator {
    width: 45px;
    height: 45px;
  }

  .column-indicator {
    font-size: 1.2rem;
  }

  .cell {
    border: 2px solid #0d47a1;
  }
}

@media (max-width: 480px) {
  .modal-popup {
    padding: 20px 15px;
    border-radius: 15px;
  }

  h1 {
    font-size: 1.5rem;
  }

  #game-screen h1 {
    font-size: 1.2rem;
  }

  #game-board {
    grid-template-columns: repeat(7, 40px);
    grid-template-rows: repeat(6, 40px);
    gap: 3px;
    padding: 3px;
  }

  #column-indicators {
    grid-template-columns: repeat(7, 40px);
    gap: 3px;
    padding: 0 3px;
    margin-bottom: 3px;
  }

  .cell,
  .column-indicator {
    width: 40px;
    height: 40px;
  }

  .column-indicator {
    font-size: 1rem;
  }

  .cell {
    border: 2px solid #0d47a1;
  }

  #game-board-wrapper {
    padding: 8px;
  }
}

@media (max-height: 600px) {
  #game-screen h1 {
    font-size: 1.2rem;
    margin-bottom: 2px;
  }

  #current-player {
    font-size: 0.8rem;
    margin-bottom: 5px;
  }

  #status-message {
    font-size: 0.7rem;
    min-height: 20px;
  }

  #game-board-wrapper {
    padding: 8px;
  }

  #game-board {
    grid-template-columns: repeat(7, 50px);
    grid-template-rows: repeat(6, 50px);
    gap: 5px;
    padding: 5px;
  }

  #column-indicators {
    grid-template-columns: repeat(7, 50px);
    gap: 5px;
    padding: 0 5px;
    margin-bottom: 5px;
  }

  .cell,
  .column-indicator {
    width: 50px;
    height: 50px;
  }

  .column-indicator {
    font-size: 1.3rem;
  }
}
