:root {
  --bg: var(--iw-paper);
  --bg-2: var(--iw-surface);
  --bg-3: var(--iw-surface);
  --line: var(--iw-line);
  --text: var(--iw-ink);
  --muted: var(--iw-muted);
  --red: var(--iw-accent);
  --red-dim: #ecded2;
  --duelist: #ff4655;
  --initiator: #49c2ff;
  --controller: #d6f25c;
  --sentinel: #f0b429;
  --soon: #c9a6ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --side: 268px;
  --display: var(--iw-display);
  --font: "Codex Text", "Microsoft YaHei", sans-serif;
}

@font-face {
  font-family: "Codex Display";
  src: url("media/fonts/barlow-condensed-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Codex Text";
  src: url("media/fonts/noto-sans-sc-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Codex Text";
  src: url("media/fonts/noto-sans-sc-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}
h1, h2, h3 { font-family: var(--display); font-weight: 700; }
.en { font-family: 'Codex Display', var(--font); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.shell { display: flex; min-height: 100vh; }
.side {
  width: var(--side);
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px 16px 28px;
  background: var(--iw-surface);
  border-right: 1px solid var(--line);
}
.logo { display: block; text-decoration: none; padding: 2px 8px 18px; }
.logo-mark {
  display: inline-block;
  font-family: var(--font);
  font-weight: 700;
  font-size: 42px;
  letter-spacing: 0.24em;
  line-height: 1;
  color: #7a5738;
  text-shadow: 0 1px 0 #fff8ef;
  border-bottom: 4px solid #2a221e;
  padding: 0 0 8px;
}
.logo-top { display: none; padding: 0; flex: none; white-space: nowrap; }
.logo-top .logo-mark { font-size: 26px; letter-spacing: 0.18em; border-bottom-width: 3px; padding-bottom: 2px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--iw-accent-hover); outline-offset: 3px; }
.search {
  position: relative;
  width: min(100%, 360px);
  margin-left: auto;
  color: var(--muted);
}
.search > svg {
  pointer-events: none;
  position: absolute;
  width: 20px;
  height: 20px;
  left: 12px;
  top: 12px;
}
.search input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 44px 8px 40px;
  border: 1px solid var(--iw-control-line);
  border-radius: 8px;
  color: var(--text);
  background: var(--bg-3);
  font-size: 16px;
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input::-webkit-search-cancel-button { display: none; }
.search button {
  position: absolute;
  inset: 0 0 0 auto;
  width: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.search button:not([hidden]) { display: grid; place-items: center; }
.search button svg { width: 20px; height: 20px; }
.search button:hover { background: var(--red-dim); color: var(--text); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label {
  margin: 14px 8px 6px;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--muted);
}
.nav button {
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  color: #5c4638;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.nav button small { color: var(--muted); }
.nav button { min-height: 40px; border-radius: var(--iw-radius); }
.nav button.active, .nav button:hover { background: var(--red-dim); color: var(--iw-accent-hover); }
.nav button.active { font-weight: 700; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.side-note { margin: 18px 8px 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
  background: var(--iw-paper);
}
.menu { display: none; background: transparent; border: 1px solid var(--line); padding: 6px 10px; }
.menu-close { display: none; }
.crumb { margin: 0; color: var(--muted); letter-spacing: 0.08em; font-size: 13px; }
.view { padding: 22px 32px 48px; max-width: 1240px; }
.panel:before, .card:before { content: none; }
.agent-hero {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 0.86fr);
  min-height: 365px;
  margin: -22px -32px 28px;
  background:
    linear-gradient(90deg, rgba(255, 248, 241, 0.94) 0%, rgba(255, 244, 232, 0.82) 48%, rgba(255, 248, 241, 0.55) 100%);
  position: relative;
  overflow: hidden;
}
.agent-hero .still {
  position: absolute;
  inset: 0 0 0 38%;
  width: 62%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  border: 0;
  z-index: 0;
  mask-image: linear-gradient(90deg, transparent, #000 18%);
}
.agent-copy { position: relative; z-index: 1; padding: 28px; align-self: center; max-width: 640px; }
.agent-hero .en { margin: 0; color: #73553a; font-size: 19px; letter-spacing: 0.07em; }
.agent-hero .back { min-height: 44px; }
.agent-hero .lead { max-width: 46ch; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.card {
  position: relative;
  text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 16px;
  min-height: 132px;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--red); }
.portrait-card, .place-card { padding: 0; border: 0; background: #efe4d4; }
.portrait-card { aspect-ratio: 3 / 4; min-height: 0; }
.place-card { aspect-ratio: 16 / 10; min-height: 0; }
.portrait-card .still, .place-card .still {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0; border: 0;
  object-fit: cover;
  object-position: center top;
}
.card-copy { position: relative; }
.portrait-card .card-copy, .place-card .card-copy {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  padding: 48px 12px 12px;
  background: linear-gradient(transparent, rgba(58, 44, 36, 0.82));
}
.portrait-card h3, .place-card h3 {
  margin: 0;
  color: #fff8ef;
  font-family: var(--font);
  font-size: 28px;
  letter-spacing: 0.06em;
  line-height: 1.1;
}
.portrait-card p, .place-card p {
  display: block;
  margin: 2px 0 0;
  font-family: var(--display);
  letter-spacing: 0.14em;
  font-size: 14px;
  color: #f6ecdf;
}
.portrait-card .role, .place-card .role { font-size: 11px; letter-spacing: 0.18em; margin-bottom: 4px; }
.portrait-card .still.official, .agent-hero .still.official {
  object-fit: contain;
  object-position: center bottom;
  background: radial-gradient(circle at 50% 78%, #f3e2c8, #e7d3b8 70%);
}
.agent-hero .still.official { mask-image: none; }
.place-card .still.official { object-fit: contain; object-position: center; background: #f3e7d8; }
.still.banner { display: block; object-fit: cover; }
.weapon-shot { display: block; width: min(100%, 760px); height: auto; margin: 18px 0; background: #f6ecdf; }
.still.banner { height: 380px; width: calc(100% + 64px); margin: 0 -32px 18px; border: 0; object-position: center; }

.codex-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.85fr);
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--iw-surface);
}
.codex-hero-copy { padding: clamp(20px, 4vw, 48px); }
.codex-hero h1, .codex-page-title, .search-heading h1, .agent-hero h1 {
  margin: 0 0 12px;
  font-family: var(--iw-display);
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.2;
}
.agent-copy h1 { margin: 12px 0 2px; }
.codex-hero .lead { max-width: 36ch; }
.codex-roles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.codex-cover { position: relative; overflow: hidden; align-self: stretch; }
.codex-hero .mascot {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 350px;
  min-height: 245px;
  object-fit: cover;
  object-position: center 8%;
}
.codex-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.codex-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid var(--iw-control-line);
  border-radius: 7px;
  background: var(--bg-3);
  color: #573820;
  font-weight: 700;
  text-decoration: none;
}
.codex-action:hover { background: #efe0cb; }
.codex-action.primary { background: var(--iw-accent); border-color: var(--iw-accent); color: var(--iw-on-accent); }
.codex-action.primary:hover { background: var(--iw-accent-hover); }
.search-heading p { overflow-wrap: anywhere; }
.search-empty { padding: 16px 0 28px; }
.search-group h2 { margin-top: 24px; }
.jump-target { scroll-margin-top: 88px; }

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%), var(--bg-2);
  border: 1px solid var(--line);
  padding: 22px;
  position: relative;
}
.kicker { margin: 0 0 8px; color: var(--red); letter-spacing: 0.18em; font-size: 12px; }
h2 { margin: 0 0 10px; font-size: 34px; letter-spacing: 0.04em; }
.lead { margin: 0; color: #6d584c; line-height: 1.7; }
.section-title { margin: 28px 0 12px; font-size: 17px; letter-spacing: 0.03em; color: var(--text); }
.player { margin: 8px 0 20px; background: rgba(255, 250, 244, 0.88); border: 1px solid var(--line); padding: 12px 12px 14px; }
.stage {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  background: #2a221e;
  border: 1px solid var(--line);
  cursor: pointer;
}
.player-bar { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.player-bar button, .player .row button { background: transparent; border: 1px solid var(--line); padding: 7px 12px; }
.player-bar input[type="range"] { flex: 1; min-width: 0; }
.clock { color: var(--muted); font-size: 12px; min-width: 92px; }
.card h3 { margin: 8px 0 6px; font-size: 22px; }
.card p { margin: 0; color: var(--muted); line-height: 1.5; font-size: 13px; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chip {
  border: 1px solid var(--line);
  padding: 3px 8px;
  font-size: 12px;
  color: #5c4638;
  background: rgba(184, 149, 106, 0.16);
}
.soon-chip { color: var(--soon); border-color: rgba(201,166,255,0.4); }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 16px; }
.filters button, .tabs button {
  background: transparent;
  border: 1px solid var(--line);
  padding: 7px 12px;
}
.filters button.on, .tabs button.on { border-color: var(--red); background: var(--red-dim); }

.detail-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-end; }
.detail-head h2 { font-size: 46px; margin: 0; }
.en { margin: 0; color: var(--muted); letter-spacing: 0.22em; }
.back { background: transparent; border: 1px solid var(--line); padding: 8px 12px; }
.skill { display: grid; grid-template-columns: 72px 1fr; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); }
.skill-icon { width: 100%; aspect-ratio: 1; object-fit: contain; background: #664b37; border-radius: 6px; }
.key {
  width: min(100%, 64px); aspect-ratio: 1;
  display: grid; place-items: center;
  background: var(--bg-3);
  border: 1px solid var(--line);
  font-size: 22px;
}
.key small { display: block; font-size: 10px; letter-spacing: 0.12em; color: var(--muted); }
.skill h3 { margin: 0 0 6px; font-size: 20px; }
.skill p { margin: 0 0 8px; line-height: 1.7; color: #5c4638; }
.use { color: var(--muted); }
.scene { margin-top: 14px; padding-top: 8px; }
.scene ol { margin: 8px 0 0; padding-left: 18px; }
.scene li { margin: 8px 0; line-height: 1.65; }
.cols { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 18px; }
.map-wrap { background: rgba(255, 250, 244, 0.9); border: 1px solid var(--line); padding: 12px; }
svg.board { width: 100%; height: auto; display: block; }
.zone { cursor: pointer; }
.zone rect, .zone polygon { fill: #f3e6d4; stroke: rgba(90, 62, 42, 0.28); }
.zone.site rect, .zone.site polygon { fill: rgba(184, 149, 106, 0.45); }
.zone.spawn rect { fill: #e7d8c4; }
.zone.special rect, .zone.special polygon { fill: rgba(42, 34, 30, 0.12); }
.zone text { fill: #3a2c24; font-size: 13px; font-family: var(--font); pointer-events: none; }
.zone.on rect, .zone.on polygon { stroke: #2a221e; stroke-width: 2; fill: rgba(184, 149, 106, 0.62); }
.callout h3 { margin-top: 0; }
.article h3 { margin: 22px 0 8px; font-size: 20px; }
.article p, .article li { line-height: 1.75; color: #5c4638; }
.article ul { padding-left: 18px; }
.warn {
  margin-top: 22px;
  padding: 14px 16px;
  border: 1px solid rgba(240, 180, 41, 0.35);
  background: rgba(240, 180, 41, 0.06);
  color: #6e5134;
  line-height: 1.65;
  font-size: 13px;
}
.empty { color: var(--muted); padding: 40px 0; }

@media (max-width: 980px) {
  .cols, .detail-head { grid-template-columns: 1fr; display: grid; }
  .topbar { padding: 8px 16px; }
  .topbar .crumb { display: none; }
  .menu { min-height: 44px; min-width: 44px; flex: none; padding: 6px 8px; border-radius: 7px; }
  .agent-hero { grid-template-columns: minmax(0, 1fr); min-height: 0; margin: 0 0 20px; border-radius: 12px; }
  .agent-hero .still { position: relative; inset: auto; width: 100%; height: min(58vw, 285px); mask-image: none; }
  .agent-copy { padding: 18px; }
  .still.banner { width: calc(100% + 36px); margin-left: -18px; margin-right: -18px; height: 220px; }
  .side {
    position: fixed; z-index: 10; transform: translateX(-105%);
    visibility: hidden;
  }
  .side.open { transform: none; visibility: visible; box-shadow: var(--shadow); }
  .menu-close {
    display: block;
    min-height: 44px;
    margin: 0 0 12px 8px;
    padding: 6px 12px;
    border: 1px solid var(--iw-control-line);
    border-radius: var(--iw-radius);
    background: var(--iw-paper);
  }
  .nav button { min-height: 44px; }
  .menu { display: inline-block; }
  .logo-top { display: block; }
  .view { padding: 16px; }
  .skill { grid-template-columns: 56px 1fr; }
}

@media (max-width: 560px) {
  .topbar { gap: 8px; padding-inline: 12px; }
  .logo-top .logo-mark { font-size: 20px; letter-spacing: 0.08em; }
  .search { min-width: 0; }
  .search > svg { left: 8px; }
  .search input { padding-left: 31px; padding-right: 6px; }
  .search:has(button:not([hidden])) input { padding-right: 44px; }
  .codex-hero { grid-template-columns: minmax(0, 1fr); }
  .codex-hero .mascot { min-height: 0; height: 142px; object-position: center 8%; }
  .codex-hero-copy { padding: 20px; }
  .codex-hero h1 { font-size: 27px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player-bar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .player-bar input[type="range"] { grid-column: 1 / -1; grid-row: 2; width: 100%; margin: 0; }
  .player-bar .clock { grid-column: 3; grid-row: 1; min-width: 0; white-space: nowrap; }
  .card-copy { overflow-wrap: anywhere; }
  .card:not(.portrait-card, .place-card) { padding: 12px; }
  .portrait-card h3 { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card:hover { transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .codex-cover-reveal .mascot { animation: codex-develop 540ms cubic-bezier(0.22, 1, 0.36, 1) both; }
  .codex-cover-reveal::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(105deg, transparent 24%, rgba(255, 228, 174, 0.5) 48%, transparent 76%);
    animation: codex-paper-light 560ms ease-out both;
  }
  .codex-action { transition: background-color 150ms ease-out, transform 150ms ease-out; }
  .codex-action:active { transform: translateY(1px); }
}
@keyframes codex-develop {
  from { opacity: 0.76; transform: scale(1.045); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes codex-paper-light {
  from { transform: translateX(-105%); }
  to { transform: translateX(105%); }
}
