#game:has(#battle:not([hidden])) {
  width: min(100%, 540px);
  margin-inline: auto;
  box-shadow: 0 0 100px #050a11;
}
.campaign-heading { display: grid; gap: 3px; margin: 0 0 12px; padding-right: 43px; }
.campaign-heading h2 { margin: 0; color: #ffe3b7; font-family: Georgia, serif; }
.campaign-heading > span { color: #d2c2b2; font-size: .83rem; }
#panel:is([data-kind="campaign"],[data-kind="chapter"]) { background: #131a22; }
#panel:is([data-kind="campaign"],[data-kind="chapter"]) #close { position: sticky; top: 0; right: auto; z-index: 4; float: right; }
.world-map {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  clear: both;
  aspect-ratio: 4 / 5;
  border: 1px solid #a28862;
  border-radius: 14px;
  background: #192a33;
  box-shadow: 0 7px 24px #0006, inset 0 0 24px #070b12;
}
.world-map > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.world-map::after { content: ''; position: absolute; inset: 4px; border: 1px solid #fbda9b55; border-radius: 10px; pointer-events: none; }
.map-pin {
  position: absolute;
  z-index: 1;
  left: var(--pin-x);
  top: var(--pin-y);
  transform: translate(-50%,-33%);
  display: grid;
  justify-items: center;
  gap: 2px;
  width: max-content;
  max-width: 39%;
  padding: 2px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #f8e8d2;
  text-align: center;
}
.map-pin[data-active="true"], .map-pin:focus-visible { z-index: 2; }
.map-pin-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--chapter-color);
  background: radial-gradient(#72543d, #18212a 76%);
  box-shadow: 0 3px 11px #020812;
}
.map-pin:is([data-active="true"],:hover,:focus-visible) .map-pin-icon { outline: 2px solid var(--chapter-color); outline-offset: 3px; }
.map-pin[data-status="locked"] .map-pin-icon { filter: saturate(.42); }
.map-pin .menu-icon { --menu-icon-size: 30px; }
.map-pin-label {
  display: grid;
  gap: 2px;
  color: #fff0db;
  padding: 3px 5px;
  border-radius: 6px;
  background: #111923ef;
  border: 1px solid #80694c;
  font-size: clamp(.66rem,2.55vw,.85rem);
  font-weight: 800;
  line-height: 1.12;
}
.map-pin-label small { font-size: .64rem; font-weight: 650; color: #dcc8a9; }
.map-pin[data-status="open"] small,.map-pin[data-status="done"] small { color: var(--chapter-color); }
.world-map-hint { margin: 11px 0 0; text-align: center; font-size: .875rem; }
.chapter-back { min-height: 39px; margin: 0 0 11px; padding: 7px 12px; font-size: .875rem; }
.map-chapter-header {
  clear: both;
  display: grid;
  align-content: end;
  gap: 3px;
  min-height: 84px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--chapter-color) 46%, #352d26);
  border-radius: 11px;
  background: linear-gradient(0deg,#101820f5,#131a2269),var(--chapter-art) center / cover;
}
.map-chapter-header h2 { margin: 0; font: 700 clamp(1.5rem, 6vw, 2.05rem)/1.06 Georgia,serif; color: #fff0da; }
.map-chapter-header span { color: var(--chapter-color); font-size: .85rem; font-weight: 750; }
.map-boss {
  display: grid;
  grid-template-columns: 68px minmax(0,1fr);
  align-items: center;
  gap: 11px;
  min-height: 80px;
  padding: 5px 10px 5px 6px;
  border: 1px solid #55707c;
  border-radius: 10px;
  background: linear-gradient(112deg, #223a44, #19252e 75%);
  text-align: left;
}
.map-boss .hunter-portrait { width: 68px; }
.map-boss-info { display: grid; gap: 3px; line-height: 1.22; }
.map-boss-info small { color: #ffc691; font-size: .72rem; font-weight: 750; }
.map-boss-info strong { color: #fff1dc; font-size: .98rem; }
.map-boss-info > span { color: #cee1e5; font-size: .82rem; }
.chapter-lock { margin: 12px 0 0; color: #ead2ad; font-size: .9rem; }
.chapter-actions .primary:disabled { opacity: .5; cursor: default; }
.chapter-route { margin-top: 12px; }
.route-preview {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: end;
  min-height: clamp(205px, 34dvh, 305px);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--chapter-color) 60%, #312e26);
  border-radius: 13px;
  background: #1b242c;
}
.route-preview > img {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 10%;
}
.route-preview::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(0deg, #090f17 0%, #090f17ed 13%, #090f178c 35%, transparent 64%);
}
.route-preview-info {
  display: flex;
  justify-content: space-between;
  align-items: end;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 12px;
}
.route-preview-copy { flex: 1 1 165px; }
.route-preview-copy small { color: var(--chapter-color); font-size: .75rem; font-weight: 800; }
.route-preview-copy h3 {
  margin: 3px 0;
  color: #fff1db;
  font: 700 clamp(1.2rem, 5vw, 1.65rem)/1.05 Georgia, serif;
}
.route-preview-copy p { margin: 0; color: #ecdfd3; font-size: .78rem; line-height: 1.35; }
.route-preview-info button {
  min-height: 44px;
  padding: 7px 10px;
  border-color: color-mix(in srgb, var(--chapter-color) 55%, #273641);
  background: #101a25ec;
  font-size: .8rem;
  white-space: nowrap;
}
.route-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  row-gap: 8px;
  list-style: none;
  margin: 10px 0 0;
  padding: 7px 1px 8px;
  border-radius: 12px;
  background: radial-gradient(ellipse at top, #25333b, #141e26 80%);
}
.route-step {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  --route-line: #69737b;
}
.route-step[data-status="done"] { --route-line: #81cab6; }
.route-step[data-status="open"] { --route-line: var(--chapter-color); }
.route-step[data-link]::after {
  content: '';
  position: absolute;
  top: calc(50% - 1px);
  width: 100%;
  border-top: 2px dashed var(--route-line);
  pointer-events: none;
}
.route-step[data-link=""]::after { content: none; }
.route-step[data-status="done"]::after { border-style: solid; }
.route-step[data-link="right"]::after { left: 50%; }
.route-step[data-link="left"]::after { right: 50%; }
.route-step[data-link="down"]::after {
  top: 50%;
  left: calc(50% - 1px);
  width: auto;
  height: calc(100% + 8px);
  border-top: 0;
  border-left: 2px dashed var(--route-line);
}
.route-step[data-link="down"][data-status="done"]::after { border-left-style: solid; }
.route-step button {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 4px;
  border: 1px solid #667781;
  border-radius: 50%;
  background: #162029;
  color: #d1d9da;
  font-size: .84rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.route-step[data-status="done"] button { color: #c7ffea; border-color: #81cab6; background: #1e3739; }
.route-step button[aria-current="step"] {
  color: #221708;
  border-color: var(--chapter-color);
  background: var(--chapter-color);
  box-shadow: 0 0 0 3px #141c25, 0 0 0 4px var(--chapter-color), 0 0 16px var(--chapter-color);
}
.route-step button:is([aria-pressed="true"],:focus-visible) {
  outline: 2px solid #fff4e2;
  outline-offset: 2px;
}
.route-boss-marker {
  position: absolute;
  right: -1px;
  top: -1px;
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  border: 1px solid #271828;
  border-radius: 2px;
  background: #ffc1f0;
  box-shadow: 0 0 7px #ff91cb;
}
.stage-roster { margin-top: 15px; }
.stage-roster p { margin: 0 0 12px; color: #c3d5dc; font-size: .9rem; }
.stage-roster h3 { color: #eddbc0; font-size: .9rem; margin: 0 0 7px; }
.stage-roster ul { display: flex; flex-wrap: wrap; gap: 5px; list-style: none; padding: 0; margin: 0; }
.stage-roster ul + h3 { margin-top: 10px; }
.stage-roster li { padding: 4px 7px; background: #233340; color: #edf1ec; border: 1px solid #4c6473; border-radius: 6px; font-size: .78rem; }
.dungeon-plan { margin-bottom: 13px; padding: 7px 10px; border: 1px solid #697b81; border-radius: 9px; background: #17242d; }
.dungeon-plan summary { padding-block: 4px; color: #ffdfaa; font-weight: 750; cursor: pointer; }
.dungeon-plan ol { margin: 6px 0 2px; padding-left: 1.55rem; }
.dungeon-plan li { padding: 7px 1px; border: 0; border-bottom: 1px solid #364650; border-radius: 0; background: transparent; }
.dungeon-plan li:last-child { border-bottom: 0; }
.dungeon-plan li small { display: block; margin-top: 2px; color: #bdd0d4; }

#panel:is([data-kind="briefing"],[data-kind="campaign"],[data-kind="chapter"],[data-kind="cleared"],[data-kind="result"]) {
  width: min(calc(100% - 22px), 520px);
  max-height: min(91dvh, calc(100% - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px));
  padding: clamp(14px, 4vw, 24px);
  overscroll-behavior: contain;
}
#panel[data-kind="briefing"] #close, #panel[data-kind="result"] #close { z-index: 1; }
.chapter-hero {
  display: grid;
  gap: 4px;
  align-content: end;
  min-height: clamp(140px, 26dvh, 224px);
  margin-bottom: 15px;
  padding: clamp(12px, 4vw, 22px);
  border: 1px solid color-mix(in srgb, var(--chapter-color) 58%, #242c34);
  border-radius: 13px;
  background: linear-gradient(0deg, #10151ff0 5%, #111921a0 47%, #10151f0c 91%), var(--chapter-art) center 54% / cover;
}
.chapter-eyebrow {
  color: var(--chapter-color);
  font-size: .73rem;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.chapter-hero h2 { max-width: 100%; margin: 0; color: #fff3df; font-size: clamp(1.7rem, 7vw, 2.8rem); line-height: 1.02; text-wrap: balance; }
.chapter-region { margin-top: 2px; color: #dee5e2; font-size: .84rem; }
.chapter-story { line-height: 1.55; color: #eee7db; text-wrap: pretty; margin: 0 0 14px; }
.chapter-scene { animation: chapter-arrive .42s ease-out both; }
@keyframes chapter-arrive { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.chapter-scene blockquote {
  margin: 0 0 17px;
  padding: 9px 12px;
  border-inline-start: 2px solid #bf976d;
  background: #1c2931;
}
.chapter-scene blockquote p { margin: 0 0 4px; color: #fcebd6; }
.chapter-scene cite { color: #dec5a3; font-size: .82rem; }
.chapter-actions { margin-top: 14px; }
.chapter-actions .primary { width: 100%; }
.chapter-actions .secondary { flex: 1 1 auto; }

.battle-chapter {
  position: absolute;
  inset: 24% 0 auto;
  display: grid;
  justify-items: center;
  pointer-events: none;
  text-align: center;
}
.battle-chapter div {
  display: grid;
  gap: 4px;
  justify-items: center;
  max-width: 95%;
  min-width: 55%;
  padding: 8px 19px 12px;
  color: #fff1dc;
  background: linear-gradient(90deg, transparent, #111923e8 24%, #111923e8 76%, transparent);
  animation: chapter-reveal 2.6s ease-in-out both;
}
.battle-chapter span { color: var(--chapter-color); font-size: .72rem; letter-spacing: .14em; font-weight: 850; text-transform: uppercase; }
.battle-chapter strong { font-size: clamp(1.25rem, 5.5vw, 1.95rem); line-height: 1.08; }
.horde-alert {
  position: absolute;
  top: max(181px, calc(env(safe-area-inset-top) + 169px));
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 8px 11px;
  border: 1px solid #f89a6b;
  border-radius: 9px;
  background: linear-gradient(105deg, #452720, #201a1d);
  box-shadow: 0 5px 20px #150a0acc;
  color: #fff4e2;
  line-height: 1.22;
  z-index: 2;
}
.horde-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #ffb37d;
  color: #331b16;
  font-style: normal;
  font-weight: 950;
}
.horde-alert strong { display: block; font-size: clamp(.86rem, 3.8vw, 1.05rem); }
.miniboss-active .boss-hud { border-color: #79c7beae; background: #122d32f5; color: #c8fff4; }
.miniboss-active .boss-track { background: #203e43; }
.miniboss-active .boss-track i { background: linear-gradient(90deg, #319183, #82e2cf, #d5fff0); }
.hunter-portrait { background-size: var(--hunter-cols, 400%) var(--hunter-rows, 400%), cover; }
.horde-alert span { display: block; margin-top: 3px; color: #ffcca8; font-size: .82rem; }
#horde-countdown { min-width: 2.1em; color: #ffbb89; text-align: right; font-variant-numeric: tabular-nums; }
.challenge-link {
  grid-column: 1 / -1;
  min-height: 46px;
  border-color: #d58c5b74;
  background: linear-gradient(112deg, #42261e, #242a32 68%);
}
.challenge-hero {
  min-height: 140px;
  display: grid;
  align-content: end;
  padding: 18px 16px;
  border: 1px solid #b681574f;
  border-radius: 10px;
  background: linear-gradient(0deg, #18151afc, #17141b22), url('./assets/crown-forge.webp') center 82% / cover;
}
.challenge-hero h2 { margin: 3px 0 0; font-size: clamp(1.45rem, 5.8vw, 2.15rem); }
.challenge-hero span { color: #ffcc9e; font-weight: 800; font-size: .78rem; }
.difficulty-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-block: 14px;
}
.difficulty-tabs button {
  min-height: 44px;
  border-radius: 7px;
  border: 1px solid #667b824d;
  background: #192730;
  font-size: .88rem;
  font-weight: 750;
}
.difficulty-tabs button[aria-pressed="true"] {
  color: var(--tier-color);
  background: #292a30;
  border-color: var(--tier-color);
}
.challenge-options { display: grid; gap: 10px; }
.challenge-options section {
  padding: 12px;
  border: 1px solid #63767f72;
  border-radius: 9px;
  background: #1a242d;
}
.challenge-options h3 { margin: 0; color: var(--tier-color); font-size: 1.01rem; }
.challenge-options p { margin: 4px 0 9px; font-size: .9rem; }
.challenge-options button { width: 100%; padding: 8px 12px; }
.challenge-options button:disabled { opacity: .45; cursor: default; }
.challenge-unlock {
  padding: 9px 12px;
  border: 1px solid #88ddc1a6;
  border-radius: 7px;
  background: #1c3632;
  color: #b8ffe7;
  font-weight: 750;
}
@media (min-width: 440px) {
  .difficulty-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@keyframes chapter-reveal {
  0%, 100% { opacity: 0; }
  12%, 76% { opacity: 1; }
}
@media (max-width: 700px) and (orientation: portrait) {
  .mission-art { height: clamp(225px, 40dvh, 490px); }
  .mission-monster { opacity: .9; }
  .mission-intro h2 { font-size: clamp(2rem, 10vw, 3.4rem); text-wrap: balance; max-width: 92%; }
  .quest-hud { width: max-content; max-width: calc(100% - 24px); }
}
@media (max-width: 480px) {
  .menu-header-actions { gap: 4px; }
  .menu-header #install { min-width: 44px; }
  .menu-header #install span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .chapter-scene, .battle-chapter div { animation: none; }
}

.chapter-tier-lock { margin: -6px 0 9px; font-size: .85rem; }
button[data-campaign-tier]:disabled { opacity: .5; cursor: default; }
