/* v1.25.0 修正: CSSの変更なし。ペア設定の「余りの処理」ボタンを削除した（HTML/JS修正のみ）ためコメントのみ更新 */
.tw-wrap{position:relative;width:100%;}


* { box-sizing: border-box; margin: 0; padding: 0; }
.tw-wrap { font-family: "BIZ UDPGothic","Yu Gothic","Hiragino Kaku Gothic ProN",sans-serif; background: #F0F2F5; min-height: 100vh; }

/* ヘッダー */
/* 修正: v1.21.0 グリッドで「見出し（1fr・左寄せ）／タブ（auto・中央）／右側の操作系（1fr・右寄せ）」の
   3列を作る。左右の列を同じ1frにすることで、右側の内容の幅が変わっても中央のタブの位置は動かない */
#hdr { background: #1e3a5f; border-top: 3px solid #d4af37; border-bottom: 3px solid #d4af37; color: #fff; min-height: 52px; display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; column-gap: 12px; padding: 8px 16px; position: sticky; top: 0; z-index: 100; }
#hdr h1 { font-size: 1.1rem; white-space: nowrap; justify-self: start; }
#app-tabs-hdr { justify-self: center; }
.hdr-right { justify-self: end; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; min-width: 0; }
/* 修正: v1.21.0 3列グリッドは見出し・タブ・右側の内容量によっては幅が足りず重なることがあるため、
   画面が狭い端末では中央寄せをやめ、折り返し可能な通常のflexレイアウトに戻す（重なりよりは折り返しを優先） */
@media (max-width: 780px) {
  #hdr { display: flex; flex-wrap: wrap; gap: 8px 12px; }
  #hdr h1 { justify-self: unset; }
  #app-tabs-hdr { justify-self: unset; }
  .hdr-right { justify-self: unset; margin-left: auto; }
}
.hbtn { background: rgba(255,255,255,0.15); color: #fff; border: 2px solid rgba(255,255,255,0.35); border-radius: 8px; padding: 5px 14px; font-size: 0.9rem; font-family: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; }
.hbtn:hover { background: rgba(255,255,255,0.28); }
.hbtn.active { background: #d4af37; color: #1e3a5f; border-color: #d4af37; }
.hbtn.gold { background: #d4af37; color: #1e3a5f; border-color: #d4af37; }
.hbtn.gold:hover { background: #b8961e; }

/* 修正: 演出選択・印刷・決めるボタンを右下のフロートボタン（FAB）に変更 */
.fab-cluster { position: fixed; right: 16px; bottom: 16px; z-index: 250; flex-direction: column; align-items: center; gap: 10px; }
.fab-btn { border: none; cursor: pointer; font-family: inherit; font-weight: 700; color: #fff; white-space: nowrap; display: flex; align-items: center; justify-content: center; padding: 0; border-radius: 50%; }
/* 修正: 演出選択（セレクトボックス）・決めるボタンをアイコンのみの丸ボタンに変更 */
.fab-anim { background: #1e3a5f; width: 44px; height: 44px; font-size: 1.2rem; box-shadow: 0 3px 10px rgba(30,58,95,0.28); }
.fab-anim:hover { background: #2a5080; }
.fab-print { background: #1e3a5f; width: 44px; height: 44px; font-size: 1.2rem; box-shadow: 0 3px 10px rgba(30,58,95,0.28); }
.fab-print:hover { background: #2a5080; }
.fab-main { background: #d4af37; color: #1e3a5f; width: 64px; height: 64px; font-size: 1.8rem; box-shadow: 0 5px 18px rgba(212,175,55,0.5); }
.fab-main:hover { background: #b8961e; }
/* 修正: 設定ボタンを右下FABに追加 */
.fab-settings { background: #1e3a5f; width: 44px; height: 44px; font-size: 1.2rem; box-shadow: 0 3px 10px rgba(30,58,95,0.28); }
.fab-settings:hover { background: #2a5080; }
@media print { .fab-cluster { display: none !important; } }
@media (max-width: 600px) {
  .fab-cluster { right: 10px; bottom: 10px; gap: 8px; }
  .fab-main { width: 56px; height: 56px; font-size: 1.5rem; }
  .fab-anim, .fab-print, .fab-settings { width: 40px; height: 40px; font-size: 1.05rem; }
}

.page { display: none; }
.page.show { display: block; }

/* ===== 設定画面（修正: モーダル表示をやめ、通常のページ切り替えに戻す。右下⚙️から開く点のみ維持） ===== */
.settings-modal-hdr {
  display: flex; align-items: center; justify-content: space-between;
  background: #1e3a5f; color: #fff; padding: 12px 16px; margin: -16px -16px 16px -16px;
  border-bottom: 3px solid #d4af37; font-size: 1.05rem; font-weight: 700;
}
.settings-modal-hdr .sbtn.gold { padding: 6px 16px; }
@media (max-width: 600px) { .settings-modal-hdr { margin: -16px -16px 14px -16px; padding: 10px 14px; } }
/* 修正: モーダルパネル（padding:20px）内で使うときは、その余白に合わせて縁までにじませる */
.modal-panel .settings-modal-hdr { margin: -20px -20px 16px -20px; border-radius: 16px 16px 0 0; }
#pg-setting { padding: 16px; max-width: 900px; margin: 0 auto; }
.scard { background: #fff; border-radius: 14px; padding: 18px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); }
.scard h2 { font-size: 1rem; font-weight: 700; color: #1e3a5f; border-bottom: 3px solid #d4af37; padding-bottom: 6px; margin-bottom: 14px; }
/* 修正: v1.23.0 scard見出しの右端に操作系（表示方式トグルなど）を並べたいときに使う見出し行。
   通常の.scard h2が持つ下線・余白をここに肩代わりさせ、h2側は.scard-hdr-h2で打ち消す */
.scard-hdr-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-bottom: 3px solid #d4af37; padding-bottom: 6px; margin-bottom: 14px; }
.scard-hdr-row .scard-hdr-h2 { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.scard-hdr-row .view-toggle { margin-bottom: 0; }
/* 修正: 児童名リストの入り口カード（設定画面）。ボタン要素なのでデフォルトスタイルをリセットして.scardの見た目に合わせる */
button.name-entry-card { border: none; width: 100%; text-align: left; cursor: pointer; font-family: inherit; }
button.name-entry-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.1); }
.name-entry-card h2 { border-bottom: none; padding-bottom: 0; margin-bottom: 2px; }
.name-entry-chevron { flex-shrink: 0; color: #b8961e; font-size: 1.4rem; line-height: 1; }
/* 修正: 児童名リストのタブ・＋追加／全削除ボタンを1行に集約（モーダル内で使うため.scard/h2への依存をなくした） */
.name-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 14px; }
.name-header-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.name-header-actions .sbtn { padding: 5px 12px; font-size: 0.8rem; }

/* 修正: 設定画面の2段階化（かんたん設定／詳細設定）用スタイル */
.tw-details { background: #fff; border-radius: 14px; padding: 4px 18px 18px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); }
.tw-details summary { cursor: pointer; font-weight: 700; color: #1e3a5f; padding: 14px 0; font-size: 0.95rem; list-style: none; }
.tw-details summary::-webkit-details-marker { display: none; }
.tw-details summary::before { content: '▶'; display: inline-block; margin-right: 8px; color: #d4af37; font-size: 0.75rem; transition: transform 0.15s; }
.tw-details[open] summary::before { transform: rotate(90deg); }
.tw-details .scard-inner { padding-top: 6px; margin-bottom: 14px; }
.tw-details .scard-inner:last-child { margin-bottom: 0; }
.tw-details .scard-inner h3 { font-size: 0.9rem; font-weight: 700; color: #1e3a5f; border-bottom: 2px solid #d4af37; padding-bottom: 5px; margin-bottom: 10px; }

/* 修正: 児童名リストの「児童名／サンプル／番号」タブ（席替えアプリと共通のタブ構成。ヘッダー内に配置） */
/* 修正: 「児童名／サンプル／番号」タブを下線式デザインに変更 */
.name-mode-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid #e2e8f0; }
.name-mode-btn { background: transparent; border: none; border-bottom: 3px solid transparent; color: #8a96a6; padding: 8px 14px; font-size: 0.88rem; font-weight: 700; cursor: pointer; font-family: inherit; margin-bottom: -2px; }
.name-mode-btn:hover { color: #1e3a5f; }
.name-mode-btn.on { color: #1e3a5f; border-bottom-color: #d4af37; }

/* 修正: 番号モードの人数カウンター */
.cnt-wrap { display: flex; align-items: center; gap: 0; border: 1px solid #c0cfe0; border-radius: 8px; overflow: hidden; }
.cnt-btn { background: #eef4fb; border: none; color: #1e3a5f; width: 32px; height: 32px; font-size: 1rem; font-weight: 700; cursor: pointer; font-family: inherit; }
.cnt-btn:hover { background: #dbe9f8; }
.cnt-val { display: inline-block; min-width: 40px; text-align: center; font-size: 0.95rem; font-weight: 700; color: #1e3a5f; }

/* 修正: 児童名リストもカード化。タップで男女（青・ピンク）をループ切り替え（役割カードと同じ見た目・操作に統一）。5列グリッドに変更 */
.name-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
@media (max-width: 700px) { .name-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 460px) { .name-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 320px) { .name-grid { grid-template-columns: 1fr; } }
.add-row { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; margin-top: 8px; }
.add-row textarea { flex: 1; min-width: 200px; height: 72px; border: 1px solid #c0cfe0; border-radius: 8px; padding: 8px; font-size: 0.88rem; font-family: inherit; resize: vertical; }
.sbtn { background: #1e3a5f; color: #fff; border: none; border-radius: 8px; padding: 7px 14px; font-size: 0.88rem; font-family: inherit; font-weight: 700; cursor: pointer; }
.sbtn:hover { background: #2a5080; }
.sbtn.gold { background: #d4af37; color: #1e3a5f; }
.sbtn.gold:hover { background: #b8961e; }
.sbtn.red { background: #c0392b; color: #fff; }
.hint { font-size: 0.8rem; color: #888; margin-top: 6px; }

/* グループ設定（モーダル内で使用） */
/* 修正: モーダル配色を全体トーン（白地＋ネイビー文字＋ゴールドの差し色）に統一。旧デザインは紺の塗りつぶし背景で浮いていたため撤去 */
.grp-hdr { display: flex; align-items: center; gap: 10px; padding: 2px 0 14px; margin-bottom: 14px; border-bottom: 2px solid #eef1f4; } /* 修正: 閉じる×ボタンを廃止したため左右均等の余白に戻す */
.grp-hdr-dot { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 3px rgba(30,58,95,0.06); }
.grp-hdr input[type=text] { flex: 1; min-width: 80px; background: #f4f8fc; border: 1px solid #c0cfe0; border-radius: 8px; padding: 8px 10px; color: #1e3a5f; font-size: 1.05rem; font-family: inherit; font-weight: 700; }
.grp-hdr input::placeholder { color: #9aa7b5; }
.grp-hdr input:focus { outline: none; border-color: #d4af37; box-shadow: 0 0 0 3px rgba(212,175,55,0.18); }
/* 修正: グループ削除ボタンをモーダル下部からヘッダーに移動 */
.grp-hdr-del { flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px; border: 1px solid #f3c9c2; background: #fdf1ef; color: #c0392b; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.grp-hdr-del:hover { background: #fbe1dc; }
.grp-body { padding: 0; } /* 修正: モーダル内で使うため左右パディングは持たせない */

/* 修正: 掃除場所（グループ）一覧を4列カードのグリッド表示に変更。タップで編集モーダルを開く */
#grp-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 4px; }
@media (max-width: 900px) { #grp-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { #grp-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 380px) { #grp-list { grid-template-columns: 1fr; } }
/* 修正: v1.22.0 一覧方式のときは、カードのグリッドではなく編集パネルを縦一列に並べる */
#grp-list.grp-list-mode { display: block; }

/* 修正: v1.22.0 グループ・役割設定の表示方式切り替え（収納方式／一覧方式）用のセグメントボタン */
.view-toggle { display: flex; gap: 0; border: 1px solid #c0cfe0; border-radius: 10px; overflow: hidden; width: fit-content; margin-bottom: 8px; }
.view-toggle-btn { background: #f4f8fc; color: #1e3a5f; border: none; padding: 8px 16px; font-size: 0.85rem; font-family: inherit; font-weight: 700; cursor: pointer; transition: background 0.15s, color 0.15s; }
.view-toggle-btn + .view-toggle-btn { border-left: 1px solid #c0cfe0; }
.view-toggle-btn.active { background: #1e3a5f; color: #fff; }
.view-toggle-btn:hover:not(.active) { background: #e7eef7; }

/* 修正: v1.22.0 一覧方式：グループごとの編集UI（.grp-hdr/.grp-body/.grp-cards-wrapを再利用）を
   カード状の箱にくるんで画面に直接並べる。収納方式のモーダル内と中身は共通（buildGrpEditorBody） */
.grp-list-item { background: #fbfcfe; border: 1px solid #e3e9f0; border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.grp-list-item .grp-hdr { padding-top: 0; }
.grp-card-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 5px;
  align-items: center;
  width: 100%;
  min-height: 76px;
  background: #fff;
  border: 1px solid #e2e6ea;
  border-radius: 14px;
  padding: 12px 12px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.grp-card-row:hover { border-color: #b8d0ea; background: #f8fbff; box-shadow: 0 3px 10px rgba(30,58,95,0.08); }
.grp-card-dot { grid-column: 1; grid-row: 1; width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.grp-card-name { grid-column: 2; grid-row: 1; font-weight: 700; color: #1e3a5f; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grp-card-meta { grid-column: 1 / 3; grid-row: 2; font-size: 0.76rem; color: #888; white-space: nowrap; }
.grp-card-chevron { grid-column: 3; grid-row: 1 / 3; align-self: center; color: #b8961e; font-size: 1.2rem; line-height: 1; }

/* 修正: グループ編集モーダル（背景オーバーレイ＋パネル） */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,30,58,0.55); z-index: 550; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.show { display: flex; }
.modal-panel { position: relative; background: #fff; border-radius: 16px; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; padding: 20px; box-shadow: 0 16px 56px rgba(0,0,0,0.35); }
/* 修正: 児童名リストのモーダルは、名簿カード一覧が入るため他のモーダルより横幅を広くとる */
#name-modal .modal-panel { max-width: 760px; }
@media print { .modal-overlay { display: none !important; } }

/* 修正: 役割入力欄を1つに（役割名のみ）。Enter／＋カードを追加でその場にカードを生成する */
.add-role-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.add-role-row input[type=text] { flex: 1; min-width: 160px; border: 1px solid #c0cfe0; border-radius: 8px; padding: 8px 10px; font-size: 0.92rem; font-family: inherit; }
.add-task-btn { background: #1e3a5f; color: #fff; border: none; border-radius: 6px; padding: 8px 14px; font-size: 0.85rem; font-family: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; }
.add-task-btn:hover { background: #2a5080; }

/* 修正: 「一人につき一枚」の役割カード。絵文字は使わず、色（青＝男子／ピンク＝女子、パステル）で男女を表現。
   カード本体タップで 男子(青)⇔女子(ピンク) を切り替え。✏️編集／🗑削除ボタンを常時表示（詳細設定の折りたたみは廃止）。
   一覧を4列グリッドに変更（タブレット幅では2列、スマホ幅では1列に自動調整）。 */
.grp-cards-wrap { margin: 4px 0 10px; }
.grp-cards-title { font-size: 0.8rem; font-weight: 700; color: #1e3a5f; margin-bottom: 6px; }
.grp-cards-empty { font-size: 0.8rem; color: #999; }
.person-card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 640px) { .person-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 380px) { .person-card-grid { grid-template-columns: 1fr; } }
.person-card { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; min-height: 78px; border-radius: 14px; border: 1.5px solid transparent; cursor: pointer; font-family: inherit; padding: 10px 10px 8px; -webkit-tap-highlight-color: transparent; }
.person-card .pc-role { font-size: 0.84rem; font-weight: 700; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pc-actions { display: flex; gap: 6px; width: 100%; } /* 修正: 編集・削除ボタンの合計幅がカード（役割ボタン）の幅と揃うよう100%に変更 */
.pc-edit, .pc-del { flex: 1; height: 26px; border-radius: 8px; border: none; background: rgba(255,255,255,0.55); color: inherit; font-size: 12px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.pc-edit:hover, .pc-del:hover { background: rgba(255,255,255,0.9); }
.person-card.m { background: #7fcaff; border-color: #46aef7; color: #0a3a5e; } /* 修正: くすんだ青→明るいパステルブルーに変更 */
.person-card.f { background: #ff9fd3; border-color: #ff6fb8; color: #6b0f42; } /* 修正: くすんだピンク→明るいパステルピンクに変更 */
.person-card.n { background: #eceff2; border-color: #d7dce2; color: #555f6b; }
.person-card:active { transform: scale(0.97); }

/* 修正: 児童名カードは編集ボタンなし。削除ボタンはカード右上に置き、
   マウス操作の端末ではカーソルを重ねたときだけ表示（タッチ端末では常時表示） */
.name-card { position: relative; min-height: 52px; justify-content: center; padding: 12px 30px 12px 12px; }
.name-card .pc-role { text-align: center; }
.nc-del { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(0,0,0,0.15); color: inherit; font-size: 11px; line-height: 22px; text-align: center; padding: 0; cursor: pointer; }
.nc-del:hover { background: rgba(0,0,0,0.3); }
@media (hover: hover) and (pointer: fine) {
  .nc-del { opacity: 0; pointer-events: none; transition: opacity 0.15s; }
  .name-card:hover .nc-del { opacity: 1; pointer-events: auto; }
}

/* 修正: 場所テンプレートのワンタップ追加ボタン */
.tpl-add-wrap { margin-bottom: 14px; }
.tpl-btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tpl-btn { background: #eef4fb; border: 1px solid #b8d0ea; color: #1e3a5f; border-radius: 20px; padding: 5px 12px; font-size: 0.82rem; font-weight: 700; cursor: pointer; font-family: inherit; white-space: nowrap; }
.tpl-btn:hover { background: #dbe9f8; }

/* JSON */
.json-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== 結果画面 ===== */
#pg-result { padding: 8px; background: #F0F2F5; }
#no-data { text-align: center; padding: 60px 20px; color: #888; font-size: 1rem; }

/* PC表示：画面フル活用 */
.a4-wrap {
  background: #fff;
  box-shadow: 0 4px 20px rgba(30,58,95,0.12);
  width: 100%;
  aspect-ratio: 297 / 210;
  max-height: calc(100vh - 72px);
  overflow: hidden;
}

/* カードグリッド */
.toban-grid { display: grid; gap: 4px; padding: 6px; width: 100%; height: 100%; }

/* 当番カード */
.toban-card { border: 1px solid #E8E8E8; display: flex; flex-direction: column; overflow: hidden; border-radius: 4px; box-shadow: 0 1px 4px rgba(30,58,95,0.06); }
.card-loc { font-weight: 900; display: flex; align-items: center; justify-content: center; padding: 3px 6px; white-space: nowrap; flex-shrink: 0; letter-spacing: 0.05em; overflow: hidden; text-overflow: ellipsis; }
.card-inner { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.task-line { display: flex; align-items: stretch; border-bottom: 1px solid rgba(0,0,0,0.07); flex: 1; min-height: 0; }
.task-line:last-child { border-bottom: none; }
.task-job { writing-mode: vertical-rl; display: flex; align-items: center; justify-content: center; border-right: 1px solid rgba(0,0,0,0.1); flex-shrink: 0; line-height: 1.2; overflow: hidden; padding: 2px 2px; font-weight: 700; word-break: break-all; }
.task-job.is-repeat { opacity: 0.4; font-size: 10px; }
.task-names { display: flex; align-items: center; justify-content: center; flex: 1; overflow: hidden; padding: 0 4px; }
.name-chip { font-weight: 700; display: flex; align-items: center; justify-content: center; border-radius: 4px; padding: 0 4px; border: 1px solid transparent; max-width: 100%; overflow: hidden; white-space: nowrap; }
.name-chip.m { background: #e6f0fa; color: #1e3a5f; border-color: #b8d0ea; }
.name-chip.f { background: #fdf6dc; color: #7a5c00; border-color: #e8d48a; }
.name-chip.n { background: #F5F5F5; color: #2C3E50; border-color: #E8E8E8; }

/* 列数インジケーター */
.result-info { font-size: 0.78rem; color: #888; margin-bottom: 6px; text-align: center; }

@media print {
  #hdr { display: none !important; }
  #pg-setting, #pg-kyushoku-setting, #pg-pair-setting { display: none !important; } /* 修正: 給食・ペアの設定モーダルも印刷時は非表示に */
  #pg-result { display: block !important; padding: 0; }
  .result-info { display: none !important; }
  .tw-wrap { background: #fff; }
  .a4-wrap {
    box-shadow: none !important;
    margin: 0 !important;
    width: 297mm !important;
    height: 210mm !important;
  }
  @page { size: A4 landscape; margin: 0; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* ===== 当番表上を飛び回るチップ ===== */
#fly-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 400;
}
.fly-chip {
  position: fixed;
  font-weight: 900;
  border-radius: 10px;
  padding: 8px 18px;
  font-size: 26px;
  pointer-events: none;
  z-index: 401;
  will-change: left, top, opacity;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.fly-chip.m { background: #e6f0fa; color: #1e3a5f; border: 2px solid #b8d0ea; box-shadow: 0 4px 16px rgba(30,58,95,0.22); }
.fly-chip.f { background: #fdf6dc; color: #7a5c00; border: 2px solid #e8d48a; box-shadow: 0 4px 16px rgba(212,175,55,0.22); }
.fly-chip.n { background: #F5F5F5; color: #2C3E50; border: 2px solid #E8E8E8; box-shadow: 0 4px 16px rgba(0,0,0,0.12); }

/* ===== アニメーションオーバーレイ ===== */
#anim-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,30,58,0.93);
  z-index: 500;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
#anim-overlay.show { display: flex; }

/* シャッフル */
#shuffle-stage { position: relative; width: 100vw; height: calc(100vh - 52px); overflow: hidden; }
.s-chip {
  position: absolute;
  font-weight: 900;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 18px;
  pointer-events: none;
  transition: left 0.5s cubic-bezier(.4,0,.2,1), top 0.5s cubic-bezier(.4,0,.2,1), opacity 0.3s;
}
.s-chip.m { background: #e6f0fa; color: #1e3a5f; border: 1px solid #b8d0ea; }
.s-chip.f { background: #fdf6dc; color: #7a5c00; border: 1px solid #e8d48a; }
.s-chip.n { background: #F5F5F5; color: #2C3E50; border: 1px solid #E8E8E8; }

/* ドラフト */
#draft-wrap { text-align: center; display: flex; flex-direction: column; align-items: center; }
#draft-card-box {
  background: #fff;
  border-radius: 20px;
  padding: 32px 48px 28px;
  box-shadow: 0 12px 48px rgba(30,58,95,0.35);
  min-width: 340px;
  max-width: 82vw;
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 0.3s, transform 0.35s cubic-bezier(.22,.68,0,1.3);
  border-top: 6px solid #d4af37;
}
#draft-card-box.show { opacity: 1; transform: scale(1); }
/* 役割と名前を横並びで同サイズ */
#draft-main-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
#draft-role {
  font-size: clamp(2.0rem,6vw,4.0rem);
  font-weight: 900;
  color: #1e3a5f;
  background: #e6f0fa;
  border: 2px solid #b8d0ea;
  border-radius: 12px;
  padding: 6px 20px;
  line-height: 1.2;
}
#draft-sep {
  font-size: clamp(1.4rem,4vw,2.5rem);
  color: #d4af37;
  font-weight: 900;
}
#draft-name {
  font-size: clamp(2.0rem,6vw,4.0rem);
  font-weight: 900;
  color: #1e3a5f;
  line-height: 1.2;
}
#draft-arrow { font-size: 1.2rem; color: #d4af37; margin: 2px 0 10px; }
#draft-place {
  font-size: clamp(0.95rem,2.5vw,1.4rem);
  font-weight: 700;
  color: #7F8C8D;
  background: #F5F5F5;
  border-radius: 8px;
  padding: 5px 16px;
  display: inline-block;
}
#draft-counter { font-size: 0.85rem; color: rgba(255,255,255,0.55); margin-top: 16px; }
#draft-progress { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; margin-top: 8px; max-width: 80vw; }
.d-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.2); transition: background 0.2s; flex-shrink: 0; }
.d-dot.done { background: #d4af37; }
#draft-skip-btn {
  margin-top: 18px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 10px;
  padding: 8px 24px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}
#draft-skip-btn:hover { background: rgba(255,255,255,0.25); }

/* スロット：当番表上に浮かせる */
#slot-overlay-inner {
  position: fixed;
  inset: 52px 0 0 0;
  background: rgba(15,30,58,0.82);
  z-index: 450;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
#slot-overlay-inner.show { display: flex; }
#slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  width: 92vw;
  max-width: 1100px;
  max-height: 80vh;
  overflow: hidden;
}
.slot-cell {
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(212,175,55,0.3);
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  overflow: hidden;
}
.slot-cell-label { font-size: 9px; color: #d4af37; font-weight: 700; text-align: center; line-height: 1.3; }
.slot-reel { height: 32px; overflow: hidden; width: 100%; position: relative; }
.slot-reel-inner { display: flex; flex-direction: column; align-items: center; }
.slot-reel-inner span { height: 32px; line-height: 32px; font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; }
.slot-cell.locked { border-color: #d4af37; background: rgba(212,175,55,0.12); }
.slot-cell.locked .slot-reel-inner span { color: #d4af37; }
#slot-msg { font-size: 1.1rem; color: rgba(255,255,255,0.8); font-weight: 700; }
@keyframes chipFly { 0%{opacity:1} 100%{opacity:0;transform:scale(0.5)} }

/* ===== タブ ===== */
/* 修正: タブボタンはヘッダー内に移動し、ヘッダー共通の.hbtnスタイルをそのまま使うため専用CSSは不要に */
.app-section { display: none; }
.app-section.show { display: block; }

/* ===== 給食当番 ===== */
#kyushoku-hdr-btns { display: flex; gap: 6px; }
#pg-kyushoku-result { padding: 8px; background: #F0F2F5; }
#pg-kyushoku-setting { padding: 16px; max-width: 900px; margin: 0 auto; }

/* 班カード（設定）修正: そうじの場所カードと同様に、班一覧も4列カードのグリッド表示に変更。タップで編集モーダルを開く */
#han-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 4px; }
@media (max-width: 900px) { #han-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { #han-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 380px) { #han-list { grid-template-columns: 1fr; } }

/* 給食役割設定（修正: 行並びのテキスト入力からカード表示に変更） */
#kyushoku-role-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
@media (max-width: 900px) { #kyushoku-role-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { #kyushoku-role-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 380px) { #kyushoku-role-list { grid-template-columns: 1fr; } }
/* 修正: v1.11.0 役割カードを白背景＋ゴールドのポイントカラー（左の帯）に変更し、他のグレーカードと区別しやすく */
/* 修正: v1.23.0 給食の役割カードに男女設定を追加したことに伴い、白背景固定の.role-card／人数入力用の.role-card-countは
   不要になったため削除（役割カードは他のperson-cardと同じくm/f/nの色で表示するようになった） */

/* ローテーション */
.rotation-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #fff; border-radius: 10px; margin-bottom: 10px; box-shadow: 0 1px 4px rgba(30,58,95,0.06); flex-wrap: wrap; }
.rotation-bar .cur-han { font-size: 1.1rem; font-weight: 900; color: #1e3a5f; background: #e6f0fa; border: 2px solid #b8d0ea; border-radius: 8px; padding: 4px 16px; }
.rotation-bar .rot-count { font-size: 0.82rem; color: #888; }

/* 修正: ローテーションバーを結果画面からヘッダーへ移動。#hdrの2行目として折り返し表示する */
/* 修正: v1.11.0 「flex-basis:100%」で強制的に2行目へ折り返していたのをやめ、ヘッダーの高さ（min-height:52px）を
   変えずに見出し・タブと同じ1行に収まるよう、バー自体もコンパクトなデザインに変更 */
#kyushoku-rotation-hdr { display: none; align-items: center; } /* 修正: v1.21.0 右寄せは親の.hdr-rightが担当するため、margin-left:autoは不要に */
#kyushoku-rotation-hdr .rotation-bar { margin-bottom: 0; padding: 3px 10px; gap: 6px; background: rgba(255,255,255,0.14); border-radius: 20px; box-shadow: none; flex-wrap: nowrap; }
#kyushoku-rotation-hdr .rotation-bar .sbtn { padding: 3px 10px; font-size: 0.76rem; border-radius: 14px; background: rgba(255,255,255,0.18); }
#kyushoku-rotation-hdr .rotation-bar .sbtn:hover { background: rgba(255,255,255,0.3); }
#kyushoku-rotation-hdr .rotation-bar .sbtn.gold { background: #d4af37; color: #1e3a5f; }
#kyushoku-rotation-hdr .rotation-bar .sbtn.gold:hover { background: #b8961e; }
#kyushoku-rotation-hdr .rotation-bar .cur-han { font-size: 0.82rem; font-weight: 900; padding: 2px 10px; background: #fff; color: #1e3a5f; border: none; white-space: nowrap; }
#kyushoku-rotation-hdr .rotation-bar .rot-count { font-size: 0.7rem; color: #e8d9a8; white-space: nowrap; }
@media (max-width: 480px) {
  #kyushoku-rotation-hdr .rotation-bar .rot-count { display: none; } /* 修正: 幅が足りない端末では周回数バッジのみ省略してヘッダー1行を維持 */
}

/* 修正: v1.18.0 列数調整ボタン（そうじ・ペア共通）。ヘッダーの高さ（min-height:52px）を変えずに1行に収まるコンパクトなデザイン */
.cols-adjust-hdr { align-items: center; gap: 5px; background: rgba(255,255,255,0.14); border-radius: 20px; padding: 3px 6px 3px 10px; } /* 修正: v1.21.0 右寄せは親の.hdr-rightが担当するため、margin-left:autoは不要に */
.cols-adjust-label { font-size: 0.76rem; color: #fff; opacity: 0.9; white-space: nowrap; }
.cols-adjust-btn { width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(255,255,255,0.2); color: #fff; font-size: 0.9rem; font-weight: 700; line-height: 1; padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.cols-adjust-btn:hover { background: rgba(255,255,255,0.35); }
.cols-adjust-val { font-size: 0.85rem; font-weight: 900; color: #fff; min-width: 14px; text-align: center; }
@media (max-width: 600px) {
  .cols-adjust-label { display: none; } /* 修正: 幅が足りない端末ではラベルを省略してヘッダー1行を維持 */
}

/* 給食結果カード */
.kyushoku-grid { display: grid; gap: 3px; padding: 5px; width: 100%; height: 100%; }
.kyushoku-han-card { border: 1px solid #E8E8E8; border-radius: 4px; overflow: hidden; box-shadow: 0 1px 4px rgba(30,58,95,0.06); display: flex; flex-direction: column; }
.kyushoku-han-hdr { font-weight: 900; font-size: 11px; display: flex; align-items: center; justify-content: center; padding: 3px 6px; letter-spacing: 0.05em; flex-shrink: 0; background: #1e3a5f; color: #fff; }
.kyushoku-role-line { display: flex; align-items: stretch; border-bottom: 1px solid rgba(0,0,0,0.07); flex: 1; min-height: 0; }
.kyushoku-role-line:last-child { border-bottom: none; }
.kyushoku-role-label { display: flex; align-items: center; border-right: 1px solid rgba(0,0,0,0.1); flex-shrink: 0; padding: 0 3px; font-weight: 700; background: #e6f0fa; color: #1e3a5f; }
.kyushoku-role-names { display: flex; align-items: center; justify-content: center; flex: 1; padding: 0 4px; background: #f8fafc; gap: 3px; flex-wrap: wrap; }
/* 表組み方式 */
.kyushoku-table-row { display: flex; align-items: stretch; border-bottom: 1px solid #E8E8E8; }
.kyushoku-table-row:last-child { border-bottom: none; }
.kyushoku-role-cell { display: flex; align-items: center; font-weight: 700; padding: 2px 5px; border-right: 1px solid rgba(0,0,0,0.1); flex-shrink: 0; line-height: 1.25; overflow: hidden; background: #e6f0fa; color: #1e3a5f; word-break: break-all; }
.kyushoku-name-cell { flex: 1; display: flex; align-items: center; justify-content: center; gap: 3px; flex-wrap: wrap; padding: 2px 4px; border-right: 1px solid #E8E8E8; overflow: hidden; }
.kyushoku-name-cell:last-child { border-right: none; }
.kyushoku-name-chip { font-weight: 700; border-radius: 4px; padding: 0 4px; border: 1px solid transparent; }
.kyushoku-name-chip.m { background: #e6f0fa; color: #1e3a5f; border-color: #b8d0ea; }
.kyushoku-name-chip.f { background: #fdf6dc; color: #7a5c00; border-color: #e8d48a; }
.kyushoku-name-chip.n { background: #F5F5F5; color: #2C3E50; border-color: #E8E8E8; }

/* ===== ペア決め ===== */
#pg-pair-result { padding: 8px; background: #F0F2F5; }
#pg-pair-setting { padding: 16px; max-width: 900px; margin: 0 auto; }
.pair-grid { display: grid; gap: 4px; padding: 6px; width: 100%; height: 100%; }
.pair-card { border: 1px solid #E8E8E8; border-radius: 4px; overflow: hidden; box-shadow: 0 1px 4px rgba(30,58,95,0.06); display: flex; flex-direction: column; }
.pair-card-hdr { font-weight: 900; display: flex; align-items: center; justify-content: center; padding: 3px 6px; letter-spacing: 0.05em; flex-shrink: 0; }
.pair-member-list { flex: 1; display: flex; flex-direction: column; }
.pair-member-row { flex: 1; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid rgba(0,0,0,0.07); }
.pair-member-row:last-child { border-bottom: none; }
.pair-name-chip { font-weight: 700; border-radius: 4px; padding: 0 4px; border: 1px solid transparent; }
.pair-name-chip.m { background: #e6f0fa; color: #1e3a5f; border-color: #b8d0ea; }
.pair-name-chip.f { background: #fdf6dc; color: #7a5c00; border-color: #e8d48a; }
.pair-name-chip.n { background: #F5F5F5; color: #2C3E50; border-color: #E8E8E8; }
