/* 全ページ共通の見た目 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --main: #2e7d32;      /* テーマ色(緑) */
  --main-dark: #1b5e20;
  --bg: #f4f6f4;
  --text: #222;
  --border: #dcdcdc;
  --danger: #c62828;
}

body {
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* 上のバー */
header {
  background: var(--main);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 52px;
}
header .app-title {
  font-size: 17px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
header nav {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
header nav a {
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 8px;
}
header nav a.current {
  background: var(--main-dark);
  font-weight: bold;
}

.app-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}

/* 狭い画面(スマホ)では、ヘッダーを「団体名」と「メニュー」の2段にする。
   1段のままだと、メニューは縮まない設定のため団体名が「…」に潰されて
   ほとんど読めなくなってしまう */
@media (max-width: 640px) {
  header {
    height: auto;
    flex-wrap: wrap;
    padding: 8px 12px 4px;
  }
  .app-title-group {
    flex-basis: 100%; /* 1段目を団体名がまるごと使う */
  }
  header nav {
    flex-basis: 100%; /* 2段目をメニューがまるごと使う */
    justify-content: flex-end;
  }
  header nav a {
    padding: 6px 10px;
  }
  /* スズメは団体名の前(左)に置き、少し小さくして、
     下の画面へのはみ出しも控えめにする(2段目のメニューの文字に重ならないように)。
     ふだんの大きさの指定(.mascot.mascot-sm)より強くするため、headerも付けて書く */
  header .mascot.mascot-sm {
    order: -1; /* 並び順だけ入れ替える(HTMLでは団体名のあとに書いてある) */
    width: 44px;
    margin-bottom: -10px;
  }
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

/* ボタン */
.btn {
  display: inline-block;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 16px;
  cursor: pointer;
  background: var(--main);
  color: #fff;
}
.btn:active {
  background: var(--main-dark);
}
.btn.small {
  padding: 10px 14px; /* 指で押しやすい大きさを確保する */
  font-size: 13px;
}
.btn.gray {
  background: #757575;
}
.btn.red {
  background: var(--danger);
}
.btn:disabled {
  background: #bbb;
  cursor: default;
}

/* 入力欄 */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
textarea,
select {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
/* 日付・時間の欄は端末ごとの独自の見た目ではみ出すことがあるので抑える */
input[type="date"],
input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  max-width: 100%;
  min-height: 48px;
}
textarea {
  min-height: 80px;
  resize: vertical;
}
/* チェックとレ点は、指で押しやすい大きさにそろえる */
input[type="checkbox"],
input[type="radio"] {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--main);
}
label {
  display: block;
  font-size: 14px;
  font-weight: bold;
  margin: 14px 0 6px;
}

/* カード */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}

/* お知らせメッセージ */
.message {
  padding: 10px 14px;
  border-radius: 10px;
  margin: 10px 0;
  font-size: 14px;
  display: none;
}
.message.ok {
  display: block;
  background: #e8f5e9;
  color: var(--main-dark);
}
.message.error {
  display: block;
  background: #ffebee;
  color: var(--danger);
}
.message.message-with-mascot {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* マップ上のポイント(絵文字のアイコン)
   .poi-hit は指で押せる範囲(44px四方の透明な枠)。中の .poi-icon が見えている丸 */
.poi-hit {
  display: flex;
  align-items: center;
  justify-content: center;
}
.poi-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #999;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
  /* 押されたときに、ヌルッと大きくなって元に戻るための下ごしらえ */
  transition: transform 0.25s ease;
}

/* イベントページの「マップで場所を見る」で来たときの目立たせ方 */
@keyframes poi-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-24px); }
}
@keyframes poi-flip {
  from { transform: rotateX(0deg); }
  to { transform: rotateX(360deg); }
}
.poi-focus-bounce .poi-icon {
  animation: poi-bounce 0.6s ease-in-out 3; /* ゆっくり3回はねる */
}
.poi-focus-flip .poi-icon {
  animation: poi-flip 0.3s linear 2; /* 速く縦に2回転 */
}

