:root {
  --sky-top: #7cc4f2;
  --sky-mid: #bfe4fb;
  --sky-low: #fff4dc;
  --ink: #2b3a55;
  --ink-sub: #5d6f8c;
  --card: #fffdf8;
  --line: #e8dfcf;
  --sun: #ffb72e;
  --sun-deep: #e8890c;
  --coral: #ff7a59;
  --coral-deep: #d9532f;
  --rain: #4f8fd8;
  --rain-deep: #2f6bb0;
  --cloud: #9fb3c8;
  --font: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', sans-serif;
  --num: 'Lilita One', 'M PLUS Rounded 1c', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 38%, var(--sky-low) 100%) fixed;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
  font-weight: 500;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* 空に浮かぶ雲（飾り） */
.sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.sky .c { position: absolute; background: #fff; border-radius: 999px; opacity: .75; filter: blur(.5px); }
.sky .c::before, .sky .c::after { content: ''; position: absolute; background: inherit; border-radius: 50%; }
.sky .c1 { width: 120px; height: 34px; top: 70px; left: -30px; animation: drift 60s linear infinite; }
.sky .c1::before { width: 56px; height: 56px; left: 18px; top: -28px; }
.sky .c1::after { width: 40px; height: 40px; left: 62px; top: -18px; }
.sky .c2 { width: 90px; height: 26px; top: 180px; right: -20px; opacity: .55; animation: drift 80s linear infinite reverse; }
.sky .c2::before { width: 40px; height: 40px; left: 14px; top: -20px; }
.sky .c2::after { width: 30px; height: 30px; left: 46px; top: -13px; }
.sky .c3 { display: none; }
@keyframes drift { from { transform: translateX(-40px); } to { transform: translateX(60px); } }

.top, .app { position: relative; z-index: 1; }
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 6px;
  max-width: 520px; margin: 0 auto;
}
.logo { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 22px; font-weight: 900; color: #fff; letter-spacing: .06em; text-shadow: 0 2px 0 rgba(47, 107, 176, .45); }
.logo-ico { width: 34px; height: 34px; animation: bob 4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px) rotate(-6deg); } }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border: none; background: rgba(255, 255, 255, .85); color: var(--rain-deep); display: grid; place-items: center; box-shadow: 0 3px 0 rgba(47, 107, 176, .35); }

.app { max-width: 520px; margin: 0 auto; padding: 4px 16px calc(env(safe-area-inset-bottom) + 28px); }

