:root {
  --paper: #f6efe0; --paper-2: #efe4cd; --ink: #4a3b2f; --ink-soft: #7a6858; --line: #d9cbb0;
  --red: #c8553d; --sage: #7f9f7a; --sky: #6f9fb8; --mustard: #dba53f; --rose: #cf8a86; --plum: #8e6d8f;
  --idle: #e3d6bd;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--ink); font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic UI", sans-serif;
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse 60% 40% at 10% 0%, rgba(219,165,63,.10), transparent 70%),
    radial-gradient(ellipse 60% 40% at 0% 80%, rgba(127,159,122,.12), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.27 0 0 0 0 0.18 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-attachment: fixed;
}
a { color: var(--sky); }

/* ---------- split layout ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.book { padding: 0 clamp(18px, 3.4vw, 48px) 40px; min-width: 0; }
.atlas { position: sticky; top: 0; height: 100vh; border-left: 1.5px solid var(--line); background: #f3ead6; }
#map { position: absolute; inset: 0; }
.atlas::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply; opacity: .55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012 .02' numOctaves='3' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .45 0 0 0 0 .32 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .24 0 0 0 0 .16 0 0 0 .08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.atlas .maplibregl-canvas { outline: none; }
.atlas .maplibregl-ctrl-attrib { background: rgba(246, 239, 224, .85); font-size: 10px; }
.atlas-card {
  position: absolute; left: 18px; top: 18px; z-index: 2; max-width: min(320px, calc(100% - 36px));
  padding: 12px 16px; border-radius: 16px; background: rgba(255, 251, 242, .92); border: 1.5px solid var(--line);
  box-shadow: 0 10px 24px -16px rgba(74, 59, 47, .45); transition: opacity .4s ease;
}
.atlas-card:empty, .atlas-card.empty { opacity: 0; }
.atlas-title { font-family: "Kiwi Maru", serif; font-size: 15px; line-height: 1.5; }
.atlas-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 12px; color: var(--ink-soft); }
.atlas-legend span { display: inline-flex; align-items: center; gap: 5px; }
.atlas-legend i { width: 12px; height: 12px; border-radius: 4px; border: 1px solid rgba(74,59,47,.2); }
.atlas-legend i.dot { border-radius: 50%; }
.atlas-back {
  position: absolute; right: 18px; top: 18px; z-index: 2; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--ink); background: rgba(255, 251, 242, .95); border: 1.5px solid var(--line);
}
.atlas-back:hover { border-color: var(--ink-soft); }
.atlas-hint {
  position: absolute; left: 50%; bottom: 26px; z-index: 2; transform: translateX(-50%); white-space: nowrap;
  padding: 7px 16px; border-radius: 999px; font-size: 12px; color: var(--paper); background: rgba(74, 59, 47, .82);
  transition: opacity .4s ease;
}
.atlas-hint.off { opacity: 0; pointer-events: none; }
.atlas-tip {
  position: absolute; z-index: 3; pointer-events: none; padding: 6px 10px; border-radius: 10px; font-size: 12px; line-height: 1.5;
  background: rgba(74, 59, 47, .92); color: #fffaf0; transform: translate(12px, 12px); white-space: nowrap;
}

/* ---------- book ---------- */
.topnav { display: flex; justify-content: space-between; padding: 18px 0 0; font-size: 13px; }
.topnav a { color: var(--ink-soft); text-decoration: none; border-bottom: 1px dashed var(--line); }
.cover { text-align: center; padding: 14px 0 6px; }
.cover svg.scene {
  width: 100%; max-width: 620px; height: auto; display: block; margin: 0 auto; border-radius: 0 0 40px 40px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 9%, #000 91%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 9%, #000 91%, transparent);
}
.cover h1 { font-family: "Kiwi Maru", serif; font-weight: 500; font-size: clamp(24px, 3.2vw, 36px); letter-spacing: .06em; margin: 10px 0 4px; }
.cover .series { font-family: "Kiwi Maru", serif; color: var(--red); font-size: 15px; letter-spacing: .3em; }
.cover .asof { color: var(--ink-soft); font-size: 13px; margin-top: 8px; }
.pref-switch { display: inline-flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--ink-soft); }
.pref-switch select {
  font: inherit; font-size: 14px; color: var(--ink); padding: 6px 30px 6px 12px; border-radius: 999px; border: 1.5px solid var(--line);
  background: #fffaf0 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237a6858' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center / 10px;
  appearance: none; cursor: pointer;
}
.scroll-hint { display: block; margin-top: 18px; color: var(--ink-soft); font-size: 12px; letter-spacing: .2em; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(6px); } }

