/**
 * Snake 3D - Stylesheet
 * Modern, responsive UI for Snake game with three.js
 */

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

body {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive, sans-serif;
  overflow: hidden;
  background: linear-gradient(135deg, #9ACD32 0%, #7FBF00 100%);
}

/* ============================================
   GAME CONTAINER
   ============================================ */

#gameContainer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#gameContainer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============================================
   UI OVERLAY
   ============================================ */

#gameUI {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10;
}

#gameUI > * {
  pointer-events: auto;
}

/* ============================================
   SCORE DISPLAY
   ============================================ */

#scoreDisplay {
  position: absolute;
  top: 20px;
  left: 20px;
  background: linear-gradient(145deg, #FFD700, #FFA500);
  padding: 20px 35px;
  border-radius: 25px;
  border: 5px solid #FFFFFF;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3),
              inset 0 -5px 15px rgba(0, 0, 0, 0.2);
  transform: rotate(-2deg);
}

.score-label {
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 5px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.score-value {
  color: #FFFFFF;
  font-size: 56px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.3),
               0 0 20px rgba(255, 255, 255, 0.5);
}

/* ============================================
   CONTROLS HINT
   ============================================ */

.controls-hint {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(145deg, #FFFFFF, #F0F0F0);
  padding: 15px 35px;
  border-radius: 30px;
  border: 4px solid #FFD700;
  color: #333333;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  transition: opacity 0.5s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.controls-hint.fade-out {
  opacity: 0;
  pointer-events: none;
}

.hint-desktop,
.hint-mobile {
  margin: 5px 0;
}

.hint-mobile {
  display: none;
}

.key {
  display: inline-block;
  background: linear-gradient(145deg, #FFD700, #FFA500);
  padding: 8px 14px;
  border-radius: 10px;
  border: 3px solid #FFFFFF;
  font-weight: 900;
  color: #FFFFFF;
  margin: 0 3px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2),
              inset 0 -2px 5px rgba(0, 0, 0, 0.2);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* ============================================
   START SCREEN
   ============================================ */

.start-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #9ACD32 0%, #7FBF00 50%, #FFD700 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.start-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.start-content {
  text-align: center;
  padding: 50px;
  background: linear-gradient(145deg, #FFFFFF, #F5F5F5);
  border-radius: 40px;
  border: 8px solid #FFD700;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4),
              inset 0 -10px 30px rgba(0, 0, 0, 0.1);
  max-width: 550px;
  width: 90%;
}

.game-title {
  font-size: 72px;
  font-weight: 900;
  background: linear-gradient(145deg, #7FBF00, #FFD700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 20px;
  text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.1);
  filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.2));
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.game-description {
  font-size: 20px;
  color: #333333;
  font-weight: 600;
  margin-bottom: 35px;
  line-height: 1.6;
}

.btn-start {
  background: linear-gradient(145deg, #FF6B6B, #FF4757);
  color: #FFFFFF;
  font-size: 28px;
  font-weight: 900;
  padding: 20px 60px;
  border: 6px solid #FFFFFF;
  border-radius: 60px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3),
              inset 0 -5px 15px rgba(0, 0, 0, 0.2);
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.btn-start:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 40px rgba(0, 255, 0, 0.6);
}

.btn-start:active {
  transform: translateY(-1px);
}

.controls-info {
  margin-top: 40px;
  padding-top: 30px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.controls-info h3 {
  color: #FF6B6B;
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.controls-desktop,
.controls-mobile {
  color: #555555;
  font-size: 18px;
  font-weight: 600;
  margin: 10px 0;
}

.controls-mobile {
  display: none;
}

/* ============================================
   GAME OVER SCREEN
   ============================================ */

.game-over {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.95) 0%, rgba(255, 71, 87, 0.95) 100%);
  backdrop-filter: blur(15px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.game-over.hidden {
  opacity: 0;
  pointer-events: none;
}

.game-over-content {
  text-align: center;
  padding: 50px;
  background: linear-gradient(145deg, #FFFFFF, #F5F5F5);
  border-radius: 40px;
  border: 8px solid #FFD700;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
              inset 0 -10px 30px rgba(0, 0, 0, 0.1);
  max-width: 650px;
  width: 90%;
}

.game-over-title {
  font-size: 64px;
  font-weight: 900;
  color: #FF4757;
  margin-bottom: 30px;
  text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.2);
  filter: drop-shadow(0 5px 15px rgba(255, 71, 87, 0.4));
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

.final-stats {
  display: flex;
  justify-content: space-around;
  margin: 30px 0;
  flex-wrap: wrap;
  gap: 20px;
}

.stat {
  flex: 1;
  min-width: 150px;
  background: linear-gradient(145deg, #7FBF00, #9ACD32);
  padding: 20px;
  border-radius: 20px;
  border: 4px solid #FFFFFF;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2),
              inset 0 -3px 10px rgba(0, 0, 0, 0.2);
}

.stat-label {
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.3);
}

.stat-value {
  color: #FFFFFF;
  font-size: 42px;
  font-weight: 900;
  text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.3);
}

.btn-restart {
  background: linear-gradient(145deg, #7FBF00, #9ACD32);
  color: #FFFFFF;
  font-size: 26px;
  font-weight: 900;
  padding: 18px 50px;
  border: 6px solid #FFFFFF;
  border-radius: 60px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3),
              inset 0 -5px 15px rgba(0, 0, 0, 0.2);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 25px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.btn-restart:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4),
              inset 0 -5px 15px rgba(0, 0, 0, 0.2);
}

.btn-restart:active {
  transform: translateY(-2px) scale(1.02);
}

.leaderboard-msg {
  color: #555555;
  font-size: 16px;
  font-weight: 600;
  margin-top: 20px;
  font-style: italic;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  /* Show mobile controls, hide desktop controls */
  .hint-desktop,
  .controls-desktop {
    display: none;
  }

  .hint-mobile,
  .controls-mobile {
    display: block;
  }

  /* Smaller UI elements on mobile */
  #scoreDisplay {
    top: 10px;
    left: 10px;
    padding: 15px 25px;
    border: 4px solid #FFFFFF;
  }

  .score-value {
    font-size: 40px;
  }

  .game-title {
    font-size: 52px;
  }

  .game-description {
    font-size: 18px;
  }

  .btn-start,
  .btn-restart {
    font-size: 22px;
    padding: 16px 40px;
    border: 5px solid #FFFFFF;
  }

  .game-over-title {
    font-size: 48px;
  }

  .stat-value {
    font-size: 32px;
  }

  .final-stats {
    gap: 12px;
  }

  .stat {
    min-width: 110px;
    padding: 15px;
    border: 3px solid #FFFFFF;
  }

  .start-content,
  .game-over-content {
    padding: 35px 25px;
    border: 6px solid #FFD700;
  }

  .controls-hint {
    border: 3px solid #FFD700;
    padding: 12px 25px;
  }

  .key {
    padding: 6px 10px;
    border: 2px solid #FFFFFF;
  }
}

@media (max-width: 480px) {
  .score-value {
    font-size: 34px;
  }

  .game-title {
    font-size: 42px;
  }

  .btn-start,
  .btn-restart {
    font-size: 20px;
    padding: 14px 35px;
    border: 4px solid #FFFFFF;
  }

  .game-description {
    font-size: 16px;
  }

  .stat-value {
    font-size: 28px;
  }
}

/* ============================================
   TOUCH DEVICE OPTIMIZATIONS
   ============================================ */

@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .btn-start,
  .btn-restart {
    min-height: 60px;
    min-width: 200px;
  }

  /* Remove hover effects on touch devices */
  .btn-start:hover,
  .btn-restart:hover {
    transform: none;
  }

  .btn-start:active,
  .btn-restart:active {
    transform: scale(0.95);
  }
}
