:root {
  --ink: #2f3a2c;
  --ink-soft: #66705f;
  --paper: #fbf8ef;
  --paper-edge: #e6dfca;
  --leaf: #4f8f4a;
  --leaf-deep: #2f6a35;
  --water: #3d86c6;
  --merit: #3f8a52;
  --demerit: #b0573e;
  --mist: #dfe6e0;
  --shadow: 0 6px 24px rgba(40, 50, 30, 0.18);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--mist);
  color: var(--ink);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  overflow: hidden;
}
#map { position: absolute; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---- 左上：ロゴ・現在地・階層 ---- */
.hud {
  position: absolute; top: 16px; left: 16px; z-index: 2;
  max-width: min(520px, calc(100vw - 32px));
  background: rgba(251, 248, 239, 0.92);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  backdrop-filter: blur(6px);
}
.logo {
  margin: 0; font-size: 26px; letter-spacing: 0.04em; color: var(--leaf-deep);
  font-weight: 700;
}
.crumbs { margin-top: 4px; font-size: 14px; color: var(--ink-soft); }
.crumbs a { color: var(--ink); text-decoration: none; border-bottom: 1px dotted var(--ink-soft); }
.crumbs a:hover { color: var(--leaf-deep); }
.crumbs .sep { margin: 0 6px; opacity: 0.6; }
.levels { display: flex; gap: 4px; margin-top: 8px; }
.levels button {
  border: 1px solid var(--paper-edge); background: #fff; border-radius: 999px;
  padding: 2px 12px; font-size: 13px; color: var(--ink-soft);
}
.levels button.on { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.stats { margin-top: 8px; font-size: 12px; color: var(--ink-soft); }
.manifesto-chip {
  display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 700;
  color: var(--leaf-deep); text-decoration: none; border-bottom: 1px dotted var(--leaf);
}
.manifesto-chip:hover { color: var(--leaf); }
.manifesto-chip[hidden] { display: none; }

/* ---- 左下：植林 ---- */
.nursery {
  position: absolute; left: 16px; bottom: 36px; z-index: 2;
  width: min(320px, calc(100vw - 32px));
  background: rgba(251, 248, 239, 0.92);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  font-size: 13px;
}
.plant-btn {
  width: 100%; border: none; border-radius: 10px; padding: 8px 10px;
  background: #e9dfbf; font-weight: 700;
}
.plant-btn:hover { background: #e0d3a8; }
.nursery summary { margin-top: 8px; color: var(--ink-soft); cursor: pointer; }
.nursery ol { margin: 6px 0 0; padding-left: 20px; }
.nursery li { margin: 2px 0; cursor: pointer; }
.nursery li:hover { color: var(--leaf-deep); text-decoration: underline; }
.nursery li small { color: var(--ink-soft); }

/* ---- 右：木の詳細 ---- */
.panel {
  position: absolute; top: 16px; right: 16px; bottom: 16px; z-index: 3;
  width: min(440px, calc(100vw - 32px));
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel[hidden] { display: none; }
.panel-body { position: relative; flex: 1; overflow-y: auto; padding: 18px 22px 16px; }
.close {
  position: absolute; top: 8px; right: 10px; border: none; background: none;
  font-size: 22px; color: var(--ink-soft);
}
.p-path { font-size: 12px; color: var(--ink-soft); padding-right: 24px; }
.p-title { font-size: 21px; line-height: 1.5; margin: 8px 0 16px; }

/* 実現までのステップ（タイトルの次に大きく、開閉なし） */
.p-steps { margin: 0 0 18px; }
.p-steps h3 { font-size: 13px; color: var(--leaf-deep); margin: 0 0 8px; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 8px; }
.steps li {
  counter-increment: step; position: relative; padding-left: 34px;
  font-size: 16px; font-weight: 600; line-height: 1.6;
}
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 1px;
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--leaf); color: #fff; font-size: 13px; font-weight: 700;
}
.steps.pending li { padding-left: 0; font-size: 13px; font-weight: 400; color: var(--ink-soft); }
.steps.pending li::before { content: none; }

/* 詳細・メリット・デメリット・背景（すべて見出しで開閉） */
.p-pair { display: grid; gap: 10px; }
.pair { border-radius: 10px; }
.pair summary {
  list-style: none; cursor: pointer; padding: 10px 36px 10px 12px; position: relative;
  display: grid; gap: 2px;
}
.pair summary::-webkit-details-marker { display: none; }
.pair summary::after {
  content: "＋"; position: absolute; right: 12px; top: 50%; translate: 0 -50%;
  font-size: 14px; color: var(--ink-soft);
}
.pair[open] summary::after { content: "−"; }
.pair-label { font-size: 12px; font-weight: 700; }
.pair-title { font-size: 15px; font-weight: 700; line-height: 1.5; }
/* 閉じているときだけ冒頭1行を見せる */
.pair-lead {
  font-size: 13px; color: var(--ink-soft); line-height: 1.6;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pair[open] .pair-lead { display: none; }
.pair p.pending { color: var(--ink-soft); font-size: 13px; }
.pair p { margin: 0; padding: 0 12px 12px; font-size: 14px; line-height: 1.85; text-align: justify; }
.plain { background: #f1ecdc; }
.plain .pair-label { color: var(--leaf-deep); }
.merit { background: #eaf3e6; }
.merit .pair-label { color: var(--merit); }
.demerit { background: #f6e9e2; }
.demerit .pair-label { color: var(--demerit); }

/* 水やり（パネル下に固定） */
.water {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  padding: 10px 22px 12px; background: #e7f0f7; border-top: 1px solid #d3e1ec;
}
.water-count { font-size: 20px; font-weight: 700; color: var(--water); min-width: 72px; }
.water-btn {
  border: none; border-radius: 999px; padding: 6px 18px;
  background: var(--water); color: #fff; font-weight: 700;
}
.water-btn:disabled { background: #a9bccb; cursor: default; }
.drops { font-size: 12px; color: var(--ink-soft); margin-left: auto; }

/* わたしのマニフェストに入れる（デメリットまで読んだあとに置く） */
.p-manifesto { margin: 14px 0 0; }
.p-manifesto[hidden] { display: none; }
.manifesto-btn {
  border: 2px solid var(--leaf); border-radius: 999px; padding: 5px 16px;
  background: #fff; color: var(--leaf-deep); font-size: 14px; font-weight: 700;
}
.manifesto-btn.on { background: var(--leaf); color: #fff; }
.manifesto-btn:disabled { border-color: #c9c0a5; color: var(--ink-soft); cursor: default; }
.manifesto-hint { margin: 6px 0 0; font-size: 11px; color: var(--ink-soft); }

.related h3 { font-size: 13px; margin: 16px 0 4px; }
.related ul { list-style: none; margin: 0; padding: 0; }
.related li {
  font-size: 13px; padding: 6px 8px; border-radius: 8px; cursor: pointer; line-height: 1.5;
}
.related li:hover { background: #f0ead6; }
.related li small { display: block; color: var(--ink-soft); font-size: 11px; }

.ai-note { font-size: 11px; color: var(--ink-soft); margin: 16px 0 8px; }
.ai-note a { color: var(--ink-soft); margin-left: 0.6em; }

.foot {
  position: absolute; left: 16px; bottom: 8px; z-index: 2;
  font-size: 11px; color: var(--ink-soft);
}
.foot a { color: var(--ink-soft); }

/* ---- 鳥と水しぶき ---- */
.bird {
  font-size: 15px; cursor: pointer; user-select: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
  animation: bob 2.4s ease-in-out infinite;
}
.bird.flying { animation: flap 0.25s ease-in-out infinite; }
.bird:hover { transform: scale(1.2); }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -3px; } }
@keyframes flap { 0%, 100% { scale: 1 1; } 50% { scale: 1 0.7; } }

.splash { font-size: 20px; pointer-events: none; animation: fall 0.9s ease-in forwards; }
@keyframes fall {
  from { translate: 0 -40px; opacity: 1; }
  to { translate: 0 10px; opacity: 0; }
}

.maplibregl-popup-content {
  font-family: inherit; font-size: 13px; line-height: 1.5; max-width: 260px;
  border-radius: 10px; padding: 8px 12px; background: var(--paper);
}
.maplibregl-popup-tip { border-top-color: var(--paper) !important; }

/* ---- スマホ：パネルは下から ---- */
@media (max-width: 640px) {
  .hud { padding: 10px 12px; }
  .logo { font-size: 22px; }
  .panel { top: auto; left: 16px; right: 16px; width: auto; height: 62vh; }
  .drops { width: 100%; margin-left: 0; }
  .nursery { bottom: 28px; }
  .nursery details { display: none; }
}
