:root {
  --bg: #1b1712;
  --parchment: #e9dcbc;
  --parchment-2: #d9c79c;
  --ink: #2b2118;
  --ink-soft: #5b4a36;
  --gold: #c9a227;
  --panel: #f3ead2;
  --line: #b9a57a;
  --sea: #9fb3b0;
  --top-h: 56px;
  --tl-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 17px;
  overflow: hidden;
}
button { font: inherit; cursor: pointer; }

/* ---------- top bar ---------- */
.top {
  height: var(--top-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: #241d16;
  border-bottom: 1px solid #3d3226;
  position: relative; z-index: 20;
}
.top h1 {
  font-family: 'Cinzel', serif; font-size: 20px; margin: 0;
  color: var(--gold); white-space: nowrap; letter-spacing: .04em;
}
.top h1 span { color: #cdbb95; font-weight: 500; }
#search {
  flex: 1; min-width: 0; max-width: 360px; margin-left: auto;
  background: #332a20; color: #f0e4c6; border: 1px solid #4d3f2f;
  border-radius: 8px; padding: 8px 12px; font: inherit; font-size: 16px;
}
.search-results {
  position: absolute; top: calc(var(--top-h) - 4px); right: 16px;
  width: min(360px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  max-height: 50vh; overflow: auto; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.search-results button {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  padding: 10px 14px; border-bottom: 1px solid #e0d2ae; color: var(--ink);
}
.search-results button:hover { background: #eadcb7; }
.search-results small { color: var(--ink-soft); }

/* ---------- layout ---------- */
.layout {
  display: flex;
  height: calc(100vh - var(--top-h) - var(--tl-h));
  height: calc(100dvh - var(--top-h) - var(--tl-h));
}
.map-wrap {
  flex: 1; position: relative; overflow: hidden;
  background: radial-gradient(ellipse at center, #a9bcb8 0%, #7f9592 100%);
  touch-action: none;
}
#map { width: 100%; height: 100%; display: block; cursor: grab; user-select: none; }
.sea-label {
  font-family: 'EB Garamond', serif; font-style: italic; font-size: 30px;
  fill: rgba(30,55,60,.45); text-anchor: middle; letter-spacing: .2em; pointer-events: none;
}
.jump {
  position: absolute; left: 12px; bottom: 12px; display: flex; gap: 6px;
}
.jump { flex-wrap: wrap; right: 70px; }
.jump select {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 6px 8px; font-family: 'Cinzel', serif; font-size: 13px;
}
.jump button {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 6px 12px; font-family: 'Cinzel', serif; font-size: 13px;
}
.mh { font-family: 'Cinzel', serif; font-size: 14px; }
#map.dragging { cursor: grabbing; }

.zoom {
  position: absolute; right: 12px; top: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.zoom button {
  width: 38px; height: 38px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: 20px; line-height: 1;
}
.era-banner {
  position: absolute; left: 12px; top: 12px; max-width: min(420px, calc(100% - 80px));
  background: rgba(243,234,210,.94); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; pointer-events: none;
}
.era-banner h2 { font-family: 'Cinzel', serif; font-size: 17px; margin: 0 0 4px; }
.era-banner p { margin: 0; font-size: 15px; line-height: 1.35; color: var(--ink-soft); }
.era-banner .yr { color: #8a6d1c; font-weight: 600; }

/* ---------- svg ---------- */
.land { fill: var(--parchment); stroke: #8c7a55; stroke-width: 2; }
.region { stroke-width: 2; transition: fill .6s, fill-opacity .6s; }
.region-label {
  font-family: 'Cinzel', serif; font-size: 22px; fill: rgba(43,33,24,.45);
  text-anchor: middle; pointer-events: none; letter-spacing: .12em;
}
.wall { stroke: #eef6f8; stroke-width: 10; stroke-linecap: round; }
.wall-edge { stroke: #7d9aa3; stroke-width: 14; stroke-linecap: round; }
.loc { cursor: pointer; outline: none; }
.loc:focus-visible .ring { opacity: 1; }
.loc .dot { stroke: #fff8e6; stroke-width: 3; transition: fill .5s; }
.loc.minor .dot { stroke-dasharray: 3 3; }
.loc .ring { fill: none; stroke: var(--gold); stroke-width: 4; opacity: 0; }
.loc.selected .ring { opacity: 1; }
.loc text {
  font-family: 'Cinzel', serif; font-size: 19px; font-weight: 700;
  fill: var(--ink); paint-order: stroke; stroke: rgba(233,220,188,.95); stroke-width: 5px;
  pointer-events: none;
}
.loc:hover .dot { stroke: var(--gold); }
.evt-badge { fill: #b3262e; stroke: #fff; stroke-width: 2; }
.evt-badge-t { font: 700 12px sans-serif; fill: #fff; text-anchor: middle; pointer-events: none; }
.changed .dot { animation: pulse 1.2s ease-out 1; }
@keyframes pulse { 0% { r: 11; } 40% { r: 20; } 100% { r: 11; } }

/* ---------- panel ---------- */
.panel {
  width: 400px; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.handle { display: none; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; border: 0; background: none; padding: 12px 8px;
  font-family: 'Cinzel', serif; font-size: 14px; color: var(--ink-soft);
  border-bottom: 3px solid transparent;
}
.tabs button.active { color: var(--ink); border-bottom-color: var(--gold); }
.panel-body { overflow: auto; padding: 16px 18px 28px; flex: 1; }
.panel-body h2 { font-family: 'Cinzel', serif; margin: 0; font-size: 22px; }
.panel-body h3 {
  font-family: 'Cinzel', serif; font-size: 14px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-soft); margin: 22px 0 8px;
  border-bottom: 1px solid #ddcda3; padding-bottom: 4px;
}
.en { color: var(--ink-soft); font-style: italic; }
.walk3d {
  display: block; width: 100%; margin: 4px 0 6px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid #a8841c; background: linear-gradient(180deg, #d9b23a, #b8901f); color: #1f170b;
  font-family: 'Cinzel', serif; font-size: 16px; font-weight: 700; letter-spacing: .03em;
  box-shadow: 0 3px 10px rgba(80,60,10,.25);
}
.walk3d:hover { filter: brightness(1.06); }
.muted { color: var(--ink-soft); }
.ruler-now {
  margin-top: 14px; padding: 12px 14px; border-radius: 10px;
  background: #fffaf0; border-left: 6px solid var(--c, #999);
}
.ruler-now .who { font-size: 19px; font-weight: 600; }
.ruler-now .hs { font-family: 'Cinzel', serif; font-size: 13px; color: var(--ink-soft); }
.history { list-style: none; margin: 0; padding: 0; }
.history li {
  display: grid; grid-template-columns: 14px 1fr; gap: 10px;
  padding: 8px 0; border-bottom: 1px dashed #dccb9f; cursor: pointer;
}
.history li.cur { background: #efe1bb; border-radius: 6px; padding-left: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 50%; margin-top: 4px; border: 1px solid rgba(0,0,0,.2); }
.history .era-n { font-family: 'Cinzel', serif; font-size: 13px; color: var(--ink-soft); }
.event {
  background: #fffaf0; border: 1px solid #e3d4ac; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px;
}
.event.other { opacity: .6; }
.event .yr { font-size: 13px; color: #8a6d1c; font-weight: 600; }
.event h4 { margin: 2px 0 4px; font-size: 18px; }
.event p { margin: 0 0 6px; line-height: 1.4; }
.event .where { font-size: 14px; color: var(--ink-soft); cursor: pointer; text-decoration: underline dotted; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid #d5c294; background: #f8f0db; border-radius: 999px;
  padding: 2px 10px; font-size: 14px; color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .swatch { width: 9px; height: 9px; margin: 0; }
.house-card {
  display: grid; grid-template-columns: 22px 1fr; gap: 10px;
  padding: 10px 0; border-bottom: 1px dashed #dccb9f;
}
.house-card .swatch { width: 22px; height: 22px; margin: 0; }
.house-card .words { font-style: italic; color: var(--ink-soft); }
.house-card .holds { font-size: 14px; margin-top: 4px; }

/* ---------- timeline ---------- */
.timeline {
  height: var(--tl-h); display: flex; align-items: center; gap: 10px;
  padding: 0 12px; background: #241d16; border-top: 1px solid #3d3226;
}
#play {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  border: 1px solid var(--gold); background: none; color: var(--gold); font-size: 16px;
}
.eras { flex: 1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.eras::-webkit-scrollbar { display: none; }
.eras button {
  flex: 1 0 auto; min-width: 110px; border: 1px solid #4d3f2f; background: #2f271e;
  color: #d8c8a2; border-radius: 8px; padding: 6px 10px; text-align: left; line-height: 1.15;
}
.eras button b { display: block; font-family: 'Cinzel', serif; font-size: 13px; }
.eras button small { font-size: 12px; opacity: .8; }
.eras button.active { background: var(--gold); color: #1f180f; border-color: var(--gold); }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--panel); border-radius: 14px; max-width: 460px; width: 100%;
  padding: 20px 22px; position: relative; max-height: 85vh; overflow: auto;
}
.modal-card .close {
  position: absolute; right: 10px; top: 6px; border: 0; background: none;
  font-size: 28px; color: var(--ink-soft);
}
.link { color: #6e1414; cursor: pointer; text-decoration: underline dotted; background: none; border: 0; padding: 0; }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  :root { --top-h: 52px; --tl-h: 60px; }
  .top h1 { font-size: 16px; }
  .top h1 span { display: none; }
  .layout { display: block; position: relative; }
  .map-wrap { height: 100%; }
  .era-banner { max-width: calc(100% - 70px); padding: 8px 10px; }
  .era-banner p { display: none; }
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0;
    width: auto; height: 46%; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0; box-shadow: 0 -8px 24px rgba(0,0,0,.35);
    transition: height .25s;
  }
  .panel.collapsed { height: 92px; }
  .jump { bottom: auto; top: 56px; }
  .panel.expanded { height: 86%; }
  .handle {
    display: block; width: 48px; height: 5px; border-radius: 3px;
    background: #bfae86; margin: 8px auto 2px; cursor: pointer;
  }
  .eras button { min-width: 96px; }
}


/* ---------- map styles ---------- */
/* shared defaults (parchment atlas) */
.coast { fill: #ecdfbf; stroke: #6f5d3c; stroke-width: 3; stroke-linejoin: round; }
.coast-glow { fill: none; stroke: rgba(80,110,115,.35); stroke-width: 18; stroke-linejoin: round; }
.river { fill: none; stroke: #6f97a3; stroke-width: 4; stroke-linecap: round; }
.road-case { fill: none; stroke: none; }
.road { fill: none; stroke: #8a6d3e; stroke-width: 2.5; stroke-dasharray: 2 7; stroke-linecap: round; }
.road.main { stroke-width: 3.5; }
.mtn { fill: #cdbb93; stroke: #6f5d3c; stroke-width: 2; stroke-linejoin: round; }
.mtn-shade { fill: #9d8a63; }
.mtn-snow { fill: #fbf7ec; }
.relief { fill: #a58658; opacity: .55; }
.tree { fill: #6f8a57; stroke: #46593a; stroke-width: 1.2; }
.trunk { stroke: #5b4630; stroke-width: 1.4; }
.forest-blob { fill: #3f7a3a; }
.biome { opacity: .9; }
.b-snow { fill: #f7f9fb; } .b-tundra { fill: #dfe6dc; } .b-swamp { fill: #8f9e6a; }
.b-steppe { fill: #d8d08c; } .b-desert { fill: #e3c98f; } .b-ash { fill: #8b7468; } .b-jungle { fill: #4e8b47; }
.terrain-label { font-family: 'EB Garamond', serif; font-style: italic; font-size: 17px; fill: rgba(60,45,25,.75); text-anchor: middle; pointer-events: none; }
.sea-label.small { font-size: 18px; letter-spacing: .08em; }
.cell { stroke: rgba(70,50,30,.45); stroke-width: 2; stroke-dasharray: 6 5; transition: fill .6s, stroke .6s; }
.cell.border { stroke-width: 3.5; stroke-dasharray: none; stroke-opacity: .9; }
.cell.solid { stroke: #fff; stroke-width: 3; stroke-dasharray: none; }
.cell.faint { stroke: rgba(120,120,120,.5); stroke-width: 1.5; }
.cell.soft { stroke: rgba(150,80,60,.45); stroke-width: 2; }
.hexcell { stroke: #2a2620; stroke-width: 2; transition: fill .6s; }
.house-label { font-family: 'Cinzel', serif; font-size: 15px; font-weight: 700; text-anchor: middle; fill: rgba(30,22,15,.75); pointer-events: none; letter-spacing: .08em; }
.compass-ring { fill: none; stroke: #6f5d3c; stroke-width: 2; opacity: .6; }
.compass-star { fill: #e9dcbc; stroke: #6f5d3c; stroke-width: 1.5; }
.compass-star2 { fill: #6f5d3c; }
.compass text { font-family: 'Cinzel', serif; font-size: 22px; fill: #6f5d3c; text-anchor: middle; }

/* towns */
.tw { fill: #fffaf0; stroke: #3a2c1e; stroke-width: 1.6; }
.tw-city { fill: #3a2c1e; }
.tw-castle { fill: #6b4e33; stroke: #2b1f14; stroke-width: 1; }
.tw-ruin { fill: none; stroke: #6b5a46; }
.tw-x { stroke: #6b5a46; stroke-width: 1.4; }
.town text { font-family: 'EB Garamond', serif; font-size: 15px; fill: #3a2c1e; paint-order: stroke; stroke: rgba(240,230,205,.9); stroke-width: 3px; pointer-events: none; }
#map.far .town text, #map.far .terrain-label, #map.far .sea-label.small { display: none; }
#map.far .town { opacity: .7; }
#map.mid .town text { font-size: 17px; }

/* pictorial */
.wave { fill: none; stroke: #ffffff; stroke-width: 2.4; stroke-linecap: round; opacity: .55; }
.hull { fill: #8a4b2a; stroke: #3d1f10; stroke-width: 1.5; }
.mast { stroke: #3d1f10; stroke-width: 2; }
.sail { fill: #fff8e8; stroke: #3d1f10; stroke-width: 1.2; }
.serpent-body { fill: none; stroke: #2f7d68; stroke-width: 9; stroke-linecap: round; }
.serpent-eye { fill: #fff; }
.castle-wall, .castle-tower { fill: #e46b4a; stroke: #6d2614; stroke-width: 1.4; }
.castle-tower { fill: #f08a63; }
.castle-flag { fill: #c9a227; stroke: #6d2614; stroke-width: 1.2; }
.castle-gate { fill: #6d2614; }

/* ---- per style ---- */
.map-wrap.s-atlas { background: radial-gradient(ellipse at center, #b4c6c1 0%, #8aa09c 100%); }

.map-wrap.s-terrain { background: linear-gradient(180deg, #a9c7df 0%, #8fb4d4 100%); }
.s-terrain .coast { fill: #cfe3b0; stroke: #5d7f8f; stroke-width: 2; }
.s-terrain .coast-glow { stroke: rgba(255,255,255,.45); stroke-width: 10; }
.s-terrain .river { stroke: #4f86b8; stroke-width: 3.5; }
.s-terrain .road { stroke: #9a5b2e; stroke-dasharray: 5 5; stroke-width: 2; }
.s-terrain .mtn { fill: #b07f4f; stroke: #5c3d22; }
.s-terrain .mtn-shade { fill: #7d5532; }
.s-terrain .sea-label { fill: rgba(30,70,110,.55); }
.s-terrain .region-label { fill: rgba(40,40,30,.6); }

.map-wrap.s-political { background: #b9d3e6; }
.s-political .coast { fill: #f4f1e8; stroke: #6f8ea3; stroke-width: 2.5; }
.s-political .river { stroke: #6aa0cf; stroke-width: 2.5; opacity: .8; }
.s-political .region-label { fill: rgba(20,15,10,.8); font-size: 24px; font-weight: 700; paint-order: stroke; stroke: rgba(255,255,255,.55); stroke-width: 4px; }
.s-political .house-label { fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.55); stroke-width: 4px; font-size: 16px; }
.s-political .sea-label { fill: rgba(40,80,120,.55); }
.s-political .tw { fill: #fff; stroke: #222; }

.map-wrap.s-pictorial { background: #1fb3d2; }
.s-pictorial .coast { fill: #f7c9a8; stroke: #7a3b22; stroke-width: 3; }
.s-pictorial .coast-glow { stroke: rgba(255,255,255,.55); stroke-width: 14; }
.s-pictorial .river { stroke: #1fb3d2; stroke-width: 5; }
.s-pictorial .tree { fill: #3c9a5f; stroke: #1f5a36; }
.s-pictorial .mtn { fill: #e9b38d; stroke: #7a3b22; }
.s-pictorial .mtn-shade { fill: #c98761; }
.s-pictorial .sea-label { fill: rgba(255,255,255,.75); }
.s-pictorial .region-label { fill: rgba(122,59,34,.8); }
.s-pictorial .terrain-label { fill: rgba(122,59,34,.75); }
.s-pictorial .compass-ring { stroke: #fff; } .s-pictorial .compass-star { fill: #e46b4a; stroke: #fff; }
.s-pictorial .compass-star2 { fill: #fff; } .s-pictorial .compass text { fill: #fff; }
.s-pictorial .loc .dot { stroke-width: 2.5; }

.map-wrap.s-roads { background: #c3d8ea; }
.s-roads .coast { fill: #f1f2ee; stroke: #9db4c7; stroke-width: 2; }
.s-roads .forest-blob { fill: #cfe0c2; }
.s-roads .river { stroke: #8eb6d8; stroke-width: 3; }
.s-roads .road-case { stroke: #b8722b; stroke-width: 7; stroke-linecap: round; }
.s-roads .road-case.main { stroke-width: 9; }
.s-roads .road { stroke: #f2b84b; stroke-width: 4.5; stroke-dasharray: none; }
.s-roads .road.main { stroke: #f5a623; stroke-width: 6; }
.s-roads .town text, .s-roads .region-label, .s-roads .sea-label, .s-roads .loc text {
  font-family: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-style: normal; }
.s-roads .region-label { fill: rgba(60,60,60,.65); font-weight: 700; }
.s-roads .sea-label { fill: rgba(70,110,150,.6); letter-spacing: .05em; }
.s-roads .tw { fill: #fff; stroke: #444; } .s-roads .tw-city { fill: #444; } .s-roads .tw-castle { fill: #7d6b8c; stroke: #333; }
.s-roads .town text { fill: #333; stroke: rgba(255,255,255,.9); }

.map-wrap.s-hex { background: #2a2620; }
.s-hex .region-label { fill: rgba(255,245,220,.75); stroke: rgba(30,25,20,.6); stroke-width: 4px; paint-order: stroke; }
.s-hex .house-label { fill: rgba(255,235,190,.85); paint-order: stroke; stroke: rgba(30,25,20,.7); stroke-width: 4px; }
.s-hex .sea-label { fill: rgba(220,200,160,.35); }
.s-hex .loc text { fill: #fff6df; stroke: rgba(30,25,20,.95); }

.map-wrap.s-night { background: radial-gradient(ellipse at center, #13212d 0%, #070d13 100%); }
.s-night .coast { fill: #1b2734; stroke: #8fc3d6; stroke-width: 2.5; }
.s-night .coast-glow { stroke: rgba(120,190,215,.18); stroke-width: 26; }
.s-night .river { stroke: #4f8fb0; }
.s-night .road { stroke: #c9a227; opacity: .6; }
.s-night .mtn { fill: #2c3a48; stroke: #8fb3c6; }
.s-night .mtn-shade { fill: #1d2833; }
.s-night .mtn-snow { fill: #cfe6f2; }
.s-night .tree { fill: #24402f; stroke: #5f9070; }
.s-night .cell { stroke: rgba(170,215,230,.35); }
.s-night .terrain-label { fill: rgba(170,200,215,.6); }
.s-night .sea-label { fill: rgba(140,190,215,.35); }
.s-night .region-label { fill: rgba(220,235,245,.55); }
.s-night .loc text, .s-night .town text { fill: #eef4f8; stroke: rgba(10,20,30,.9); }
.s-night .tw { fill: #13212d; stroke: #8fc3d6; } .s-night .tw-city { fill: #8fc3d6; }
.s-night .compass-ring, .s-night .compass-star { stroke: #8fc3d6; } .s-night .compass-star { fill: #13212d; }
.s-night .compass-star2 { fill: #8fc3d6; } .s-night .compass text { fill: #8fc3d6; }
.s-night .wall { stroke: #dff6ff; } .s-night .wall-edge { stroke: #5fa8c4; }

@media (max-width: 820px) {
  .jump { right: auto; max-width: calc(100% - 70px); }
  .jump select { font-size: 12px; }
}

/* user map image styles */
.s-img-world .region, .s-img-westeros .region { display: none; }
.img-missing { fill: #f3e3b8; font: 600 44px Georgia, serif; }
.img-missing.small { font-size: 26px; fill: #d9c9a0; }
.s-img-world .loc text, .s-img-westeros .loc text { paint-order: stroke; stroke: rgba(10,16,24,.85); stroke-width: 5px; fill: #fff6dc; }

/* ---------------------------------------------------------------- family trees */
.tree-btn { margin-top: 8px; background: #2d2418; color: #f3e3b8; border: 1px solid #c9a227; border-radius: 8px; padding: 5px 10px; font: 600 13px Georgia, serif; cursor: pointer; }
.tree-btn:hover { background: #3a2f1e; }
#tree { position: fixed; inset: 0; z-index: 60; background: #14110d; color: #f3e3b8; display: none; flex-direction: column; font-family: Georgia, serif; }
#tree.open { display: flex; }
#tree header { display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: linear-gradient(#2a2117, #1b1510); border-bottom: 1px solid #5a4a2a; flex-wrap: wrap; }
#tree .t-title { display: flex; align-items: center; gap: 10px; }
#tree .t-title h2 { margin: 0; font: 600 20px Cinzel, Georgia, serif; color: #e9c766; }
#tree .t-houses { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
#tree .t-houses button { background: #221b14; color: #e8dcc0; border: 1px solid var(--c, #8a7a5a); border-left: 6px solid var(--c, #8a7a5a); border-radius: 6px; padding: 4px 9px; font: 13px Georgia, serif; cursor: pointer; }
#tree .t-houses button.on { background: var(--c); color: #fff; text-shadow: 0 1px 2px #000; }
#tree .t-close { background: none; border: 1px solid #5a4a2a; color: #f3e3b8; border-radius: 8px; width: 36px; height: 36px; font-size: 18px; cursor: pointer; }
#tree .t-body { flex: 1; display: grid; grid-template-columns: 1fr 340px; min-height: 0; }
#tree .t-canvas { position: relative; background: radial-gradient(ellipse at 50% 30%, #262019, #120f0b 70%); }
#tree svg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#tree svg:active { cursor: grabbing; }
#tree .t-help { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: #9a8a6a; pointer-events: none; }
#tree .t-zoom { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; }
#tree .t-zoom button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid #5a4a2a; background: #221b14; color: #f3e3b8; font-size: 18px; cursor: pointer; }
#tree .t-card { background: #1d1711; border-left: 1px solid #5a4a2a; padding: 14px 16px; overflow: auto; }
#tree .t-card h3 { margin: 10px 0 2px; font: 600 20px Cinzel, Georgia, serif; color: #e9c766; }
#tree .t-card .t-tl { margin: 0 0 4px; color: #d9c9a0; font-style: italic; }
#tree .t-card .muted { color: #9a8a6a; font-size: 13px; }
#tree .t-card .t-bio { line-height: 1.5; font-size: 14px; }
#tree .t-portrait { width: 100%; max-width: 220px; border-radius: 10px; border: 1px solid #5a4a2a; display: block; }
#tree .t-rel { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#tree .t-rel b { width: 100%; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: #c9a227; }
#tree .t-link { background: #2a2219; border: 1px solid #5a4a2a; color: #f3e3b8; border-radius: 6px; padding: 3px 8px; font: 13px Georgia, serif; cursor: pointer; }
#tree .t-link small { color: #9a8a6a; }
#tree .t-link:hover { border-color: #c9a227; }
#tree .t-open { display: block; margin-top: 12px; width: 100%; background: #2d2418; color: #f3e3b8; border: 1px solid #c9a227; border-radius: 8px; padding: 7px 10px; font: 600 13px Georgia, serif; cursor: pointer; text-align: left; }
#tree .t-node { cursor: pointer; }
#tree .t-box { stroke: rgba(255,255,255,.25); stroke-width: 1; }
#tree .t-node.inlaw .t-box { opacity: .55; stroke-dasharray: 4 3; }
#tree .t-node.sel .t-box { stroke: #ffe28a; stroke-width: 3; filter: drop-shadow(0 0 8px #e9c766); }
#tree .t-node:hover .t-box { stroke: #fff; stroke-width: 2; }
#tree .t-name { fill: #fff; font: 600 13px Georgia, serif; paint-order: stroke; stroke: rgba(0,0,0,.6); stroke-width: 3px; pointer-events: none; }
#tree .t-dates { fill: #f3e3b8; font: 11px Georgia, serif; paint-order: stroke; stroke: rgba(0,0,0,.6); stroke-width: 3px; pointer-events: none; }
#tree .t-inlaw { fill: #ffe28a; font: italic 10px Georgia, serif; pointer-events: none; }
#tree .t-skull { fill: #fff; font: 12px Georgia, serif; opacity: .8; pointer-events: none; }
#tree .t-marr { stroke: #e9c766; stroke-width: 2.5; }
#tree .t-marr.dashed { stroke-dasharray: 6 5; stroke: #c9a227; }
#tree .t-ring { fill: #14110d; stroke: #e9c766; stroke-width: 2; }
#tree .t-desc { stroke: #a08a5a; stroke-width: 1.8; fill: none; }
#tree .t-note { fill: #d9c9a0; font: italic 10px Georgia, serif; }
body.tree-open { overflow: hidden; }
@media (max-width: 800px) { #tree .t-body { grid-template-columns: 1fr; grid-template-rows: 1fr 42%; } #tree .t-card { border-left: 0; border-top: 1px solid #5a4a2a; } #tree .t-title h2 { font-size: 16px; } }
#tree .t-marr.far { fill: none; stroke-width: 1.6; opacity: .8; }
#tree .t-desc.dashed { stroke-dasharray: 5 4; }

/* ---------------------------------------------------------------- wars */
.war-layer { pointer-events: none; }
.war-trail { fill: none; stroke-width: 3; stroke-dasharray: 7 5; stroke-linecap: round; opacity: .8; }
.war-trail.live { stroke-dasharray: none; stroke-width: 3.5; opacity: .95; }
.war-arrow { opacity: .9; }
.war-token .war-ring { fill: rgba(255,255,255,.35); stroke-width: 3; }
.war-token .war-dot { stroke: #fff8e8; stroke-width: 2; }
.war-token.marching .war-ring { animation: war-march .5s linear infinite; }
@keyframes war-march { from { stroke-dasharray: 6 4; stroke-dashoffset: 0 } to { stroke-dasharray: 6 4; stroke-dashoffset: -10 } }
.war-token.dead { opacity: .55; }
.war-token .war-x { stroke: #fff; stroke-width: 3; }
.war-label { font: 600 14px/1 'EB Garamond', serif; fill: #2b2118; paint-order: stroke; stroke: rgba(255,250,235,.9); stroke-width: 4; }
.s-night .war-label { fill: #f4ecd8; stroke: rgba(10,14,20,.9); }
.war-dragon { fill: #c0392b; stroke: #3a0d0d; stroke-width: .8; }
.war-dragon.win { fill: #ff8a2a; }
.war-battle .war-bg { stroke-width: 3; }
.war-battle .war-swords { fill: none; stroke-width: 2.4; stroke-linecap: round; }
.war-battle .war-fire { opacity: .35; animation: war-fire 1.6s ease-in-out infinite alternate; }
@keyframes war-fire { from { transform: scale(1); opacity: .25 } to { transform: scale(1.35); opacity: .5 } }
.war-pulse, .war-fire { transform-box: fill-box; transform-origin: center; }
.war-pulse { fill: none; stroke-width: 3; animation: war-pulse 1.4s ease-out 3; opacity: 0; }
.war-pulse.d2 { animation-delay: .45s; }
@keyframes war-pulse { 0% { transform: scale(1); opacity: 1 } 100% { transform: scale(5); opacity: 0 } }
.war-bname { font: 700 13px 'Cinzel', serif; fill: #2b2118; text-anchor: middle; paint-order: stroke; stroke: rgba(255,250,235,.92); stroke-width: 4; }
.war-bwin { font: 600 12px 'EB Garamond', serif; text-anchor: middle; paint-order: stroke; stroke: rgba(255,250,235,.92); stroke-width: 4; }
.s-night .war-bname, .s-night .war-bwin { stroke: rgba(10,14,20,.9); } .s-night .war-bname { fill: #f4ecd8; }
svg.far .war-label, svg.far .war-bwin { display: none; }
.war-caption { position: absolute; left: 12px; right: 12px; bottom: 12px; max-width: 520px; margin: 0 auto; background: rgba(28,22,16,.88); color: #f3ead6; border: 1px solid rgba(214,180,100,.5); border-radius: 10px; padding: 10px 14px; font-family: 'EB Garamond', serif; box-shadow: 0 6px 24px rgba(0,0,0,.35); pointer-events: none; z-index: 5; }
.war-caption small { display: block; color: #d6b464; font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: .06em; }
.war-caption b { display: block; font-family: 'Cinzel', serif; font-size: 16px; margin: 2px 0 4px; }
.war-caption p { margin: 0; font-size: 14px; line-height: 1.35; }
.war-caption em { display: block; margin-top: 6px; color: #ffb37a; font-style: normal; font-size: 13px; }
.wars h2 { font-family: 'Cinzel', serif; margin: 0 0 6px; }
.wars .muted { opacity: .75; font-size: 14px; margin: 0 0 8px; }
.wars select { width: 100%; padding: 6px 8px; font: inherit; margin-bottom: 8px; }
.wars .war-sum { font-size: 14px; line-height: 1.4; margin: 0 0 8px; }
.war-ctl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.war-ctl button { font: inherit; padding: 5px 9px; border-radius: 6px; border: 1px solid rgba(120,100,70,.4); background: rgba(255,255,255,.5); cursor: pointer; }
.war-ctl button.play { font-weight: 600; background: #d6b464; border-color: #a9853e; }
.war-ctl select { width: auto; margin: 0; padding: 4px 6px; }
.war-ctl label { font-size: 13px; display: flex; align-items: center; gap: 4px; }
.war-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; margin-bottom: 8px; }
.war-legend span { display: inline-flex; align-items: center; gap: 5px; } .war-legend span.dead { text-decoration: line-through; opacity: .6; }
.war-legend i { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0,0,0,.3); display: inline-block; }
.war-steps { list-style: none; padding: 0; margin: 0 0 10px; border-left: 2px solid rgba(120,100,70,.35); }
.war-steps li { position: relative; padding: 5px 8px 5px 16px; cursor: pointer; border-radius: 0 6px 6px 0; }
.war-steps li::before { content: ''; position: absolute; left: -6px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: #c9bb98; border: 2px solid #fff; }
.war-steps li.done::before { background: #7a6a4a; } .war-steps li.cur::before { background: #c0392b; box-shadow: 0 0 0 4px rgba(192,57,43,.25); }
.war-steps li.cur { background: rgba(214,180,100,.18); }
.war-steps li small { display: block; font-size: 11px; opacity: .7; font-family: 'Cinzel', serif; }
.war-steps li b { font-size: 14px; } .war-steps li .bt { display: block; font-size: 12px; color: #8a2a1a; }
.war-steps li p { margin: 4px 0 0; font-size: 13px; line-height: 1.35; }
.wars button.ghost { font: inherit; background: none; border: 1px solid rgba(120,100,70,.4); border-radius: 6px; padding: 5px 9px; cursor: pointer; }
@media (max-width: 760px) { .war-caption { bottom: auto; top: 70px; font-size: 13px; } .war-caption p { display: none; } }

/* ------------------------------------------------------------- SEO shell */
.index-links { display: flex; gap: 10px; margin-left: 14px; font-family: 'Cinzel', serif; font-size: 12px; letter-spacing: .04em; }
.index-links a { color: #d6b464; text-decoration: none; opacity: .85; } .index-links a:hover { opacity: 1; text-decoration: underline; }
@media (max-width: 760px) { .index-links { display: none; } }
.noscript-index { max-width: 900px; margin: 20px auto; padding: 16px; background: #f6efdc; color: #2b2118; font-family: 'EB Garamond', serif; }
.noscript-index a { color: #7a3a1a; }

/* ---- the Dragon Hall ---- */
#dragons { position: fixed; inset: 0; z-index: 60; background: #14110d; color: #f3e3b8; display: none; flex-direction: column; font-family: Georgia, serif; }
#dragons.open { display: flex; }
#dragons header { display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: linear-gradient(#2a2117, #1b1510); border-bottom: 1px solid #5a4a2a; }
#dragons .d-title { display: flex; align-items: center; gap: 10px; flex: 1; flex-wrap: wrap; }
#dragons .d-title h2 { margin: 0; font: 600 20px Cinzel, Georgia, serif; color: #e9c766; }
#dragons .d-sub { color: #b9a98a; font-size: 13px; }
#dragons .d-icon { font-size: 22px; }
#dragons .d-close { background: #221b14; color: #e8dcc0; border: 1px solid #8a7a5a; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
#dragons .d-body { display: flex; flex: 1; min-height: 0; }
#dragons .d-list { width: 210px; overflow: auto; background: #1b1510; border-right: 1px solid #3a2f1e; }
#dragons .d-list-head { padding: 8px 12px; font: 600 12px Cinzel, serif; color: #c9a227; letter-spacing: .06em; border-bottom: 1px solid #3a2f1e; }
#dragons .d-list ul { list-style: none; margin: 0; padding: 4px 0; }
#dragons .d-list li { display: flex; align-items: center; gap: 8px; padding: 5px 12px; cursor: pointer; font-size: 14px; }
#dragons .d-list li:hover { background: #2a2117; }
#dragons .d-list li.cur { background: #3a2c18; color: #ffe9a8; }
#dragons .d-list li i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid; flex: none; }
#dragons .d-list li span { flex: 1; }
#dragons .d-list li small { color: #9a8a6a; }
#dragons .d-canvas { flex: 1; position: relative; min-width: 0; }
#dragons .d-canvas canvas { width: 100%; height: 100%; display: block; }
#dragons .d-help { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: #b9a98a; background: rgba(20,16,10,.6); padding: 4px 8px; border-radius: 6px; pointer-events: none; }
#dragons .d-ctl { position: absolute; right: 12px; top: 10px; display: flex; gap: 6px; }
#dragons .d-ctl button { background: #221b14; color: #e8dcc0; border: 1px solid #8a7a5a; border-radius: 6px; padding: 5px 10px; font: 13px Georgia, serif; cursor: pointer; }
#dragons .d-card { width: 320px; overflow: auto; background: #1b1510; border-left: 1px solid #3a2f1e; padding: 14px 16px; font-size: 14px; line-height: 1.45; }
#dragons .d-card .d-empty { color: #9a8a6a; font-style: italic; }
#dragons .d-card .d-swatch { height: 8px; border-radius: 4px; margin-bottom: 8px; }
#dragons .d-card h3 { margin: 0; font: 600 22px Cinzel, serif; color: #e9c766; }
#dragons .d-card .d-epi { color: #b9a98a; font-style: italic; margin-bottom: 8px; }
#dragons .d-card h4 { margin: 12px 0 4px; font: 600 12px Cinzel, serif; color: #c9a227; letter-spacing: .06em; }
#dragons .d-card dl { margin: 8px 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
#dragons .d-card dt { color: #9a8a6a; }
#dragons .d-card dd { margin: 0; }
#dragons .d-card p { margin: 0 0 6px; }
#dragons .d-riders { margin: 0; padding-left: 18px; }
#dragons .d-cmp { margin-top: 12px; }
#dragons .d-bar { height: 10px; background: #2a2117; border-radius: 5px; overflow: hidden; border: 1px solid #3a2f1e; }
#dragons .d-bar i { display: block; height: 100%; background: linear-gradient(90deg, #8a1c22, #e9c766); }
#dragons .d-cmp small { color: #9a8a6a; }
.d-mini { list-style: none; padding: 0; margin: 12px 0 0; }
.d-mini li { display: flex; gap: 8px; align-items: flex-start; padding: 6px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.d-mini li:hover { background: rgba(201,162,39,.08); }
.d-mini li i { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1px solid #8a7a5a; margin-top: 4px; }
.d-mini li small { display: inline; }
.d-mini li em { color: #8a7a5a; font-size: 13px; }
.d-mini li small { color: #7a6a4a; }
@media (max-width: 900px) { #dragons .d-list { width: 140px; } #dragons .d-list li small { display: none; } #dragons .d-card { width: 240px; } }
@media (max-width: 640px) { #dragons .d-body { flex-direction: column; } #dragons .d-list { width: auto; max-height: 90px; } #dragons .d-list ul { display: flex; flex-wrap: wrap; } #dragons .d-card { width: auto; max-height: 38vh; } }
#dragons .d-fly.on { background: #5a2a1a; border-color: #e9c766; color: #ffe9a8; }
#dragons .d-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 600 22px Cinzel, serif; color: #e9c766; background: rgba(18,15,12,.85); pointer-events: none; }
#dragons canvas:focus { outline: none; }
#dragons .d-credit { color: #8a7a5a; font-size: 12px; font-style: italic; margin-top: 10px; }
