/* ═══════════════════════════════════════════════════════════════
   SNAKE CLASSIC — Modern Edition
   Complete Stylesheet with Animations
   ═══════════════════════════════════════════════════════════════ */

/* ─── CSS Variables / Theme ─── */
:root {
  /* Dark theme (default) */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a1f2e;
  --bg-card-hover: #242a3d;
  --text-primary: #f0f4ff;
  --text-secondary: #8892a8;
  --text-muted: #4a5568;
  --accent: #22d65b;
  --accent-glow: rgba(34, 214, 91, 0.3);
  --accent-hover: #1bbd4f;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.3);
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(139, 92, 246, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(139, 92, 246, 0.3);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font-game: "Press Start 2P", monospace;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light theme */
body.light-theme {
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8f9fb;
  --text-primary: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #a0aec0;
  --border: rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.16);
}

/* ─── Reset & Base ─── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Static Background ─── */
.bg-wave-wrapper {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* ═══════════════════════ PAGE SYSTEM ═══════════════════════ */
.page {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.96) translateY(12px);
  transition:
    opacity var(--transition-slow),
    transform var(--transition-slow),
    visibility 0s linear 0.5s;
}

.page.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
  transition:
    opacity var(--transition-slow),
    transform var(--transition-slow),
    visibility 0s linear 0s;
}

/* Page exit animation */
.page.exit {
  opacity: 0;
  transform: scale(1.02) translateY(-8px);
}

/* ═══════════════════════ HOME PAGE ═══════════════════════ */
.home-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  align-items: center;
  width: 100%;
  max-width: 960px;
  padding: 40px;
  animation: cardEntrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ─── Left: Main Card ─── */
.home-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
}

.game-title {
  font-family: var(--font-game);
  font-size: 64px;
  letter-spacing: 12px;
  font-weight: 900;
  background: linear-gradient(135deg, #5eead4 0%, #818cf8 50%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 4px 24px rgba(139, 92, 246, 0.25));
  line-height: 1.1;
}

.game-subtitle {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 8px;
  text-transform: uppercase;
  margin-top: -8px;
  opacity: 0;
  animation: fadeInUp 0.6s ease-out 0.5s forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Best Score Card */
.best-score-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  animation: fadeInUp 0.5s ease-out 0.7s both;
  min-width: 200px;
}

.best-score-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.best-score-value {
  font-family: var(--font-game);
  font-size: 28px;
  color: var(--text-primary);
}

/* Play Button */
.btn-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px 56px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9, #5b21b6);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow:
    0 6px 30px rgba(124, 58, 237, 0.45),
    0 2px 12px rgba(0, 0, 0, 0.3);
  animation: fadeInUp 0.5s ease-out 0.9s both;
  outline: none;
}

.btn-play:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow:
    0 10px 50px rgba(124, 58, 237, 0.55),
    0 4px 20px rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg, #8b5cf6, #7c3aed, #6d28d9);
}

.btn-play:active {
  transform: translateY(0) scale(0.97);
  transition: all 0.1s;
}

.btn-play-icon {
  font-size: 16px;
}

/* How to Play Link */
.how-to-play-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  opacity: 0;
  animation: fadeInUp 0.5s ease-out 1.1s forwards;
  padding: 6px 12px;
  border-radius: 8px;
}

.how-to-play-link:hover {
  color: #a78bfa;
  background: rgba(139, 92, 246, 0.08);
}

/* ─── Right: Setup Cards ─── */
.home-setup {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeInUp 0.6s ease-out 0.6s both;
}

.setup-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.setup-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  font-family: var(--font-ui);
  outline: none;
  text-align: center;
}

.setup-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-accent);
  box-shadow: var(--shadow-md);
  background: var(--bg-card-hover);
}

.setup-card:active {
  transform: translateY(0) scale(0.97);
  transition: all 0.1s;
}

.setup-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border-radius: 12px;
  background: var(--bg-secondary);
}

/* Colored icon backgrounds to match design */
.setup-icon-difficulty {
  background: rgba(109, 40, 217, 0.18);
  color: #8b5cf6;
}

