#main-container {
  margin-top: 20px !important;
}

.snake-container {
  display: flex;
  width: 100%;
  height: 100%;
  flex-flow: column wrap;
  justify-content: center;
}

.snake-wrapper {
  display: flex;
  flex-flow: row wrap;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
}

#gameCanvas {
  background-color: #F5F5F5 !important;
  background-image:
    linear-gradient(90deg, #E0E0E0 1px, transparent 1px),
    linear-gradient(#E0E0E0 1px, transparent 1px) !important;
  background-size: 22px 22px;
  border-radius: 10px !important;
}

#ui {
  display: flex;
  align-items: center;
  font-size: 10px;
  flex-flow: column;
  margin-left: 10px;
}

#scoreboard {
  display: flex;
  justify-content: space-between;
  border-radius: 5px;
  margin-bottom: 20px;
  align-items: center;
}

.score,
.high-score {
  background-color: #19A4EF;
  color: #fff !important;
  text-align: center;
  width: 130px;
  border-radius: 5px;
  font-size: 1.2rem;
  font-weight: bold;
}

.high-score { background-color: #0A2B50; }

.score h2,
.high-score h2 {
  color: #fff !important;
  margin: 10px auto 10px;
  letter-spacing: 1.2px;
}

#game-container {
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6),
              inset 0 0 12px rgba(255, 255, 255, 0.05);
  padding: 13px;
}

#replay {
  margin: 15px auto 0;
  padding: 10px 25px;
  border: none;
  border-radius: 25px;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  font-size: 16px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: inline-block;
  width: auto;
}

#replay:hover { transform: translateY(-2px); }

#gameOverOverlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 99999999;
}

#gameOverOverlay .popup {
  background: #FFF;
  padding: 40px 30px;
  border-radius: 15px;
  text-align: center;
  color: #fff;
  box-shadow: 0 0 25px rgba(0,0,0,0.9);
  display: block;
}

#gameOverOverlay .popup h1 {
  color: #19A4EF;
  margin-bottom: 20px;
  font-size: 45px;
}

#popupRestart {
  margin-top: 15px;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  background: #0A2B50;
  color: #fff;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}
#replay:focus-visible{
  outline: none !important;
}

/* --- responsive (unchanged) --- */
@media screen and (max-width: 992px) {
  .scorebox { flex-direction: row; justify-content: space-between; width: 100%; }
  .score, .high-score { font-size: 1.2rem; }
  .hero-section h2{ width: 60% !important; }
}
@media screen and (max-width: 768px) {
  .score, .high-score { font-size: 1.2rem; width: 110px; }
  #gameCanvas { height: 400px; }
  #scoreboard h2 { font-size: 18px; }
}
@media (max-width: 600px) {
  #replay { font-size: 14px; padding: 10px 40px; }
  #replay, h2 { transform: rotate(0deg); }
  #ui { flex-flow: row wrap; margin-bottom: 20px; }
  #score { margin-top: 0; transform: rotate(0deg); }
  .snake-container { flex-flow: column wrap; }
}
@media (max-width: 580px) {
  #gameCanvas { width: 100% !important; height: auto !important; max-width: 450px; }
  .snake-container { padding: 0 10px; }
}
@media (max-width: 350px) {
  #gameCanvas { width: 100% !important; height: 240px !important; max-width: 300px; }
  #scoreboard h2 { font-size: 16px; }
  #replay { font-size: 13px; }
}
@media (max-width: 320px) {
  #gameCanvas { width: 280px !important; height: 220px !important; }
  #scoreboard { display: flex; justify-content: space-between; font-size: 14px; }
  #replay { font-size: 12px; }
}
