:root {
  --bg: #0b0f14;
  --panel: #141a22;
  --ink: #f4f1e8;
  --accent: #ffcf4d;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(120% 120% at 50% 0%, #16202b 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas#game {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 0 2px rgba(255, 255, 255, 0.04);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 512 / 448;
}

#hint {
  position: fixed;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: rgba(244, 241, 232, 0.55);
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 10px;
  border-radius: 20px;
  pointer-events: none;
  white-space: nowrap;
}

.hidden { display: none !important; }

/* ---- Touch controls ---- */
#touch {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
#touch button {
  pointer-events: auto;
  appearance: none;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.10);
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  user-select: none;
}
#touch button:active { background: rgba(255, 255, 255, 0.28); }

.dpad {
  position: absolute;
  left: 22px;
  bottom: 26px;
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 4px;
}
.dpad [data-dir="up"] { grid-column: 2; grid-row: 1; }
.dpad [data-dir="left"] { grid-column: 1; grid-row: 2; }
.dpad [data-dir="down"] { grid-column: 2; grid-row: 3; }
.dpad [data-dir="right"] { grid-column: 3; grid-row: 2; }

.abtns {
  position: absolute;
  right: 26px;
  bottom: 30px;
  display: flex;
  gap: 14px;
  align-items: flex-end;
}
#btn-a { width: 64px; height: 64px; border-radius: 50%; font-size: 22px; }
#btn-b { width: 52px; height: 52px; border-radius: 50%; margin-bottom: 18px; }

@media (pointer: coarse) {
  #touch { display: block; }
}
