:root {
  --bg: #0d1117;
  --panel: #161b22;
  --accent: #3fb950;
  --accent-dim: #1f6f2a;
  --text: #e6edf3;
  --muted: #8b949e;
  --food: #f85149;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  min-height: 100vh;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 16px;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
}

header {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid #21262d;
  padding-bottom: 12px;
}

h1 {
  margin: 0;
  letter-spacing: 6px;
  color: var(--accent);
  font-size: 2.2rem;
}

.hud {
  display: flex;
  gap: 20px;
  color: var(--muted);
  font-size: 0.95rem;
}
.hud strong { color: var(--text); }

.game-area {
  position: relative;
  background: var(--panel);
  border: 1px solid #21262d;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: center;
}

canvas {
  background: #010409;
  border-radius: 4px;
  image-rendering: pixelated;
  display: block;
  max-width: 100%;
}

.overlay {
  position: absolute;
  inset: 12px;
  background: rgba(1, 4, 9, 0.85);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: opacity 0.2s;
}
.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.overlay-inner h2 { margin: 0 0 8px; color: var(--accent); }
.overlay-inner p { margin: 0 0 16px; color: var(--muted); }

button {
  background: var(--accent);
  color: #0d1117;
  border: 0;
  padding: 8px 20px;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
}
button:hover { background: #4ac95f; }

.leaderboard {
  background: var(--panel);
  border: 1px solid #21262d;
  border-radius: 8px;
  padding: 16px;
}
.leaderboard h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 2px;
}
ol#scores-list {
  margin: 0;
  padding-left: 24px;
  list-style: decimal;
}
#scores-list li {
  padding: 4px 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px dashed #21262d;
  font-size: 0.9rem;
}
#scores-list li:last-child { border-bottom: 0; }
#scores-list li.empty {
  list-style: none;
  margin-left: -24px;
  color: var(--muted);
  border: 0;
  text-align: center;
}
#scores-list li .nick { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
#scores-list li .pts { color: var(--accent); font-weight: bold; }
#scores-list li.you { background: rgba(63, 185, 80, 0.1); border-radius: 2px; }

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid #21262d;
  border-radius: 8px;
  padding: 24px;
  min-width: 280px;
}
dialog::backdrop { background: rgba(0,0,0,0.6); }
dialog h3 { margin: 0 0 16px; color: var(--accent); }
dialog label { display: block; margin-bottom: 12px; }
dialog input {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 8px;
  font-family: inherit;
  font-size: 1rem;
}
dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
}
dialog button[value="cancel"] {
  background: #30363d;
  color: var(--text);
}

@media (max-width: 720px) {
  main { grid-template-columns: 1fr; }
}
