:root {
  color-scheme: dark;
  --bg: #101310;
  --panel: #191d19;
  --line: #353a32;
  --ink: #f2f2e9;
  --muted: #b7beaf;
  --dim: #9ea696;
  --gold: #e8c77d;
  --serif: "Baskervville", Georgia, "Times New Roman", serif;
  --sans: "Inter", "Segoe UI", system-ui, sans-serif;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-size: 1rem; line-height: 1.5; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
a { color: inherit; text-decoration: none; }
a:hover, button:hover:not(:disabled) { color: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
[hidden] { display: none !important; }
h1, h2, h3, p, dl, ul { margin: 0; }
.skip { position: absolute; left: 12px; top: -70px; z-index: 5; padding: 12px; background: var(--panel); }
.skip:focus { top: 10px; }
.top { background: #171a16; border-bottom: 1px solid var(--line); }
.bar, main { width: min(1200px, 100%); margin-inline: auto; padding-inline: clamp(16px, 4.5vw, 56px); }
.bar { min-height: 72px; display: flex; align-items: center; gap: clamp(20px, 5vw, 80px); }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 740; font-size: 1.4rem; letter-spacing: -.055em; white-space: nowrap; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center; background: var(--gold);
  color: #2a261c; font: bold italic 1.7rem/1 Georgia, serif;
  clip-path: polygon(18% 0,100% 0,100% 82%,82% 100%,0 100%,0 18%);
}
nav { align-self: stretch; display: flex; align-items: stretch; gap: clamp(14px, 3vw, 36px); }
nav a, nav button { display: flex; align-items: center; padding: 0 1px; border: 0; border-bottom: 2px solid transparent; background: none; font-size: .925rem; color: var(--muted); }
nav [aria-current="page"] { border-color: var(--gold); color: var(--ink); }
.access, .action, .close { display: inline-flex; justify-content: center; align-items: center; gap: 10px; border: 1px solid #54594c; border-radius: 5px; color: var(--ink); background: transparent; min-height: 44px; padding: .51rem 1.05rem; font-weight: 580; font-size: .9rem; }
.access { margin-left: auto; white-space: nowrap; }
.access:hover, .action:hover:not(:disabled), .close:hover { border-color: var(--gold); }
.lock { width: 11px; height: 9px; border: 1.5px solid currentColor; border-radius: 2px; position: relative; margin-top: 4px; }
.lock::before { content: ""; position: absolute; width: 5px; height: 6px; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 5px 5px 0 0; top: -7px; left: 1px; }
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: clamp(28px, 5vw, 59px) 0 24px; }
.eyebrow { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: .76rem; line-height: 1.5; text-transform: uppercase; letter-spacing: .145em; color: var(--gold); }
.diamond { width: 7px; height: 7px; transform: rotate(45deg); background: var(--gold); }
h1 { font: 400 clamp(2.2rem, 5vw, 4rem)/1.04 var(--serif); letter-spacing: -.059em; margin-top: 8px; text-wrap: balance; }
.connection { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .875rem; margin-bottom: 4px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9b9f94; flex: 0 0 auto; }
.dot[data-tone="good"] { background: #9bc59d; }
.dot[data-tone="warn"] { background: var(--gold); }
.dot[data-tone="bad"] { background: #e79880; }
#notice { border: 1px solid #615638; background: #28261d; color: #f1d89e; border-radius: 6px; padding: .7rem 1rem; margin: 0 0 14px; overflow-wrap: anywhere; }
.character-card {
  border: 1px solid #5c543a; border-radius: 9px; position: relative; isolation: isolate; overflow: hidden;
  background: linear-gradient(110deg,#343124,#302f22 50%,#202419); min-height: 228px;
  display: flex; align-items: center;
}
.cartography { position: absolute; inset: 0 0 0 32%; z-index: -2; opacity: .96; }
.cartography canvas { width: 100%; height: 100%; display: block; }
.character-card::before { content: ""; z-index: -1; pointer-events: none; position: absolute; inset: 0; background: linear-gradient(90deg,#312e22 0%,#312e22f5 28%,#312e2299 47%,transparent 74%); }
.character-info { padding: 30px clamp(20px, 3.6vw, 42px); }
.character-info h2 { font: 400 clamp(2.4rem, 5vw, 4.25rem)/1.13 var(--serif); letter-spacing: -.055em; margin: 6px 0; overflow-wrap: anywhere; }
.character-details { color: #e0dfcd; }
.level-row { display: flex; align-items: center; gap: 12px; margin-top: 18px; color: #d9d9c5; font-size: .875rem; flex-wrap: wrap; }
.level-tag { border: 1px solid #766840; color: var(--gold); padding: .13rem .6rem; border-radius: 3px; }
.map-caption { position: absolute; right: 17px; bottom: 14px; display: inline-flex; align-items: center; gap: 8px; padding: 4px 9px; border-radius: 3px; background: #1c211bdc; color: #e1dfc3; font: .76rem/1.35 ui-monospace, Consolas, monospace; }
.map-cross { width: 7px; height: 7px; border: 1px solid var(--gold); transform: rotate(45deg); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: clamp(18px, 2.5vw, 28px); min-width: 0; }
.controls { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-block: 14px 18px; padding-block: 18px; }
.controls .eyebrow { color: var(--dim); }
.bot-state { display: flex; align-items: center; gap: 8px; font-size: 1.04rem; margin-top: 2px; }
.actions, .dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions { margin-left: auto; }
#control-help { flex-basis: 100%; color: var(--muted); font-size: .875rem; }
.action.start { background: var(--gold); border-color: var(--gold); color: #29251b; }
.action.start:not(:disabled):hover { background: #f3d891; color: #201e17; }
.play-icon { border-left: 9px solid currentColor; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.pause-icon { width: 10px; height: 11px; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }
.stop-icon { width: 9px; height: 9px; background: currentColor; }
.restart-icon { font-size: 1.25rem; line-height: 1; }
.grid { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(0,1fr); gap: 16px; }
.panel-heading, .chart-title, .xp-summary, .chart-axis { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-heading { align-items: baseline; margin-bottom: 19px; flex-wrap: wrap; }
.panel-heading h2 { font: 500 1.55rem/1.2 var(--serif); letter-spacing: -.035em; }
.meta, .sub, .chart-axis, .event-time, .empty { color: var(--muted); }
.meta, .sub, .text-link { font-size: .875rem; }
.text-link { color: var(--gold); text-decoration: underline; text-underline-offset: .2em; }
.xp-summary { align-items: flex-end; }
.align-end { text-align: right; }
.large { font: 450 clamp(2.15rem, 3.5vw, 3.1rem)/1.18 var(--sans); letter-spacing: -.075em; color: #f1d390; font-variant-numeric: tabular-nums; }
.unit { font-size: .55em; margin-left: .13em; }
.measure { font: 550 1.08rem/1.6 var(--sans); }
progress { appearance: none; border: 0; height: 5px; width: 100%; border-radius: 2px; overflow: hidden; background: #35392e; display: block; margin: 12px 0 20px; color: var(--gold); }
progress::-webkit-progress-bar { background: #35392e; }
progress::-webkit-progress-value { background: var(--gold); }
progress::-moz-progress-bar { background: var(--gold); }
.chart-title h3 { font-size: .92rem; }
.chart-wrap { position: relative; height: 87px; margin-top: 10px; background: repeating-linear-gradient(to top,var(--line) 0px,var(--line) 1px,transparent 1px,transparent 28px); }
#xp-chart { width: 100%; height: 100%; display: block; }
#chart-empty { position: absolute; inset: 0; display: grid; place-content: center; font-size: .875rem; color: var(--muted); }
.chart-axis { font-size: .75rem; margin-top: 4px; }
.pair, .resource-pair { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.pair { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.pair strong, .resource-pair strong { font-size: 1.13rem; font-variant-numeric: tabular-nums; }
.levels { margin-top: 12px; color: var(--muted); font-size: .875rem; border-top: 1px solid var(--line); }
.levels summary { cursor: pointer; width: fit-content; padding: 10px 0; color: var(--gold); }
.levels ul { list-style: none; padding: 0 0 5px; }
.levels li { margin-block: 5px; }
.resource-pair { padding-bottom: 13px; }
.resource-pair strong { font-size: 1.55rem; font-weight: 550; }
.indicator { display: inline-block; width: 3px; height: .8em; margin-right: 6px; }
.hp { background: #ce998d; } .mp { background: #93b1c6; }
.data-list > div { display: flex; align-items: center; justify-content: space-between; gap: 13px; padding: 9px 0; border-top: 1px solid var(--line); }
.data-list > div:last-child { padding-bottom: 0; }
.data-list dt { color: var(--muted); font-size: .9rem; }
.data-list dd { margin: 0; font-weight: 550; font-size: .94rem; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
[data-health="true"] { color: #aecdad; } [data-health="false"] { color: #e4ab96; }
.event-list { padding: 0; list-style: none; }
.event-list li { display: grid; grid-template-columns: 60px minmax(0,1fr); column-gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.event-list .empty { display: block; }
.event-time { font: .77rem/1.7 ui-monospace, Consolas, monospace; }
.event-details { min-width: 0; }
.event-type { display: block; color: var(--gold); font-size: .76rem; letter-spacing: .045em; overflow-wrap: anywhere; }
.event-text { font-size: .92rem; overflow-wrap: anywhere; }
footer { display: flex; gap: 12px; justify-content: space-between; align-items: center; margin-top: 30px; padding: 20px 0 max(24px,env(safe-area-inset-bottom)); color: var(--dim); border-top: 1px solid var(--line); font-size: .875rem; }
footer strong { color: var(--muted); }
dialog { background: #1b201a; color: var(--ink); border: 1px solid #5f634f; border-radius: 9px; width: min(430px,calc(100% - 32px)); padding: 24px; max-height: min(88dvh,760px); }
dialog::backdrop { background: #070a07c9; }
dialog h2 { margin: 0; }
dialog .panel-heading { align-items: center; }
dialog label { display: block; margin: 15px 0 5px; font-size: .925rem; }
dialog input { width: 100%; color: var(--ink); border: 1px solid #62674f; background: #111710; border-radius: 4px; padding: 9px; min-height: 44px; }
dialog input:disabled { opacity: .8; }
dialog .sub { margin-top: 6px; }
.close { width: 44px; padding: 0; font-size: 1.45rem; }
.form-note { color: var(--gold); margin: 13px 0; font-size: .9rem; overflow-wrap: anywhere; }
.dialog-actions { margin-top: 20px; }
@media (max-width: 760px) {
  .bar { flex-wrap: wrap; align-items: center; gap: 0; padding-top: 12px; }
  .bar nav { order: 3; flex-basis: 100%; gap: 25px; }
  .bar nav a, .bar nav button { min-height: 44px; }
  .brand { font-size: 1.25rem; }
  .brand-mark { width: 31px; height: 31px; font-size: 1.5rem; }
  .grid { grid-template-columns: 1fr; }
  .controls { gap: 12px; }
  .actions { gap: 6px; }
  .action { padding-inline: 12px; }
}
@media (max-width: 540px) {
  .title-row { align-items: start; flex-direction: column; gap: 10px; margin: 25px 0 14px; }
  .connection { margin: 0; }
  .character-card { min-height: 220px; align-items: flex-start; }
  .character-info { padding: 19px 16px 44px; }
  .cartography { left: 10%; }
  .character-card::before { background: linear-gradient(90deg,#312e22fa,#312e22d4 45%,#312e2230); }
  .map-caption { bottom: 9px; right: 9px; }
  .level-row { margin-top: 12px; }
  .actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); width: 100%; }
  .controls { align-items: start; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
