:root {
  color-scheme: light;
  --navy: #17375f;
  --navy-light: #1d3f6b;
  --paper: #fffef9;
  --page: #f2efe7;
  --ink: #172133;
  --muted: #46536a;
  --line: #b8ac97;
  --blue: #075b9a;
  --gold: #a76800;
  --green: #237858;
  --red: #b3332f;
  --shadow: 0 10px 28px #40301a14;
}
* { box-sizing: border-box; }
html { scroll-behavior: auto; scroll-padding-top: 74px; }
body { margin: 0; min-width: 320px; overflow-anchor: none; background: var(--page); color: var(--ink); font: 16px/1.78 "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif; }
a { color: var(--blue); text-underline-offset: .2em; }
button, input, select { font: inherit; }
button, summary, select, input[type="checkbox"] { cursor: pointer; }
button { min-height: 42px; padding: 7px 14px; border: 1px solid #9f8c70; border-radius: 9px; background: var(--paper); color: var(--navy); }
button:hover { background: #f5ecdc; }
:focus-visible { outline: 3px solid #b77719; outline-offset: 3px; }
[hidden] { display: none !important; }
.skip { position: fixed; top: -100px; left: 10px; z-index: 1000; padding: 8px 14px; background: white; }
.skip:focus { top: 10px; }
.language-bar { position: sticky; top: 0; z-index: 450; padding: 8px max(108px, calc((100vw - 1480px) / 2 + 108px)) 8px max(20px, calc((100vw - 1480px) / 2 + 24px)); display: flex; justify-content: flex-end; gap: 8px; background: #eee8dc; border-bottom: 1px solid var(--line); }
.language-bar button { min-height: 34px; padding: 4px 14px; border-radius: 999px; font-size: .82rem; }
.language-bar [aria-pressed="true"] { color: white; background: var(--navy); border-color: var(--navy); }
.hero { background: linear-gradient(118deg, var(--navy), var(--navy-light)); color: white; }
.hero-inner { max-width: 1480px; margin: auto; padding: 42px clamp(24px, 5.2vw, 80px) 32px; }
h1 { margin: 0; color: white; font-family: YuMincho, "Yu Mincho", serif; font-size: clamp(2rem, 4.1vw, 3.45rem); line-height: 1.24; letter-spacing: .015em; text-wrap: balance; }
html[lang="en"] h1 { font-size: clamp(1.8rem, 3.7vw, 3.25rem); }
.edition { margin: 12px 0 0; color: #f5e7c8; font-size: .88rem; font-weight: 700; }
.nav { overflow-x: auto; border-bottom: 1px solid #aeb8c7; background: #fffdf8; box-shadow: 0 3px 12px #14233c12; }
.nav-inner { display: flex; align-items: center; gap: 22px; width: max-content; min-width: min(100%, 1480px); margin: auto; padding: 10px clamp(24px, 5.2vw, 80px); }
.nav a { display: inline-flex; min-height: 32px; align-items: center; white-space: nowrap; font-size: .92rem; font-weight: 800; text-decoration: none; border-bottom: 2px solid transparent; }
.nav a[aria-current="page"] { color: var(--navy); border-color: var(--gold); }
.tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; max-width: 1440px; margin: auto; padding: 14px clamp(20px, 4vw, 56px); }
.tools-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sound-on { background: #e6f4ed; border-color: var(--green); color: #155a42; }
.search { display: grid; grid-template-columns: minmax(150px, 1fr) auto; align-items: end; gap: 8px; flex: 1 1 430px; max-width: 650px; }
.search label { display: block; font-size: .82rem; color: var(--muted); font-weight: 700; }
.search input { width: 100%; min-height: 44px; border: 1px solid #8796ac; border-radius: 7px; background: white; padding: 8px 12px; }
.search-results { max-width: 1328px; margin: 0 auto 20px; padding: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.search-results h2 { margin: 0 0 8px; font-size: 1.15rem; }
.result { padding: 12px 0; border-bottom: 1px solid #d7cfbf; }
.result:last-child { border-bottom: 0; }
.result p { margin: 3px 0; font-size: .9rem; }
.category-tag { display: inline-block; margin-right: 8px; padding: 1px 6px; border: 1px solid #8a9db8; border-radius: 5px; color: var(--navy); font-size: .75rem; }
.warning-banner { max-width: 1328px; margin: 12px auto 0; padding: 14px 20px; border: 1px solid #ad6f65; border-radius: 12px; background: #f8e9e3; }
.warning-banner p { margin: 3px 0; }
.storage-warning { background: #fff1ce; border-color: #b69243; }
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 34px; max-width: 1440px; margin: auto; padding: 26px clamp(20px, 4vw, 56px) 80px; }
.toc { position: sticky; top: 18px; align-self: start; max-height: calc(100vh - 36px); overflow-y: auto; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: var(--shadow); }
.toc h2 { margin: 0 0 10px; color: var(--gold); font-size: .8rem; letter-spacing: .12em; }
.toc a { display: block; padding: 7px 8px; color: var(--muted); font-size: .87rem; line-height: 1.4; text-decoration: none; }
.toc a:hover { background: #f4ecdc; border-radius: 5px; }
.toc-group { padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--line); }
main { min-width: 0; }
.panel { margin: 0 0 20px; padding: 22px 24px; border: 1px solid var(--line); border-radius: 17px; background: var(--paper); box-shadow: var(--shadow); }
h2 { margin: 0 0 14px; font-size: 1.45rem; line-height: 1.4; color: var(--navy); }
h3 { margin: 0 0 10px; line-height: 1.45; color: var(--navy); }
p { margin: 9px 0; }
.progress-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; background: linear-gradient(135deg, #fffefa, #f7f1e5); }
.progress-panel h2 { font-size: 1rem; }
.progress-panel p { color: var(--muted); font-size: .84rem; }
.progress-total { display: grid; justify-items: end; gap: 10px; min-width: 155px; }
.progress-number { color: #875b06; font-size: 1.38rem; font-variant-numeric: tabular-nums; }
.reset-confirm { grid-column: 1 / -1; padding: 12px; border: 1px solid #ad6f65; border-radius: 9px; background: #f8e9e3; }
.progress-track { height: 11px; border: 1px solid #c7b99e; border-radius: 999px; overflow: hidden; background: #e9e2d6; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), #d29b2e); transition: width .24s ease; }
.floating-progress { position: fixed; top: 12px; right: 14px; z-index: 500; display: grid; place-items: center; width: 72px; height: 72px; border: 3px solid #1d3f6b; border-radius: 50%; background: #fffdf8f7; box-shadow: 0 8px 24px #09182c40, inset 0 0 0 3px white; color: #194a3c; font-size: 1.06rem; font-weight: 900; pointer-events: none; }
.floating-progress.bump { animation: progress-bump .64s ease; }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.note { padding: 17px; border: 1px solid #aeb8c7; border-radius: 14px; background: #e8eef5; }
.note.warn { background: #f8e9e3; border-color: #ad6f65; }
.note.good { background: #e4f0e9; border-color: #438565; }
.note h3 { font-size: 1rem; }
.note p { font-size: .91rem; }
.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 18px 0; }
.chapter { margin-bottom: 20px; border: 1px solid var(--line); border-radius: 17px; background: #e9e1d2; overflow: clip; box-shadow: var(--shadow); }
.chapter > summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; list-style: none; background: var(--paper); padding: 20px 22px; font-size: 1.18rem; font-weight: 800; color: var(--navy); }
.chapter > summary::-webkit-details-marker { display: none; }
.chapter > summary::after { content: "+"; display: grid; place-items: center; flex: 0 0 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; color: var(--gold); }
.chapter[open] > summary::after { content: "−"; }
.chapter-body { padding: 10px 20px 22px; }
.chapter-intro { padding: 5px 2px 8px; font-size: .9rem; }
.route-card { position: relative; margin-top: 12px; padding: 18px 18px 18px 62px; border: 1px solid #c4b8a4; border-radius: 14px; background: var(--paper); }
.route-card input[type="checkbox"] { position: absolute; top: 21px; left: 18px; width: 24px; height: 24px; margin: 0; accent-color: var(--green); }
.route-card h3 { font-size: 1.05rem; color: var(--ink); }
.route-card ol, .route-card ul { margin: 8px 0 0; padding-left: 1.35em; }
.route-card li + li { margin-top: 6px; }
.route-card.is-checked { padding-bottom: 58px; border-color: var(--green); box-shadow: 0 7px 18px #1857421a; }
.route-card.is-checked::after { content: attr(data-stamp); position: absolute; right: 15px; bottom: 12px; display: grid; place-items: center; width: 62px; height: 31px; border: 2px solid #b3332feb; border-radius: 4px 6px 5px 3px; color: var(--red); font-size: .92rem; font-weight: 900; letter-spacing: .1em; line-height: 1; background: radial-gradient(circle at 16% 28%, #fffdf8eb 0 1px, transparent 1.35px) 0 0 / 9px 8px, #fffdf8dc; text-shadow: .5px 0 #78191770; transform: none; }
.route-card.bump { animation: card-bump .58s ease; }
.route-card.bump::after { animation: stamp-pop .58s ease; }
.tip { margin-top: 12px; padding: 10px 12px; border: 1px solid #c4b8a4; border-radius: 8px; background: #f4ecdc; font-size: .87rem; }
.crossrefs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.crossrefs a { border: 1px solid #9babc2; border-radius: 5px; padding: 2px 8px; font-size: .82rem; text-decoration: none; }
.muted { color: var(--muted); font-size: .87rem; }
.table-wrap { overflow-x: auto; border: 1px solid #9babc2; border-radius: 9px; background: white; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { background: #233e65; color: white; text-align: left; white-space: nowrap; }
th, td { padding: 9px 10px; border-right: 1px solid #d5dbe3; border-bottom: 1px solid #c8d0da; vertical-align: top; }
tbody th { background: white; color: var(--ink); white-space: normal; min-width: 160px; }
tr:nth-child(even) td, tbody tr:nth-child(even) th { background: #f0f3f7; }
td.number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.name { min-width: 150px; }
td.text { min-width: 220px; }
td[data-column="faction"], td[data-column="rank"] { min-width: 5.5em; white-space: nowrap; }
tr:target td, tbody tr:target th { background: #fff1ca; }
.table-filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; align-items: center; }
.table-filter input, .table-filter select { min-height: 42px; max-width: 100%; padding: 7px 10px; border: 1px solid #8796ac; border-radius: 6px; background: white; }
.map-shell { position: relative; overflow-x: auto; border: 1px solid #9babc2; border-radius: 10px; background: #f6f0e4; }
.map-canvas { position: relative; width: 100%; min-width: 580px; max-width: 800px; margin: auto; }
.map-canvas img { display: block; width: 100%; height: auto; }
.map-pin { position: absolute; min-height: 34px; min-width: 44px; padding: 2px 5px; border: 0; border-radius: 5px; background: transparent; color: transparent; font-size: .78rem; font-weight: 900; transform: translate(-50%, -50%); }
.map-pin:hover { background: #dba84b44; }
.map-pin[aria-pressed="true"] { outline: 3px solid var(--blue); outline-offset: 3px; }
.map-point { padding: 12px; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; background: #f4ecdc; }
.map-point.selected { border-color: var(--blue); background: #e8eef5; }
.back-top { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 520; width: 46px; height: 46px; padding: 0; border: 1px solid #7e8998; border-radius: 50%; background: #fffdf8; color: var(--navy); box-shadow: 0 8px 22px #09182c38; font-weight: 900; }
footer { padding: 20px 75px 50px 24px; border-top: 1px solid var(--line); text-align: center; background: var(--paper); }
@keyframes card-bump { 0%, 100% { transform: scale(1); } 36% { transform: scale(1.018); } 68% { transform: scale(.995); } }
@keyframes stamp-pop { 0% { opacity: 0; transform: scale(1.42); } 58% { opacity: 1; transform: scale(.92); } 100% { opacity: 1; transform: scale(1); } }
@keyframes progress-bump { 0%, 100% { transform: scale(1); } 34% { transform: scale(1.22); } 62% { transform: scale(.91); } 82% { transform: scale(1.07); } }
@media (min-width: 761px) {
  .hero-inner { padding-right: 100px; }
  .nav { margin-right: 88px; }
  .tools, .layout { padding-right: 88px; }
  .warning-banner, .search-results {
    margin-left: max(20px, calc((100vw - 1440px) / 2 + 56px));
    margin-right: max(88px, calc((100vw - 1440px) / 2 + 88px));
  }
}
@media (max-width: 760px) {
  .language-bar { padding-right: 80px; }
  .floating-progress { top: 10px; right: 10px; width: 58px; height: 58px; border-width: 2px; font-size: .9rem; }
  .hero-inner { padding: 30px 68px 25px 20px; }
  h1 { font-size: clamp(1.55rem, 7vw, 2.15rem); text-wrap: wrap; }
  html[lang="en"] h1 { font-size: 1.8rem; }
  .nav-inner { gap: 18px; padding: 9px 20px; }
  .nav { margin-right: 68px; }
  .nav a { font-size: .84rem; }
  .tools { padding: 14px 68px 14px 14px; }
  .search { flex-basis: 100%; }
  .warning-banner, .search-results { margin-left: 14px; margin-right: 68px; }
  .layout { grid-template-columns: 1fr; gap: 20px; padding: 22px 68px 80px 14px; }
  .toc { position: static; max-height: none; padding: 14px 16px; }
  .toc a { padding: 7px 4px; }
  .panel { padding: 18px; }
  .progress-panel { grid-template-columns: 1fr; gap: 10px; }
  .progress-total { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; min-width: 0; }
  .progress-number { font-size: 1.2rem; }
  .overview-grid { grid-template-columns: 1fr; }
  .chapter > summary { padding: 17px 16px; font-size: 1.07rem; }
  .chapter-body { padding: 8px 10px 16px; }
  .route-card { padding: 18px 14px; }
  .route-card input[type="checkbox"] { position: static; display: block; margin: 0 0 12px; }
  .route-card h3 { font-size: 1rem; }
  .route-card.is-checked { padding-bottom: 58px; }
  th, td { padding: 9px 10px; }
  .back-top { right: 18px; bottom: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .language-bar, .nav, .tools, .floating-progress, .toc, .controls, .back-top, .search-results, .crossrefs, footer, .map-pin, .table-filter, #reset, .reset-confirm { display: none !important; }
  body { background: white; font-size: 11pt; }
  .hero { background: white; color: black; }
  h1, .edition { color: black; }
  .hero-inner { padding: 8mm; }
  .layout { display: block; padding: 5mm; }
  .panel, .chapter, .route-card { box-shadow: none; }
  .route-card { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  table { font-size: 8pt; table-layout: fixed; }
  th, td, tbody th, td.text { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  td[data-column="faction"], td[data-column="rank"] { min-width: 0; white-space: normal; }
  .map-shell { overflow: visible; }
  .map-canvas { min-width: 0; }
}
