:root {
  --navy: #17375f;
  --navy-light: #1d3f6b;
  --paper: #fffef9;
  --page: #f2efe7;
  --ink: #142033;
  --muted: #465165;
  --blue: #075b9a;
  --gold: #a76800;
  --line: #bdaf98;
  --green: #237858;
  --red: #b3332f;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body { margin: 0; min-width: 320px; height: 100dvh; overflow: hidden; color: var(--ink); background: linear-gradient(#e9e3d6, var(--page) 650px); font: 16px/1.78 "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif; }
.page-scroll { height: calc(100dvh - 70px); overflow-y: auto; overflow-x: clip; scroll-padding-top: 24px; scroll-behavior: smooth; }
a { color: var(--blue); text-underline-offset: 3px; }
button, input { font: inherit; }
button { min-height: 42px; padding: 7px 15px; color: var(--navy); background: var(--paper); border: 1px solid #968873; border-radius: 10px; cursor: pointer; white-space: nowrap; }
button:hover { background: #f4ecdc; }
:focus-visible { outline: 3px solid #ac751c; outline-offset: 3px; }
.skip-link { position: absolute; left: 16px; top: -100px; z-index: 20; background: white; padding: 10px; }
.skip-link:focus { top: 8px; }
.language-bar { max-width: 1480px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 30px; }
.guides-link { font-size: .85rem; font-weight: 700; }
.languages { display: flex; gap: 8px; }
.languages button { border-radius: 999px; min-height: 34px; font-size: .82rem; padding: 4px 14px; }
.languages [aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: white; }
.hero { background: linear-gradient(118deg, var(--navy), var(--navy-light)); color: white; }
.hero-inner { max-width: 1440px; margin: auto; padding: 34px clamp(24px, 5vw, 72px) 32px; }
.hero p { margin: 0 0 8px; font-size: .86rem; letter-spacing: .04em; }
h1 { font: 700 clamp(2rem, 3.84vw, 3.45rem)/1.3 YuMincho, "Yu Mincho", serif; letter-spacing: .015em; margin: 0; text-wrap: balance; }
html[lang="en"] h1 { font-size: clamp(1.8rem, 3.6vw, 3.25rem); }
.category-nav { overflow-x: auto; background: #fffdf8; border-bottom: 1px solid #aeb8c7; box-shadow: 0 3px 12px #14233c12; }
.nav-inner { display: flex; gap: 24px; width: max-content; min-width: min(100%, 1320px); margin: auto; padding: 10px 25px; }
.category-nav a { display: block; font-size: .92rem; font-weight: 800; padding: 6px 0; white-space: nowrap; text-decoration: none; border-bottom: 2px solid transparent; }
.category-nav [aria-current="page"] { border-color: var(--gold); color: var(--navy); }
.toolbar { max-width: 1320px; margin: auto; display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 18px 24px; }
.search-control { flex: 1; max-width: 800px; }
.search-control label { display: block; font-size: .82rem; font-weight: 700; margin-bottom: 4px; }
.search-input { display: flex; gap: 8px; }
.search-input button { flex-shrink: 0; }
input[type="search"] { width: 100%; min-width: 0; height: 44px; border: 1px solid #879ab5; border-radius: 7px; padding: 7px 12px; background: white; color: var(--ink); }
.toolbar-buttons { display: flex; gap: 8px; flex-shrink: 0; }
.search-results { max-width: 1272px; margin: 0 auto 20px; padding: 18px 24px; background: var(--paper); border: 1px solid #9aacc4; border-radius: 14px; }
.search-results ol { margin: 0; padding-left: 25px; max-height: 420px; overflow-y: auto; }
.search-results li { margin-bottom: 13px; }
.result-category { font-size: .78rem; color: var(--gold); margin-right: 8px; }
.result-context { display: block; color: var(--muted); font-size: .85rem; }
.critical { max-width: 1272px; margin: 0 auto 8px; padding: 15px 20px; background: #f6e8df; border: 1px solid #a96951; border-radius: 14px; font-size: .89rem; }
.critical strong { display: block; color: #683c30; margin-bottom: 3px; }
.critical ul { margin: 0; padding-left: 20px; }
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 34px; max-width: 1440px; padding: 28px clamp(20px, 4vw, 56px) 100px; margin: auto; align-items: start; }
aside { position: sticky; top: 20px; }
.toc { padding: 16px; background: var(--paper); border: 1px solid #a5957f; border-radius: 18px; box-shadow: 0 12px 30px #2e26191a; max-height: calc(100vh - 50px); overflow: auto; }
.toc summary { color: var(--gold); font-size: .82rem; font-weight: 800; cursor: pointer; }
.toc nav { padding-top: 10px; }
.toc a { display: block; padding: 7px 8px; font-size: .84rem; line-height: 1.4; color: var(--muted); text-decoration: none; border-radius: 6px; }
.toc a:hover { background: #f4ecdc; }
main { min-width: 0; }
.progress-panel { display: grid; grid-template-columns: 1fr auto; gap: 20px; background: linear-gradient(120deg, var(--paper), #f5f0e4); padding: 22px 24px; border: 1px solid #c4b8a4; border-radius: 18px; margin-bottom: 8px; box-shadow: 0 10px 25px #2e261914; }
.progress-panel h2 { font-size: 1rem; color: var(--blue); margin: 0; }
.progress-panel p { font-size: .83rem; color: var(--muted); margin: 5px 0 12px; }
.progress-track { overflow: hidden; height: 10px; border: 1px solid #a6977f; background: #e9e3d7; border-radius: 99px; }
#progress-fill { height: 100%; background: var(--green); transition: width .35s ease; }
.progress-actions { display: grid; justify-items: end; align-content: center; gap: 8px; }
.progress-actions strong { color: var(--gold); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
#save-status { font-size: .78rem; color: var(--muted); margin: 6px 4px 20px; }
main > h2, .section-title { color: var(--navy); font-size: 1.45rem; margin: 24px 0 14px; }
.page-intro { margin: 0 0 22px; }
.bulk-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.chapter { border: 1px solid #a5957f; border-radius: 18px; background: #eae3d5; margin: 0 0 22px; overflow: hidden; }
.chapter > summary { background: var(--paper); padding: 19px 22px; color: var(--navy); font-size: 1.13rem; font-weight: 800; cursor: pointer; }
.chapter-body { padding: 18px; }
.route-card { position: relative; padding: 20px 20px 20px 60px; margin-bottom: 13px; background: var(--paper); border: 1px solid #c4b8a4; border-radius: 15px; box-shadow: 0 5px 15px #2e261911; }
.route-card:last-child { margin-bottom: 0; }
.route-card h3 { font-size: 1rem; margin: 0 0 10px; color: var(--ink); }
.route-card p { margin: 8px 0; }
.route-card ol, .route-card ul { padding-left: 22px; margin: 9px 0; }
.route-card li { margin-bottom: 5px; }
.route-card input { position: absolute; top: 24px; left: 20px; width: 23px; height: 23px; accent-color: #087653; cursor: pointer; }
.badge { display: inline-block; border: 1px solid #a5957f; border-radius: 99px; padding: 1px 9px; font-size: .71rem; color: #795413; margin-bottom: 7px; }
.route-card.is-done { border-color: var(--green); padding-bottom: 64px; }
.stamp { position: absolute; right: 15px; bottom: 12px; min-width: 62px; height: 31px; display: grid; place-items: center; padding: 0 7px; border: 2px solid #b3332feb; border-radius: 4px 6px 5px 3px; color: var(--red); font-size: .85rem; font-weight: 900; letter-spacing: .08em; line-height: 1; background: radial-gradient(circle at 16% 28%, #fffdf8eb 0 1px, transparent 1.35px) 0 0 / 9px 8px, #fffdf8db; transform: none; box-shadow: inset 0 0 0 1px #b3332f29; }
.stamp[hidden] { display: none; }
.is-bumping { animation: card-bump .58s ease; }
.is-bumping .stamp { animation: stamp-pop .58s ease; }
@keyframes card-bump { 0% { transform: scale(1); } 35% { transform: scale(1.012); } 65% { transform: scale(.997); } 100% { transform: scale(1); } }
@keyframes stamp-pop { 0% { opacity: 0; transform: scale(1.4); } 58% { opacity: 1; transform: scale(.93); } 100% { opacity: 1; transform: scale(1); } }
.note { padding: 11px 14px; background: #f3ead6; border: 1px solid #c6b99f; border-radius: 8px; font-size: .87rem; }
.cross-links { display: flex; gap: 8px 16px; flex-wrap: wrap; margin-top: 12px; font-size: .85rem; }
.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; align-items: start; }
.data-card { border: 1px solid #bdaf98; border-radius: 14px; background: var(--paper); padding: 19px; }
.data-card h3 { color: var(--navy); margin: 0 0 9px; font-size: 1.04rem; }
.data-card p { margin: 8px 0; }
.data-card details { margin-top: 8px; }
.table-panel { padding: 20px; border: 1px solid #aeb8c7; border-radius: 15px; background: var(--paper); margin: 18px 0; }
.table-panel h3 { margin: 0 0 15px; color: var(--navy); font-size: 1.13rem; }
.table-wrap { width: 100%; overflow-x: auto; border-radius: 9px; border: 1px solid #aeb8c7; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; min-width: 720px; }
th { background: #203f69; color: white; text-align: left; font-weight: 800; }
th, td { padding: 10px 11px; border: 1px solid #ccd5e1; vertical-align: top; line-height: 1.7; }
th:first-child, td:first-child { min-width: 140px; font-weight: 700; }
tbody tr:nth-child(even) { background: #eff3f7; }
td { min-width: 75px; }
tr:target { background: #fff1c5; }
.table-caption { color: var(--muted); font-size: .81rem; margin: 8px 0; }
.back-top { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 10; width: 46px; height: 46px; padding: 0; border: 1px solid #7e8998; border-radius: 50%; background: #fffdf8; box-shadow: 0 8px 22px #09182c38; color: var(--navy); font-size: 1.15rem; font-weight: 900; }
footer { padding: 24px 80px 85px 24px; text-align: center; border-top: 1px solid #c4b8a4; background: #eae4d8; }
[hidden] { display: none !important; }
@media (max-width: 760px) {
  .language-bar { padding: 8px 14px; gap: 7px; }
  .guides-link { font-size: .72rem; }
  .languages { gap: 5px; }
  .languages button { padding: 4px 10px; font-size: .74rem; }
  .hero-inner { padding: 27px 20px 26px; }
  h1 { font-size: clamp(1.65rem, 7vw, 2.15rem); line-height: 1.35; }
  html[lang="en"] h1 { font-size: clamp(1.55rem, 7.1vw, 2rem); }
  .hero p { font-size: .75rem; }
  .nav-inner { gap: 20px; padding: 8px 20px; }
  .category-nav a { font-size: .84rem; }
  .toolbar { padding: 15px; gap: 12px; flex-wrap: wrap; }
  .search-control { flex-basis: 100%; }
  .toolbar-buttons { margin-left: auto; }
  .search-results, .critical { margin-left: 14px; margin-right: 14px; padding: 13px 16px; }
  .critical { font-size: .82rem; }
  .layout { display: block; padding: 20px 14px 80px; }
  aside { position: static; margin-bottom: 20px; }
  .toc { padding: 13px 16px; max-height: none; }
  .toc nav { max-height: 350px; overflow-y: auto; }
  .progress-panel { grid-template-columns: 1fr; padding: 18px; gap: 10px; }
  .progress-actions { grid-template-columns: 1fr auto; justify-items: start; align-items: center; }
  .progress-actions strong { font-size: 1.05rem; }
  .progress-actions button { padding: 6px 9px; font-size: .79rem; }
  .chapter > summary { padding: 17px; font-size: 1rem; }
  .chapter-body { padding: 11px; }
  .route-card { padding: 18px 14px; }
  .route-card h3 { padding-top: 35px; }
  .route-card input { top: 19px; left: 15px; }
  .route-card.is-done { padding-bottom: 64px; }
  .data-grid { grid-template-columns: 1fr; }
  .table-panel { padding: 15px; }
  table { font-size: .82rem; }
  th:first-child, td:first-child { min-width: 135px; }
  .page-intro { font-size: .93rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  body { height: auto; overflow: visible; }
  .page-scroll { height: auto; overflow: visible; }
  body { background: white; color: black; font-size: 11pt; }
  .language-bar, .category-nav, .toolbar, .search-results, aside, .back-top, .bulk-actions, .progress-actions button, #retry-save, footer { display: none !important; }
  .hero { background: white; color: black; }
  .hero-inner { padding: 10px 0; }
  h1, html[lang="en"] h1 { font-size: 22pt; }
  .layout { display: block; padding: 15px 0; }
  .critical { margin: 0; }
  .chapter, .route-card, .table-panel, .data-card { box-shadow: none; break-inside: avoid; }
  table { min-width: 0; font-size: 8pt; }
  th, td { min-width: 0 !important; padding: 5px; }
  .table-wrap { overflow: visible; }
}

.puzzle-figure{margin:22px 0;padding:12px;border:1px solid #bdcce0;border-radius:10px;background:#fff}.puzzle-scroll{overflow-x:auto}.puzzle-figure img{display:block;width:100%;height:auto;min-width:500px;max-width:700px;margin:auto}.puzzle-figure figcaption{margin-top:10px;color:#51677f;font-size:.86rem;text-align:center}
