/* はじまりのまち：参加者向け画面（大きな文字・大きなボタン・操作は最小限） */
:root {
  --ink: #1f2a33;
  --muted: #5d6b76;
  --bg: #f7f4ec;
  --paper: #fff;
  --line: #ddd6c6;
  --primary: #1d4f73;
  --primary-ink: #fff;
  --accent: #c2410c;
  --ok: #2b8a3e;
  --warn: #b35c00;
  --error: #c92a2a;
  --noticed: #1d4f73;
  --question: #d9480f;
  --researched: #2b8a3e;
  --radius: 12px;
  --tabbar-h: 64px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 18px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--bg);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: var(--primary); }
img { max-width: 100%; }
h1 { font-size: 1.5rem; line-height: 1.4; margin: 0.6em 0 0.4em; }
h2 { font-size: 1.2rem; line-height: 1.4; margin: 1.2em 0 0.5em; }
p { margin: 0.5em 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hint { color: var(--muted); font-size: 0.95rem; margin: 0.3em 0; }
.optional { font-size: 0.85rem; color: var(--muted); font-weight: normal; margin-left: 0.4em; }
[hidden] { display: none !important; }

/* ヘッダー */
.site-header {
  background: var(--primary);
  color: #fff;
  padding: 10px 16px 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.brand { color: #fff; text-decoration: none; display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: 1.45rem; font-weight: 800; letter-spacing: 0.08em; }
.brand-sub { font-size: 0.8rem; opacity: 0.9; }
.brand-org { font-size: 0.72rem; opacity: 0.85; }

.main { max-width: 720px; margin: 0 auto; padding: 8px 16px 24px; }
.page-map .main { max-width: none; padding: 0; }

/* ボタン */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 8px 18px;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  background: #fff;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-big { min-height: 60px; font-size: 1.15rem; width: 100%; }
.btn-small { min-height: 40px; padding: 4px 12px; font-size: 0.95rem; }
.btn-line { background: #06c755; border-color: #06c755; color: #fff; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.btn-col { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; }

/* フォーム */
input[type="text"], input[type="search"], input[type="date"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid #74c0fc; border-color: var(--primary); }
label { display: block; font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label textarea, .stack label input { margin-top: 4px; font-weight: normal; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; }
.inline-form label { flex: 1; }

/* お知らせ */
.flash { max-width: 720px; margin: 10px auto 0; padding: 12px 16px; border-radius: var(--radius); background: #e6fcf5; border: 2px solid #96f2d7; }
.flash-error { background: #fff5f5; border-color: #ffa8a8; }
.flash-warn { background: #fff9db; border-color: #ffe066; }
.notice { background: #fff9db; border: 2px solid #ffe066; padding: 10px 14px; border-radius: var(--radius); }
.login-nudge { background: #e7f5ff; border: 2px solid #a5d8ff; padding: 12px 16px; border-radius: var(--radius); margin: 12px 0; }
.login-nudge a { font-weight: 700; margin-left: 4px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px); transform: translate(-50%, 20px);
  background: #1f2a33; color: #fff; padding: 12px 20px; border-radius: 999px; opacity: 0; transition: 0.25s; z-index: 2000;
  max-width: 90vw; pointer-events: none;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.toast[data-type="error"] { background: var(--error); }

/* カード */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; display: block; color: inherit; text-decoration: none; }
.section { margin: 18px 0; }
.empty { color: var(--muted); padding: 20px 0; }

/* トップ */
.hero { padding: 18px 4px 4px; }
.hero-lead { font-size: 1.3rem; font-weight: 700; line-height: 1.6; }
.event-title { font-size: 1.2rem; font-weight: 800; }
.big-links { display: grid; gap: 10px; }
.big-link { display: block; background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--ink); }
.big-link strong { display: block; font-size: 1.15rem; color: var(--primary); }
.big-link span { font-size: 0.9rem; color: var(--muted); }
.thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb-item { text-decoration: none; color: var(--ink); font-size: 0.8rem; line-height: 1.4; }
.thumb-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; margin-bottom: 4px; }

/* 投稿画面 */
.post-head h1 { margin-bottom: 0; }
.field { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 14px 0; }
.field-title { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.step { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 1rem; }
.photo-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.photo-buttons .btn-big { font-size: 1.05rem; }
.photo-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-item { position: relative; aspect-ratio: 1; background: #eee; border-radius: 10px; overflow: hidden; display: grid; place-items: center; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-no { position: absolute; left: 6px; top: 6px; background: rgba(0, 0, 0, 0.6); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 0.85rem; }
.photo-remove { position: absolute; right: 4px; top: 4px; width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 1.4rem; line-height: 1; cursor: pointer; }
.photo-loading { color: var(--muted); font-size: 0.85rem; }
.caution { font-size: 0.9rem; background: #fff4e6; border-radius: 8px; padding: 8px 10px; margin-top: 10px; }
.chips, .status-choice { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { font-weight: normal; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 8px 14px; border: 2px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; min-height: 44px; }
.chip input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid #74c0fc; }
.mini-map { height: 260px; border-radius: 10px; margin: 8px 0; border: 1px solid var(--line); }
.loc-status { font-weight: 700; color: var(--muted); }
.loc-status.is-ok { color: var(--ok); }
.loc-status.is-warn { color: var(--warn); }
.publish-note { font-size: 0.9rem; color: var(--muted); margin: 14px 2px; }
.form-error { background: #fff5f5; border: 2px solid #ffa8a8; color: var(--error); padding: 12px 14px; border-radius: var(--radius); white-space: pre-line; font-weight: 700; }
.submit-area { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); background: var(--bg); padding: 10px 0; }
.btn-submit { width: 100%; min-height: 64px; font-size: 1.3rem; }
.progress { margin-top: 10px; }
.progress::before { content: ""; display: block; }
.progress { background: transparent; }
.progress-bar { height: 12px; width: 0; background: var(--ok); border-radius: 999px; transition: width 0.2s; }
.progress-text { font-weight: 700; }
#retry-btn { margin-top: 8px; }

/* 完了画面 */
.done { text-align: center; padding-top: 20px; }
.done-mark { width: 84px; height: 84px; margin: 0 auto; border-radius: 50%; background: var(--ok); color: #fff; font-size: 3rem; line-height: 84px; }
.points-earned { background: #fff9db; border: 2px solid #ffe066; border-radius: var(--radius); padding: 12px; margin: 16px 0; }
.points-big { font-size: 2rem; font-weight: 800; color: var(--accent); }
.points-mid { font-size: 1.4rem; font-weight: 800; }
.points-breakdown { list-style: none; padding: 0; margin: 4px 0 0; font-size: 0.95rem; }
.points-card { display: flex; justify-content: space-around; text-align: center; }

/* 地図画面 */
.map-page { position: relative; height: calc(100vh - 62px - var(--tabbar-h)); height: calc(100dvh - 62px - var(--tabbar-h) - env(safe-area-inset-bottom)); }
.map-full { position: absolute; inset: 0; }
.map-filters { position: absolute; z-index: 800; top: 8px; left: 56px; right: 56px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.map-filters select { width: auto; max-width: 48%; padding: 6px 8px; font-size: 0.95rem; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); }
.map-count { background: rgba(255, 255, 255, 0.9); border-radius: 999px; padding: 2px 10px; font-size: 0.9rem; }
.legend { position: absolute; z-index: 700; right: 8px; bottom: 24px; background: rgba(255, 255, 255, 0.92); border-radius: 8px; padding: 4px 8px; font-size: 0.8rem; display: flex; flex-direction: column; }
.pin-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.pin-dot.pin-noticed { background: var(--noticed); }
.pin-dot.pin-question { background: var(--question); }
.pin-dot.pin-researched { background: var(--researched); }
.sheet {
  position: absolute; z-index: 1000; left: 0; right: 0; bottom: 0; max-height: 78%;
  background: #fff; border-radius: 18px 18px 0 0; box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
  display: flex; flex-direction: column;
}
.sheet-body { overflow-y: auto; padding: 8px 16px 16px; }
.sheet-close { align-self: flex-end; margin: 6px 8px 0; width: 48px; height: 48px; border: none; background: #f1f3f5; border-radius: 50%; font-size: 1.6rem; cursor: pointer; }
@media (min-width: 900px) {
  .sheet { left: auto; top: 8px; bottom: 8px; right: 8px; width: 420px; max-height: none; border-radius: 16px; }
}

/* ピン */
.pin-wrap { background: none; border: none; }
.pin {
  --s: 46px; --c: var(--noticed);
  position: relative; width: var(--s); height: var(--s); border-radius: 50%; border: 4px solid var(--c); background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.pin::after { content: ""; position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); border: 7px solid transparent; border-top: 9px solid var(--c); }
/* Leaflet はマーカー内の img を width:auto !important にするので、ここで上書きする */
.leaflet-container .leaflet-marker-pane .pin img { width: 100% !important; height: 100% !important; object-fit: cover; border-radius: 50%; display: block; }
.pin-question { --c: var(--question); }
.pin-researched { --c: var(--researched); }
.pin.is-pending { opacity: 0.6; border-style: dashed; }
.pin.is-picked { box-shadow: 0 0 0 3px #fcc419, 0 2px 6px rgba(0, 0, 0, 0.35); }
.pin-mark { position: absolute; right: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--c); color: #fff; font-size: 14px; line-height: 22px; text-align: center; }
.pin-star { position: absolute; left: -8px; top: -8px; color: #f59f00; font-size: 20px; text-shadow: 0 0 2px #fff, 0 0 2px #fff; }
.leaflet-marker-icon.is-new .pin { animation: pop 1.2s ease-out 3; }
@keyframes pop { 0% { transform: scale(1); } 30% { transform: scale(1.5); } 100% { transform: scale(1); } }
.locate-btn { width: 44px; height: 44px; background: #fff; border: 2px solid rgba(0, 0, 0, 0.2); border-radius: 6px; font-size: 22px; cursor: pointer; }
.locate-btn.is-busy { opacity: 0.5; }
.leaflet-container { font: inherit; font-size: 14px; }
.leaflet-control-layers-toggle { width: 44px; height: 44px; }

/* 古地図スライダー */
.oldmap-control { background: rgba(255, 255, 255, 0.95); padding: 6px 10px; border-radius: 10px; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3); font-size: 0.95rem; min-width: 220px; }
.oldmap-control select { padding: 4px; font-size: 0.9rem; }
.oldmap-name { font-weight: 700; }
.oldmap-slider { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.oldmap-slider input { flex: 1; height: 32px; }
.page-map .leaflet-bottom.leaflet-left { margin-bottom: 18px; }

/* 投稿カード */
.post-card { background: #fff; }
.carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 6px; border-radius: 10px; -webkit-overflow-scrolling: touch; }
.slide { flex: 0 0 100%; margin: 0; scroll-snap-align: center; background: #111; display: grid; place-items: center; border-radius: 10px; overflow: hidden; }
.slide img { width: 100%; height: auto; max-height: 60vh; object-fit: contain; display: block; }
.carousel-hint { text-align: center; font-size: 0.85rem; color: var(--muted); margin: 2px 0; }
.post-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 700; color: #fff; background: var(--noticed); }
.badge-question { background: var(--question); }
.badge-researched { background: var(--researched); }
.badge-picked { background: #f59f00; }
.badge-pending { background: #868e96; }
.post-comment { font-size: 1.1rem; }
.post-by { font-weight: 700; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-block; font-size: 0.85rem; background: #edf2f7; border-radius: 6px; padding: 0 8px; color: var(--ink); }
.notes { background: #ebfbee; border-radius: 10px; padding: 8px 12px; margin: 10px 0; }
.notes h3 { margin: 4px 0; font-size: 1rem; color: var(--researched); }
.note + .note { border-top: 1px dashed #b2f2bb; }
.note-sources { font-size: 0.9rem; color: var(--muted); }
.note-photos { display: flex; gap: 6px; flex-wrap: wrap; }
.note-photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }
.post-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.btn-like { min-height: 44px; padding: 4px 14px; border-radius: 999px; border: 2px solid #ffc9c9; background: #fff; color: #c92a2a; font: inherit; font-weight: 700; cursor: pointer; }
.btn-like.is-liked { background: #ff8787; border-color: #ff8787; color: #fff; }
.btn-like:disabled { opacity: 0.5; }
.btn-report { margin-left: auto; background: none; border: none; color: var(--muted); text-decoration: underline; font: inherit; font-size: 0.85rem; cursor: pointer; min-height: 44px; }
.back { margin: 8px 0; }

/* 一覧 */
.filters { padding: 12px; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.filter-grid label { font-size: 0.9rem; }
.filter-grid select, .filter-grid input { margin-top: 2px; padding: 8px; }
.span-2 { grid-column: span 2; }
.post-list { display: flex; flex-direction: column; gap: 8px; }
.post-row { display: flex; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; text-decoration: none; color: var(--ink); align-items: flex-start; }
.post-row img { width: 88px; height: 88px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.post-row-comment { margin: 2px 0; line-height: 1.5; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 16px 0; }

/* コース */
.course-card h2 { margin: 4px 0; }
.map-course { height: 340px; border-radius: var(--radius); border: 1px solid var(--line); margin: 10px 0; }
.checkpoints { padding-left: 0; list-style: none; counter-reset: cp; }
.checkpoint { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; counter-increment: cp; }
.checkpoint .cp-head::before { content: counter(cp); display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #e8590c; color: #fff; margin-right: 8px; font-size: 0.9rem; }
.checkpoint.is-visited { border-color: #8ce99a; background: #f4fce3; }
.checkpoint.is-visited .cp-head::before { background: #2f9e44; }
.cp-state { margin-left: 8px; color: var(--ok); font-weight: 700; }
.cp-msg { font-weight: 700; color: var(--primary); }
.cp-label { background: transparent; border: none; box-shadow: none; color: #fff; font-weight: 800; }
.progress-line { font-size: 1.1rem; }
.course-progress { list-style: none; padding: 0; }
.course-progress li { margin: 6px 0; }
.bar { display: inline-block; width: 100px; height: 10px; background: #e9ecef; border-radius: 999px; vertical-align: middle; margin: 0 8px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--ok); }

/* マイページ */
.history { list-style: none; padding: 0; font-size: 0.95rem; }
.history span { color: var(--muted); font-size: 0.85rem; }
.ranking { padding-left: 1.6em; }
.ranking li { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 4px 0; }
.ranking li.is-me { font-weight: 800; color: var(--accent); }
.logout { margin-top: 30px; }

/* ログイン */
.login-page { text-align: center; }
.login-title { font-size: 2.2rem; letter-spacing: 0.1em; margin-bottom: 0; color: var(--primary); }
.login-org { font-size: 0.85rem; color: var(--muted); margin-top: 0; }
.login-page .card { text-align: left; }
.check-list { padding-left: 1.2em; }

/* 規約など */
.doc h2 { border-left: 5px solid var(--primary); padding-left: 10px; }
.big-list li { font-size: 1.1rem; margin: 4px 0; }
.note-target { display: flex; gap: 12px; align-items: flex-start; }
.note-target img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }
.error-page { text-align: center; padding: 40px 0; }

/* フッターとタブバー */
.site-footer { max-width: 720px; margin: 20px auto 0; padding: 16px; font-size: 0.85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 16px; }
.site-footer p { width: 100%; margin: 4px 0 0; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--muted); font-size: 0.78rem; font-weight: 700; line-height: 1.2; }
.tabbar a.is-active { color: var(--primary); }
.tab-icon { width: 26px; height: 26px; margin-bottom: 2px; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.tab-post { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 3 7.2 5H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-3.2L15 3H9zm3 5a5 5 0 1 1 0 10 5 5 0 0 1 0-10zm0 2a3 3 0 1 0 0 6 3 3 0 0 0 0-6z'/%3E%3C/svg%3E"); }
.tab-map { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-7 7c0 5.2 7 13 7 13s7-7.8 7-13a7 7 0 0 0-7-7zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5z'/%3E%3C/svg%3E"); }
.tab-list { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 4h7v7H3zm11 1h7v2h-7zm0 3h5v2h-5zM3 13h7v7H3zm11 1h7v2h-7zm0 3h5v2h-5z'/%3E%3C/svg%3E"); }
.tab-me { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm0 2c-4.4 0-9 2.2-9 5v3h18v-3c0-2.8-4.6-5-9-5z'/%3E%3C/svg%3E"); }
