/* Import Google font */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
  user-select: none;
}
body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #0f172a;
  color: #fff;
}
.wrapper {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 12px;
  background: #1e293b;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  padding: 20px;
  margin: 20px;
  position: relative;
}
.game-details {
  color: #cbd5e1;
  font-weight: 600;
  font-size: 1.2rem;
  padding: 10px 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.game-details i {
  color: #fbbf24;
  margin-right: 5px;
}
.score, .high-score {
  display: flex;
  align-items: center;
  background: #334155;
  padding: 5px 15px;
  border-radius: 8px;
}
.action-btn {
  background: #3b82f6;
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: transform 0.1s ease;
}
.action-btn:active {
  transform: scale(0.9);
}
.play-board {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  background: #0f172a;
  border-radius: 8px;
  border: 4px solid #334155;
  grid-template: repeat(30, 1fr) / repeat(30, 1fr);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}
.play-board .food {
  background: #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 10px #ef4444;
}
.play-board .head {
  background: linear-gradient(145deg, #10b981, #059669);
  border-radius: 6px;
  transform: scale(0.9);
  box-shadow: 0 0 5px rgba(16,185,129,0.5);
}
.play-board .head:first-child {
  background: linear-gradient(145deg, #34d399, #10b981); /* lighter color for actual head */
  border-radius: 10px;
  transform: scale(1);
  box-shadow: 0 0 10px rgba(52,211,153,0.8);
  z-index: 2;
}

/* Custom Game Over Overlay */
.game-over-overlay {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.85);
  border-radius: 12px;
  backdrop-filter: blur(4px);
  z-index: 10;
}
.game-over-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #1e293b;
  border: 2px solid #334155;
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
  width: 80%;
  max-width: 350px;
}
.game-over-content h2 {
  font-size: 2.2rem;
  color: #ef4444;
  margin-bottom: 20px;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}
.game-over-content p {
  font-size: 1.3rem;
  margin-bottom: 30px;
  color: #e2e8f0;
}
.game-over-content #finalScore {
  color: #fbbf24;
  font-weight: bold;
  font-size: 1.5rem;
}
.game-over-content button {
  padding: 12px 30px;
  font-size: 1.2rem;
  background: #10b981;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}
.game-over-content button:hover {
  background: #059669;
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
}

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 30px;
}

.d-pad {
  display: grid;
  grid-template-columns: 60px 60px 60px;
  grid-template-rows: 60px 60px 60px;
  gap: 10px;
}

.d-pad button {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #334155;
  border: none;
  border-radius: 12px;
  color: #cbd5e1;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 5px 0 #1e293b, 0 8px 10px rgba(0,0,0,0.3);
  transition: all 0.1s ease;
  outline: none;
}

.d-pad button:active {
  box-shadow: 0 2px 0 #1e293b, 0 3px 5px rgba(0,0,0,0.3);
  transform: translateY(3px);
  background: #475569;
  color: #fff;
}

.d-pad .up { grid-column: 2; grid-row: 1; }
.d-pad .left { grid-column: 1; grid-row: 2; border-radius: 12px 6px 6px 12px; }
.d-pad .right { grid-column: 3; grid-row: 2; border-radius: 6px 12px 12px 6px; }
.d-pad .down { grid-column: 2; grid-row: 3; }

@media screen and (min-width: 800px) {
  /* On larger screens make the board larger */
  .wrapper {
    max-width: 600px;
  }
  /* Optional: we can hide controls on PC if we want, but showing them is fine */
}
@media screen and (max-height: 800px) {
  .wrapper {
    max-width: 400px;
  }
  .d-pad {
    grid-template-columns: 50px 50px 50px;
    grid-template-rows: 50px 50px 50px;
    gap: 8px;
  }
  .d-pad button {
    font-size: 1.2rem;
  }
}
