/**
 * Browser Arcade - Snake Retro Game Styling & Responsive Canvas
 * Hardware-accelerated 60 FPS neon aesthetics and responsive viewport layout.
 */

:root {
  --snake-board-size: min(92vw, 460px);
}

/* ==========================================================================
   Game Page Header & HUD
   ========================================================================== */

.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: var(--snake-board-size);
  margin: 0 auto;
  padding: 16px 0 32px;
}

.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 16px;
  gap: 12px;
}

.game-title-group {
  display: flex;
  flex-direction: column;
}

.game-title {
  font-size: clamp(1.85rem, 5.5vw, 2.75rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(135deg, #10B981 0%, #34D399 50%, #06B6D4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.game-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 4px;
}

.game-scores {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-box {
  position: relative;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  min-width: 80px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.score-box-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.score-box-value {
  font-size: clamp(1.1rem, 3.5vw, 1.45rem);
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

/* Score floating increment animation */
.score-addition {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent-emerald, #10b981);
  pointer-events: none;
  animation: floatUp 0.6s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translate(-50%, -30%) scale(0.9);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -130%) scale(1.1);
  }
}

/* ==========================================================================
   Game Controls Toolbar
   ========================================================================== */

.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 16px;
  gap: 12px;
}

.game-toolbar-left,
.game-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   Snake Canvas Game Board
   ========================================================================== */

.game-board-container {
  position: relative;
  width: 100%;
  max-width: var(--snake-board-size);
  aspect-ratio: 1 / 1;
  background: rgba(15, 17, 26, 0.98);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 0 16px rgba(16, 185, 129, 0.04);
  touch-action: none; /* Prevents mobile scroll while playing */
  overflow: hidden;
  user-select: none;
  contain: layout paint;
}

#snakeCanvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
}

/* ==========================================================================
   Overlay Modals (Start, Pause, Game Over)
   ========================================================================== */

.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 12, 20, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 10;
  border-radius: inherit;
}

.game-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.game-overlay-icon {
  font-size: 2.75rem;
  margin-bottom: 10px;
  line-height: 1;
}

.game-overlay-title {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  margin: 0 0 8px 0;
}

.game-overlay-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 0 20px 0;
  line-height: 1.5;
}

.game-overlay-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ==========================================================================
   Virtual Touch D-Pad (Mobile Comfort)
   ========================================================================== */

.snake-touch-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 18px;
  gap: 8px;
  user-select: none;
  touch-action: none;
}

.dpad-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.dpad-btn {
  width: 58px;
  height: 54px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, background 0.15s ease;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

.dpad-btn:active {
  transform: scale(0.92);
  background: var(--primary-500, #6366f1);
  color: #FFFFFF;
}

.dpad-btn svg {
  pointer-events: none;
}

/* On large desktop screens, keep D-pad compact or auxiliary */
@media (min-width: 992px) {
  .snake-touch-controls {
    display: none;
  }
}

/* ==========================================================================
   Accessibility & Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .game-overlay {
    transition: none !important;
  }
  .score-addition {
    animation: none !important;
    display: none;
  }
  .dpad-btn {
    transition: none !important;
  }
}

/* Keyboard hint badges */
.control-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