.setup-icon-skin {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.setup-icon-food {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  font-size: 24px;
}

.setup-icon-map {
  background: rgba(20, 184, 166, 0.15);
  color: #2dd4bf;
}

.setup-icon-settings {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
}

body.light-theme .setup-icon-difficulty {
  background: rgba(109, 40, 217, 0.1);
}
body.light-theme .setup-icon-skin {
  background: rgba(168, 85, 247, 0.1);
}
body.light-theme .setup-icon-food {
  background: rgba(244, 63, 94, 0.1);
}
body.light-theme .setup-icon-map {
  background: rgba(20, 184, 166, 0.1);
}
body.light-theme .setup-icon-settings {
  background: rgba(100, 116, 139, 0.1);
}

.setup-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.setup-card-value {
  font-size: 11px;
  color: #8b5cf6;
  font-weight: 600;
}

body.light-theme .setup-card-value {
  color: #7c3aed;
}

/* Settings Row (full width beneath grid) */
.setup-settings-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  font-family: var(--font-ui);
  outline: none;
  width: 100%;
  color: var(--text-primary);
}

.setup-settings-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(139, 92, 246, 0.35);
  box-shadow: var(--shadow-md);
  background: var(--bg-card-hover);
}

.setup-settings-btn:active {
  transform: translateY(0) scale(0.98);
  transition: all 0.1s;
}

.setup-settings-btn .setup-card-title {
  flex: 1;
  text-align: left;
}

.setup-settings-btn .setup-card-value {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
}

/* How to Play Modal */
.howto-content {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.howto-content strong {
  color: var(--text-primary);
}

/* ═══════════════════════ BUTTONS ═══════════════════════ */
.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  overflow: hidden;
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
}

.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.03));
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::before {
  opacity: 1;
}

.btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-md);
  border-color: var(--border-accent);
}

.btn:active {
  transform: translateY(0) scale(0.98);
  transition: all 0.1s ease;
}

.btn-icon {
  font-size: 16px;
}

/* Primary Button */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #1bbd4f);
  color: #fff;
  border-color: transparent;
  font-weight: 700;
}

.btn-primary:hover {
  box-shadow: var(--shadow-glow), var(--shadow-md);
  border-color: transparent;
}

/* Danger Button */
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
}

.btn-danger:hover {
  box-shadow: 0 0 20px var(--danger-glow);
  border-color: transparent;
}

.btn-small {
  width: auto;
  padding: 8px 20px;
  font-size: 13px;
}

/* ═══════════════════════ GAME PAGE ═══════════════════════ */
#page-game {
  background: var(--bg-primary);
}

body.light-theme #page-game {
  background: var(--bg-primary);
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 100%;
  padding: 16px;
  box-sizing: border-box;
}

/* HUD */
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(20px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

body.light-theme .game-hud {
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.hud-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.hud-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  transform: scale(1.1);
}

.hud-score,
.hud-highscore {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hud-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.5px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.hud-value {
  font-family: var(--font-game);
  font-size: 20px;
  color: var(--accent);
  transition: all var(--transition-fast);
}

.hud-value.bump {
  animation: scoreBump 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scoreBump {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.4);
    color: #fff;
  }
  100% {
    transform: scale(1);
  }
}

/* Canvas Wrapper — dimensions set entirely by JS resize() */
.canvas-wrapper {
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  box-sizing: content-box;
  border: 4px solid rgba(148, 163, 184, 0.5);
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.55),
    0 12px 40px rgba(0, 0, 0, 0.6),
    0 4px 12px rgba(0, 0, 0, 0.3);
  background: #0a0e17;
}

body.light-theme .canvas-wrapper {
  border-color: rgba(100, 116, 139, 0.5);
  background: #e8ecf1;
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.08),
    0 8px 32px rgba(0, 0, 0, 0.1),
    0 2px 6px rgba(0, 0, 0, 0.06);
}

/* No-wall maps: dashed border */
.canvas-wrapper.no-walls {
  border: 2px dashed rgba(148, 163, 184, 0.2);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.6),
    0 4px 12px rgba(0, 0, 0, 0.3);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: crisp-edges;
}

/* Tap To Play Overlay */
.tap-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(15, 22, 38, 0.7);
  backdrop-filter: none;
  z-index: 5;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--transition-normal),
    visibility 0s linear 0.3s;
}

body.light-theme .tap-overlay {
  background: rgba(232, 236, 241, 0.72);
}

.tap-overlay.active {
  opacity: 1;
  visibility: visible;
  transition:
    opacity var(--transition-normal),
    visibility 0s linear 0s;
}

.tap-title {
  font-family: var(--font-game);
  font-size: 13px;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
  letter-spacing: 2px;
  animation: tapPulse 1.4s ease-in-out infinite;
  margin: 0;
}

