/* ==========================================================================
   CLASSIC MODERN SNAKE GAME - GAMEPLAY & CANVAS STYLES
   Retro-Arcade Frame, Clean HUD, Tactile D-Pad Controls
   ========================================================================== */

.game-viewport {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

/* Classic Arcade Canvas Container */
.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 540px;
  max-height: 540px;
  background: #0f172a;
  border-radius: var(--radius-lg);
  border: 4px solid #334155;
  box-shadow: 
    0 12px 32px rgba(0, 0, 0, 0.45),
    inset 0 2px 6px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  transition: border-color 0.25s ease;
}

/* Retro Arcade Status Indicator LED */
.canvas-wrapper::before {
  content: '';
  position: absolute;
  top: 12px;
  right: 14px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #475569;
  z-index: 5;
  border: 1px solid rgba(0, 0, 0, 0.6);
  transition: all 0.3s ease;
}

.canvas-wrapper.playing {
  border-color: #22c55e;
}

.canvas-wrapper.playing::before {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.canvas-wrapper.game-over-pulse {
  border-color: #ef4444;
}

.canvas-wrapper.game-over-pulse::before {
  background: #ef4444;
  box-shadow: 0 0 6px #ef4444;
}

#snakeCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

/* In-Game HUD */
.game-hud {
  width: 100%;
  max-width: 540px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.hud-item {
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.75rem;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.hud-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  margin-bottom: 0.15rem;
}

.hud-value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}

/* Distinct Top Accent Highlights for Each Metric */
.game-hud .hud-item:nth-child(1) { border-top: 3px solid #22c55e; }
.game-hud .hud-item:nth-child(2) { border-top: 3px solid #f59e0b; }
.game-hud .hud-item:nth-child(3) { border-top: 3px solid #38bdf8; }
.game-hud .hud-item:nth-child(4) { border-top: 3px solid #ef4444; }

/* Canvas Overlays */
.game-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  z-index: 10;
  border-radius: calc(var(--radius-lg) - 4px);
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

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

/* Countdown Display */
.countdown-number {
  font-family: var(--font-display);
  font-size: 4.5rem;
  font-weight: 900;
  color: #22c55e;
  animation: countdownPop 0.8s ease-out infinite;
}

@keyframes countdownPop {
  0% { transform: scale(0.7); opacity: 0; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Game Over Card in Overlay */
.game-over-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  color: #ef4444;
  margin-bottom: 0.35rem;
}

.game-over-stats {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.4rem;
  margin: 1.1rem 0;
  width: 100%;
  max-width: 300px;
}

.game-over-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  font-size: 0.95rem;
}

.game-over-stat-row:not(:last-child) {
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

/* Controls Toolbar */
.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 540px;
  margin-top: 0.85rem;
  gap: 0.65rem;
}

.btn-game-action {
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #f8fafc;
  border-radius: var(--radius-md);
  padding: 0.55rem 1.2rem;
  font-size: 0.88rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-game-action:hover {
  background: #334155;
  color: #22c55e;
  border-color: #22c55e;
}

/* Desktop Key Hints */
.key-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.85rem;
}

.key-badge {
  background: #1e293b;
  border: 1px solid #475569;
  border-bottom: 2px solid #334155;
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

/* Tactile Retro D-Pad for Mobile */
.virtual-dpad {
  display: none;
  grid-template-columns: repeat(3, 62px);
  grid-template-rows: repeat(3, 62px);
  gap: 10px;
  margin-top: 1.25rem;
  justify-content: center;
  touch-action: manipulation;
}

.dpad-btn {
  background: #1e293b;
  border: 2px solid #334155;
  border-bottom: 4px solid #090d16;
  border-radius: 16px;
  color: #f8fafc;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: all 0.1s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.dpad-btn:active, .dpad-btn.pressed {
  background: #22c55e;
  color: #ffffff;
  border-color: #16a34a;
  border-bottom-width: 2px;
  transform: translateY(2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-pause { 
  grid-column: 2; 
  grid-row: 2; 
  font-size: 0.95rem; 
  background: #0f172a; 
  border-color: #475569; 
  border-radius: 50%;
}
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }
