/*
だいあぱんスタジオ Rev.A02.01
*/

/* 画面を固定し、スクロール・Pull to Refresh を止める
   （タッチ操作の禁止 touch-action は操作エリアごとに付ける。html に付けると操作説明がスクロールできないため。
     ページ拡大は dp_studio.js で止めている） */
html, body{
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: #b8b8b8;   /* 00bg.jpg の端と同じ色 */
}
body{
  position: fixed;
  inset: 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* 背景（位置・大きさ・回転は dp_studio.js が決める） */
#bg_image{
  position: absolute;
  top: 0; left: 0;
  max-width: none;
  height: auto;
  z-index: 0;
  /* 下地の色は付けない：iPhone で描き直しが遅れたとき下地だけが見えて光るため。
     00bg.jpg は白地に重ねた不透明な画像にしてある（透かしは 20watermark.png に分けた） */
}
/* 自分で選んだ画像のときだけ：iPhone の HDR 写真で画面が明るくならないようにする。
   html 全体に付けると iPhone の Safari で何も表示されなくなったので、背景画像だけに付ける。
   最初の背景は HDR ではないので付けない（描画の負担を減らすため） */
#bg_image.user-image{
  dynamic-range-limit: standard;
}

/* 「DiaPan Studio」の透かし：画面上部の中央に固定（最初の位置のキャラやボタンに被らない所）。
   最初の背景のときだけ出す。写真にも写す */
#watermark{
  position: absolute;
  top: 2vmin;
  left: 50%;
  width: 28vmin;
  transform: translateX(-50%);
  z-index: 5;
  pointer-events: none;
}
#watermark[hidden]{
  display: none;
}

/* キャラ配置エリア */
#stage{
  position: absolute;
  inset: 0;
  z-index: 10;
  touch-action: none;
}
.dp-chara{
  position: absolute;
  height: auto;
  cursor: grab;
  touch-action: none;
}
.dp-chara.dragging{
  cursor: grabbing;
}

/* 絵柄の候補（キャラ長押しで出る輪） */
#picker{
  position: absolute;
  inset: 0;
  z-index: 200;
  background-color: rgba(0, 0, 0, 0.3);
  touch-action: none;
}
.dp-pick{
  position: absolute;
  width: var(--pick-size);
  height: var(--pick-size);
  border-radius: 50%;
  background-color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translate(var(--from-x), var(--from-y)) scale(0.3);
  transition: transform 200ms ease-out, opacity 200ms ease-out;
}
#picker.open .dp-pick{
  opacity: 1;
  transform: none;
}
.dp-pick img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
/* 今の絵柄 */
.dp-pick.current{
  box-shadow: 0 0 0 3px #ff5fa2, 0 2px 6px rgba(0, 0, 0, 0.35);
}
.dp-pick.random{
  background-color: #ff5fa2;
  color: #ffffff;
  font-weight: bold;
  line-height: 1;
}
.dp-pick.random .q{
  font-size: calc(var(--pick-size) * 0.45);
}
.dp-pick.random .label{
  font-size: calc(var(--pick-size) * 0.2);
}
@media (prefers-reduced-motion: reduce){
  .dp-pick{ transition: none; }
}

/* ****アイコン**** */
#ui{
  position: absolute;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}
.ui-btn, .ui-icon{
  position: absolute;
  object-fit: contain;
  transition: transform 300ms, opacity 300ms;
}
.ui-btn{
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;
}
/* 長押し中（背景変更ボタン）：押し込まれた感じにする */
.ui-btn.pressing,
.ui-btn.pressing:hover{
  transform: scale(0.85);
  transition: transform 600ms;
}
@media (hover: hover){
  .ui-btn:hover{
    transform: scale(1.15);
  }
}
/* 撮った写真のプレビュー */
#shot{
  position: absolute;
  inset: 0;
  z-index: 300;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  box-sizing: border-box;
  touch-action: none;
}
#shot[hidden]{
  display: none;
}
/* 写真と、トリミングの枠を重ねる入れ物 */
#shot_frame{
  position: relative;
  line-height: 0;
  border: 4px solid #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  overflow: hidden;   /* 枠の外を暗くする影をはみ出させない */
}
#shot_image{
  display: block;
  max-width: calc(100vw - 40px);
  max-height: 65vh;
  -webkit-touch-callout: default;   /* 長押しで保存できるようにする */
}
#shot_hint{
  margin: 0;
  color: #ffffff;
  font-size: 13px;
}
.shot-buttons{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.shot-buttons[hidden]{
  display: none;
}
.shot-buttons button{
  font-size: 15px;
  font-weight: bold;
  padding: 10px 18px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  background-color: #ffffff;
  color: #333333;
}
.shot-buttons button:disabled{
  opacity: 0.4;
  cursor: default;
}
#shot_save,
#crop_ok{
  background-color: #ff5fa2;
  color: #ffffff;
}

