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

html,
body {
  height: 100%;
  overflow: hidden;
  background: #040612;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#space {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: none;
  display: block;
}

/* 色を選ぶ点の列 */
#palette {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
  z-index: 2;
}

.swatch {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: var(--c);
  box-shadow: 0 0 8px var(--g);
  opacity: 0.35;
  cursor: pointer;
  transition: opacity 0.25s, box-shadow 0.25s, transform 0.25s;
}

.swatch:hover {
  opacity: 0.7;
}

.swatch.sel {
  opacity: 1;
  box-shadow: 0 0 14px var(--g), 0 0 0 1.5px var(--c);
  transform: scale(1.15);
}

/* 左下のツール群 */
#tools {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 3;
  display: flex;
  gap: 8px;
}

.tool {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(200, 215, 255, 0.14);
  color: rgba(210, 225, 255, 0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s, color 0.25s, box-shadow 0.25s;
}

.tool svg {
  width: 15px;
  height: 15px;
}

.tool.dim {
  opacity: 0.3;
}

.tool.on {
  background: rgba(200, 215, 255, 0.3);
  color: #fff;
  box-shadow: 0 0 12px rgba(180, 200, 255, 0.45);
}

/* 左下「?」と右下モード切替 */
#helpbtn,
#mode {
  position: fixed;
  bottom: 22px;
  z-index: 3;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(200, 215, 255, 0.14);
  color: rgba(210, 225, 255, 0.75);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.25s;
}

#helpbtn {
  left: 22px;
  bottom: 64px;
}

#mode {
  right: 22px;
  width: auto;
  padding: 0 10px;
  border-radius: 13px;
  gap: 3px;
}

#mode .lbl {
  font-size: 9px;
  letter-spacing: 0.08em;
  color: rgba(210, 225, 255, 0.7);
  margin-left: 3px;
}

/* 右上のミニマップ */
#minimap {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 108px;
  height: 108px;
  z-index: 3;
  border-radius: 12px;
  border: 1px solid rgba(160, 190, 255, 0.18);
  background: rgba(8, 12, 30, 0.4);
  touch-action: none;
  cursor: crosshair;
}

#mode .dot1 {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(210, 225, 255, 0.8);
  box-shadow: 0 0 6px rgba(180, 200, 255, 0.8);
}

#helpbtn:hover,
#mode:hover {
  background: rgba(200, 215, 255, 0.28);
}

/* 説明パネル */
#help {
  position: fixed;
  left: 22px;
  bottom: 60px;
  z-index: 3;
  max-width: 260px;
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(8, 12, 30, 0.85);
  border: 1px solid rgba(160, 190, 255, 0.18);
  backdrop-filter: blur(8px);
  color: rgba(220, 230, 255, 0.85);
  font-size: 0.72rem;
  line-height: 2;
  letter-spacing: 0.04em;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

#help.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#help .dim {
  margin-top: 6px;
  color: rgba(160, 175, 215, 0.6);
}

#keybtn,
#revivebtn {
  border: 1px solid rgba(160, 190, 255, 0.3);
  background: rgba(160, 190, 255, 0.12);
  color: rgba(210, 225, 255, 0.85);
  font-size: 0.68rem;
  padding: 3px 10px;
  border-radius: 10px;
  cursor: pointer;
}

/* 狭い画面ではツールを左端の縦列にしてパレットと重ならないように */
@media (max-width: 520px) {
  #tools {
    flex-direction: column;
    bottom: 60px;
    gap: 6px;
  }
  .tool {
    width: 28px;
    height: 28px;
  }
  #helpbtn {
    bottom: 22px;
  }
}
