/* app.css — 参加者アプリ（PWA）
   歩行中・屋外・片手操作を前提に、文字とタップ領域を大きめに取る。 */

:root {
  --green:      #1b5e20;
  --green-dark: #123f16;
  --green-soft: #e8f3e9;
  --orange:     #e5661a;
  --gold:       #d4a017;
  --red:        #c62828;
  --ink:        #1c2321;
  --ink-mid:    #5b6b63;
  --ink-soft:   #7b8783;
  --line:       #dfe6e2;
  --bg:         #f4f7f4;
  --white:      #fff;
  --radius:     14px;
  --shadow:     0 2px 12px rgba(20, 50, 30, .09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* ───────── 起動画面 ───────── */

.gate {
  position: fixed; inset: 0; z-index: 50;
  background: linear-gradient(165deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff; overflow-y: auto;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gate-inner { width: 100%; max-width: 400px; text-align: center; }
.gate-logo { font-size: 56px; }
.gate h1 { font-size: 22px; line-height: 1.45; margin: 12px 0 6px; }
.gate-lead { font-size: 13px; opacity: .8; margin: 0 0 26px; }

.gate-form {
  background: rgba(255,255,255,.11); border-radius: var(--radius);
  padding: 18px; text-align: left;
}
.gate-form label { font-size: 13px; font-weight: 700; display: block; margin-bottom: 8px; }
.gate-form input {
  width: 100%; padding: 13px; font-size: 16px; border: none;
  border-radius: 9px; margin-bottom: 10px;
}
.gate-hint { font-size: 11px; opacity: .72; margin: 10px 0 0; line-height: 1.6; }

.gate-demo { margin-top: 22px; text-align: left; }
.gate-demo-title { font-size: 12px; opacity: .8; margin: 0 0 8px; }
.gate-demo-list { display: flex; flex-direction: column; gap: 6px; }
.gate-demo-item {
  background: rgba(255,255,255,.1); border: none; color: #fff;
  padding: 11px 13px; border-radius: 9px; text-align: left;
  font-size: 13px; cursor: pointer; font-family: inherit;
}
.gate-demo-item:active { background: rgba(255,255,255,.2); }
.gate-demo-item b { font-weight: 700; }
.gate-demo-item span { opacity: .7; font-size: 11px; display: block; margin-top: 2px; }

/* ───────── アプリ枠 ───────── */

/* SOSボタンが最下部のコンテンツに重ならないよう、スクロール余白を多めに取る */
.app { padding-bottom: 150px; }

.appbar {
  /* Leaflet が内部で z-index 1000 まで使うため、それより前に出す。
     低いままだと地図がヘッダーを覆う（LINEのアプリ内ブラウザで発生） */
  position: sticky; top: 0; z-index: 1100;
  background: var(--green); color: #fff;
  padding: 11px 15px; display: flex; align-items: center; gap: 10px;
  padding-top: max(11px, env(safe-area-inset-top));
}
.appbar-main { flex: 1; min-width: 0; }
.appbar-title { font-size: 14px; font-weight: 700; }
.appbar-sub { font-size: 11px; opacity: .85; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.net-badge {
  font-size: 10px; padding: 4px 9px; border-radius: 99px;
  background: rgba(255,255,255,.2); white-space: nowrap;
}
.net-badge.offline { background: var(--orange); font-weight: 700; }

.views { position: relative; }
.view { display: none; padding: 15px; }
.view.active { display: block; }

/* ───────── 参加証 ───────── */

.pass-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; text-align: center;
  border-top: 4px solid var(--green);
}
.pass-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.pass-label { font-size: 11px; color: var(--ink-soft); letter-spacing: .06em; font-weight: 700; }
.pass-status {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 99px;
  background: #eef1ef; color: var(--ink-soft);
}
.pass-status.done { background: var(--green-soft); color: var(--green); }

.pass-qr { display: flex; justify-content: center; padding: 6px; }
.pass-qr img, .pass-qr canvas { display: block; }

.pass-name { font-size: 21px; font-weight: 700; margin: 14px 0 4px; }

.pass-meta {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--line);
}
.pass-meta div { text-align: center; }
.pass-meta dt { font-size: 10px; color: var(--ink-soft); margin-bottom: 3px; }
.pass-meta dd { margin: 0; font-size: 13px; font-weight: 700; }

.pass-note { font-size: 11px; color: var(--ink-soft); margin: 13px 0 0; }

/* ───────── パネル ───────── */

.panel {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-top: 13px;
}
.panel-title { font-size: 13px; margin: 0 0 12px; font-weight: 700; }

.progress-row { display: flex; align-items: center; gap: 11px; }
.progress-bar { flex: 1; height: 9px; background: #e9eeea; border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--green), #4c9a2a);
  border-radius: 99px; transition: width .5s ease;
}
.progress-text { font-size: 13px; font-weight: 700; white-space: nowrap; }

.next-cp { font-size: 12px; color: var(--ink-soft); margin-top: 11px; line-height: 1.6; }
.next-cp b { color: var(--ink); }

.panel-safety { background: var(--green-soft); box-shadow: none; }
.safety-text { font-size: 12px; line-height: 1.75; margin: 0; color: #35473a; }
.consent-state { font-size: 11px; margin-top: 9px; font-weight: 700; color: var(--green); }

/* ───────── マップ ───────── */

#view-map { padding: 0; }
/* 高さはJSがヘッダーとタブバーを実測して --map-h に入れる。
   ブラウザごとにヘッダー等の実寸が違うため、固定値で引くと必ずどこかでずれる。
   JSが動く前・失敗時のための保険として calc() を残す。 */
.map { width: 100%; height: calc(100vh - 175px); height: var(--map-h, calc(100vh - 175px)); }
@supports (height: 100dvh) {
  .map { height: var(--map-h, calc(100dvh - 175px)); }
}
.map-legend {
  position: absolute; bottom: 12px; left: 12px; z-index: 400;
  background: rgba(255,255,255,.94); border-radius: 9px; padding: 8px 11px;
  display: flex; gap: 12px; font-size: 11px; box-shadow: var(--shadow);
}
.map-legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-done { background: var(--gold); }
.dot-todo { background: #b6c2bb; }
.dot-me   { background: #1976d2; }

.cp-marker {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: #fff; border: 2.5px solid #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,.35);
}
.cp-marker.done { background: var(--gold); }
.cp-marker.todo { background: #94a49b; }
.cp-marker.goal { background: var(--red); }

.me-marker {
  width: 18px; height: 18px; border-radius: 50%; background: #1976d2;
  border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(25,118,210,.22);
}

/* ───────── スタンプ ───────── */

.stamp-head { margin-bottom: 14px; }
.section-title { font-size: 17px; margin: 0 0 5px; }
.section-lead { font-size: 12px; color: var(--ink-soft); margin: 0; line-height: 1.6; }

.btn {
  font-family: inherit; font-size: 15px; border: none; border-radius: 11px;
  padding: 14px; cursor: pointer; width: 100%; font-weight: 700;
}
.btn-primary { background: var(--gold); color: #fff; }
.btn-scan { background: var(--green); color: #fff; margin-bottom: 15px; }
.btn-ghost { background: #eef1ef; color: var(--ink-mid); }
.btn-furusato { background: var(--orange); color: #fff; display: block;
  text-align: center; text-decoration: none; margin-top: 13px; }

.scanner { background: #000; border-radius: var(--radius); padding: 11px; margin-bottom: 15px; }
#reader { border-radius: 9px; overflow: hidden; }
.scanner .btn { margin-top: 11px; }

.demo-scan {
  background: #fff8e6; border: 1px dashed var(--gold);
  border-radius: var(--radius); padding: 13px; margin-bottom: 15px;
}
.demo-scan-title { font-size: 11px; font-weight: 700; color: #8a6d1a; margin: 0 0 9px; }
.demo-scan-list { display: flex; flex-direction: column; gap: 6px; }
.demo-cp-btn {
  background: #fff; border: 1px solid #e5d9b4; border-radius: 9px;
  padding: 11px 13px; font-size: 13px; text-align: left; cursor: pointer;
  font-family: inherit; display: flex; align-items: center; gap: 9px;
}
.demo-cp-btn:disabled { opacity: .45; }
.demo-cp-btn b { flex: 1; font-weight: 600; }

.stamp-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
.stamp-cell {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 15px 11px; text-align: center; position: relative;
}
.stamp-cell.locked { opacity: .55; }
.stamp-circle {
  width: 62px; height: 62px; margin: 0 auto 9px; border-radius: 50%;
  display: grid; place-items: center; font-size: 27px;
  border: 2.5px dashed #c3cec7; color: #b3bfb8;
}
.stamp-cell.got .stamp-circle {
  border: 2.5px solid var(--gold); background: #fdf6e3; color: inherit;
}
.stamp-cp-name { font-size: 12px; font-weight: 700; line-height: 1.4; }
.stamp-dist { font-size: 10px; color: var(--ink-soft); margin-top: 3px; }
.stamp-time { font-size: 10px; color: var(--gold); font-weight: 700; margin-top: 5px; }

/* ───────── 特産品カード ───────── */

.card-list { display: flex; flex-direction: column; gap: 12px; }
.product-item {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 15px; display: flex; gap: 13px; align-items: flex-start;
}
.product-item.locked { opacity: .5; }
.product-item-emoji {
  font-size: 34px; width: 54px; height: 54px; border-radius: 12px;
  background: var(--green-soft); display: grid; place-items: center; flex-shrink: 0;
}
.product-item-body { flex: 1; min-width: 0; }
.product-item-name { font-size: 14px; font-weight: 700; }
.product-item-cp { font-size: 10px; color: var(--ink-soft); margin: 2px 0 6px; }
.product-item-desc { font-size: 12px; line-height: 1.65; margin: 0 0 9px; color: #47524d; }
.product-item-link {
  font-size: 12px; color: var(--orange); font-weight: 700; text-decoration: none;
}
.locked-note { font-size: 11px; color: var(--ink-soft); }

/* ───────── SOS ───────── */

.sos-fab {
  position: fixed; right: 15px; z-index: 1050;
  bottom: calc(var(--tabbar-h, 62px) + 18px);
  width: 62px; height: 62px; border-radius: 50%; border: 3px solid #fff;
  background: var(--red); color: #fff; font-size: 15px; font-weight: 700;
  box-shadow: 0 3px 14px rgba(198,40,40,.45); cursor: pointer; font-family: inherit;
}
.sos-fab:active { transform: scale(.94); }

/* ───────── タブバー ───────── */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
  background: var(--white); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  border: none; background: none; padding: 9px 0 10px; font-size: 10px;
  color: var(--ink-soft); cursor: pointer; font-family: inherit; font-weight: 700;
}
.tab span { display: block; font-size: 20px; margin-bottom: 2px; filter: grayscale(1); opacity: .5; }
.tab.active { color: var(--green); }
.tab.active span { filter: none; opacity: 1; }

/* ───────── モーダル ───────── */

.modal {
  position: fixed; inset: 0; z-index: 60; background: rgba(15,30,20,.62);
  display: flex; align-items: center; justify-content: center; padding: 22px;
  overflow-y: auto;
}
.modal-box {
  background: var(--white); border-radius: 18px; padding: 24px 20px;
  width: 100%; max-width: 360px; text-align: center;
  animation: pop .28s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { transform: scale(.86); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.stamp-burst { font-size: 60px; animation: bounce .6s ease; }
@keyframes bounce { 0%{transform:scale(0)} 55%{transform:scale(1.25)} 100%{transform:scale(1)} }
.stamp-got { font-size: 19px; font-weight: 700; color: var(--gold); margin-top: 5px; }
.stamp-cp { font-size: 13px; color: var(--ink-soft); margin-top: 5px; }

.product-card {
  background: var(--green-soft); border-radius: var(--radius);
  padding: 18px; margin-top: 18px;
}
.product-emoji { font-size: 44px; }
.product-name { font-size: 17px; font-weight: 700; margin-top: 7px; }
.product-desc { font-size: 12.5px; line-height: 1.75; margin: 9px 0 0; color: #3a4a3e; text-align: left; }

.stamp-next { font-size: 12px; color: var(--ink-soft); margin-top: 15px; }
.modal-close { margin-top: 15px; }

.complete-emoji { font-size: 56px; }
.complete-modal h2 { font-size: 19px; margin: 9px 0 4px; }
.complete-modal p { font-size: 13px; color: var(--ink-soft); margin: 0; }
.complete-cert {
  margin-top: 18px; padding: 20px 15px; border-radius: 12px;
  background: linear-gradient(160deg, #fdf8e8, #f6ecd0);
  border: 2px solid var(--gold);
}
.cert-title { font-size: 11px; letter-spacing: .14em; color: #8a6d1a; font-weight: 700; }
.cert-name { font-size: 22px; font-weight: 700; margin: 9px 0; }
.cert-body { font-size: 11px; color: #6b5a2a; line-height: 1.8; }

.sos-modal { text-align: left; }
.sos-title { font-size: 18px; margin: 0 0 5px; color: var(--red); }
.sos-lead { font-size: 12px; color: var(--ink-soft); margin: 0 0 16px; }
.sos-options { display: flex; flex-direction: column; gap: 9px; }
.btn-sos-opt { background: #fdecec; color: #8b2020; text-align: left; font-size: 14px; }

.sos-done-icon { font-size: 46px; }
.sos-done-modal h2 { font-size: 18px; margin: 9px 0 9px; }
.sos-done-modal p { font-size: 13px; line-height: 1.75; color: var(--ink-mid); margin: 0; }
.sos-done-pos {
  font-size: 11px; color: var(--ink-soft); margin-top: 13px;
  background: #f2f5f3; border-radius: 9px; padding: 9px;
}

/* ───────── トースト ───────── */

.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: rgba(25,40,30,.94); color: #fff; padding: 12px 20px;
  border-radius: 99px; font-size: 13px; z-index: 70; max-width: 88%;
  text-align: center; box-shadow: var(--shadow);
}

/* ───────── カメラが使えない環境への案内 ───────── */

.scan-blocked {
  background: #fff8e1; border: 1px solid #f0d78c; border-radius: var(--radius);
  padding: 16px; margin-top: 12px;
}
.scan-blocked .blocked-msg {
  font-size: 14px; font-weight: 700; color: #7a5400; margin: 0 0 8px; line-height: 1.6;
}
.scan-blocked .blocked-how {
  font-size: 12.5px; color: var(--ink-mid); line-height: 1.8; margin: 0 0 12px;
}
