/* ベース */
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Helvetica Neue", "Noto Sans JP", "Segoe UI", Roboto, "Yu Gothic", sans-serif;
  display: flex;
  height: 100vh;
  background: #f1edeb;
  color: #111;
}

/* 左メニュー */
#menu {
  width: 220px;
  background: linear-gradient(180deg,#1f2937,#111827);
  color: #fff;
  padding: 12px;
  box-sizing: border-box;
  border-top-right-radius: 18px;
  border-bottom-right-radius: 18px;
  box-shadow: 6px 0 20px rgba(0,0,0,0.12);
}

.menu-item, .menu-parent {
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 10px;
  margin-bottom: 6px;
  font-family:"Helvetica Neue", Arial, "Hiragino Mincho ProN", "YuMincho", "Hiragino Mincho Pro", "Yu Mincho", serif;
}

.menu-children {
  display: none;
}


.menu-item:hover, .menu-parent:hover { background: rgba(255,255,255,0.04); }

/* メインエリア */
#main { flex:1; display:flex; align-items:center; justify-content:center; padding:20px; }

/* アプリ領域 */
#app {
  width: 92%;
  max-width: 720px;
  text-align: center;
  position: relative;
}

/* top controls（右上） */
#topControls { position: absolute; top: 20px; right: 200px; display:flex; gap:8px; z-index:30;}
.icon-btn { border: none; background: #fff; padding:15px 25px; border-radius:20px; box-shadow:0 6px 18px rgba(0,0,0,0.08); cursor:pointer; font-size:16px; }
.icon-btn:hover { transform: translateY(-2px); }


/* 保存ボタン（右上） */
.save-btn {
  position: fixed;
  right: 45px;
  top: 15px;
  background: #63896d;
  color: white;
  padding: 20px 50px;
  border: none;
  border-radius: 30px;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 10px 30px rgba(3,105,161,0.18);
  cursor: pointer;
  z-index: 70;
}

/* カード（丸っこく） */
.card {
  position: relative;
  width: 100%;
  height: 340px;
  perspective: 1200px;
  cursor: pointer;
  margin: 12px 0;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  border-radius: 22px;
}

.card.flipped .card-inner { transform: rotateY(180deg); }

.face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  background: linear-gradient(180deg,#ffffff,#f7fbff);
  border-radius: 22px;
  box-shadow: 0 16px 40px rgba(16,24,40,0.12);
  padding: 18px;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.face .face-top { display:flex; justify-content:flex-end; position: relative;}
.icon-small { background: transparent; border: none; font-size:20px; cursor:pointer; padding:8px; border-radius:10px; }
.filter { position: absolute; top: 15px; left:15px; z-index: 5; transition: opacity 0.01s ease; pointer-events: auto; background: transparent; border: none; font-size:20px; cursor:pointer; padding:8px; border-radius:10px;  }
.card.flipped > .filter {
  opacity: 0;
  pointer-events: none;
}
.card:not(.flipped) > .filter {
  transition-delay: 0.55s;
}


.face-content {
  flex:1;
  display:flex;
  justify-content:center;
  align-items:center;
  font-size:28px;
  text-align:center;
  white-space: pre-line;
  padding: 6px 14px;
}

/* back face style */
.back { transform: rotateY(180deg); background: linear-gradient(180deg,#eef3ff,#f0f7ff); }
.back .face-content { margin-bottom:40px; margin-left:10px; }

/* bottom controls inside card */
.face-bottom { display:flex; justify-content:flex-end; gap:10px; align-items:center; margin-top:8px; position:relative; }

.level-badge {
  background: #ffffff;
  border-radius: 14px;
  padding: 8px 12px;
  box-shadow: 0 8px 20px rgba(16,24,40,0.08);
  cursor:pointer;
}

/* レベル選択パネル */
.level-selector {
  position: absolute;
  right: 18px;
  bottom: 58px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  overflow: hidden;
  display:flex;
  flex-direction: column;
  z-index: 40;
}
.level-item {
  padding: 10px 18px;
  cursor: pointer;
  min-width: 48px;
}
.level-item:hover { background: #f3f4f6; }

/* コントロールボタン */
.controls { margin-top:12px; display:flex; gap:12px; justify-content:center; }
button.rounded { background:#fff; border:none; padding:10px 18px; border-radius:14px; box-shadow:0 8px 20px rgba(16,24,40,0.06); cursor:pointer; font-size:16px; }
button.rounded:hover { transform: translateY(-2px); }

/* スライダー */
input[type="range"] { height: 40px; border-radius:20px; }

/* フィルタパネル */
.panel {
  position: absolute;
  top: 30px;
  left: 60px;
  width: 70px;
  background: white;
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
  z-index: 50;
}


/* モーダル */
.modal {
  position: fixed;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,0.36);
  z-index: 80;
}
.modal.large .modal-content { width: 90%; max-width: 900px; max-height: 80vh; overflow:auto; }
.modal-content {
  position: relative;
  background: white;
  padding: 40px;
  border-radius: 16px;
  gap: 10px;
  width: 480px;
  box-shadow: 0 20px 60px rgba(2,6,23,0.2);

}
/* モーダル右上の × ボタン */
.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  border: none;
  border-radius: 8px;
  padding: 4px 8px;
  background: transparent;
  font-size: 30px;
  cursor: pointer;
  line-height: 1;
  color: #444;
}

.modal-close:hover {
  color: #000;
}

.modal-select{
  border-radius:10px;
  margin: 10px 0px 10px 10px;
  padding : 10px;
}
.modal-textbox{
  margin: 5px 0px 8px 0px;
  width: 480px;
  height: 70px;
  resize: none;
  font-size: 18px;
  font-family:"Helvetica Neue", Arial, "Hiragino Mincho ProN", "YuMincho", "Hiragino Mincho Pro", "Yu Mincho", serif;
  border-radius: 15px;
  padding: 10px;
}

.hidden {
  display: none !important;
}

.modal-content h3 { margin-top:0; }

/* バッチリスト */
.patch_bar{
  border: 1px solid #a3a3a3;
  border-radius: 15px;
  height : 36px;
  margin-top: 12px;
}
.batch-list { max-height: 48vh; overflow:auto; margin-top:8px; border-radius:10px; background:#fafafa; padding:8px; }
.batch-row { display:flex; gap:8px; align-items:center; padding:8px; border-bottom:1px solid #eee; border-radius:8px; }
.batch-row:last-child { border-bottom: none; }
.batch-row .num { width:36px; text-align:center; color:#666; }
.batch-row .text { flex:1; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.batch-row .lv { width:48px; text-align:center; }
.batch-text {
  width: 3500px;
  height: 40px;
  resize: none;
  border-radius: 10px;
  padding: 6px;
  border: 1px solid #ccc;
}


/* loading spinner */
#loading { position: fixed; inset: 0; display:flex; align-items:center; justify-content:center; z-index: 9999; }
.spinner {
  width: 56px; height:56px;
  border: 6px solid #e6eef6;
  border-top: 6px solid #0891b2;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#batchBottomBar {
  justify-content: flex-end;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================
   スマホ用レスポンシブ設定 (768px以下)
   ========================================= */
@media (max-width: 768px) {

  /* ボディ：縦並びレイアウトに変更 */
  body {
    flex-direction: column;
    height: 100vh; /* 画面いっぱいに固定 */
    overflow: hidden; /* 全体のスクロールを禁止（内部でスクロールさせる） */
    background: #f1edeb;
  }

  /* -------------------------
     1. 上部メニューバー
     ------------------------- */
  #menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: auto; /* 開いたときに伸びるように */
    min-height: 60px;
    border-radius: 0 0 15px 15px; /* 下側だけ丸く */
    z-index: 1000;
    
    /* 横並び設定 */
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    overflow-x: auto; /* 横スクロール許可 */
    white-space: nowrap;
    padding: 15px;
    gap: 10px;
  }

  /* メニューの各グループ */
  .menu-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 4px;
  }

  .menu-parent {
    margin: 0;
    padding: 8px 12px;
    font-size: 20px;
  }

  /* 子メニュー（展開時）のデザイン調整 */
  .menu-children {
    position: relative;
    background: transparent;
    padding-left: 10px;
  }
  .menu-item {
    font-size: 17px;
    padding: 8px;
  }

  /* -------------------------
     2. 下部操作バー (一覧・保存)
     ------------------------- */
  #topControls {
    position: fixed;
    top: auto;    /* 上部固定を解除 */
    right: auto;
    bottom: 15px;    /* 下部に固定 */
    left: 0;
    width: 100%;
    height: 90px;
    background: transparent;
    z-index: 1000;
    display: flex;
    justify-content: space-around; /* 均等配置 */
    align-items: center;
    padding: 0;
    gap: 0;
  }

  /* ボタンのスタイル上書き */
  .icon-btn {
    position: static;
    transform: none;
    box-shadow: none;
    background: #ffffff;
    color: #333;
    font-weight: bold;
    font-size: 15px;
    border: 1px solid #eee;
    padding: 20px 20px;
    width: 40%; /* 幅を広めに */
  }

  /* 保存ボタンの固定位置解除とスタイル調整 */
  .save-btn {
    position: static; /* 固定解除 */
    margin: 0;
    border-radius: 12px;
    padding: 20px 20px;
    width: 40%;
    font-size: 15px;
    box-shadow: none;
  }

  /* -------------------------
     3. メインエリア (カードとスライダー)
     ------------------------- */
  #main {
    margin-top: 70px;    /* 上部メニューの分空ける */
    margin-bottom: 70px; /* 下部バーの分空ける */
    padding: 10px;
    height: calc(100vh - 140px); /* 上下の高さを引いた残り */
    overflow-y: auto;    /* コンテンツが多い場合はスクロール */
    display: flex;
    align-items: center; /* 上下中央寄せ */
  }

  #app {
    width: 100%;
    max-width: 100%;
  }

  /* カードの高さ調整 */
  .card {
    height: 50vh; /* 画面の半分の高さ */
    max-height: 400px;
    margin: 0 auto 20px auto; /* 下に余白 */
  }

  /* カード内の文字サイズ調整 */
  .face-content {
    font-size: 25px; /* スマホ用に少し小さく */
    padding: 10px;
    font-family:"Helvetica Neue", Arial, "Hiragino Mincho ProN", "YuMincho", "Hiragino Mincho Pro", "Yu Mincho", serif;
;
  }

  .icon-small {font-size:25px;}
  .filter {font-size:25px;}
  

  /* スライダーとカウンター */
  input[type="range"] {
    margin-top: 20px;
    height: 30px; /* タップしやすいように少し太く */
  }
  
  #cardCount {
    margin-bottom: 10px;
  }

  /* モーダル調整（画面からはみ出ないように） */
  .modal-content {
    width: 90%;
    padding: 20px;
    max-height: 80vh;
    overflow-y: auto;
  }
  .modal-textbox {
    margin-top: 20px;
    width: 100%; /* 幅を親に合わせる */
    box-sizing: border-box;
  }
  .modal-close{
    top: 5px;
  }
}