@keyframes tapPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.tap-arrows {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.tap-row {
  display: flex;
  gap: 6px;
}

.tap-arrow {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid var(--accent);
  border-radius: 10px;
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  transition:
    background 0.15s,
    transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tap-arrow:hover,
.tap-arrow:active {
  background: var(--accent);
  color: #0f1626;
  transform: scale(1.12);
}

/* ═══════════════════════ MOBILE CONTROLS ═══════════════════════ */
.mobile-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
}

.ctrl-row {
  display: flex;
  gap: 6px;
}

.ctrl-btn {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

.ctrl-btn:active {
  background: var(--accent);
  color: #fff;
  transform: scale(0.92);
  border-color: var(--accent);
}

/* ═══════════════════════ SUB PAGES (Skins, Maps, Settings) ═══════════════════════ */
.sub-page {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  padding: 24px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

.sub-page::-webkit-scrollbar {
  width: 4px;
}

.sub-page::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

.sub-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.sub-header h2 {
  font-family: var(--font-game);
  font-size: 16px;
  letter-spacing: 2px;
}

.back-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-ui);
}

.back-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  transform: translateX(-3px);
}

/* ─── Skins Page: Split Layout ─── */
.skins-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 32px;
  width: 100%;
  max-width: 920px;
  max-height: 90vh;
  padding: 32px;
  animation: cardEntrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.skins-panel-left {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 80vh;
}

.skins-panel-left .sub-header {
  margin-bottom: 16px;
  flex-shrink: 0;
}

.skins-panel-left .skin-grid {
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
  flex: 1;
}

.skins-panel-left .skin-grid::-webkit-scrollbar {
  width: 4px;
}

.skins-panel-left .skin-grid::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

.skins-panel-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.skin-preview-box {
  width: 100%;
  max-width: 380px;
  aspect-ratio: 1;
  background: #e8ecf1;
  border-radius: var(--radius-lg);
  border: 2px solid rgba(200, 210, 225, 0.5);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeInUp 0.5s ease-out 0.2s both;
}

/* Food preview box */
.food-preview-box {
  width: 100%;
  max-width: 380px;
  aspect-ratio: 1;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeInUp 0.5s ease-out 0.2s both;
}

.food-preview-emoji {
  font-size: 120px;
  line-height: 1;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.25));
  animation: foodBounce 1.8s ease-in-out infinite;
  user-select: none;
}

@keyframes foodBounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-14px) scale(1.07);
  }
}

.skin-preview-box canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.skin-preview-label {
  font-family: var(--font-game);
  font-size: 16px;
  color: var(--text-primary);
  letter-spacing: 1px;
  animation: fadeInUp 0.5s ease-out 0.3s both;
}

.skin-preview-desc {
  font-size: 13px;
  color: var(--text-secondary);
  animation: fadeInUp 0.5s ease-out 0.35s both;
}

/* ─── Skin Grid (list items) ─── */
.skin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.skin-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  animation: fadeInUp 0.4s ease-out both;
}

.skin-card:nth-child(1) {
  animation-delay: 0.05s;
}
.skin-card:nth-child(2) {
  animation-delay: 0.1s;
}
.skin-card:nth-child(3) {
  animation-delay: 0.15s;
}
.skin-card:nth-child(4) {
  animation-delay: 0.2s;
}
.skin-card:nth-child(5) {
  animation-delay: 0.25s;
}
.skin-card:nth-child(6) {
  animation-delay: 0.3s;
}
.skin-card:nth-child(7) {
  animation-delay: 0.35s;
}

.skin-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-accent);
  box-shadow: var(--shadow-md);
}

.skin-card.selected {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
  background: rgba(34, 214, 91, 0.05);
}

