:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #30363d;
  --ink: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.game {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: 2rem;
}

.actions {
  display: flex;
  gap: 8px;
}

button {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button:focus-visible,
.board:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.scores {
  display: flex;
  gap: 24px;
  margin-top: 12px;
}

.scores p {
  margin: 0;
  color: var(--muted);
}

.scores strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.help {
  color: var(--muted);
  margin: 12px 0 16px;
  font-size: 0.95rem;
}

.board {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  touch-action: none;
}

.status {
  min-height: 1.5em;
  margin: 12px 0 0;
  text-align: center;
  color: var(--muted);
}

.pad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(2, 56px);
  grid-template-areas:
    ". up ."
    "left down right";
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

.pad button {
  padding: 0;
  font-size: 1.2rem;
  touch-action: manipulation;
}

.pad-up { grid-area: up; }
.pad-left { grid-area: left; }
.pad-right { grid-area: right; }
.pad-down { grid-area: down; }

@media (max-width: 400px) {
  .game {
    padding: 16px 12px 32px;
  }

  .help {
    font-size: 0.9rem;
  }
}

@media (hover: hover) and (pointer: fine) {
  .pad {
    display: none;
  }
}
