:root {
  /* ロゴとおなじ、ポップな色（ピンク・水色・ミント・黄・紺）。線と文字は紺、紙は白 */
  --pink: #ff4f7e;
  --blue: #19a7f2;
  --teal: #14c4b2;
  --yellow: #ffc23d;
  --navy: #3b3f9f;
  --paper: #f3f7ff;
  --paper-2: #ffffff;
  --ink: #2f3270;
  --ink-soft: #6a6f9e;
  --line: var(--navy);
  --accent: var(--pink);
  --accent-dark: #d63566;
  --green: var(--teal);
  --sky: #bfe2f2;
  --radius: 16px;
  --shadow: 0 3px 0 var(--line);
  --font: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'BIZ UDPGothic', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.6), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(191, 226, 242, 0.35), transparent 45%);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  line-height: 1.6;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

h1, h2, p { margin: 0; }

/* ---------- ボタン ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper-2);
  border: 2.5px solid var(--line);
  border-radius: 999px;
  padding: 0.7em 1.4em;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--line); }
.btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent-dark); box-shadow: 0 3px 0 var(--accent-dark); }
.btn--primary:active:not(:disabled) { box-shadow: 0 0 0 var(--accent-dark); }
.btn--big { font-size: 1.3rem; padding: 0.7em 2.4em; }
.btn--ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; }

/* ---------- 3D盤面（全画面の背景） ---------- */
.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(#a9dbf0, #e6f4ee 70%, #f7f0dc);
}
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.stage canvas { cursor: grab; }
.stage canvas:active { cursor: grabbing; }
.board-error { padding: 40px 16px; text-align: center; font-weight: 700; }

/* ---------- 地図の吹き出し（休憩所など） ---------- */
.map-bubble {
  position: absolute;
  z-index: 2;
  width: max-content;
  max-width: min(240px, 70vw);
  padding: 8px 12px;
  background: var(--paper-2);
  border: 2.5px solid var(--line);
  border-radius: 14px;
  box-shadow: 3px 3px 0 rgba(59, 63, 159, 0.3);
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: left;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
  animation: fade 0.15s ease; /* transform は位置に使うので、フェードだけ */
}
.map-bubble strong { display: block; font-weight: 900; font-size: 0.95rem; }
.map-bubble p { margin: 2px 0 0; }
/* 下向きのしっぽ */
.map-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 14px;
  height: 14px;
  background: var(--paper-2);
  border-right: 2.5px solid var(--line);
  border-bottom: 2.5px solid var(--line);
  transform: translateX(calc(-50% + var(--tail, 0px))) rotate(45deg);
}
/* 休憩所の下に出すとき（しっぽは上向き） */
.map-bubble.is-below { transform: translate(-50%, 14px); }
.map-bubble.is-below::after {
  bottom: auto;
  top: -9px;
  border: 0;
  border-left: 2.5px solid var(--line);
  border-top: 2.5px solid var(--line);
}