.page {
  position: relative; margin: 48px 0; padding: 34px 30px 28px; border-radius: 22px; min-height: 58vh;
  display: flex; flex-direction: column; justify-content: center;
  background: rgba(255, 251, 242, .78); border: 1.5px solid var(--line);
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 12px 30px -18px rgba(74, 59, 47, .35);
  opacity: .45; transform: translateY(10px); transition: opacity .6s ease, transform .6s ease, border-color .6s ease;
}
.page.show { opacity: 1; transform: none; }
.page.current { border-color: color-mix(in srgb, var(--c, var(--red)) 55%, var(--line)); }
.page::before {
  content: attr(data-no); position: absolute; top: -16px; left: 28px; width: 34px; height: 34px; line-height: 32px;
  text-align: center; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--line);
  font-family: "Kiwi Maru", serif; font-size: 14px; color: var(--ink-soft);
}
.verse { font-size: clamp(15px, 1.5vw, 18px); line-height: 2.05; margin: 0; letter-spacing: .02em; }
.verse + .verse { margin-top: 8px; }
.num { font-family: "Kiwi Maru", serif; font-size: 1.7em; font-weight: 500; color: var(--c, var(--red)); padding: 0 .08em; font-variant-numeric: tabular-nums; }
.place { font-weight: 700; background: linear-gradient(transparent 62%, color-mix(in srgb, var(--c, var(--mustard)) 30%, transparent) 62%); padding: 0 .1em; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; padding: 0; list-style: none; }
.tags li { font-size: 13px; padding: 3px 12px 3px 22px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line); position: relative; }
.tags li::before { content: ""; position: absolute; left: 9px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--c, var(--red)); }
.viz { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; margin-top: 20px; }
.grid-box { flex: 1 1 220px; }
.grid-cap { font-size: 12px; color: var(--ink-soft); margin: 0 0 6px; letter-spacing: .08em; }
.grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px 3px; max-width: 280px; }
.grid svg { width: 100%; height: auto; display: block; color: var(--idle); transition: color .5s ease, transform .5s ease; }
.grid svg.on { color: var(--c, var(--red)); }
.grid svg.new { color: var(--c, var(--red)); opacity: .55; animation: pulse 1.8s ease-in-out infinite; }
.grid svg.pop { transform: translateY(-2px) scale(1.06); }
@keyframes pulse { 50% { opacity: 1; } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-soft); margin-top: 10px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; background: var(--k); vertical-align: -1px; }
.aside { flex: 0 1 180px; align-self: center; text-align: center; padding: 16px 10px; border-radius: 18px; background: color-mix(in srgb, var(--c) 10%, transparent); border: 1.5px dashed color-mix(in srgb, var(--c) 45%, transparent); }
.aside .big { font-family: "Kiwi Maru", serif; font-size: 50px; line-height: 1; color: var(--c); }
.aside .of { font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; }
.aside .txt { font-size: 12px; line-height: 1.7; margin-top: 8px; }
.regions { margin-top: 18px; display: grid; gap: 7px; }
.reg { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 10px; font-size: 13px; }
.reg .bars { display: grid; gap: 3px; }
.bar { height: 9px; border-radius: 6px; background: var(--k); width: 0; transition: width 1.1s cubic-bezier(.2,.8,.2,1); }
.page.show .bar { width: var(--w); }
.reg-legend { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
.reg-legend i { display: inline-block; width: 18px; height: 8px; border-radius: 4px; background: var(--k); margin: 0 4px 0 10px; }
.finale { text-align: center; }
.finale svg { width: 110px; height: auto; margin: 6px auto 0; display: block; }
.choose { text-align: center; }
.choose .verse { font-family: "Kiwi Maru", serif; }
.pref-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 14px; }
.pref-chips button {
  font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  background: #fffaf0; border: 1.5px solid var(--line); color: var(--ink);
}
.pref-chips button:hover { border-color: var(--c, var(--red)); color: var(--c, var(--red)); }
.closing { font-family: "Kiwi Maru", serif; text-align: center; font-size: 16px; line-height: 2.2; color: var(--ink-soft); margin: 50px 0 20px; }
footer { font-size: 12px; line-height: 1.8; color: var(--ink-soft); border-top: 1.5px dashed var(--line); padding: 18px 0 40px; margin-top: 30px; }

/* ---------- mobile: map on top ---------- */
@media (max-width: 900px) {
  .split { display: flex; flex-direction: column-reverse; }
  .atlas { height: 42vh; z-index: 5; border-left: 0; border-bottom: 1.5px solid var(--line); }
  .atlas-card { left: 10px; top: 10px; padding: 8px 12px; }
  .atlas-title { font-size: 13px; }
  .atlas-legend { font-size: 11px; }
  .atlas-back { right: 10px; top: auto; bottom: 10px; }
  .atlas-hint { bottom: 12px; font-size: 11px; }
  .page { min-height: 0; margin: 36px 0; padding: 30px 18px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .page, .bar, .grid svg { transition: none; } .page { opacity: 1; transform: none; }
  .scroll-hint, .grid svg.new { animation: none; }
}