/* 集合場所を1回押したときに出る「Tap!」の吹き出し。
   もう1回押すと、その班の道順を 🚶 が歩き出す。
   説明の窓はアイコンの上に開くので、吹き出しは下に出してぶつからないようにする */
.poi-tap-hint {
  /* 吹き出しが隣の印の下に隠れないように、押した印だけ手前に出す
     (Leaflet が各印に直接 z-index を書き込むので、!important で上書きする) */
  z-index: 1000 !important;
}
/* 押されているあいだは、アイコンがヌルッとひとまわり大きくなる
   (押されないまま吹き出しが消えると、そのまま元の大きさに戻る) */
.poi-tap-hint .poi-icon {
  transform: scale(1.35);
}
.poi-tap-hint::after {
  content: "Tap!";
  position: absolute;
  /* 大きくなったアイコン(丸の下端が42pxあたり)の、すぐ下に出す */
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 10px;
  background: #fff8e1;
  border: 1.5px solid #f0c36d;
  border-radius: 12px;
  color: #6b4c00;
  font-size: 13px;
  font-weight: bold;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  /* 吹き出しはタップを通す(2回目のタップの邪魔をしない) */
  pointer-events: none;
  animation: poi-tap-hint-shake 0.5s ease-in-out infinite;
}
/* 吹き出しの上のとんがり(アイコンを指している) */
.poi-tap-hint::before {
  content: "";
  position: absolute;
  top: 44px;
  left: 50%;
  margin-left: -5px;
  width: 10px;
  height: 10px;
  background: #fff8e1;
  border-left: 1.5px solid #f0c36d;
  border-top: 1.5px solid #f0c36d;
  transform: rotate(45deg);
  pointer-events: none;
}
/* ゆらゆら揺らして「押してね」と伝える */
@keyframes poi-tap-hint-shake {
  0%, 100% { transform: translateX(-50%) rotate(-5deg); }
  50%      { transform: translateX(-50%) rotate(5deg); }
}
/* 動きを減らす設定にしている端末では、揺らさず・ヌルッとさせずに、出すだけにする */
@media (prefers-reduced-motion: reduce) {
  .poi-tap-hint::after { animation: none; }
  .poi-icon { transition: none; }
}

/* 登校班のルート選択バー */
.route-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap; /* 地区の絞り込みが増えても、狭い画面では2段に折り返す */
  gap: 10px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.route-bar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 150px; /* ラベルと選択欄が離れて折り返さないようにする */
}
.route-bar select {
  flex: 1;
  max-width: 280px;
  padding: 8px;
  font-size: 14px;
}

/* ルートを歩く人 */
.walker-img {
  height: 36px;
  width: auto;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
  /* 歩いているあいだ、左右に首を振る */
  transform-origin: 50% 90%;
  animation: walkerWaddle 0.7s ease-in-out infinite;
}
@keyframes walkerWaddle {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}
/* ゴールしたあとは、首振りをちょうど2回だけして止まる
   (名前を変えて別のアニメーションにすることで、最初からやり直させる) */
.walker-img.walker-goal {
  animation: walkerGoalWaddle 0.7s ease-in-out 2;
}
@keyframes walkerGoalWaddle {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}