/* ---------- 方位磁針 ---------- */
.compass {
  position: fixed;
  z-index: 3;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.compass:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
/* 北の向きに合わせて回す円盤（JSで rotate を入れる） */
.compass-disc {
  position: absolute;
  inset: 0;
  display: block;
}
.compass-disc svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; }
/* 時計とおなじ：白い円に、茶色のふち。北は赤、南はグレーの針 */
.compass-ring { fill: var(--paper-2); stroke: var(--line); stroke-width: 3; }
.needle-n { fill: var(--accent); }
.needle-s { fill: #c9cde0; }
/* ゲーム中は上のバーの下に出す */
/* ゲーム中の右上：上から コンパス → 時計 → 体力 をたてに1列にならべる（位置はこの3つの値で決める） */
:root {
  --rc-top: calc(max(10px, env(safe-area-inset-top)) + 4px);
  --rc-size: 60px;
  --rc-right: 16px;
}
@media (max-width: 560px) {
  :root { --rc-size: 52px; --rc-right: 12px; }
  .compass { width: 52px; height: 52px; right: 12px; }
}
body[data-screen="game"] .compass { top: var(--rc-top); right: var(--rc-right); width: var(--rc-size); height: var(--rc-size); }

/* ---------- 画面共通（盤面の上に重ねる） ---------- */
.screen {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  text-align: center;
  pointer-events: none; /* すき間は盤面にさわれるように */
}
.screen > * { pointer-events: auto; }

.title {
  font-weight: 900;
  font-size: 2.6rem;
  line-height: 1.15;
  letter-spacing: 0.04em;
}
.title span { color: var(--accent); }
.title--sm { font-size: 1.8rem; }

.sheet {
  width: min(100% - 32px, 480px);
  margin: auto auto 0;
  max-height: 62dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(255, 255, 255, 0.94);
  border: 3px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -4px 0 rgba(59, 63, 159, 0.15);
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
}

.actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.note { font-size: 0.7rem; color: var(--ink-soft); margin-top: 12px; text-align: left; }

/* ---------- タイトル＋登山口えらび ---------- */
.hero {
  /* タイトルは画面の真ん中より少し上に置く */
  position: absolute;
  left: 0;
  right: 0;
  top: 38%;
  transform: translateY(-50%);
  padding: 0 16px;
  pointer-events: none;
  /* 山の上でも読めるよう、文字に白いふち */
  text-shadow:
    0 0 2px var(--paper-2), 2px 2px 0 var(--paper-2), -2px 2px 0 var(--paper-2), 2px -2px 0 var(--paper-2), -2px -2px 0 var(--paper-2),
    0 3px 0 var(--paper-2), 0 -3px 0 var(--paper-2), 3px 0 0 var(--paper-2), -3px 0 0 var(--paper-2);
}
/* タイトル画面：タイトルとボタン。「あそぶ」をおすと登山口えらびになり、タイトルは消える */
.hero-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 18px; pointer-events: auto; text-shadow: none; }
.hero-actions #play { min-width: 11em; }
.hero-actions #howto { min-width: 13em; }
.screen--start[data-phase="title"] .sheet { display: none; }
.screen--start[data-phase="title"] .album-btn { display: none; } /* タイトル画面には出さない（登山口えらびと結果画面で見られる） */
.screen--start[data-phase="pick"] .hero { display: none; }
.pick-back { display: block; margin: 8px auto 0; font-size: 0.85rem; padding: 0.2em 0.8em; }
/* 季節のえらびボタン */
.season-pick { display: flex; justify-content: center; gap: 8px; margin-top: 14px; pointer-events: auto; text-shadow: none; }
.season-btn {
  font: inherit; font-weight: 900; font-size: 1rem; color: var(--ink);
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--paper-2); border: 2.5px solid var(--line); box-shadow: var(--shadow); cursor: pointer;
}
.season-btn[data-season="spring"] { background: #fde4ec; }
.season-btn[data-season="summer"] { background: #d6f0cf; }
.season-btn[data-season="autumn"] { background: #fde0b8; }
.season-btn[data-season="winter"] { background: #e3eef7; }
.season-btn[aria-pressed="true"] { border-color: var(--accent-dark); box-shadow: 0 0 0 3px var(--accent), var(--shadow); transform: translateY(-2px); }
.season-btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
body.is-previewing .hero { opacity: 0; }
.hero { transition: opacity 0.25s; }
/* ---------- タイトルロゴ ---------- */
/* 1文字ずつ色をかえ、角度と高さを少しずつずらす。地図の上でも読めるよう、白いふちと影をつける */
.logo {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; column-gap: 0.25em;
  font-size: clamp(2.6rem, 11vw, 4.4rem); font-weight: 900; line-height: 1.05; letter-spacing: 0;
  position: relative; padding-bottom: 0.45em;
}
.logo-word { display: inline-flex; align-items: flex-end; white-space: nowrap; }
.logo-word > span {
  display: inline-block;
  text-shadow:
    0 0 1px #fff, 3px 0 0 #fff, -3px 0 0 #fff, 0 3px 0 #fff, 0 -3px 0 #fff,
    2px 2px 0 #fff, -2px 2px 0 #fff, 2px -2px 0 #fff, -2px -2px 0 #fff,
    0 7px 0 rgba(59, 63, 159, 0.28);
  transform: translateY(var(--y, 0)) rotate(var(--r, 0deg));
  animation: logo-pop 0.5s cubic-bezier(0.3, 1.7, 0.5, 1) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}
.logo-word:first-child > span:nth-child(1) { color: var(--pink);   --r: -7deg; --y: 0.04em;  --i: 0; }
.logo-word:first-child > span:nth-child(2) { color: var(--blue);   --r: 4deg;  --y: -0.08em; --i: 1; }
.logo-word:first-child > span:nth-child(3) { color: var(--teal);   --r: -3deg; --y: 0.02em;  --i: 2; }
.logo-word:nth-child(2) > span:nth-child(1)  { color: var(--yellow); --r: 6deg;  --y: -0.05em; --i: 3; }
.logo-word:nth-child(2) > span:nth-child(2)  { color: var(--pink);   --r: -5deg; --y: 0.06em;  --i: 4; }
.logo-word:nth-child(2) > span:nth-child(3)  { color: var(--blue);   --r: 3deg;  --y: -0.06em; --i: 5; }
.logo-word:nth-child(2) > span:nth-child(4)  { color: var(--teal);   --r: -6deg; --y: 0.03em;  --i: 6; }
.logo-word > .logo-bang { color: var(--navy); --r: 10deg; --y: -0.02em; --i: 7; margin-left: 0.04em; }
.logo-sub {
  position: absolute; left: 50%; bottom: 0; translate: -50% 0;
  font-size: 0.6rem; font-weight: 900; letter-spacing: 0.18em; white-space: nowrap;
  color: var(--navy); background: #fff; border-radius: 999px; padding: 0.1em 0.9em;
  box-shadow: 0 2px 0 rgba(59, 63, 159, 0.25);
}
@keyframes logo-pop {
  from { opacity: 0; transform: translateY(0.4em) rotate(0deg) scale(0.6); }
  to { opacity: 1; transform: translateY(var(--y, 0)) rotate(var(--r, 0deg)) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .logo-word > span { animation: none; } }
.hero-lead { font-weight: 700; margin-top: 6px; }

.sheet-title { font-size: 1.25rem; font-weight: 900; margin-bottom: 10px; }

/* 登山口のえらびボタン（2列） */
.start-options { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.start-option { width: 100%; display: grid; gap: 0; border-radius: 16px; padding: 8px 10px; text-align: center; line-height: 1.3; }
.start-option-name { font-size: 1.1rem; font-weight: 900; }
.start-option-meta { font-size: 0.72rem; font-weight: 700; color: var(--ink-soft); }

/* えらんだ登山口の説明 */
.start-detail { text-align: left; }
.start-detail-name { font-size: 1.4rem; font-weight: 900; line-height: 1.3; }
.start-detail-meta { font-size: 0.8rem; color: var(--ink-soft); font-weight: 700; }
.start-detail-desc { margin-top: 8px; }
.start-detail-actions { display: flex; gap: 10px; margin-top: 14px; }
/* ボタンの文字は折り返さない（せまい画面では、左右の余白をつめて1行におさめる） */
.start-detail-actions .btn { flex: 1 1 auto; min-width: 0; white-space: nowrap; padding-inline: 0.8em; }
.start-detail-actions .btn--primary { flex-grow: 1.6; font-size: 1.15rem; }
@media (max-width: 360px) {
  .start-detail-actions .btn { font-size: 0.9rem; padding-inline: 0.6em; }
  .start-detail-actions .btn--primary { font-size: 1rem; }
}

@media (max-width: 560px) {
  .hero-lead { font-size: 0.85rem; }
  .screen--start .sheet { padding-top: 12px; }
  .sheet-title { font-size: 1.1rem; margin-bottom: 4px; }
}

/* 登山口えらび・結果のパネルは、画面の下にくっつけず、まわりに隙間をあけて浮かせる */
.screen--start .sheet, .sheet--result {
  margin-bottom: max(16px, env(safe-area-inset-bottom));
  padding-bottom: 16px;
  border-bottom: 3px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 4px 0 rgba(59, 63, 159, 0.15);
}

/* ---------- 左下の「？」（どの画面でも出す） ---------- */
/* 下のパネルと重なるときは、JS が --lift の分だけ上にずらす */
.info-btn {
  position: fixed; z-index: 15;
  left: max(12px, env(safe-area-inset-left));
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + var(--lift, 0px));
  display: grid; place-items: center;
  width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%;
  background: var(--navy); color: #fff; font: 900 0.95rem/1 var(--font);
  cursor: pointer;
}
.info-btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
/* あそびかた・ご注意・出典のダイアログ */
.card.info { width: min(100%, 440px); max-height: calc(100dvh - 32px); overflow: auto; text-align: left; }
.info .card-title { text-align: center; }
.info-section { margin: 12px 0 16px; }
.info-head { font-size: 1rem; font-weight: 900; margin-bottom: 6px; padding-bottom: 4px; border-bottom: 2px dashed rgba(59, 63, 159, 0.3); }
.info-howto { display: grid; gap: 6px; font-size: 0.88rem; line-height: 1.6; }
.info-list { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; font-size: 0.82rem; line-height: 1.6; }
.info .btn { display: block; margin: 0 auto; min-width: 160px; }

/* ---------- ゲーム画面 ---------- */
.screen--game { justify-content: space-between; }

.hud {
  flex: none;
  /* 左右を同じ幅にして、めざす場所をまん中に置く（せまい画面では、左右が重ならないぶんだけ寄る） */
  display: grid;
  grid-template-columns: 1fr minmax(0, auto) 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  /* 背景の色や線はなし。地図の上でも読めるよう、文字に白いふち */
  background: none;
  text-shadow:
    0 0 2px var(--paper-2), 2px 2px 0 var(--paper-2), -2px 2px 0 var(--paper-2), 2px -2px 0 var(--paper-2), -2px -2px 0 var(--paper-2),
    0 2px 0 var(--paper-2), 0 -2px 0 var(--paper-2), 2px 0 0 var(--paper-2), -2px 0 0 var(--paper-2);
}
/* いまめざしている場所。ホバー（スマホはタップ）で、通ってきた場所を出す */
.hud-goal { position: relative; min-width: 0; text-shadow: none; }
.hud-left { justify-self: start; }
.hud-left-row { display: flex; align-items: center; gap: 8px; }
/* ハトぶーの体力ゲージ：コンパスの真下に、たて向きで置く（下からたまる。多いと緑、へると黄、少ないと赤） */
.stamina {
  position: fixed; z-index: 3;
  /* 時計（＋下の日没の時刻）のさらに下 */
  top: calc(var(--rc-top) + var(--rc-size) * 2 + 8px + 26px);
  right: var(--rc-right); width: var(--rc-size);
  display: grid; justify-items: center; gap: 4px;
}
.stamina-label {
  font-size: 0.68rem; font-weight: 900; color: var(--ink);
  background: var(--paper-2); border: 2px solid var(--line); border-radius: 999px; padding: 0 6px; line-height: 1.5;
}
.stamina-bar {
  position: relative; width: 16px; height: 110px; overflow: hidden;
  background: var(--paper-2); border: 2px solid var(--line); border-radius: 999px;
}
.stamina-fill {
  position: absolute; inset: auto 0 0 0; height: 100%; border-radius: 999px;
  background: var(--teal); transition: height 0.5s ease, background-color 0.5s;
}
.stamina[data-level="mid"] .stamina-fill { background: var(--yellow); }
.stamina[data-level="low"] .stamina-fill { background: var(--pink); animation: stamina-blink 1s ease-in-out infinite; }
@keyframes stamina-blink { 50% { opacity: 0.55; } }
@media (max-width: 560px) {
  /* コンパスが小さくなるのに合わせる */
  .stamina-bar { height: 90px; }
}
@media (prefers-reduced-motion: reduce) { .stamina[data-level="low"] .stamina-fill { animation: none; } }
/* 時計：上のバーからはなして、コンパスの下に置く */
.hud-clock { position: fixed; z-index: 3; top: calc(var(--rc-top) + var(--rc-size) + 8px); right: var(--rc-right); width: var(--rc-size); height: var(--rc-size); }
/* てんぼうカードを見るボタン（もどるボタンと同じ丸い枠で、集めた数をそえる） */
.hud-album {
  font: inherit; font-weight: 800; font-size: 0.85rem; color: var(--ink); line-height: 1;
  height: 36px; padding: 0 10px; display: inline-flex; align-items: center; gap: 4px; flex: none;
  border-radius: 999px; border: 2px solid var(--line); background: var(--paper-2);
  text-shadow: none; cursor: pointer;
}
.hud-album span { font-size: 1.1rem; }
.hud-album b { color: var(--accent); }
.hud-album:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
/* せまい画面では、めざす場所がまん中に入るよう、カメラだけにする */
@media (max-width: 420px) {
  .hud-album { width: 36px; padding: 0; justify-content: center; }
  .hud-album b { display: none; }
}
/* 枠でかこんだ「めざす場所」 */
/* めざす場所：上に水色の札、大きな行き先の名前、ピンクの「あと◯マス」 */
.hud-goal-btn {
  font: inherit; color: inherit; text-align: center; line-height: 1.2; cursor: pointer;
  position: relative; display: grid; justify-items: center; max-width: 100%;
  background: var(--paper-2); border: 3px solid var(--line); border-radius: 18px;
  box-shadow: 0 4px 0 var(--line); padding: 14px 16px 7px;
  margin-top: 8px; /* 札が上にはみ出す分 */
}
.hud-goal-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--line); }
.hud-goal-btn small {
  position: absolute; top: 0; left: 50%; translate: -50% -55%;
  white-space: nowrap; font-size: 0.68rem; font-weight: 900; color: #fff; letter-spacing: 0.08em;
  background: var(--blue); border: 2.5px solid var(--line); border-radius: 999px; padding: 1px 10px;
}
.hud-goal-main { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.hud-goal-flag { font-size: 1.1rem; line-height: 1; }
.hud-goal-btn b { font-weight: 900; font-size: 1.35rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hud-goal-sub {
  font-size: 0.75rem; font-weight: 900; color: #fff; white-space: nowrap;
  background: var(--pink); border-radius: 999px; padding: 1px 8px;
}
.hud-goal-sub:empty { display: none; }
.hud-goal-caret { font-size: 0.8rem; color: var(--ink-soft); }
.hud-goal-btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.hud-goal.menu-open .route-pop { display: none; }
.dest-menu {
  position: absolute; top: calc(100% + 8px); left: 50%; translate: -50% 0; z-index: 9;
  width: max-content; min-width: 200px; max-width: min(300px, calc(100vw - 32px));
  background: var(--paper-2); border: 2.5px solid var(--line); border-radius: 16px;
  box-shadow: 4px 4px 0 rgba(59, 63, 159, 0.25); padding: 10px 12px;
}
.dest-list { display: grid; gap: 6px; }
.dest-item {
  font: inherit; font-weight: 800; color: var(--ink); text-align: left; cursor: pointer;
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 6px 10px;
}
.dest-item small { font-weight: 700; color: var(--ink-soft); font-size: 0.75rem; }
.dest-item[aria-pressed="true"] { background: #ffe3ec; border-color: var(--accent-dark); }
.dest-item:disabled { opacity: 0.45; cursor: default; }
.dest-item:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.route-pop {
  position: absolute; top: calc(100% + 8px); left: 50%; translate: -50% 0; z-index: 8;
  width: max-content; max-width: min(300px, calc(100vw - 32px));
  background: var(--paper-2); border: 2.5px solid var(--line); border-radius: 16px;
  box-shadow: 4px 4px 0 rgba(59, 63, 159, 0.25); padding: 10px 14px;
  opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
  pointer-events: none;
}
.hud-goal:hover .route-pop { opacity: 1; visibility: visible; transform: none; }
.route-pop-title { font-size: 0.75rem; font-weight: 800; color: var(--ink-soft); margin-bottom: 4px; }
.route-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-weight: 700; font-size: 0.9rem; }
.route-list li { display: flex; align-items: baseline; gap: 6px; }
.route-list li::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); transform: translateY(-1px); }
.hud-quit {
  font: inherit; font-weight: 900; font-size: 1.1rem;
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  cursor: pointer;
}
.dusk { position: fixed; inset: 0; z-index: 0; pointer-events: none; background: #ff7a33; mix-blend-mode: multiply; opacity: 0; transition: opacity 1.5s; }
/* ハトぶーのひとりごと：頭の上に出る吹き出し（JSで left/top を動かす） */
.speech {
  position: fixed; z-index: 4; left: 0; top: 0;
  max-width: min(240px, calc(100vw - 16px));
  padding: 6px 12px;
  background: var(--paper-2); color: var(--ink);
  border: 2px solid var(--line); border-radius: 16px;
  box-shadow: 0 2px 0 var(--line);
  font-size: 0.92rem; font-weight: 700; line-height: 1.35; text-align: center;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px)) scale(0.6);
  transform-origin: calc(50% + var(--tail, 0px)) calc(100% + 12px);
  opacity: 0;
  transition: opacity 0.18s, transform 0.22s cubic-bezier(.3, 1.6, .5, 1);
}
.speech.is-on { opacity: 1; transform: translate(-50%, calc(-100% - 12px)); }
/* しっぽ（下向きの三角）。吹き出しが端に寄っても、ハトぶーの方をさす */
.speech::before, .speech::after {
  content: ''; position: absolute; left: calc(50% + var(--tail, 0px)); top: 100%;
  border: 8px solid transparent; transform: translateX(-50%);
}
.speech::before { border-top-color: var(--line); margin-top: 2px; }
.speech::after { border-top-color: var(--paper-2); margin-top: -1px; border-width: 7px; }
.speech[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .speech { transition: none; } }
/* 時計：行動できる時間だけ白、ほかはグレー。下に日没の時刻 */
.hud-clock { flex: none; }
.hud-clock svg { display: block; width: 100%; height: 100%; overflow: visible; }
.clock-off { fill: #c9cde0; }
.clock-on { fill: var(--paper-2); }
.clock-tick { stroke: var(--ink-soft); stroke-width: 1.4; stroke-linecap: round; }
.clock-tick--big { stroke: var(--ink); stroke-width: 2.2; }
.clock-hand { stroke: var(--ink); stroke-linecap: round; }
.clock-hand--h { stroke-width: 3.6; }
.clock-hand--m { stroke-width: 2.2; }
.clock-pin { fill: var(--accent); }
.clock-rim { fill: none; stroke: var(--line); stroke-width: 3; }
.clock-sunset {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: 2px; white-space: nowrap; font-size: 0.72rem; font-weight: 700; color: var(--ink-soft);
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chip-sub { margin-left: 8px; font-size: 0.72rem; color: var(--ink-soft); font-weight: 700; }
.chip {
  flex: none;
  font-size: 0.9rem;
  background: var(--paper-2);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}

.dock {
  flex: none;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  /* 枠はなし。地図の上でも読めるよう、文字に白いふち */
  text-shadow:
    0 0 2px var(--paper-2), 2px 2px 0 var(--paper-2), -2px 2px 0 var(--paper-2), 2px -2px 0 var(--paper-2), -2px -2px 0 var(--paper-2),
    0 2px 0 var(--paper-2), 0 -2px 0 var(--paper-2), 2px 0 0 var(--paper-2), -2px 0 0 var(--paper-2);
}
.dock-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.btn--roll { width: 100%; font-size: 1.15rem; text-shadow: none; }


/* ---------- 3Dのサイコロ（盤面の上の透明なキャンバス） ---------- */
.dice-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 15;
  pointer-events: none;
  transition: opacity 0.2s;
}

/* ---------- カード ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto; /* 念のため：中身が画面より大きくても、スクロールでとどくように */
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(30, 32, 80, 0.45);
  animation: fade 0.15s ease;
}
.card {
  width: min(100%, 360px);
  background: var(--paper-2);
  border: 3px solid var(--line);
  border-radius: 22px;
  box-shadow: 6px 6px 0 rgba(59, 63, 159, 0.35);
  padding: 22px 18px 18px;
  text-align: center;
  animation: pop 0.25s cubic-bezier(0.3, 1.6, 0.6, 1);
  /* 長い文（あそびかたなど）で画面からはみ出さないよう、高さは画面まで。はみ出す分はカードの中でスクロール */
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
/* ボタンはカードの下にくっつけて、スクロールしなくても押せるようにする */
.card-buttons {
  position: sticky; bottom: -18px; z-index: 1;
  margin: 0 -18px -18px; padding: 10px 18px 18px;
  background: inherit;
}
.card--spot { background: #fff8d6; }
.card--quiz { background: #e3f8f5; }
.card-emoji { font-size: 52px; line-height: 1.1; }
.card-title { font-size: 1.4rem; font-weight: 900; margin: 6px 0; }
.card-text { white-space: pre-line; margin-bottom: 16px; }
.card-buttons { display: flex; flex-direction: column; gap: 10px; }
.card-buttons .btn { width: 100%; }

.btn--choice {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  text-align: left;
  border-radius: 16px;
  padding: 10px 14px;
}
.btn--choice .btn-emoji { grid-row: span 2; font-size: 28px; align-self: center; }
.btn--choice .btn-desc { font-weight: 500; font-size: 0.82rem; color: var(--ink-soft); }

/* ---------- てんぼうカード ---------- */
.card--view { background: #e8f4fb; }
.card-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 14px; border: 2.5px solid var(--line); margin: 6px 0; }
.album { width: min(100%, 420px); max-height: calc(100dvh - 32px); overflow: auto; }
.album-list { list-style: none; margin: 8px 0 16px; padding: 0; display: grid; gap: 12px; text-align: left; }
/* 一覧のカード（タップでくわしく） */
.album-card {
  font: inherit; color: var(--ink); text-align: left; cursor: pointer; width: 100%;
  display: grid; grid-template-columns: 84px 1fr auto; column-gap: 12px; align-items: center;
  background: #e8f4fb; border: 2.5px solid var(--line); border-radius: 16px; padding: 8px 12px 8px 8px;
  box-shadow: 0 3px 0 var(--line);
}
.album-card::after { content: '›'; font-size: 1.4rem; font-weight: 900; color: var(--ink-soft); }
.album-card:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.album-card:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.album-card.is-locked { background: #e6e8f2; color: var(--ink-soft); }
.album-pic { width: 84px; height: 64px; display: grid; place-items: center; font-size: 34px; background: #fff; border-radius: 10px; overflow: hidden; }
.album-card.is-locked .album-pic { background: #cfd3e6; color: #9aa0c3; }
.album-pic img { width: 100%; height: 100%; object-fit: cover; }
.album-info { display: grid; justify-items: start; gap: 2px; min-width: 0; }
.album-no {
  font-size: 0.68rem; font-weight: 900; color: #fff; line-height: 1.4;
  background: var(--accent); border-radius: 999px; padding: 0 7px;
}
.album-card.is-locked .album-no { background: #9aa0c3; }
.album-name { font-weight: 900; line-height: 1.3; }
/* くわしく見ているときは、ダイアログの枠を消して、カードだけを見せる */
.album.is-detail { background: none; border: none; box-shadow: none; }
.view-card-slot { display: contents; }
/* ゲットしたとき：見出し・カード・ボタンだけ（ダイアログの枠はなし） */
.get-view { width: min(100%, 360px); display: grid; gap: 14px; justify-items: center; }
.get-view-title {
  font-size: 1.5rem; font-weight: 900; color: var(--paper-2); text-align: center;
  text-shadow: 0 0 2px var(--line), 2px 2px 0 var(--line), -2px 2px 0 var(--line), 2px -2px 0 var(--line), -2px -2px 0 var(--line),
    0 2px 0 var(--line), 0 -2px 0 var(--line), 2px 0 0 var(--line), -2px 0 0 var(--line);
  animation: pop 0.3s cubic-bezier(0.3, 1.6, 0.6, 1);
}
.get-view .btn { min-width: 200px; position: relative; }
/* カードのうしろの放射状の光：ゆっくり回りながら、ふちに向かって消える */
#get-view { overflow: hidden; } /* 光が画面からはみ出しても、スクロールさせない */
.get-view-stage { position: relative; display: grid; justify-items: center; width: 100%; }
.get-view-stage .view-card { position: relative; }
.get-view-rays {
  position: absolute; left: 50%; top: 50%; z-index: 0; pointer-events: none;
  width: 760px; height: 760px; margin: -380px 0 0 -380px;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, rgba(255, 244, 196, 0.95), rgba(255, 228, 140, 0.55) 35%, transparent 72%),
    repeating-conic-gradient(rgba(255, 236, 150, 0.75) 0deg 9deg, transparent 9deg 20deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 25%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 25%, transparent 100%);
  animation: rays-in 0.5s ease-out, rays-spin 14s linear infinite;
}
@keyframes rays-in { from { opacity: 0; scale: 0.4; } to { opacity: 1; scale: 1; } }
@keyframes rays-spin { to { rotate: 360deg; } }
@media (prefers-reduced-motion: reduce) { .get-view-rays { animation: none; } }
/* くわしく：集めるカードらしい見た目 */
.album-detail { display: grid; gap: 16px; justify-items: center; }
.view-card {
  position: relative; overflow: hidden;
  width: min(100%, 320px);
  /* トレーディングカードと同じ縦横比（63 × 88mm）。あまった高さは説明の欄にまわす */
  aspect-ratio: 63 / 88;
  display: grid; gap: 8px; grid-template-rows: auto auto 1fr auto;
  padding: 10px 10px 8px;
  text-align: left;
  /* 台紙：空いろのグラデーションに、太い枠と内がわの白い線 */
  background: linear-gradient(160deg, #8fd0ef 0%, #cbe9f6 45%, #f3d9a4 100%);
  border: 3px solid var(--line);
  border-radius: 18px;
  box-shadow: inset 0 0 0 3px var(--paper-2), 5px 6px 0 rgba(59, 63, 159, 0.3);
}
.view-card-head {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper-2); border: 2.5px solid var(--line); border-radius: 12px;
  padding: 4px 8px 4px 12px;
}
.view-card-title { flex: 1; min-width: 0; font-size: 1.05rem; font-weight: 900; line-height: 1.25; }
.view-card-no {
  flex: none; font-size: 0.72rem; font-weight: 900; color: #fff;
  background: var(--accent); border-radius: 999px; padding: 2px 8px;
}
.view-card-pic { border: 3px solid var(--paper-2); border-radius: 10px; outline: 2.5px solid var(--line); overflow: hidden; }
.view-card-img { display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; font-size: 64px; background: #fff; }
.view-card-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.view-card-text {
  background: rgba(255, 255, 255, 0.92); border: 2.5px solid var(--line); border-radius: 12px;
  padding: 8px 10px; font-size: 0.88rem; font-weight: 700; line-height: 1.55; min-height: 4.8em;
}
.view-card-foot { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.08em; color: rgba(47, 50, 112, 0.6); text-align: right; padding-right: 4px; }
/* まだのカード：色をおとす */
.view-card.is-locked { background: linear-gradient(160deg, #cfd3e6, #e6e8f2); }
.view-card.is-locked .view-card-img { background: #cfd3e6; color: #9aa0c3; }
.view-card.is-locked .view-card-title, .view-card.is-locked .view-card-text { color: var(--ink-soft); }
/* ひらいたとき：ひょいと出てきて、光がさっと横切る */
.view-card.is-shown { animation: card-in 0.35s cubic-bezier(0.3, 1.5, 0.6, 1); }
.view-card:not(.is-locked)::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.55) 50%, transparent 65%);
  transform: translateX(-120%);
}
.view-card.is-shown:not(.is-locked)::after { animation: card-shine 0.9s 0.25s ease-out; }
@keyframes card-in { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes card-shine { to { transform: translateX(120%); } }
@media (prefers-reduced-motion: reduce) {
  .view-card.is-shown, .view-card.is-shown:not(.is-locked)::after { animation: none; }
}
.album-btn {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; z-index: 5;
  font: inherit; font-weight: 800; font-size: 0.9rem; color: var(--ink);
  background: var(--paper-2); border: 2.5px solid var(--line); border-radius: 999px;
  padding: 0.35em 0.9em; box-shadow: var(--shadow); cursor: pointer;
}
.album-btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
.album-btn b { color: var(--accent); }

/* ---------- 結果 ---------- */
.sheet--result { max-width: 420px; }
.result-emoji { font-size: 48px; line-height: 1.1; }
/* 通ってきた道すじ：名前を丸い枠に入れて、矢印でつなぐ（せまいと折り返す） */
.result-route {
  list-style: none; margin: 10px 0 6px; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 4px;
}
.result-route li {
  font-weight: 900; font-size: 1rem;
  background: #fff; border: 2.5px solid var(--line); border-radius: 999px; padding: 2px 12px;
}
.result-route li + li { margin-left: 20px; position: relative; }
.result-route li + li::before {
  content: '→'; position: absolute; left: -19px; top: 50%; translate: 0 -50%;
  color: var(--ink-soft); font-weight: 900;
}
.result-time { font-size: 0.9rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 16px; }

/* ---------- アニメ ---------- */
@keyframes ring { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* 結果画面のボタン：横いっぱいにして、文字を1行におさめる */
.sheet--result .actions .btn { width: 100%; max-width: 340px; white-space: nowrap; }
.sheet--result .actions .btn--big { padding-inline: 1em; font-size: 1.15rem; }
/* せまい画面のめざす場所：旗と▾をはぶき、入りきらなければ「あと◯マス」を下の行に回す（名前は切らない） */
@media (max-width: 420px) {
  .hud-goal-btn { padding: 12px 10px 6px; }
  .hud-goal-flag, .hud-goal-caret { display: none; }
  .hud-goal-main { flex-wrap: wrap; justify-content: center; row-gap: 2px; }
  .hud-goal-btn b { flex: none; font-size: 1.25rem; }
}
/* 結果をシェア */
.btn--share { background: var(--blue); color: #fff; }
.share-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.share-opt {
  font: inherit; font-size: 0.85rem; font-weight: 900; text-decoration: none; cursor: pointer;
  color: var(--ink); background: var(--paper-2); border: 2.5px solid var(--line); border-radius: 999px;
  padding: 0.35em 1em; box-shadow: 0 2px 0 var(--line);
}
.share-opt--x { background: #111; color: #fff; }
.share-opt--line { background: #06c755; color: #fff; }
.share-opt:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.share-preview {
  display: block; width: 100%; aspect-ratio: 1200 / 630; object-fit: cover;
  border: 2.5px solid var(--line); border-radius: 12px; margin-bottom: 4px;
}
.share-opt--save { background: var(--yellow); }
