/**
 * Snake Game - Specific Styling
 */

.game-wrapper {
  max-width: 1200px;
  margin: 0 auto;
}

.game-header {
  text-align: center;
  padding: 2rem 0;
}

.game-header h1 {
  font-size: 2.5rem;
  background: linear-gradient(135deg, #FFD700, #7C3AED);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.game-canvas-wrapper {
  display: flex;
  justify-content: center;
  min-height: 400px;
  background: linear-gradient(135deg, #161B22 0%, #0D1117 100%);
}

.game-canvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  background: #161B22;
}

#gameCanvas {
  display: block;
  margin: auto;
  /* Stop the page from scrolling/zooming while the player swipes on the
     canvas to steer the snake on a phone. */
  touch-action: none;
}

/* Wraps the canvas so the ready/paused/game-over overlay below can be
   positioned exactly on top of it, at whatever size the canvas currently is. */
.canvas-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.canvas-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 11, 0.72);
  border-radius: 8px;
  text-align: center;
  color: #F1F5F9;
  pointer-events: none;
}

.canvas-overlay-icon {
  display: block;
  font-size: 2.5rem;
  color: #7C3AED;
  margin-bottom: 0.5rem;
}

.canvas-overlay-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.canvas-overlay-subtitle {
  font-size: 0.9rem;
  color: #94A3B8;
}

/* On-screen D-pad (phones / touch devices) — swipe still works, this adds
   a visible, precise alternative since there's no keyboard on mobile. */
.dpad-mobile {
  display: none;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 6px;
  justify-content: center;
  margin: 1.25rem auto 0;
}

.dpad-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #F1F5F9;
  font-size: 1.25rem;
  touch-action: manipulation;
  user-select: none;
}

.dpad-btn:active {
  background: rgba(124, 58, 237, 0.4);
  border-color: #7C3AED;
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }
.dpad-right { grid-column: 3; grid-row: 2; }

/* Responsive Game */
@media (max-width: 768px) {
  .game-header h1 {
    font-size: 1.8rem;
  }

  .game-controls {
    flex-direction: column;
  }

  .game-controls .btn-group {
    width: 100%;
  }

  .game-canvas-wrapper {
    padding: 1rem;
  }

  #gameCanvas {
    width: 100% !important;
    max-width: 100%;
    height: auto;
  }
}

/* Show the D-pad on small screens and on any touch/coarse-pointer device
   (covers touch laptops/tablets at wider widths too). */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  .dpad-mobile {
    display: grid;
  }
}

/* Game Stats */
.game-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.stat-card {
  padding: 1.5rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-label {
  font-size: 0.875rem;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #FFD700, #7C3AED);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}