:root {
  --bg: #f5f5f5;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --snake: #111827;
  --food: #dc2626;
  --obstacle: #d97706;
  --empty: #e5e7eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 1rem;
  padding: 1rem;
}

.panel {
  width: min(92vw, 540px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: normal;
  margin-right: 0.25rem;
}

.back:hover {
  color: var(--text);
}

.meta {
  display: flex;
  justify-content: space-between;
  margin: 0 0 0.75rem;
}

.board {
  width: min(86vw, 500px);
  aspect-ratio: 1 / 1;
  display: grid;
  border: 1px solid var(--border);
  background: var(--empty);
}

.cell {
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.cell.empty {
  background: var(--empty);
}

.cell.snake {
  background: var(--snake);
}

.cell.food {
  background: var(--food);
}

.cell.obstacle {
  background: var(--obstacle);
  border-radius: 2px;
}

.actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

.hint {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.controls {
  width: min(92vw, 200px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.controls button {
  width: 60px;
  height: 60px;
  font-size: 1.5rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #f3f4f6;
  border: 1px solid var(--border);
  touch-action: manipulation;
  user-select: none;
}

.controls button:active {
  background: #d1d5db;
}

.controls-middle {
  display: grid;
  grid-template-columns: repeat(3, 60px);
  gap: 0.35rem;
}

@media (min-width: 900px) {
  .controls {
    display: none;
  }
}