/* 行き先の文字検索 */
.search { margin: 0 0 10px; }
.search-row { display: flex; gap: 6px; background: rgba(255, 255, 255, .55); padding: 5px; border-radius: 18px; }
.search input { flex: 1; min-width: 0; height: 42px; border: none; border-radius: 13px; padding: 0 12px; font: 700 16px var(--font); color: var(--ink); background: #fff; box-shadow: inset 0 2px 0 #eee5d6; }
.search input::placeholder { color: #9aa7bb; font-weight: 700; font-size: 14px; }
.search button[type=submit] { flex: none; height: 42px; padding: 0 16px; border: none; border-radius: 13px; background: var(--rain); color: #fff; font: 800 15px var(--font); box-shadow: 0 3px 0 var(--rain-deep); }
.search button[type=submit]:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--rain-deep); }
.search-list { list-style: none; margin: 6px 0 0; padding: 6px; background: var(--card); border-radius: 18px; box-shadow: 0 4px 0 var(--line); display: grid; gap: 4px; }
.search-list button { width: 100%; text-align: left; border: none; background: transparent; border-radius: 12px; padding: 8px 10px; font-family: var(--font); color: var(--ink); display: grid; gap: 2px; }
.search-list button:hover, .search-list button:focus-visible { background: #eef6fd; }
.search-list b { font-size: 15px; font-weight: 800; }
.search-list span { font-size: 12px; font-weight: 700; color: var(--ink-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-note { margin: 4px 6px 0; font-size: 11px; font-weight: 700; color: var(--ink-sub); }
.res-route { margin-top: 10px; padding: 8px 12px; background: rgba(255, 255, 255, .7); border-radius: 14px; display: grid; gap: 3px; }
.res-empty { flex-wrap: wrap; }
.res-empty .res-route { flex-basis: 100%; margin-top: 2px; }
.route { margin: 0; display: flex; gap: 8px; align-items: baseline; font-size: 13px; font-weight: 800; min-width: 0; }
.route-k { flex: none; font-size: 11px; color: var(--ink-sub); min-width: 5.2em; }
.route-v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* タブ */
.controls { display: grid; gap: 8px; margin-bottom: 10px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: rgba(255, 255, 255, .55); padding: 5px; border-radius: 18px; }
.seg > * {
  position: relative; border: none; background: transparent; border-radius: 13px; min-height: 42px;
  font-weight: 800; font-size: 15px; color: var(--ink-sub); display: grid; place-items: center; overflow: hidden;
}
.seg > [aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 3px 0 #d6cbb8; }
.seg-mode > [aria-selected="true"] { background: var(--coral); color: #fff; box-shadow: 0 3px 0 var(--coral-deep); }
.seg-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* 地図 */
.map-wrap { position: relative; border-radius: 22px; overflow: hidden; border: 4px solid #fff; box-shadow: 0 6px 0 rgba(47, 107, 176, .22), 0 12px 24px rgba(43, 58, 85, .12); }
#map { height: clamp(260px, 46vh, 380px); background: #dfeefa; }
.map-hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 500; margin: 0;
  background: var(--ink); color: #fff; font-weight: 800; font-size: 14px; padding: 8px 14px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .2); animation: hint 2.4s ease-in-out infinite; pointer-events: none;
}
@keyframes hint { 50% { transform: translate(-50%, 3px); } }
.locate { position: absolute; right: 10px; top: calc(clamp(260px, 46vh, 380px) - 72px); z-index: 500; width: 46px; height: 46px; border-radius: 50%; border: none; background: #fff; color: var(--rain); box-shadow: 0 3px 0 #c9d6e4; display: grid; place-items: center; }
.origin-note { margin: 0; background: #fff; padding: 8px 12px 10px; font-size: 12px; line-height: 1.6; font-weight: 700; color: var(--ink-sub); }
.locate[hidden] { display: none; }
.origin-note.warn { background: #fff1e8; border-top: 3px solid var(--coral); color: var(--ink); padding: 12px 14px 14px; }
.note-title { margin: 0 0 6px; font-size: 15px; font-weight: 900; color: var(--coral-deep); display: flex; align-items: center; gap: 6px; }
.note-title::before { content: '!'; flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--coral); color: #fff; font: 400 15px/22px var(--num); text-align: center; }
.note-steps { margin: 0 0 6px; padding-left: 1.3em; font-size: 12.5px; line-height: 1.65; font-weight: 700; }
.note-steps li + li { margin-top: 4px; }
.note-dev { margin: 6px 0 2px; font-size: 12px; font-weight: 900; color: var(--ink); }
.note-others { margin: 6px 0 4px; font-size: 12.5px; }
.note-others summary { font-weight: 800; color: var(--rain-deep); cursor: pointer; padding: 4px 0; }
.note-text { margin: 0; font-size: 12.5px; font-weight: 800; color: var(--ink-sub); }
.warn .note-btn { margin-top: 10px; }
.note-btn { display: block; margin-top: 4px; border: none; background: var(--rain); color: #fff; font: 800 12px var(--font); padding: 5px 10px; border-radius: 999px; box-shadow: 0 2px 0 var(--rain-deep); }
.pin-origin span { display: block; width: 22px; height: 22px; border-radius: 50%; background: var(--rain); border: 4px solid #fff; box-shadow: 0 0 0 6px rgba(79, 143, 216, .25); }
.pin-bubble { width: 52px; height: 52px; border-radius: 50% 50% 50% 6px; transform: rotate(-45deg); background: #fff; border: 3px solid var(--coral); display: grid; place-items: center; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); }
.pin-bubble .wi { width: 34px; height: 34px; transform: rotate(45deg); }
.leaflet-container { font-family: var(--font); }

/* 結果 */
.result { margin: 14px 0; }
.res { background: var(--card); border-radius: 24px; padding: 16px; box-shadow: 0 6px 0 var(--line); position: relative; overflow: hidden; }
.res.w-sunny { background: linear-gradient(160deg, #fff6c9, #ffe08a); box-shadow: 0 6px 0 #f0b84a; }
.res.w-fair { background: linear-gradient(160deg, #fffbe6, #e3f3ff); box-shadow: 0 6px 0 #c9dff0; }
.res.w-cloudy { background: linear-gradient(160deg, #f7f9fc, #e3e9f1); box-shadow: 0 6px 0 #c6d0dc; }
.res.w-rain { background: linear-gradient(160deg, #eef5ff, #cfe2f7); box-shadow: 0 6px 0 #a9c4e2; }
.res-main { display: flex; align-items: center; gap: 12px; }
.wi { width: 28px; height: 28px; flex: none; }
.wi-big { width: 104px; height: 104px; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .08)); animation: pop .5s cubic-bezier(.3, 1.6, .5, 1); }
.w-sunny .wi-big { animation: pop .5s cubic-bezier(.3, 1.6, .5, 1), spin 24s linear .5s infinite; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.res-text { min-width: 0; }
.res-when { margin: 0; font-size: 12px; font-weight: 700; color: var(--ink-sub); }
.res-dir { margin: 2px 0; font-size: 18px; font-weight: 800; line-height: 1.3; }
.dir-name { font-size: 30px; font-weight: 900; margin-right: 2px; }
.w-name { font-size: 30px; font-weight: 900; margin-left: 4px; }
.w-sunny .w-name { color: var(--sun-deep); }
.w-fair .w-name { color: #e39a12; }
.w-cloudy .w-name { color: #6d8099; }
.w-rain .w-name { color: var(--rain-deep); }
.res-mean { margin: 0; font-weight: 800; font-size: 14px; }
.dist { margin-left: 8px; font-family: var(--num); font-weight: 400; color: var(--ink-sub); }
.kills { margin: 6px 0 0; font-size: 12px; font-weight: 700; color: var(--rain-deep); }
.sub2 { margin: 6px 0 0; font-size: 12px; font-weight: 700; color: var(--ink-sub); }
.res-talk, .res-empty { display: flex; align-items: flex-end; gap: 10px; margin-top: 12px; }
.res-empty { margin-top: 0; align-items: center; }

/* 案内役 */
.guide { position: relative; flex: none; width: 64px; padding-bottom: 12px; }
.guide-face {
  width: 64px; height: 64px; border-radius: 50%; background: #fff url(img/guide.webp) center 30% / cover no-repeat;
  border: 3px solid #fff; box-shadow: 0 3px 10px rgba(43, 58, 85, .15);
  animation: peek 3.2s ease-in-out infinite;
}
.guide-face.face-rain { filter: saturate(.85); }
@keyframes peek { 50% { transform: translateY(-2px); } }
.guide-name {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  background: #fff; border-radius: 999px; padding: 1px 9px; font-size: 11px; font-weight: 800; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(43, 58, 85, .15);
}
.guide-lg { width: 96px; margin: 0 auto 6px; padding-bottom: 14px; }
.guide-lg .guide-face { width: 96px; height: 96px; }
.guide-lg .guide-name { font-size: 13px; }
.bubble {
  position: relative; background: #fff; border-radius: 18px; padding: 10px 14px; font-size: 14px; font-weight: 700; line-height: 1.6;
  box-shadow: 0 3px 0 rgba(43, 58, 85, .08); flex: 1; margin-bottom: 14px;
}
.bubble::before { content: ''; position: absolute; left: -7px; bottom: 14px; border: 8px solid transparent; border-right-color: #fff; border-left: 0; }
.res-empty .bubble { margin-bottom: 0; }

/* 盤 */
.board-wrap { background: var(--card); border-radius: 24px; padding: 14px; box-shadow: 0 6px 0 var(--line); }
.board-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.board-head h2, .me h2 { margin: 0; font-size: 17px; font-weight: 900; }
.board-head p { margin: 0; font-size: 12px; font-weight: 700; color: var(--ink-sub); }
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.cell {
  border: none; border-radius: 16px; padding: 8px 4px 7px; min-height: 88px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: #f3f6fa; box-shadow: 0 4px 0 #d3dbe5; transition: transform .1s;
}
.cell:active { transform: translateY(3px); box-shadow: 0 1px 0 #d3dbe5; }
.cell .wi { width: 36px; height: 36px; }
.c-dir { font-size: 13px; font-weight: 900; }
.c-w { font-size: 12px; font-weight: 800; }
.c-kill { font-size: 10px; font-weight: 700; color: var(--rain-deep); line-height: 1.2; }
.cell.w-sunny { background: #ffe9a8; box-shadow: 0 4px 0 #f0bf55; }
.cell.w-fair { background: #fff5d6; box-shadow: 0 4px 0 #ecd59a; }
.cell.w-cloudy { background: #eef2f7; box-shadow: 0 4px 0 #cfd8e3; }
.cell.w-rain { background: #dde9f8; box-shadow: 0 4px 0 #a9c1e0; }
.cell.is-sel { outline: 3px solid var(--coral); outline-offset: 1px; }
.cell-center { background: linear-gradient(160deg, #7cc4f2, #4f8fd8); color: #fff; box-shadow: 0 4px 0 var(--rain-deep); }
.c-date { font-size: 12px; font-weight: 800; }
.c-star { font-family: var(--font); font-size: 22px; font-weight: 900; line-height: 1.2; }
.c-kan { font-size: 11px; font-weight: 700; opacity: .9; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 12px 0 0; font-size: 11px; font-weight: 700; color: var(--ink-sub); }
.legend span { display: inline-flex; align-items: center; gap: 2px; }
.legend svg { width: 20px; height: 20px; }

/* あなたの星 */
.me { margin-top: 14px; background: rgba(255, 255, 255, .7); border-radius: 24px; padding: 14px; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0 6px; }
.star-chip { background: #fff; border-radius: 14px; padding: 6px 4px; text-align: center; font-weight: 900; font-size: 13px; box-shadow: 0 3px 0 var(--line); }
.star-chip small { display: block; font-size: 10px; font-weight: 700; color: var(--ink-sub); }
.star-chip.is-main { background: var(--coral); color: #fff; box-shadow: 0 3px 0 var(--coral-deep); }
.star-chip.is-main small { color: #ffe6dc; }
.small { font-size: 12px; color: var(--ink-sub); line-height: 1.7; }
.foot { text-align: center; font-size: 12px; font-weight: 700; color: var(--ink-sub); line-height: 1.8; margin-top: 18px; }
.link { background: none; border: none; color: var(--rain-deep); text-decoration: underline; font-weight: 800; padding: 6px; }

/* シート */
.sheet { position: fixed; inset: 0; z-index: 2000; background: rgba(43, 58, 85, .35); display: grid; align-items: end; justify-items: center; padding: 16px; overflow-y: auto; }
#onboard { background: linear-gradient(180deg, var(--sky-top), var(--sky-low)); align-items: center; }
.sheet-card { position: relative; width: 100%; max-width: 440px; background: var(--card); border-radius: 28px; padding: 22px 20px calc(env(safe-area-inset-bottom) + 20px); box-shadow: 0 8px 0 var(--line); text-align: center; }
.sheet-card h2 { margin: 0 0 8px; font-size: 22px; font-weight: 900; }
.sheet-card > p { font-weight: 700; line-height: 1.7; margin: 0 0 12px; }
.field { display: grid; gap: 6px; text-align: left; font-weight: 800; font-size: 14px; margin: 10px 0; }
.field input { min-height: 52px; border-radius: 14px; border: 3px solid var(--line); background: #fff; padding: 8px 12px; font-size: 18px; font-family: var(--num); }
.field input:focus { outline: none; border-color: var(--rain); }
.btn-main, .btn-sub { display: block; width: 100%; min-height: 54px; border: none; border-radius: 999px; font-weight: 900; font-size: 17px; margin-top: 10px; transition: transform .1s; }
.btn-main { background: var(--coral); color: #fff; box-shadow: 0 5px 0 var(--coral-deep); }
.btn-sub { background: #fff; color: var(--ink); box-shadow: 0 5px 0 var(--line); border: 2px solid var(--line); }
.btn-main:active, .btn-sub:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--coral-deep); }
.close { position: absolute; right: 12px; top: 10px; width: 44px; height: 44px; border: none; background: #f1ebe0; border-radius: 50%; font-size: 22px; font-weight: 900; }
.sheet-full { align-items: start; }
.sheet-full .close { position: sticky; top: 0; float: right; margin: -8px -6px 0 0; z-index: 1; box-shadow: 0 2px 6px rgba(43, 58, 85, .15); }
.rules { text-align: left; }
.rules h2 { text-align: center; }
.rules h3 { font-size: 15px; font-weight: 900; margin: 18px 0 6px; padding: 4px 12px; background: #e3f3ff; border-radius: 999px; display: inline-block; }
.rules ul { margin: 0; padding-left: 1.2em; }
.rules li { font-size: 14px; line-height: 1.75; margin: 4px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
