:root {
  --navy: #0f2742;
  --navy2: #19395f;
  --orange: #ff7a1a;
  --green: #1fa86b;
  --red: #e0453a;
  --yellow: #ffc83d;
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #1c2733;
  --muted: #6b7a8c;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(10, 30, 60, .18);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif; color: var(--text); background: #dde6ee; -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }
#map { position: fixed; inset: 0; z-index: 0; background: #e9eef2; }
.leaflet-container { font-family: inherit; }

/* ---------- 演出 ---------- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 450; }
#fx-rain {
  background-image:
    repeating-linear-gradient(105deg, rgba(160, 190, 230, .0) 0 9px, rgba(160, 190, 230, .35) 9px 10px, rgba(160, 190, 230, 0) 10px 23px),
    repeating-linear-gradient(100deg, rgba(200, 220, 255, .0) 0 15px, rgba(200, 220, 255, .25) 15px 16px, rgba(200, 220, 255, 0) 16px 37px);
  background-size: 200px 200px, 300px 300px;
  animation: rain .35s linear infinite;
  background-color: rgba(40, 60, 90, .12);
}
@keyframes rain { to { background-position: -40px 200px, -50px 300px; } }
#fx-night { z-index: 440; }
#fx-flash { opacity: 0; transition: opacity .4s; z-index: 460; }
body.shake #map { animation: shake .12s linear infinite; }
@keyframes shake { 0% { transform: translate(0, 0) } 25% { transform: translate(-6px, 3px) } 50% { transform: translate(5px, -4px) } 75% { transform: translate(-3px, -5px) } 100% { transform: translate(0, 0) } }

/* ---------- マーカー ---------- */
.gi { display: flex; align-items: center; justify-content: center; }
.gi > div { font-size: 22px; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)); }
.gi.player > div { font-size: 30px; transition: transform .2s; }
.gi.player.flip > div { transform: scaleX(-1); }
.gi.player::before { content: ""; position: absolute; width: 44px; height: 44px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 122, 26, .45), rgba(255, 122, 26, 0) 70%); animation: pulse 1.6s infinite; z-index: -1; }
.gi.player.in-water::after { content: ""; position: absolute; bottom: 2px; width: 34px; height: 12px; border-radius: 50%; background: rgba(40, 110, 220, .6); }
@keyframes pulse { 0% { transform: scale(.7); opacity: 1 } 100% { transform: scale(1.4); opacity: 0 } }
.gi.sh > div { background: #fff; border: 2px solid #5a6b80; border-radius: 9px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.gi.sh-valid > div { border-color: var(--green); background: #e5fff1; box-shadow: 0 0 0 4px rgba(31, 168, 107, .35); }
.gi.sh-radio > div { animation: glow 1s infinite alternate; border-color: var(--orange); }
@keyframes glow { from { box-shadow: 0 0 0 2px rgba(255, 122, 26, .3) } to { box-shadow: 0 0 0 10px rgba(255, 122, 26, .6) } }
.gi.item > div { animation: bob 1.4s ease-in-out infinite alternate; }
@keyframes bob { from { transform: translateY(0) } to { transform: translateY(-5px) } }
.gi.npc > div { font-size: 26px; }
.gi.npc .help { position: absolute; top: -6px; right: -4px; background: var(--red); color: #fff; font-size: 11px; font-weight: bold; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; animation: pulse2 .8s infinite alternate; }
@keyframes pulse2 { to { transform: scale(1.25) } }
.gi.presign > div { animation: blink .5s infinite alternate; font-size: 26px; }
@keyframes blink { to { opacity: .3 } }
.gi.mini > div { font-size: 16px; }
.gi.home > div { font-size: 28px; }
.dyn-layer { pointer-events: none; }
.hz-tiles { mix-blend-mode: multiply; }

/* ---------- 表紙 ---------- */
#cover { position: fixed; inset: 0; z-index: 800; background: linear-gradient(160deg, rgba(15, 39, 66, .93), rgba(25, 57, 95, .86)); color: #fff; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto; }
.cover-inner { max-width: 520px; width: 100%; text-align: center; }
.logo { font-size: 44px; font-weight: 900; letter-spacing: .04em; margin: 8px 0 0; text-shadow: 0 4px 0 #0a1b2e; }
.logo span { color: var(--orange); }
.sub { opacity: .85; margin: 6px 0 22px; }
.cover-art { font-size: 54px; letter-spacing: 10px; margin: 10px 0; }
.feature-list { text-align: left; background: rgba(255, 255, 255, .08); border-radius: var(--radius); padding: 14px 18px; margin: 18px 0; font-size: 14px; line-height: 1.8; }

/* ---------- パネル（メニュー） ---------- */
#panel { position: fixed; z-index: 700; top: 12px; left: 12px; bottom: 12px; width: 410px; background: var(--bg); border-radius: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.p-head { background: var(--navy); color: #fff; padding: 14px 16px 12px; flex-shrink: 0; }
.p-head h2 { margin: 0; font-size: 19px; }
.p-head .back { background: rgba(255, 255, 255, .15); color: #fff; border: 0; border-radius: 10px; padding: 6px 10px; margin-right: 8px; font-size: 14px; }
.p-head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.p-body { padding: 14px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.p-body h3 { font-size: 15px; margin: 16px 0 8px; color: var(--navy); display: flex; align-items: center; gap: 6px; }
.p-body h3:first-child { margin-top: 2px; }
.p-collapse { display: none; }
.lv-box { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; }
.lv-num { background: var(--orange); color: #fff; font-weight: 900; border-radius: 10px; padding: 3px 9px; font-size: 14px; }
.lv-bar { flex: 1; height: 7px; background: rgba(255, 255, 255, .2); border-radius: 4px; overflow: hidden; }
.lv-bar div { height: 100%; background: var(--yellow); }

.card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 2px 8px rgba(10, 30, 60, .06); margin-bottom: 10px; }
.diag-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.diag { border-radius: 12px; padding: 8px 10px; background: #f1f4f8; font-size: 12px; position: relative; cursor: pointer; border: 2px solid transparent; }
.diag.on { border-color: var(--navy2); }
.diag b { display: block; font-size: 14px; margin-top: 2px; }
.diag .pct { color: var(--muted); font-size: 11px; }
.diag.lv1 { background: #fff8d6; } .diag.lv2 { background: #ffe7d2; } .diag.lv3 { background: #ffd6d6; }
.diag .chip-eye { position: absolute; right: 8px; top: 7px; font-size: 12px; opacity: .6; }

.sc-list { display: grid; gap: 8px; }
.sc { display: flex; align-items: center; gap: 12px; background: #fff; border: 2px solid #e3e9f0; border-radius: 14px; padding: 10px 12px; text-align: left; width: 100%; transition: .15s; }
.sc:hover { border-color: #b9c7d8; }
.sc.sel { border-color: var(--orange); background: #fff6ee; box-shadow: 0 0 0 3px rgba(255, 122, 26, .2); }
.sc.dis { opacity: .5; }
.sc .ic { font-size: 30px; width: 40px; text-align: center; }
.sc .nm { font-weight: 800; font-size: 15px; }
.sc .ds { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.sc .best { margin-left: auto; font-size: 11px; color: var(--muted); text-align: right; white-space: nowrap; }
.tag { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 20px; margin-left: 4px; font-weight: bold; vertical-align: middle; }
.tag.hi { background: #ffe1e1; color: #b8261b; } .tag.mid { background: #fff0c9; color: #8a5b00; } .tag.no { background: #e5ecf3; color: #567; }

.seg { display: flex; background: #e6ecf3; border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 4px; border-radius: 9px; font-weight: bold; font-size: 13px; color: #456; }
.seg button.on { background: #fff; color: var(--navy); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.hint { font-size: 12px; color: var(--muted); margin: 6px 2px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 2px solid #dbe3ec; background: #fff; border-radius: 20px; padding: 5px 11px; font-size: 13px; font-weight: bold; color: #345; }
.chip.on { border-color: var(--orange); background: #fff1e5; color: #b04c00; }
.chip.lock { opacity: .45; }

.btn { display: block; width: 100%; border: 0; border-radius: 14px; padding: 14px; font-size: 17px; font-weight: 900; background: #e3e9f0; color: var(--navy); }
.btn.primary { background: linear-gradient(180deg, #ff8d33, #ff6a00); color: #fff; box-shadow: 0 4px 0 #c24f00; }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #c24f00; }
.btn.green { background: linear-gradient(180deg, #2bc07e, #179a5f); color: #fff; box-shadow: 0 4px 0 #0f7247; }
.btn.navy { background: var(--navy2); color: #fff; }
.btn.small { padding: 9px; font-size: 14px; }
.btn + .btn { margin-top: 8px; }
.btn:disabled { opacity: .5; }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mbtn { border: 0; background: #fff; border-radius: 14px; padding: 10px 4px; font-size: 12px; font-weight: bold; color: var(--navy); box-shadow: 0 2px 6px rgba(10, 30, 60, .07); position: relative; }
.mbtn .e { font-size: 24px; display: block; margin-bottom: 3px; }
.mbtn .badge { position: absolute; top: 4px; right: 6px; background: var(--red); color: #fff; font-size: 10px; border-radius: 8px; padding: 0 5px; }

/* ---------- 場所選択 ---------- */
.crosshair { position: fixed; left: 50%; top: 50%; z-index: 600; transform: translate(-50%, -100%); font-size: 40px; pointer-events: none; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .4)); }
.search-row { display: flex; gap: 6px; }
.search-row input { flex: 1; border: 2px solid #d5dee8; border-radius: 12px; padding: 10px; font-size: 15px; font-family: inherit; min-width: 0; }
.search-row button { border: 0; background: var(--navy2); color: #fff; border-radius: 12px; padding: 0 14px; font-weight: bold; }
.results { margin-top: 6px; }
.results button { display: block; width: 100%; text-align: left; border: 0; background: #fff; border-bottom: 1px solid #eef2f6; padding: 9px; font-size: 14px; }
.preset { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 読み込み ---------- */
.loading { text-align: center; padding: 20px 6px; }
.loading .spin { font-size: 46px; animation: spin 1.6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg) } }
.prog { height: 12px; background: #e3e9f0; border-radius: 8px; overflow: hidden; margin: 16px 0 8px; }
.prog div { height: 100%; background: linear-gradient(90deg, var(--orange), var(--yellow)); width: 0; transition: width .3s; }
.load-steps { text-align: left; font-size: 13px; line-height: 1.9; margin-top: 12px; }
.tip { background: #fff7e8; border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-top: 16px; text-align: left; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 650; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 20px)); background: rgba(15, 39, 66, .9); color: #fff; border-radius: 16px; padding: 8px 12px; box-shadow: var(--shadow); }
.hud-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hud-sc { font-weight: 900; font-size: 15px; }
.hud-time { text-align: right; }
.hud-phase { font-weight: 900; font-size: 15px; color: var(--yellow); }
.hud-phase.danger { color: #ff8a80; animation: blink .6s infinite alternate; }
.hud-limit { font-size: 11px; opacity: .8; }
.bars { margin: 6px 0 4px; }
.bar { flex: 1; display: flex; align-items: center; gap: 5px; }
.bar .lbl { font-size: 13px; }
.track { flex: 1; height: 9px; background: rgba(255, 255, 255, .18); border-radius: 6px; overflow: hidden; }
.fill { height: 100%; border-radius: 6px; transition: width .2s; }
.fill.hp { background: linear-gradient(90deg, #ff5a4e, #ff9d6e); }
.fill.st { background: linear-gradient(90deg, #4fc3f7, #a5e9ff); }
.hud-feet { font-size: 12.5px; padding: 3px 8px; border-radius: 8px; background: rgba(255, 255, 255, .12); }
.hud-feet.w1 { background: #f0e17a; color: #432; } .hud-feet.w2 { background: #ffb36b; color: #421; } .hud-feet.w3 { background: #ff5a4e; color: #fff; }
.hud-bag { font-size: 16px; letter-spacing: 1px; }
.hud-log { position: absolute; left: 12px; bottom: 86px; width: min(420px, calc(100% - 24px)); display: flex; flex-direction: column; gap: 5px; pointer-events: none !important; }
.hud-log div { background: rgba(15, 39, 66, .82); color: #fff; padding: 7px 11px; border-radius: 10px; font-size: 13px; animation: logIn .3s; transition: opacity 1s; }
.hud-log div.alert { background: rgba(200, 40, 30, .9); font-weight: bold; }
.hud-log div.old { opacity: .55; }
@keyframes logIn { from { transform: translateX(-20px); opacity: 0 } }
.hud-bottom { position: absolute; bottom: max(12px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.hbtn { width: 62px; height: 60px; border: 0; border-radius: 16px; background: rgba(255, 255, 255, .95); box-shadow: var(--shadow); font-size: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--navy); }
.hbtn small { font-size: 10.5px; font-weight: bold; margin-top: 2px; }
.hbtn.on { background: var(--orange); color: #fff; }
.hbtn.off { opacity: .45; }
.legend { position: absolute; right: 12px; bottom: 86px; background: #fff; border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); font-size: 12px; max-width: 240px; }
.legend .row { display: flex; align-items: center; gap: 7px; margin: 3px 0; }
.legend .sw { width: 18px; height: 12px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .15); flex-shrink: 0; }

#banner { position: fixed; z-index: 760; top: 30%; left: 50%; transform: translateX(-50%); background: rgba(15, 39, 66, .93); color: #fff; padding: 16px 22px; border-radius: 18px; text-align: center; box-shadow: var(--shadow); }
#banner .big { font-size: 40px; font-weight: 900; color: var(--yellow); }
#banner button { margin-top: 8px; }

/* ---------- モーダル ---------- */
#modal { position: fixed; inset: 0; z-index: 900; background: rgba(8, 20, 35, .5); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0 } }
.modal-card { background: #fff; border-radius: 22px; padding: 20px; width: min(460px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); animation: pop .25s cubic-bezier(.2, 1.4, .5, 1); }
@keyframes pop { from { transform: scale(.85); opacity: 0 } }
.modal-card h2 { margin: 0 0 10px; font-size: 20px; color: var(--navy); }
.modal-card p { line-height: 1.7; margin: 8px 0; }
.modal-card .small, .small { font-size: 13px; color: var(--muted); }
.modal-card .btns { margin-top: 16px; display: grid; gap: 8px; }
.info-box { background: #f1f5fa; border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.9; }
.info-box .note { font-size: 12.5px; color: #8a5b00; line-height: 1.5; margin-top: 4px; }
.howto { padding-left: 18px; font-size: 13.5px; line-height: 1.8; margin: 10px 0 0; }
.speech { background: #fff7e0; border-radius: 14px; padding: 12px; font-size: 15px; }
.choice { display: block; width: 100%; text-align: left; border: 2px solid #dfe6ee; background: #fff; border-radius: 14px; padding: 12px 14px; font-size: 15px; font-weight: bold; color: var(--text); margin-top: 8px; }
.choice:hover { border-color: var(--orange); }
.choice.ok { border-color: var(--green); background: #e7fff3; }
.choice.ng { border-color: var(--red); background: #ffecea; }
.timer { height: 8px; background: #eee; border-radius: 4px; overflow: hidden; margin: 10px 0; }
.timer div { height: 100%; background: var(--red); width: 100%; }
.verdict { font-size: 22px; font-weight: 900; margin: 12px 0 4px; }
.verdict.ok { color: var(--green); } .verdict.ng { color: var(--red); }
.quake-title { font-size: 26px; font-weight: 900; color: var(--red); animation: blink .3s infinite alternate; }
.flags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.flag { font-size: 12px; background: #eef2f6; border-radius: 8px; padding: 2px 7px; }
.flag.hit { background: #d7f7e6; color: #0c6b41; font-weight: bold; }

#toasts { position: fixed; z-index: 950; top: 130px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; width: min(440px, calc(100% - 24px)); pointer-events: none; }
.toast { background: #fff; border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow); font-size: 14px; animation: pop .25s; }
.toast .desc { font-size: 12px; color: var(--muted); margin-top: 3px; }
.toast .get { font-size: 15px; }

/* ---------- 結果 ---------- */
.rank { font-size: 90px; font-weight: 900; text-align: center; line-height: 1; margin: 4px 0; }
.rank.S { color: #e6a700; text-shadow: 0 4px 0 #9b6f00; } .rank.A { color: #e0453a; } .rank.B { color: #2f7bd8; } .rank.C { color: #1fa86b; } .rank.D { color: #8794a3; }
.result-title { text-align: center; font-size: 18px; font-weight: 900; }
.result-score { text-align: center; font-size: 30px; font-weight: 900; color: var(--navy); }
.score-lines { font-size: 13.5px; }
.score-lines div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed #e3e9f0; }
.score-lines .neg { color: var(--red); }
.fb li, .lessons li { font-size: 13.5px; line-height: 1.7; margin-bottom: 4px; }
.newbadge { display: flex; align-items: center; gap: 10px; background: linear-gradient(90deg, #fff4d6, #fff); border-radius: 12px; padding: 8px 10px; margin-bottom: 6px; animation: pop .4s; }
.newbadge .e { font-size: 30px; }

/* ---------- 図鑑・バッジ ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bdg { background: #fff; border-radius: 14px; padding: 10px 6px; text-align: center; font-size: 11px; color: var(--muted); }
.bdg .e { font-size: 30px; display: block; }
.bdg b { display: block; color: var(--text); font-size: 12px; margin: 3px 0; }
.bdg.lock { filter: grayscale(1); opacity: .45; }
.sh-row { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 8px 10px; margin-bottom: 6px; font-size: 13px; cursor: pointer; }
.sh-row .st { font-size: 22px; width: 30px; text-align: center; }
.sh-row .nm { font-weight: bold; }
.sh-row .ad { font-size: 11px; color: var(--muted); }
.sh-row .fl { font-size: 12px; }
.progress-ring { display: flex; align-items: center; gap: 12px; }
.item-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.itm { background: #fff; border-radius: 12px; padding: 10px; font-size: 12px; }
.itm .e { font-size: 26px; }
.itm b { display: block; font-size: 13px; }
.itm.lock { opacity: .5; }
.hist { display: flex; justify-content: space-between; font-size: 13px; padding: 7px 0; border-bottom: 1px solid #eef2f6; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat-grid div { background: #fff; border-radius: 12px; padding: 8px 4px; font-size: 11px; color: var(--muted); }
.stat-grid b { display: block; font-size: 18px; color: var(--navy); }

/* ---------- 避難カード ---------- */
.mycard { background: #fff; border: 3px solid var(--navy); border-radius: 16px; padding: 14px; }
.mycard h4 { margin: 0 0 6px; font-size: 16px; }
.mycard table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mycard td, .mycard th { border-bottom: 1px solid #e3e9f0; padding: 6px 4px; text-align: left; vertical-align: top; }
.mycard th { white-space: nowrap; }

/* ---------- ハザード当てクイズ ---------- */
.hq-bar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 700; background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 14px; width: min(480px, calc(100% - 20px)); }
.hq-bar .q { font-weight: 900; margin-bottom: 4px; }
.hq-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hq-choices .choice { margin: 0; font-size: 13.5px; padding: 10px; }
.hq-pin > div { font-size: 38px; }

@media (max-width: 760px) {
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 64vh; border-radius: 22px 22px 0 0; }
  #panel.tall { max-height: 92vh; top: 8vh; }
  #panel.mini { max-height: 30vh; }
  .logo { font-size: 36px; }
  .hud-log { bottom: 82px; }
  .hbtn { width: 56px; height: 56px; }
  .legend { bottom: 82px; }
}
@media print {
  body * { visibility: hidden; }
  .mycard, .mycard * { visibility: visible; }
  .mycard { position: absolute; left: 0; top: 0; width: 100%; }
}
