* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Courier New', monospace;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 20px;
  width: 100%;
  max-width: 600px;
}

.score-panel {
  display: flex;
  gap: 30px;
  justify-content: center;
  width: 100%;
  padding: 10px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.score, .high-score {
  font-size: 1.2rem;
  font-weight: bold;
  color: #764ba2;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  grid-template-rows: repeat(20, 1fr);
  width: min(90vw, 90vh, 600px);
  height: min(90vw, 90vh, 600px);
  background: repeating-conic-gradient(
    #ffffff 0% 25%,
    #ffe4e1 25% 50%
  );
  background-size: 50% 50%;
  border: 4px solid #764ba2;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  position: relative;
}

.cell {
  border: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: center;
  align-items: center;
}

.snake-head {
  position: absolute;
  width: 5%;
  height: 5%;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.05s linear;
}

.snake-head img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.snake-head.fallback {
  background: linear-gradient(135deg, #ff6b9d 0%, #c44569 100%);
  border-radius: 3px;
}

.snake-body {
  font-family: 'Courier New', monospace;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

.food {
  position: absolute;
  width: 5%;
  height: 5%;
  background: linear-gradient(135deg, #00d9ff 0%, #00a8cc 100%);
  transform: rotate(45deg);
  border-radius: 3px;
  box-shadow: 0 0 15px rgba(0, 217, 255, 0.6);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { transform: rotate(45deg) scale(1); }
  50% { transform: rotate(45deg) scale(1.1); }
}

.d-pad {
  display: none;
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(3, 60px);
  gap: 5px;
  margin-top: 10px;
}

.d-pad-btn {
  width: 60px;
  height: 60px;
  font-size: 1.5rem;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  color: #764ba2;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transition: all 0.2s;
}

.d-pad-btn:active {
  transform: scale(0.95);
  background: #764ba2;
  color: white;
}

.d-pad-btn[data-direction="up"] {
  grid-column: 2;
  grid-row: 1;
}

.d-pad-btn[data-direction="left"] {
  grid-column: 1;
  grid-row: 2;
}

.d-pad-btn[data-direction="down"] {
  grid-column: 2;
  grid-row: 2;
}

.d-pad-btn[data-direction="right"] {
  grid-column: 3;
  grid-row: 2;
}

@media (max-width: 767px) {
  .d-pad {
    display: grid;
  }
}

.game-over {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.game-over-content {
  background: white;
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.game-over-content h2 {
  color: #764ba2;
  margin-bottom: 20px;
  font-size: 2rem;
}

.game-over-content p {
  color: #666;
  font-size: 1.2rem;
  margin-bottom: 30px;
}

.restart-btn {
  padding: 15px 40px;
  font-size: 1.2rem;
  font-weight: bold;
  color: white;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.restart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(118, 75, 162, 0.4);
}

/* Cute diamond decorations */
.decoration {
  position: fixed;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.15);
  transform: rotate(45deg);
  border-radius: 8px;
  pointer-events: none;
  z-index: 0;
  animation: bounce 1.2s ease-in-out infinite;
}

.diamond-1 {
  top: 10%;
  left: 5%;
  background: rgba(255, 182, 193, 0.2);
  animation-delay: 0s;
  width: 30px;
  height: 30px;
}

.diamond-2 {
  top: 20%;
  right: 8%;
  background: rgba(173, 216, 230, 0.2);
  animation-delay: 1s;
  width: 50px;
  height: 50px;
}

.diamond-3 {
  top: 60%;
  left: 3%;
  background: rgba(255, 218, 223, 0.2);
  animation-delay: 2s;
  width: 35px;
  height: 35px;
}

.diamond-4 {
  bottom: 15%;
  right: 5%;
  background: rgba(221, 160, 221, 0.2);
  animation-delay: 3s;
  width: 45px;
  height: 45px;
}

.diamond-5 {
  top: 35%;
  left: 10%;
  background: rgba(176, 224, 230, 0.2);
  animation-delay: 4s;
  width: 25px;
  height: 25px;
}

.diamond-6 {
  bottom: 30%;
  left: 15%;
  background: rgba(255, 192, 203, 0.2);
  animation-delay: 5s;
  width: 38px;
  height: 38px;
}

.diamond-7 {
  top: 70%;
  right: 12%;
  background: rgba(230, 230, 250, 0.2);
  animation-delay: 2.5s;
  width: 32px;
  height: 32px;
}

.diamond-8 {
  top: 45%;
  right: 3%;
  background: rgba(255, 228, 225, 0.2);
  animation-delay: 1.5s;
  width: 42px;
  height: 42px;
}

@keyframes bounce {
  0%, 100% {
    transform: rotate(45deg) translateY(0px) scale(1);
  }
  20% {
    transform: rotate(45deg) translateY(-20px) scale(0.95, 1.05);
  }
  40% {
    transform: rotate(45deg) translateY(-10px) scale(1.02, 0.98);
  }
  60% {
    transform: rotate(45deg) translateY(-18px) scale(0.98, 1.02);
  }
  80% {
    transform: rotate(45deg) translateY(-5px) scale(1.01, 0.99);
  }
}

@media (max-width: 767px) {
  .decoration {
    width: 25px;
    height: 25px;
  }
  
  .diamond-2, .diamond-4, .diamond-8 {
    width: 30px;
    height: 30px;
  }
}