@import url("https://fonts.googleapis.com/css2?family=Great+Vibes&display=swap");
* {
  box-sizing: border-box;
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 10px;
  background: radial-gradient(circle at center, #1b1b1b, #121212);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: white;
  overflow-y: auto;
}

.game-container {
  position: relative;
  width: 100%;
  max-width: 1100px;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #222;
  border-radius: 15px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
  border: 1px solid #444;
  overflow: hidden;
}

.message-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(30, 30, 30, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

.turn-message {
  text-align: center;
  padding: 12px 0 0 0;
  font-size: 24px;
  font-weight: 700;
  color: #8bc34a;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 0;
}

.game-message {
  text-align: center;
  padding: 8px 0 12px 0;
  font-size: 20px;
  font-weight: bold;
  color: #ffc107;
  text-shadow: 0 0 10px rgba(255, 193, 7, 0.3);
  letter-spacing: 1px;
  margin: 0;
}

.score-container {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 15px;
}

.score {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 15px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}

#player1Score {
  color: #4caf50;
}

#player2Score {
  color: #f44336;
}

.balls-container {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 5px 15px 10px 15px;
}

.player-balls {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 10px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 12px;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-container {
  flex-grow: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  touch-action: none;
}

canvas {
  border: none;
  background: #0a4d25;
  box-shadow:
    inset 0 0 0 10px #5d4037,
    0 0 25px rgba(0, 0, 0, 0.9);
  border-radius: 12px;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.instructions-container,
.reset-container {
  width: 100%;
  background: rgba(30, 30, 30, 0.9);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 0;
  text-align: center;
}

.instructions {
  font-size: 16px;
  color: #aaa;
  text-shadow: 0 0 5px black;
  letter-spacing: 0.5px;
  padding: 0 10px;
}

.reset-btn {
  margin: 0 auto;
  padding: 12px 30px;
  font-size: 16px;
  background: linear-gradient(135deg, #5d4037, #8d6e63);
  color: white;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: bold;
}

.reset-btn:hover {
  background: linear-gradient(135deg, #8d6e63, #a1887f);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.menu-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #1a1a1a, #000000);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 1.2s ease;
}

.menu-title {
  color: #f7ff04;
  font-size: 64px;
  font-family: "Great Vibes", cursive;
  margin-bottom: 50px;
  text-shadow: 3px 3px 12px #000;
  text-align: center;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.menu-btn {
  padding: 18px 50px;
  font-size: 24px;
  font-weight: bold;
  border: none;
  border-radius: 40px;
  cursor: pointer;
  background: linear-gradient(135deg, #4caf50, #2e7d32);
  color: white;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.menu-btn:hover {
  background: linear-gradient(135deg, #66bb6a, #388e3c);
  transform: scale(1.07);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile-specific styles */

@media (max-width: 768px) {
  body {
    padding: 0;
    margin: 0;
    height: auto;
    overflow-y: auto;
    align-items: flex-start;
  }
  .game-container {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
    max-height: none;
  }
  .turn-message {
    font-size: 18px;
    padding-top: 10px;
  }
  .game-message {
    font-size: 16px;
  }
  .score-container,
  .balls-container {
    flex-direction: column;
    gap: 8px;
    align-items: center;
  }
  .score,
  .player-balls {
    font-size: 14px;
    width: 90%;
    max-width: 90%;
    text-align: center;
  }
  .instructions {
    font-size: 14px;
    padding: 8px;
  }
  .reset-btn {
    font-size: 14px;
    padding: 10px 20px;
  }
  canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 11 / 6;
    display: block;
  }
}

@media (max-height: 700px) {
  .game-container {
    max-height: 100vh;
  }
  .turn-message,
  .game-message {
    font-size: 16px;
  }
}

@media (max-height: 800px), (max-width: 1200px) {
  body {
    align-items: flex-start;
    overflow-y: auto;
  }
  .game-container {
    max-height: none;
  }
  canvas {
    height: auto;
    aspect-ratio: 11 / 6;
  }
}

@media (min-width: 769px) and (max-width: 1199px) {
  .game-container {
    max-height: none;
    height: auto;
  }
  canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 11 / 6;
  }
  .reset-container {
    padding-bottom: 20px;
  }
}

html,
body {
  overflow-x: hidden;
}

/* Αποτρέπει προσωρινά την εμφάνιση περιεχομένου πριν φορτώσει πλήρως */

body.preload #mainMenu,
body.preload .game-container {
  display: none !important;
}