.skin-preview {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.skin-preview canvas {
  width: 100%;
  height: 100%;
}

.skin-info {
  flex: 1;
  min-width: 0;
}

.skin-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skin-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

.skin-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.skin-card.selected .skin-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Responsive: stack on small screens */
@media (max-width: 768px) {
  .skins-layout {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px;
    max-width: 480px;
  }

  .skins-panel-right {
    order: -1;
  }

  .skin-preview-box {
    max-width: 240px;
  }

  .skins-panel-left {
    max-height: 45vh;
  }
}

/* ─── Map Grid (now uses skin-card style via skins-layout) ─── */
.map-preview-box {
  width: 100%;
  max-width: 380px;
  aspect-ratio: 1;
  background: #0a0e17;
  border-radius: 0;
  border: none;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeInUp 0.5s ease-out 0.2s both;
}

body.light-theme .map-preview-box {
  background: #e8ecf1;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04);
}

.map-preview-box canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Extra animation delays for more map items */
.skin-card:nth-child(8) {
  animation-delay: 0.4s;
}
.skin-card:nth-child(9) {
  animation-delay: 0.45s;
}
.skin-card:nth-child(10) {
  animation-delay: 0.5s;
}
.skin-card:nth-child(11) {
  animation-delay: 0.55s;
}
.skin-card:nth-child(12) {
  animation-delay: 0.6s;
}
.skin-card:nth-child(13) {
  animation-delay: 0.65s;
}

/* ═══════════════════════ SETTINGS ═══════════════════════ */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: background var(--transition-fast);
}

.setting-row:first-child {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.setting-row:last-child {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.setting-row:hover {
  background: var(--bg-card-hover);
}

.setting-label {
  font-weight: 500;
  font-size: 14px;
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 48px;
  height: 26px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 26px;
  transition: all var(--transition-normal);
}

.toggle-slider::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: all var(--transition-spring);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::after {
  transform: translateX(22px);
  background: #fff;
}

/* Speed / Control Selector */
.speed-selector {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.speed-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.speed-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.speed-btn:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* ═══════════════════════ MODALS ═══════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--transition-normal),
    visibility 0s linear 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
  transition:
    opacity var(--transition-normal),
    visibility 0s linear 0s;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 90%;
  max-width: 360px;
  text-align: center;
  transform: scale(0.85) translateY(20px);
  transition: transform var(--transition-spring);
  box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-title {
  font-family: var(--font-game);
  font-size: 22px;
  letter-spacing: 3px;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Game Over Modal */
.gameover-title {
  color: var(--danger);
  text-shadow: 0 0 30px var(--danger-glow);
  animation: gameoverShake 0.6s ease-out;
}

@keyframes gameoverShake {
  0%,
  100% {
    transform: translateX(0);
  }
  10% {
    transform: translateX(-8px);
  }
  20% {
    transform: translateX(8px);
  }
  30% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  50% {
    transform: translateX(-3px);
  }
  60% {
    transform: translateX(3px);
  }
}

.gameover-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 24px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-game);
  font-size: 28px;
  color: var(--accent);
}

.new-highscore-badge {
  display: none;
  font-family: var(--font-game);
  font-size: 11px;
  color: #fbbf24;
  margin-bottom: 20px;
  animation: badgePulse 1s ease-in-out infinite;
}

.new-highscore-badge.show {
  display: block;
}

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

/* ═══════════════════════ FOOD PARTICLE EFFECTS (canvas-based, styled placeholder) ═══════════════════════ */

/* ═══════════════════════ RESPONSIVE ═══════════════════════ */
@media (max-width: 860px) {
  .home-layout {
    grid-template-columns: 1fr;
    gap: 32px;
    max-width: 440px;
    padding: 32px 24px;
  }

  .game-title {
    font-size: 48px;
    letter-spacing: 8px;
  }

  .mobile-controls {
    display: flex;
  }
}

@media (max-width: 480px) {
  .home-layout {
    padding: 24px 16px;
  }

  .game-title {
    font-size: 36px;
    letter-spacing: 5px;
  }

  .game-subtitle {
    font-size: 10px;
    letter-spacing: 5px;
  }

  .btn-play {
    padding: 16px 40px;
    font-size: 15px;
  }

  .setup-grid {
    gap: 8px;
  }

  .setup-card {
    padding: 16px 10px;
  }

  .btn {
    padding: 14px 20px;
    font-size: 14px;
  }

  .modal {
    padding: 28px 20px;
  }

  .canvas-wrapper {
    border-width: 3px;
  }

  .ctrl-btn {
    width: 56px;
    height: 56px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .mobile-controls {
    display: flex;
  }
}

/* ═══════════════════════ UTILITY ANIMATIONS ═══════════════════════ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Ripple effect on buttons */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0);
  animation: ripple 0.6s linear;
  pointer-events: none;
}

/* Smooth scroll for sub-pages */
.sub-page {
  scroll-behavior: smooth;
}

/* Selection colors */
::selection {
  background: var(--accent);
  color: #fff;
}