/* 歩く人の吹き出し(迂回の期間中だけ、歩いているあいだ出る) */
.walker-wrap {
  position: relative;
  width: 36px;
  height: 36px;
}
.walker-bubble {
  position: absolute;
  bottom: 38px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff8e1;
  border: 1.5px solid #f0c36d;
  color: #6b4c00;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  /* 吹き出しはタップを通す(下の地図やアイコンが触れなくならないように) */
  pointer-events: none;
}
/* 吹き出しの下のとんがり */
.walker-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  margin-left: -5px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  background: #fff8e1;
  border-right: 1.5px solid #f0c36d;
  border-bottom: 1.5px solid #f0c36d;
  transform: rotate(45deg);
}
/* 🚧がゆらゆら、「迂回中」の文字が順番にぽんぽん跳ねる */
.walker-cone {
  display: inline-block;
  margin-right: 2px;
  animation: walker-cone-swing 0.9s ease-in-out infinite;
}
.walker-char {
  display: inline-block;
  animation: walker-char-pop 1.4s ease-in-out infinite;
}
@keyframes walker-cone-swing {
  0%, 100% { transform: rotate(-14deg); }
  50% { transform: rotate(14deg); }
}
@keyframes walker-char-pop {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}
/* 動きを減らす設定にしている端末では、揺らさない */
@media (prefers-reduced-motion: reduce) {
  .walker-cone,
  .walker-char,
  .walker-img,
  .walker-img.walker-goal {
    animation: none;
  }
}

/* 一覧の行(資料・ポイント・イベントの管理用) */
.doc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  text-decoration: none;
  color: var(--text);
}
.doc-row .doc-title {
  font-size: 16px;
  font-weight: bold;
}
.doc-row .doc-date {
  font-size: 12px;
  color: #595959; /* 小さい文字でも読める濃さにする */
  margin-top: 4px;
}

/* 役員画面のタブ */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.tab-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}
.tab-btn.current {
  background: var(--main);
  border-color: var(--main);
  color: #fff;
  font-weight: bold;
}

/* イベントのカード */
.event-card .event-date {
  font-size: 14px;
  font-weight: bold;
  color: var(--main-dark);
}
.event-card .event-title {
  font-size: 18px;
  font-weight: bold;
  margin: 4px 0;
}
.event-card .event-place {
  font-size: 13px;
  color: #555;
}
.event-card .event-detail {
  font-size: 14px;
  margin-top: 8px;
  white-space: pre-wrap;
}

