:root {
  --bg: #0f172a;
  --board-bg: #1e293b;
  --grid-line: #263349;
  --card-bg: #1e293b;
  --food: #f87171;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --danger: #f87171;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
}
body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px;
  touch-action: none;
  user-select: none;
}
header { text-align: center; }
h1 {
  margin: 4px 0 0;
  font-size: 1.5rem;
  letter-spacing: 0.05em;
}
h1 .accent { color: var(--accent); }

.screen { width: 100%; max-width: 480px; display: flex; justify-content: center; }
.screen.hidden { display: none; }

.card {
  width: 100%;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 0 0 1px var(--grid-line);
}

label { font-size: 0.85rem; color: var(--muted); }
input {
  background: var(--bg);
  border: 1px solid var(--grid-line);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 1rem;
}
input:focus { outline: 2px solid var(--accent); }

button {
  background: var(--board-bg);
  color: var(--text);
  border: none;
  box-shadow: 0 0 0 1px var(--grid-line);
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
button.primary { background: var(--accent); color: #082032; box-shadow: none; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:active:not(:disabled) { transform: scale(0.97); }

.divider {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin: 4px 0;
}

.error { color: var(--danger); font-size: 0.85rem; }
.hint { color: var(--muted); font-size: 0.85rem; text-align: center; }
.label { color: var(--muted); font-size: 0.85rem; margin: 0; }
.hidden { display: none !important; }

.room-code {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-align: center;
  color: var(--accent);
}

.player-list {
  list-style: none;
  margin: 4px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.player-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 6px;
  padding: 8px 10px;
}
.player-list .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.player-list .host-badge {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--accent);
}

#screen-game {
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#scoreboard {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  font-size: 0.85rem;
}
#scoreboard .entry {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card-bg);
  padding: 4px 10px;
  border-radius: 20px;
}
#scoreboard .entry.dead { opacity: 0.4; text-decoration: line-through; }
#scoreboard .dot { width: 10px; height: 10px; border-radius: 50%; }

#board-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--board-bg);
  border-radius: 8px;
  box-shadow: 0 0 0 2px var(--grid-line);
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 8px;
  text-align: center;
  padding: 16px;
}
#overlay h2 { margin: 0; font-size: 1.3rem; }
#results { width: 100%; max-width: 280px; display: flex; flex-direction: column; gap: 6px; }
.result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--board-bg);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
}
.result-row .place { color: var(--accent); font-weight: 700; width: 1.5em; }
.result-row .score { margin-left: auto; color: var(--muted); }

#controls {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 6px;
}
#controls button { font-size: 1.4rem; }
.c-up { grid-column: 2; grid-row: 1; }
.c-left { grid-column: 1; grid-row: 2; }
.c-right { grid-column: 3; grid-row: 2; }
.c-down { grid-column: 2; grid-row: 3; }
