/* 歩行スプライト生成ツール スタイル */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  font-size: 14px; background: #1e2230; color: #e8eaf2;
  overscroll-behavior: none;
}
#app { display: flex; height: 100%; }

/* ===== 左パネル ===== */
#panel {
  width: 280px; min-width: 280px; height: 100%; overflow-y: auto;
  background: #262b3d; padding: 12px; border-right: 1px solid #3a4160;
  -webkit-overflow-scrolling: touch;
}
#panel h1 { font-size: 16px; margin-bottom: 10px; color: #9fd8ef; }
#panel section { margin-bottom: 14px; border-bottom: 1px solid #333a55; padding-bottom: 10px; }
#panel h2 { font-size: 13px; color: #8fa3d0; margin-bottom: 6px; }
label { display: block; margin: 6px 0; font-size: 13px; }
select, input[type="number"] {
  width: 100%; margin-top: 3px; padding: 6px; border-radius: 6px;
  border: 1px solid #4a5378; background: #1a1e2c; color: #fff; font-size: 14px;
}
input[type="range"] { width: 70%; vertical-align: middle; }
.val { display: inline-block; min-width: 44px; text-align: right; color: #9fd8ef; font-size: 12px; }
.checkRow { display: flex; align-items: center; gap: 6px; }
.checkRow input { width: 18px; height: 18px; }
.colorRow { display: flex; align-items: center; justify-content: space-between; margin: 4px 0; }
.colorRow input[type="color"] { width: 52px; height: 28px; border: none; background: none; }
.hidden { display: none !important; }
details summary { cursor: pointer; color: #8fa3d0; font-size: 13px; margin: 6px 0; }

.dirGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 6px 0; }
.dirBtn {
  padding: 8px 0; border-radius: 6px; border: 1px solid #4a5378;
  background: #1a1e2c; color: #cdd4ea; font-size: 13px; cursor: pointer;
}
.dirBtn.active { background: #4a7fd6; color: #fff; border-color: #4a7fd6; }

.fileLabel input[type="file"] { display: block; margin-top: 4px; font-size: 12px; width: 100%; }
.miniBtn, .btnRow button, .btnLike {
  padding: 8px 10px; border-radius: 8px; border: 1px solid #4a5378;
  background: #323a58; color: #fff; font-size: 13px; cursor: pointer;
}
.btnRow button.primary { background: #4a7fd6; border-color: #4a7fd6; }
.btnRow { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.btnLike { display: inline-block; }
.btnLike input { display: none; }

.debugList { list-style: none; font-size: 11px; max-height: 160px; overflow-y: auto; margin-top: 6px; }
.debugList li { padding: 2px 4px; border-bottom: 1px dotted #3a4160; }
.debugList .cat { color: #9fd8ef; font-weight: bold; }

/* ===== 中央 ===== */
#center { flex: 1; height: 100%; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
#previewWrap { display: flex; flex-direction: column; align-items: center; }
#preview {
  background:
    repeating-conic-gradient(#2a3048 0% 25%, #232840 0% 50%) 0 0 / 24px 24px;
  border: 1px solid #3a4160; border-radius: 8px;
  image-rendering: pixelated; image-rendering: crisp-edges;
  max-width: 100%;
  /* プレビューcanvasにドラッグ操作は無いため、スクロール等は
     ブラウザ既定動作に渡す。iOSのWKWebViewはpan-y等の対応が
     不完全な場合があるため、最も互換性の高いmanipulationを使用
     (パン・ピンチを許可、ダブルタップズームのみ無効) */
  touch-action: manipulation;
}
#previewInfo { font-size: 12px; color: #8fa3d0; margin-top: 4px; }
.playRow { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 10px 0; }
.playRow button { padding: 8px 14px; border-radius: 8px; border: none; background: #4a7fd6; color: #fff; font-size: 14px; }

#bottom { margin-top: 8px; border-top: 1px solid #3a4160; padding-top: 10px; }
#bottom h2 { font-size: 14px; color: #8fa3d0; margin-bottom: 6px; }
#sheetWrap {
  overflow-x: auto; background:
    repeating-conic-gradient(#2a3048 0% 25%, #232840 0% 50%) 0 0 / 16px 16px;
  border: 1px solid #3a4160; border-radius: 8px; min-height: 80px; padding: 4px;
}
#sheetCanvas { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
#status { font-size: 12px; color: #9fd8ef; min-height: 18px; margin-top: 4px; }

/* iPad縦持ち・狭い画面: 縦並び */
@media (max-width: 760px) {
  #app { flex-direction: column; }
  #panel { width: 100%; min-width: 0; height: 44%; border-right: none; border-bottom: 1px solid #3a4160; }
  #center { height: 56%; }
  /* スマホ: プレビューを画面高さの約1/3に制限し、
     下の情報表示・再生ボタン・シート欄までスクロールで届くようにする */
  #preview { width: min(92vw, 34vh); height: min(92vw, 34vh); }
}

/* モバイルブラウザのアドレスバー変動対策(対応環境のみdvhを使用)。
   Flutter WebView内では100%と同値のため影響なし */
@supports (height: 100dvh) {
  @media (max-width: 760px) {
    #app { height: 100dvh; }
  }
}

/* ===== Pro機能UI ===== */
.dirGrid8 { grid-template-columns: repeat(3, 1fr); }
.hint { font-size: 11px; color: #7d88ad; margin: 4px 0; }
.lockIcon { font-size: 11px; margin-left: 2px; }
body.pro .lockIcon { display: none; }
.proBadge {
  display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 8px;
  background: #d6a44a; color: #1e2230; font-weight: bold; margin-left: 4px; vertical-align: middle;
}
.proSection { margin: 10px 0; border: 1px dashed #4a5378; border-radius: 8px; padding: 8px; }
.proSection h3 { font-size: 12px; color: #8fa3d0; margin-bottom: 6px; }
body:not(.pro) .proSection .proSectionBody { opacity: 0.45; pointer-events: none; }
.optGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; }
.optGrid label { font-size: 12px; }
.optGrid input { width: 100%; }

.itemList { list-style: none; margin-top: 6px; }
.itemList li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 4px; border-bottom: 1px dotted #3a4160; font-size: 12px;
}
.thumb { width: 40px; height: 40px; border-radius: 6px; background: #1a1e2c; object-fit: contain;
  image-rendering: pixelated; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.thumbFile { font-size: 20px; }
.itemBody { flex: 1; min-width: 0; }
.itemName { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.itemMeta { font-size: 10px; color: #7d88ad; }
.itemBtns { display: flex; gap: 4px; flex-shrink: 0; }
.miniBtn.tiny { padding: 4px 8px; font-size: 11px; }

.promoBox {
  margin: 12px 0; padding: 10px; border-radius: 8px;
  background: #2c3654; border: 1px solid #4a7fd6; font-size: 12px; line-height: 1.6;
}

.modalOverlay {
  position: fixed; inset: 0; background: rgba(10, 12, 20, 0.7);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modalBox {
  background: #262b3d; border: 1px solid #4a5378; border-radius: 12px;
  padding: 20px; max-width: 340px; width: 88%;
}
.modalBox h2 { font-size: 15px; color: #ffd98a; margin-bottom: 8px; }
.modalBox p { font-size: 13px; line-height: 1.6; margin: 6px 0; }
.modalBox .modalSub { color: #a8b3d6; font-size: 12px; }

/* iPad / タブレット横画面(広い画面)最適化 */
@media (min-width: 1000px) {
  #panel { width: 320px; min-width: 320px; }
  #center { display: flex; flex-direction: column; }
  #previewWrap { flex: 1; justify-content: center; }
  #preview { width: min(56vh, 560px); height: min(56vh, 560px); }
}


/* ===== 公開済みアプリへの誘導バー ===== */
.nativeAppBar {
  position: sticky;
  top: 0;
  z-index: 10000;
  min-height: 64px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  background: rgba(19, 23, 31, 0.97);
  border-bottom: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 3px 14px rgba(0,0,0,.28);
  color: #fff;
}
.nativeAppBar.is-hidden { display: none; }
.nativeAppBarIcon {
  width: 44px; height: 44px; flex: 0 0 44px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, #6aa8ff, #4a7fd6);
  font-size: 24px; font-weight: 800;
}
.nativeAppBarText { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.nativeAppBarText strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nativeAppBarText span { margin-top: 4px; font-size: 12px; opacity: .72; }
.nativeAppBarButton {
  margin-left: auto;
  padding: 9px 16px;
  border: 0; border-radius: 18px;
  background: #4a7fd6; color: white;
  font-weight: 700; font-size: 15px;
  cursor: pointer;
}
.nativeAppBarClose {
  width: 32px; height: 32px; padding: 0;
  border: 0; background: transparent; color: rgba(255,255,255,.72);
  font-size: 25px; line-height: 1; cursor: pointer;
}
@media (min-width: 760px) {
  .nativeAppBar { padding-left: 18px; padding-right: 18px; }
}
