* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --accent: #ffcb05;
  --blue: #3b4cca;
  --muted: #8b949e;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 20%, #1a2744 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, #1a3a28 0%, transparent 50%),
    var(--bg);
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  max-width: 100vw;
}

header {
  text-align: center;
  user-select: none;
}

header h1 {
  font-family: "Courier New", monospace;
  font-size: 1.5rem;
  color: var(--accent);
  text-shadow: 2px 2px 0 var(--blue);
  letter-spacing: 0.08em;
}

header p {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 4px;
}

#game-wrap {
  position: relative;
  border: 4px solid #404060;
  border-radius: 8px;
  box-shadow:
    0 0 0 2px #90a0c0,
    0 12px 40px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px #202030;
  background: #000;
  line-height: 0;
}

#game-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  max-width: min(100vw - 32px, 480px);
  width: 480px;
  height: auto;
  background: #000;
}

#controls {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
  user-select: none;
}

.dpad {
  display: grid;
  grid-template-columns: 48px 48px 48px;
  grid-template-rows: 48px 48px 48px;
  gap: 4px;
}

.dpad .spacer { visibility: hidden; }

.btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(160deg, #3a3f4b, #2a2f3a);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 3px 0 #1a1f28, 0 4px 8px rgba(0,0,0,0.3);
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #1a1f28;
}

.action-btns {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn.a {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(160deg, #e06060, #c03030);
  font-size: 0.85rem;
}

.btn.b {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(160deg, #6080e0, #3040a0);
  font-size: 0.85rem;
}

#help {
  max-width: 480px;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

#help strong {
  color: var(--accent);
}

#help kbd {
  background: #21262d;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: "Courier New", monospace;
  font-size: 0.75rem;
  color: var(--text);
}

@media (max-width: 520px) {
  #game-canvas {
    width: 100%;
    max-width: 100vw;
  }
  header h1 { font-size: 1.2rem; }
}
