:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --ink: #2a2118;
  --muted: #7a6a58;
  --line: #e3d8c4;
  --accent: #b3261e;
  --accent-ink: #fff;
  --gold: #b8892b;
  --cap: #2e7d32;
  --cap-bg: rgba(46, 125, 50, .10);
  --bar: linear-gradient(90deg, #d4562c, #e9a23b);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16120f;
    --surface: #211b16;
    --ink: #efe6d8;
    --muted: #a8977f;
    --line: #3a3027;
    --accent: #e0533f;
    --gold: #d9a94a;
    --cap: #6fcf7a;
    --cap-bg: rgba(111, 207, 122, .12);
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 system-ui, -apple-system, "PingFang SC", "Hiragino Sans", "Noto Sans CJK SC", sans-serif;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 1.7rem; margin: 1.2rem 0 1rem; letter-spacing: .02em; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; color: var(--muted); font-weight: 600; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* header */
.site-header { background: #1d1712; color: #f3e9d8; border-bottom: 3px solid var(--gold); }
.header-inner { display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.crest { color: var(--gold); }
.main-nav { display: flex; gap: 4px; flex: 1; }
.main-nav a, .lang-switch a { padding: 6px 12px; border-radius: 6px; opacity: .8; }
.main-nav a:hover, .lang-switch a:hover { opacity: 1; background: rgba(255,255,255,.08); }
.main-nav a.active { opacity: 1; background: rgba(255,255,255,.12); box-shadow: inset 0 -2px 0 var(--gold); }
.lang-switch { display: flex; gap: 2px; font-size: .85rem; background: rgba(255,255,255,.06); border-radius: 8px; padding: 2px; }
.lang-switch a.active { background: var(--gold); color: #1d1712; opacity: 1; font-weight: 600; }
.proto-note { background: #fbe9c6; color: #6b4b12; font-size: .82rem; padding: 4px 0; }
@media (prefers-color-scheme: dark) { .proto-note { background: #3a2c12; color: #e8c97c; } }

/* home */
.hero { padding: 40px 0 16px; }
.hero h1 { font-size: 2.2rem; margin: 0 0 .4rem; }
.hero p { color: var(--muted); max-width: 640px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding-bottom: 40px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); border-color: var(--gold); }
.tile-icon { font-size: 1.8rem; }
.tile-title { font-weight: 700; font-size: 1.15rem; }
.tile-count { color: var(--muted); font-size: .9rem; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.search { flex: 1 1 220px; max-width: 320px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 4px 12px;
  border-radius: 999px; cursor: pointer; font: inherit; font-size: .85rem; }
.filter.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; padding-bottom: 40px; }
.list { display: grid; gap: 8px; padding-bottom: 40px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); transition: border-color .15s; }
.card:hover { border-color: var(--gold); }
.card[hidden], tr[hidden] { display: none; }
.card-body { display: flex; flex-direction: column; min-width: 0; }
.card-title { font-weight: 700; }
.card-sub { color: var(--muted); font-size: .85rem; }
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--gold)); color: #fff; font-weight: 700; font-size: 1.1rem; }
.avatar.big { width: 72px; height: 72px; font-size: 1.8rem; }
.chapter-no { flex: none; min-width: 84px; font-size: .8rem; font-weight: 700; color: var(--gold); letter-spacing: .03em; }
.chapter-no.big { font-size: 1rem; min-width: auto; padding: 10px 14px; border: 2px solid var(--gold); border-radius: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { font-size: .72rem; padding: 1px 8px; border-radius: 999px; background: var(--line); color: var(--ink); white-space: nowrap; }
.chip.muted { color: var(--muted); }
.w-sword { background: #dbe7f5; color: #1f4a7a; } .w-lance { background: #e2efd9; color: #2f5d1f; }
.w-axe { background: #f6dcd6; color: #8a2a1a; } .w-bow { background: #f2e6c9; color: #6e5212; }
.w-anima { background: #fbdcc2; color: #8c3c06; } .w-light { background: #fbf3c4; color: #6b5a00; }
.w-dark { background: #e1d8ef; color: #4a2f75; } .w-staff { background: #d9f0ee; color: #1a5f59; }
.w-item { background: #e8e3da; color: #5b5146; }
@media (prefers-color-scheme: dark) { .chip[class*="w-"] { filter: brightness(.75) saturate(1.2); } }

/* detail */
.back { display: inline-block; margin-top: 16px; color: var(--muted); font-size: .9rem; }
.back:hover { color: var(--accent); }
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  margin: 12px 0 40px; box-shadow: var(--shadow); }
.detail-head { display: flex; gap: 18px; align-items: center; }
.detail-head h1 { margin: 0; }
.aka { margin: 0; color: var(--muted); font-size: .85rem; }
.desc { margin: 18px 0; }
.mini-stats { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.mini-stats div { border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px; display: flex; gap: 10px; align-items: baseline; }
.mini-stats span { color: var(--muted); font-size: .8rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.stats { width: 100%; border-collapse: collapse; }
.stats th { text-align: left; font-weight: 500; color: var(--muted); width: 70px; padding: 3px 0; font-size: .88rem; }
.stats .num { width: 48px; text-align: right; padding-right: 10px; font-variant-numeric: tabular-nums; font-weight: 600; }
.bar-cell { width: auto; }
.bar { display: block; height: 8px; border-radius: 4px; background: var(--bar); min-width: 2px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0 0 18px; }
.facts div { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.facts dt { color: var(--muted); font-size: .8rem; }
.facts dd { margin: 0; font-weight: 600; }
.map-placeholder { height: 220px; border: 2px dashed var(--line); border-radius: var(--radius); display: grid; place-items: center;
  color: var(--muted); letter-spacing: .3em; font-weight: 700;
  background: repeating-linear-gradient(0deg, transparent 0 23px, var(--line) 23px 24px),
              repeating-linear-gradient(90deg, transparent 0 23px, var(--line) 23px 24px); background-blend-mode: normal; opacity: .8; }
.pager { display: flex; justify-content: space-between; margin-top: 18px; }
.pager a { color: var(--accent); font-weight: 600; }

/* table */
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 40px; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th { text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--line); white-space: nowrap;
  cursor: pointer; user-select: none; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
.data-table th:hover { color: var(--accent); }
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.name { font-weight: 600; }
.data-table td.note { white-space: normal; color: var(--muted); min-width: 200px; }
.data-table tbody tr:hover { background: rgba(184, 137, 43, .08); }

.site-footer { color: var(--muted); font-size: .8rem; padding: 24px 16px 40px; border-top: 1px solid var(--line); }

@media (max-width: 640px) {
  .header-inner { gap: 8px; padding: 8px 16px; }
  .main-nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .hero h1 { font-size: 1.6rem; }
  .detail { padding: 16px; }
}

/* images */
.px { image-rendering: pixelated; image-rendering: crisp-edges; }
.icon { width: 16px; height: 16px; vertical-align: -3px; margin-right: 3px; }
.chip { display: inline-flex; align-items: center; }
.avatar.has-img { background: linear-gradient(160deg, #3b5f8a, #20324a); overflow: hidden; border: 2px solid var(--gold); }
.avatar.has-img img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; image-rendering: pixelated; }
.avatar { width: 56px; height: 56px; }
.avatar.big { width: auto; height: auto; border-radius: 10px; }
.avatar.big.has-img img { width: 192px; height: 160px; object-fit: contain; }
.avatar.sm { width: 32px; height: 32px; font-size: .8rem; border-width: 1px; }
.facts dd { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.boss-fact dd .avatar { margin-right: 4px; }
.recruits a { display: inline-flex; align-items: center; gap: 6px; }
.recruits a:hover { color: var(--accent); }
.map-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.map-card { flex-direction: column; align-items: stretch; padding: 0; overflow: hidden; }
.map-card .card-body { padding: 10px 14px 12px; }
.map-thumb { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; object-position: top; display: block; background: #222; }
.map-card .chapter-no { min-width: 0; }
.map-figure { margin: 0; text-align: center; background: #111; border-radius: var(--radius); padding: 12px; overflow-x: auto; }
.map-figure img { width: 100%; max-width: 640px; height: auto; }
.item-icon { width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; }
@media (max-width: 640px) { .avatar.big.has-img img { width: 120px; height: 100px; } }

/* stories / recruitment */
h1 .count { font-size: .9rem; color: var(--muted); font-weight: 500; margin-left: 6px; }
.story-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.story-tabs a { padding: 8px 16px; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.story-tabs a:hover { color: var(--ink); }
.story-tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.story-dots { display: inline-flex; gap: 3px; margin-left: 8px; vertical-align: 2px; }
.story-dot { font-size: .62rem; width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 700; }
.s-lyn { background: #2f8a57; } .s-eliwood { background: #b3261e; } .s-hector { background: #2f5aa8; }
.roster td.ch { font-weight: 700; color: var(--gold); white-space: nowrap; }
.roster td.note { min-width: 280px; color: var(--ink); }
.roster .who { display: inline-flex; align-items: center; gap: 8px; }
.roster .who:hover { color: var(--accent); }
.roster td { vertical-align: middle; }
.recruit-sec { margin-bottom: 24px; }
.recruit-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.recruit-table th { text-align: left; white-space: nowrap; padding: 8px 12px 8px 0; width: 1%; font-weight: 600; }
.recruit-table th a:hover { color: var(--accent); }
.recruit-table td { padding: 8px 12px 8px 0; border-top: 1px solid var(--line); }
.recruit-table th { border-top: 1px solid var(--line); }
.recruit-table td.ch { white-space: nowrap; width: 1%; color: var(--gold); font-weight: 700; }
.recruit-table .muted { color: var(--muted); }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { font: inherit; font-size: .85rem; font-weight: 600; border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 5px 12px; border-radius: 8px; cursor: pointer; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs h2 { margin: 0; }
.ranks { align-items: center; margin: -6px 0 14px; }
.ranks .label { font-size: .8rem; color: var(--muted); margin-right: 4px; }
.chip b { margin-left: 3px; }
.hm-note { font-size: .82rem; color: var(--muted); margin: 8px 0 0; }
.hm-note b { color: var(--accent); margin-right: 4px; }
.aff { background: #efe3c8; color: #6b4b12; }
.source-note { color: var(--muted); font-size: .8rem; margin: -24px 0 40px; }

/* growth table + expected stats */
.growth-table td.g { background: linear-gradient(90deg, rgba(212, 86, 44, .22) var(--g), transparent var(--g)); }
.growth-table td.total, .exp-table td.total { font-weight: 700; }
.expected { margin-top: 28px; }
.exp-controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-bottom: 12px; }
.exp-controls label { display: inline-flex; gap: 8px; align-items: center; font-size: .85rem; color: var(--muted); }
.exp-controls select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.exp-status { font-size: .85rem; font-weight: 600; }
.expected .table-scroll { margin-bottom: 8px; box-shadow: none; }
.exp-table th small { display: block; font-weight: 400; font-size: .72rem; color: var(--muted); }
.exp-table tbody th { text-align: left; padding: 6px 12px; white-space: nowrap; color: var(--ink); cursor: default; position: static; border-bottom: 1px solid var(--line); }
.exp-table thead th { cursor: default; }
.exp-table td.capped { color: var(--cap); font-weight: 700; background: var(--cap-bg); }
.exp-table tr.promo-sep td { background: rgba(184, 137, 43, .14); color: var(--gold); font-weight: 700; font-size: .82rem; padding: 4px 12px; }
.exp-hm { cursor: pointer; user-select: none; }
.exp-hm input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.exp-hm.off { opacity: .45; cursor: not-allowed; }
.exp-table.hm-on tbody tr:first-child th { color: var(--accent); }
.expected .table-scroll { max-height: none; overflow-y: visible; }
.exp-table thead th { position: static; }
.exp-table tr.mark5 th, .exp-table tr.mark5 td:not(.capped) { background: rgba(184, 137, 43, .09); }
.exp-table td, .exp-table tbody th { padding-top: 4px; padding-bottom: 4px; }

/* equipment sections */
.item-section { margin-bottom: 28px; }
.item-section[hidden] { display: none; }
.item-section .table-scroll { margin-bottom: 0; }
.item-h2 { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: 1.1rem; margin: 0 0 10px; }
.item-h2 .icon { width: 20px; height: 20px; }
.item-h2 small { font-size: .78rem; color: var(--muted); font-weight: 500; margin-left: 4px; }
.item-table td.price { font-weight: 600; }
.item-table td.price small { color: var(--muted); font-weight: 400; margin-left: 2px; }
.item-table td.muted { color: var(--muted); font-size: .82rem; }
.item-table th:first-child, .item-table td.name { width: 190px; }
.source-note { margin-top: 0; }

/* equipment: expandable "how to obtain" rows */
.hint { color: var(--muted); font-size: .82rem; margin: -6px 0 14px; }
tr.item-row { cursor: pointer; }
tr.item-row td.name::before { content: "▸"; display: inline-block; width: 14px; color: var(--muted); transition: transform .15s; }
tr.item-row[aria-expanded="true"] td.name::before { transform: rotate(90deg); color: var(--accent); }
tr.item-row[aria-expanded="true"] td { background: rgba(184, 137, 43, .10); border-bottom-color: transparent; }
tr.item-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
tr.obtain-row > td { white-space: normal; background: rgba(184, 137, 43, .05); padding: 4px 16px 14px 34px; }
.obtain h3 { font-size: .82rem; color: var(--muted); margin: 6px 0 8px; font-weight: 600; }
.obtain ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.obtain li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: .88rem; }
.obtain-none { color: var(--muted); font-size: .85rem; margin: 6px 0; }
.okind { font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 4px; min-width: 64px; text-align: center; }
.k-found { background: #e2efd9; color: #2f5d1f; } .k-shop { background: #dbe7f5; color: #1f4a7a; } .k-secret { background: #e1d8ef; color: #4a2f75; }
.ochs { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.och { font-size: .72rem; padding: 1px 8px; border-radius: 999px; color: #fff; white-space: nowrap; font-weight: 600; }
.s-lyn-bg { background: #2f8a57; } .s-eliwood-bg { background: #b3261e; } .s-hector-bg { background: #2f5aa8; }
.s-both-bg { background: linear-gradient(90deg, #b3261e, #2f5aa8); }
.otext { color: var(--ink); }
@media (prefers-color-scheme: dark) { .okind { filter: brightness(.8) saturate(1.2); } }

/* map detail: story switch, recruits, shops, items, reinforcements */
.story-tabs a small { font-weight: 500; color: var(--muted); margin-left: 2px; }
.map-story { margin: 16px 0 0; }
.map-sec { margin-top: 28px; }
.map-sec h2 { color: var(--ink); font-size: 1.05rem; border-bottom: 2px solid var(--line); padding-bottom: 6px; }
.map-sec h2 small { color: var(--muted); font-weight: 500; font-size: .8rem; }
.muted { color: var(--muted); }
.boss { display: inline-flex; align-items: center; gap: 6px; margin-right: 10px; }
.recruit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.recruit-list li { display: grid; grid-template-columns: auto auto 1fr; gap: 4px 14px; align-items: center; }
.recruit-list .who { display: inline-flex; align-items: center; gap: 8px; }
.recruit-list .who:hover b { color: var(--accent); }
.recruit-list .muted { font-size: .82rem; white-space: nowrap; }
.recruit-list .cond { font-size: .9rem; }
@media (max-width: 640px) { .recruit-list li { grid-template-columns: auto 1fr; } .recruit-list .cond { grid-column: 1 / -1; } }
.shops { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.shop { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.shop h4 { margin: 0 0 8px; }
.shop ul, .found-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.shop li { display: flex; align-items: center; gap: 6px; font-size: .88rem; }
.shop li .price { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.found-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .9rem; }
.waves { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.wave { border-left: 3px solid var(--gold); padding: 2px 0 2px 12px; }
.wave .when { font-weight: 700; font-size: .88rem; margin-bottom: 2px; }
.wave ul { margin: 0; padding-left: 18px; font-size: .9rem; }
.ch-link { color: inherit; text-decoration: underline; text-decoration-color: rgba(127,127,127,.5); text-underline-offset: 2px; }
.ch-link:hover { color: var(--accent); }
.och .ch-link { color: #fff; }

/* multi-game */
.game-chip { font-size: .82rem; padding: 4px 10px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; opacity: .9; white-space: nowrap; }
.game-chip:hover { opacity: 1; border-color: var(--gold); }
.game-tile .tile-title { font-size: 1.2rem; }
.game-tile.soon { opacity: .55; }
.s-main-bg { background: #8a5a2f; } .s-main { background: #8a5a2f; }
