:root {
  --bg-dark: #0f172a;
  --bg-mesh: #020617;
  --card-bg: rgba(30, 41, 59, 0.7);
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --snake-head: #4ade80;
  --snake-body: #166534;
  --apple: #ef4444;
  --wall: #475569;
  --font-main: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --shadow-sm: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

.background-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--bg-mesh);
  background-image: 
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.1) 0px, transparent 50%),
    radial-gradient(at 0% 100%, rgba(56, 189, 248, 0.1) 0px, transparent 50%);
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

.main-header {
  padding: 1.5rem 0;
  text-align: center;
}

.main-header h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 0.25rem;
  background: linear-gradient(to right, var(--accent), #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  background: var(--accent);
  border-radius: 9999px;
  -webkit-text-fill-color: var(--bg-dark);
  vertical-align: middle;
  margin-left: 0.4rem;
  text-transform: uppercase;
  font-weight: 700;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.main-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-bottom: 2rem;
}

@media (min-width: 968px) {
  .main-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
  }
}

.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.25rem;
  padding: 1.25rem;
  box-shadow: var(--shadow-xl);
  margin-bottom: 1rem;
}

.card h3 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.5rem;
  color: var(--accent);
}

.canvas-wrapper {
  position: relative;
  background: #000;
  border-radius: 1.25rem;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 600px;
  margin: 0 auto;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(8px);
}

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

.overlay-content h2 {
  font-size: 2.5rem;
  color: var(--snake-head);
  margin-bottom: 0.5rem;
  text-shadow: 0 0 15px rgba(74, 222, 128, 0.3);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.stat-item {
  background: rgba(15, 23, 42, 0.5);
  padding: 0.75rem;
  border-radius: 1rem;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.2s;
}

.stat-item:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.2);
}

.stat-item .label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.2rem;
  letter-spacing: 0.05em;
}

.stat-item .value {
  display: block;
  font-size: 1.25rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-main);
}

.control-group {
  margin-bottom: 1.25rem;
}

.control-group label {
  display: block;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 6px;
  border-radius: 3px;
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

.button-group {
  display: flex;
  gap: 0.75rem;
}

.btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.info-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.info-card strong {
  color: var(--accent);
}

.main-footer {
  margin-top: auto;
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .main-header h1 {
    font-size: 1.75rem;
  }
  
  .canvas-wrapper {
    border-radius: 1rem;
  }
  
  .card {
    padding: 1rem;
  }
  
  .overlay-content h2 {
    font-size: 2rem;
  }
}

@media (max-height: 700px) and (orientation: landscape) {
  .main-layout {
    flex-direction: row;
  }
  .canvas-wrapper {
    max-width: 400px;
  }
}