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

body {
  background: #1a1a2e;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Chrome mobile: excludes address bar */
  font-family: 'Courier New', monospace;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#game-container {
  position: relative;
  overflow: hidden;
}

canvas {
  display: block;
  image-rendering: pixelated;
}

/* ===== Touch Controls ===== */
#touch-controls {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

#touch-controls.visible {
  display: block;
}

.ctrl-btn {
  pointer-events: auto;
  position: absolute;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 28px;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.1s;
}

.ctrl-btn:active {
  background: rgba(255, 215, 0, 0.4);
}

/* Arrow button positions */
#btn-left {
  bottom: 16px;
  left: 16px;
}

#btn-right {
  bottom: 16px;
  left: 92px;
}

#btn-up {
  bottom: 120px;
  right: 16px;
}

#btn-down {
  bottom: 16px;
  right: 16px;
}

/* Pause & Mode buttons — positioned by JS */
#btn-pause,
#btn-mode {
  width: 44px;
  height: 44px;
  font-size: 18px;
  background: rgba(0, 0, 0, 0.45);
}

/* Gesture mode: flick replaces ◀▶; ▲▼ stay, stacked on the left edge */
#touch-controls.gesture-mode #btn-left,
#touch-controls.gesture-mode #btn-right {
  display: none;
}

#touch-controls.gesture-mode #btn-up {
  right: auto;
  left: 16px;
}

#touch-controls.gesture-mode #btn-down {
  right: auto;
  left: 16px;
}

/* Gesture mode without the ▲▼ keys (setting "上下キー": なし) */
#touch-controls.no-updown #btn-up,
#touch-controls.no-updown #btn-down {
  display: none;
}

/* ===== Overlay ===== */
#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10;
}

#overlay.hidden {
  display: none;
}

#overlay-content {
  background: #2a2a4a;
  border: 3px solid #8888cc;
  border-radius: 8px;
  padding: 24px;
  color: #eee;
  text-align: center;
  font-size: 16px;
  min-width: 240px;
}

#overlay-content .menu-item {
  padding: 8px 16px;
  margin: 4px 0;
  cursor: pointer;
}

#overlay-content .menu-item.selected {
  background: #4444aa;
  border-radius: 4px;
}

/* ===== Name registration (settings, OS keyboard) ===== */
#overlay-content .name-title {
  font-size: 20px;
  font-weight: bold;
  color: #FFD700;
  margin-bottom: 12px;
}

#overlay-content input#name-input {
  width: 100%;
  font-size: 20px; /* 16px or more keeps iOS from zooming in */
  font-family: 'Courier New', monospace;
  padding: 8px 10px;
  border: 2px solid #8888cc;
  border-radius: 6px;
  background: #fff;
  color: #222;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}

#overlay-content .name-note {
  font-size: 13px;
  color: #bbb;
  margin-top: 8px;
}

#overlay-content .name-error {
  font-size: 13px;
  color: #ff8080;
  min-height: 18px;
  margin-top: 4px;
}

#overlay-content .name-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 12px;
}

#overlay-content .name-buttons button {
  font-size: 16px;
  font-weight: bold;
  padding: 10px 18px;
  border-radius: 6px;
  border: 2px solid #666;
  background: #333;
  color: #eee;
  touch-action: manipulation;
}

#overlay-content .name-buttons #name-ok {
  border-color: #FFD700;
  background: #886610;
  color: #fff;
}
