body {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  position: relative;
  font-family: sans-serif;
  background: #f5f5f5;
}

#app {
  position: relative;
}

/* 左上：操作ボタン */
#controls {
  position: fixed;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  z-index: 1000;
}

/* 右上：サイズ表示＋縮小 */
#sizeArea {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 1000;
}

#sizeInfo {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 14px;
}

/* 画像表示 */
#canvasArea {
  position: relative;
  display: inline-block;
}

#preview {
  display: none;
  max-width: 72vw;
  max-height: 72vh;
  width: auto;
  height: auto;
  vertical-align: middle;
}

/* ＋ボタン */
.plus {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  color: white;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  display: none;
  z-index: 10;
}

/* 外側（メイン：青） */
.plus[data-pos="top"],
.plus[data-pos="bottom"],
.plus[data-pos="left"],
.plus[data-pos="right"] {
  background: rgba(0, 110, 255, 0.85);
}

/* 内側（サブ） */
.plus[data-pos="top-inner"],
.plus[data-pos="bottom-inner"],
.plus[data-pos="left-inner"],
.plus[data-pos="right-inner"] {
  background: rgba(0, 0, 0, 0.6);
}

.plus:hover {
  filter: brightness(1.1);
}

.plus:active {
  transform: scale(0.95);
}

/* 外側配置 */
[data-pos="top"] {
  top: -38px;
  left: 50%;
  transform: translateX(-50%);
}

[data-pos="bottom"] {
  bottom: -38px;
  left: 50%;
  transform: translateX(-50%);
}

[data-pos="left"] {
  left: -38px;
  top: 50%;
  transform: translateY(-50%);
}

[data-pos="right"] {
  right: -38px;
  top: 50%;
  transform: translateY(-50%);
}

/* 内側配置 */
[data-pos="top-inner"] {
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
}

[data-pos="bottom-inner"] {
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
}

[data-pos="left-inner"] {
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
}

[data-pos="right-inner"] {
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
}

/* モーダル共通 */
#resizeModal,
#resetModal,
#warningModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

#resizeBox,
#resetBox,
#warningBox {
  background: white;
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  min-width: 280px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#warningBox {
  max-width: 360px;
}

#resizeBox h3,
#resetBox h3,
#warningBox h3 {
  margin-top: 0;
  margin-bottom: 16px;
}

#resetBox p,
#warningBox p {
  margin: 0 0 16px 0;
  font-size: 16px;
}

#resizeSlider {
  width: 100%;
  margin: 12px 0;
}

#resizePercent,
#resizeResultWrap {
  margin-top: 8px;
  font-size: 16px;
}

#resizeResultWrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#resizeDanger {
  color: #d90000;
  font-weight: bold;
  font-size: 14px;
}

.modalButtons {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* 警告4択 */
#warningButtons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
}

#warningButtons button {
  padding: 10px 14px;
  font-size: 14px;
}

button {
  font-size: 14px;
  padding: 8px 12px;
}

/* =========================
   スマホ最適化
========================= */
@media (max-width: 700px) {
  #controls {
    top: 8px;
    left: 8px;
    gap: 6px;
    max-width: 52vw;
  }

  #sizeArea {
    top: 8px;
    right: 8px;
    gap: 6px;
    max-width: 40vw;
  }

  #sizeInfo {
    font-size: 12px;
    padding: 6px 10px;
  }

  button {
    font-size: 12px;
    padding: 6px 10px;
  }

  #preview {
    max-width: 68vw;
    max-height: 68vh;
  }

  .plus {
    width: 34px;
    height: 34px;
    font-size: 20px;
  }

  /* 外側（スマホ用） */
  [data-pos="top"] {
    top: -32px;
  }

  [data-pos="bottom"] {
    bottom: -32px;
  }

  [data-pos="left"] {
    left: -32px;
  }

  [data-pos="right"] {
    right: -32px;
  }

  /* 内側 */
  [data-pos="top-inner"] {
    top: 12px;
  }

  [data-pos="bottom-inner"] {
    bottom: 12px;
  }

  [data-pos="left-inner"] {
    left: 12px;
  }

  [data-pos="right-inner"] {
    right: 12px;
  }
}