/* ルート線の色えらび */
.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.color-choice {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.color-choice.selected {
  border-color: #222;
  transform: scale(1.12);
}

/* ルート一覧の色見本 */
.color-chip {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  vertical-align: -2px;
  margin-right: 6px;
}

/* 見出しタップで開閉するカード */
.collapsible .card-body {
  display: none;
}
.collapsible.open .card-body {
  display: block;
  margin-top: 12px;
}
.card-toggle {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}
.card-toggle .chev {
  font-size: 12px;
  color: #888;
  transition: transform 0.15s;
}
.collapsible.open .card-toggle .chev {
  transform: rotate(180deg);
}

/* 種類のドラッグ並び替え */
.type-row .drag-handle {
  cursor: grab;
  color: #6b6b6b;
  font-size: 18px;
  padding: 8px;
  touch-action: none; /* 指でつかんだとき画面ごとスクロールしないように */
}
.type-row.dragging {
  opacity: 0.5;
  background: #e8f5e9;
}

/* 画面の真ん中に浮かぶ窓(ポイントの登録・修正用) */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2000;
  overflow-y: auto;
  padding: 20px 16px;
}
.modal-backdrop.show {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.modal-card {
  width: 100%;
  max-width: 520px;
  margin: auto;
}

/* マーク(絵文字)の候補 */
.emoji-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.emoji-choice {
  width: 46px;
  height: 46px;
  font-size: 22px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.emoji-choice.selected {
  border-color: var(--main);
  background: #e8f5e9;
}

/* 報告の件数バッジ */
.badge {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: bold;
  margin-left: 5px;
}

/* 表示するアイコンを選ぶ窓のチェック一覧 */
.icon-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: normal;
  margin: 0;
  cursor: pointer;
}
/* 大きさは input[type="checkbox"] の共通の決まりにそろえてある */

/* ---------- 使いかたの案内(チュートリアル) ---------- */
/* 説明の間、うっかり画面を触ってしまわないように受け止める板 */
.tut-cover {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: transparent;
}
/* 説明したいところだけを明るく残し、まわりを暗くする */
.tut-hole {
  position: fixed;
  z-index: 4001;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transition: top 0.2s, left 0.2s, width 0.2s, height 0.2s;
}
.tut-bubble {
  position: fixed;
  z-index: 4002;
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.tut-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 6px;
}
.tut-text {
  font-size: 14px;
  line-height: 1.6;
  color: #333;
}
.tut-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.tut-count {
  flex: 1;
  font-size: 12px;
  color: #767676;
}
@media (prefers-reduced-motion: reduce) {
  .tut-hole { transition: none; }
}
/* まだ何も登録されていないときに、案内のあいだだけ出る「見本」 */
.tut-sample {
  position: relative;
  border: 2px dashed #b0b0b0;
  border-radius: 12px;
  background: #fafafa;
  padding: 14px;
  margin-top: 10px;
}
.tut-sample-tag {
  position: absolute;
  top: -11px;
  left: 12px;
  background: #767676;
  color: #fff;
  font-size: 11px;
  border-radius: 6px;
  padding: 2px 8px;
}

/* 案内の吹き出し内で、スズメを左・説明文を右に並べる */
.tut-bubble-content {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.tut-bubble-body {
  flex: 1;
  min-width: 0;
}
.tut-mascot-slot {
  display: none;
}
.tut-mascot-slot.has-mascot {
  display: block;
}

/* 長押しして「動かせる状態」になったポイント(役員ページ)。
   印の位置は地図の部品が transform で決めているので、中の絵だけを動かす */
.point-moving .poi-icon {
  animation: point-moving-pulse 1s ease-in-out infinite;
  filter: drop-shadow(0 0 5px #2e7d32);
}
@keyframes point-moving-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}
@media (prefers-reduced-motion: reduce) {
  .point-moving .poi-icon { animation: none; }
}

/* 書庫のフォルダ */
.folder-row {
  cursor: pointer;
  user-select: none;
  background: #f0f4f0;
}
.folder-row .chev {
  font-size: 12px;
  color: #888;
}
.folder-body {
  padding-left: 18px;
}

/* 期限切れの印 */
.expired-badge {
  display: inline-block;
  background: #eee;
  color: #888;
  font-size: 11px;
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: 6px;
}

/* ---------- スズメの案内キャラクター ---------- */
.mascot {
  width: 108px;
  height: auto;
  display: block;
  animation: mascotPop .35s ease-out,
             mascotFloat 2.6s ease-in-out .35s infinite;
}
.mascot.mascot-sm {
  width: 64px;
  flex-shrink: 0;
  /* ヘッダー(高さ52px)より大きくして、下の画面側へ少しはみ出させる。
     マイナスの余白で「レイアウト上の高さ」を縮め、はみ出し分を下に逃がす */
  margin-bottom: -20px;
  position: relative;
  z-index: 1500; /* 地図の部品(〜1000)より手前、浮かぶ窓(2000〜)より奥 */
  pointer-events: none; /* 飾りなので、重なった下のボタンの操作を邪魔しない */
}
.mascot.mascot-md {
  width: 72px;
}
/* ヘッダーのスズメは画面の上端に近く、上下5pxのふわふわだと
   頭が画面の上にはみ出るため、上下2pxの控えめなふわふわにする */
header .mascot-sm {
  animation: mascotPop .35s ease-out,
             mascotFloatSm 2.6s ease-in-out .35s infinite;
}
/* とても狭い画面では、ヘッダーのスズメを隠して団体名の幅を確保する */
@media (max-width: 360px) {
  header .mascot-sm { display: none; }
}
@keyframes mascotPop {
  0%   { transform: translateY(14px) scale(.7); opacity: 0; }
  60%  { transform: translateY(-4px) scale(1.05); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes mascotFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}
@keyframes mascotFloatSm {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2px); }
}
/* header .mascot-sm の指定は .mascot 単独より強いため、こちらにも並べて止める */
@media (prefers-reduced-motion: reduce) {
  .mascot,
  header .mascot-sm { animation: none; }
}
