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

body {
  background: #0f0f0f;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100svh;
  font-family: 'Courier New', monospace;
  color: #fff;
  user-select: none;
  overflow: hidden;
}

h1 {
  font-size: 2rem;
  letter-spacing: 0.3em;
  color: #4ade80;
  margin-bottom: 1rem;
  text-transform: uppercase;
}

#hud {
  display: flex;
  gap: 3rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #aaa;
  letter-spacing: 0.1em;
}

#hud span { color: #fff; font-weight: bold; }
#combo { transition: color 0.2s, transform 0.15s; display: inline-block; }
#combo.hot { color: #facc15; transform: scale(1.25); }

#canvas-wrapper { position: relative; }

canvas {
  display: block;
  border: 2px solid #333;
  border-radius: 4px;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.82);
  border-radius: 4px;
  gap: 1rem;
}

#overlay h2 { font-size: 2rem; letter-spacing: 0.2em; }
#overlay p  { color: #aaa; font-size: 0.85rem; letter-spacing: 0.05em; }

#overlay button {
  margin-top: 0.5rem;
  padding: 0.6rem 2.4rem;
  background: #4ade80;
  color: #0f0f0f;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.15s;
}

#overlay button:hover { background: #86efac; }

#hint { margin-top: 0.75rem; font-size: 0.75rem; color: #999; letter-spacing: 0.05em; }

/* ── Focus visible ──────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid #4ade80;
  outline-offset: 3px;
  border-radius: 3px;
}

#speed-selector { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
#speed-label { font-size: 0.75rem; color: #999; letter-spacing: 0.12em; }
#speed-btns { display: flex; gap: 0.3rem; }
#speed-btns button {
  margin: 0; padding: 0.3rem 0;
  width: 2rem; text-align: center;
  background: #1a1a1a; color: #999;
  border: 1px solid #333; border-radius: 3px;
  font-family: inherit; font-size: 0.8rem; font-weight: bold;
  cursor: pointer; transition: background 0.1s, color 0.1s, border-color 0.1s;
}
#speed-btns button:hover { background: #222; color: #aaa; border-color: #555; }
#speed-btns button.active { background: #166534; color: #4ade80; border-color: #4ade80; }

#gamepad-status {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  font-size: 0.7rem;
  color: #666;
  letter-spacing: 0.05em;
  transition: color 0.3s;
}
#gamepad-status.on { color: #4ade80; }

/* ── Mobile / responsive ───────────────────────────────────────────────── */
#canvas-wrapper {
  width: min(560px, calc(100vw - 8px), calc(100svh - 300px));
  aspect-ratio: 1 / 1;
}

canvas { touch-action: none; width: 100%; height: 100%; }

/* D-pad */
#dpad {
  display: none;
  margin-top: 1.25rem;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(3, 64px);
  gap: 6px;
}
#dpad button {
  background: #1a1a1a;
  color: #4ade80;
  border: 1px solid #333;
  border-radius: 8px;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, border-color 0.1s;
  -webkit-tap-highlight-color: transparent;
}
#dpad button:active { background: #166534; border-color: #4ade80; }
#dpad-up    { grid-column: 2; grid-row: 1; }
#dpad-left  { grid-column: 1; grid-row: 2; }
#dpad-right { grid-column: 3; grid-row: 2; }
#dpad-down  { grid-column: 2; grid-row: 3; }

@media (pointer: coarse), (max-width: 600px) {
  #dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); gap: 4px; margin-top: 0.75rem; }
  h1 { font-size: 1.3rem; margin-bottom: 0.4rem; }
  #hud { gap: 0.6rem; font-size: 0.72rem; letter-spacing: 0; margin-bottom: 0.4rem; }
  #overlay { gap: 0.6rem; }
  #speed-btns { flex-wrap: wrap; justify-content: center; max-width: 190px; }
  #speed-btns button { width: 1.8rem; padding: 0.3rem 0; font-size: 0.75rem; }
  #overlay button { margin-top: 0; padding: 0.6rem 2rem; font-size: 1rem; }
  #hint { margin-top: 0.2rem; }
}