/* トリミングの枠：枠の外は大きな影で暗くする */
#crop_box{
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  cursor: move;
  touch-action: none;
}
#crop_box[hidden]{
  display: none;
}
.crop-handle{
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: #ff5fa2;
  border: 3px solid #ffffff;
  box-sizing: border-box;
  touch-action: none;
}
/* つまみは枠の内側の角に置く（写真の端でも隠れないように） */
.crop-handle[data-corner="tl"]{ left: -3px;  top: -3px;    cursor: nwse-resize; }
.crop-handle[data-corner="tr"]{ right: -3px; top: -3px;    cursor: nesw-resize; }
.crop-handle[data-corner="bl"]{ left: -3px;  bottom: -3px; cursor: nesw-resize; }
.crop-handle[data-corner="br"]{ right: -3px; bottom: -3px; cursor: nwse-resize; }

/* シャッターの光（光るときだけ表示する） */
#flash{
  display: none;
  position: absolute;
  inset: 0;
  z-index: 400;
  background-color: #ffffff;
  opacity: 0;
  pointer-events: none;
}
#flash.on{
  display: block;
  animation: flash 300ms ease-out;
}
@keyframes flash{
  from{ opacity: 0.9; }
  to{ opacity: 0; }
}
@media (prefers-reduced-motion: reduce){
  #flash.on{ animation: none; }
}

/* 横方向と大きさは画面の短い辺(vmin)基準：スマホ縦持ちでは従来の%と同じ、PCでは大きくなりすぎない */
#btn_pannosaki{ top: 2%;                  right: 5vmin; width: 16vmin; }
#btn_mnempn   { top: calc(2% + 18vmin);   right: 5vmin; width: 16vmin; }   /* ぱんノ咲の下 */
#btn_village  { top: calc(2% + 36vmin);   right: 5vmin; width: 16vmin; }   /* ミニえもぱんの下 */
#btn_mnempn[hidden]{ display: none; }
#btn_bg       { bottom: 16%; left: 5vmin; width: 10vmin; }
#btn_camera   { bottom: 2%; right: 5vmin; width: 20vmin; }
#btn_help     { bottom: calc(2% + 17vmin); right: 10vmin; width: 10vmin; }   /* カメラの上 */

/* 操作説明 */
#help{
  position: absolute;
  inset: 0;
  z-index: 300;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  touch-action: none;
}
#help[hidden]{
  display: none;
}
#help_panel{
  background-color: #ffffff;
  color: #333333;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;   /* 縦スクロールだけ許す */
  padding: 20px 20px 16px;
  box-sizing: border-box;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Meiryo", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}
#help_panel h1{
  font-size: 18px;
  margin: 0 0 8px;
  color: #ff5fa2;
}
#help_panel h2{
  font-size: 15px;
  margin: 16px 0 6px;
  padding-bottom: 2px;
  border-bottom: 2px solid #ffd1e4;
}
/* 項目名の下に説明を置く（横並びだとスマホ幅で説明が細切れに折り返すため） */
#help_panel dl{
  margin: 0;
}
#help_panel dt{
  font-weight: bold;
  margin-top: 6px;
}
#help_panel dd{
  margin: 0 0 0 1em;
}
#help_panel .pc{
  display: block;
  font-size: 12px;
  color: #888888;
}
#help_panel .note{
  margin: 6px 0 0;
  font-size: 12px;
  color: #888888;
}
#help_panel .buttons{
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
#help_panel .buttons li{
  display: flex;
  align-items: center;
  gap: 10px;
}
#help_panel .buttons li[hidden]{
  display: none;
}
#help_panel .buttons img{
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex: none;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.5));   /* 白っぽいアイコンを白地で見やすくする */
}
#help_panel .buttons b{
  display: block;
}
#help_close{
  display: block;
  margin: 16px auto 0;
  font-size: 16px;
  font-weight: bold;
  padding: 10px 40px;
  border: none;
  border-radius: 999px;
  background-color: #ff5fa2;
  color: #ffffff;
  cursor: pointer;
}

#icon_n   { bottom: 3%; left: 5vmin;  width: 10vmin; }
#btn_n_add{ bottom: 2%; left: 3vmin;  width: 5vmin; }
#btn_n_rem{ bottom: 2%; left: 12vmin; width: 5vmin; }

#icon_b   { bottom: 3%; left: 20vmin; width: 10vmin; }
#btn_b_add{ bottom: 2%; left: 18vmin; width: 5vmin; }
#btn_b_rem{ bottom: 2%; left: 27vmin; width: 5vmin; }
