.territory-map-overview{margin:30px 0;padding:26px;border:1px solid #315573;border-radius:20px;background:linear-gradient(125deg,#0d2032,#081421)}
.territory-map-intro{display:flex;align-items:center;justify-content:space-between;gap:24px;margin-bottom:20px}
.territory-map-intro h2{margin:5px 0;color:#ffc165}
.territory-map-intro .eyebrow{margin:0;color:#66c7ff}
.territory-map-intro>p{margin:0;color:#bbd8ee;font-size:.9rem;line-height:1.65}
.territory-map{margin:0;min-width:0}
.territory-map-image-link{display:block;border-radius:12px;overflow:hidden;background:#0c1c2d;border:1px solid #294a63}
.territory-map-image-link:focus-visible,.territory-map figcaption a:focus-visible{outline:3px solid #ffba48;outline-offset:4px}
.territory-map img{display:block;width:100%;height:auto;max-width:100%;object-fit:contain;aspect-ratio:2980/1880}
.territory-map-full{max-width:1080px;margin-inline:auto}
.territory-atlas{display:block;width:100%;height:auto;aspect-ratio:2980/1880;border-radius:12px;background:#0c1c2d;border:1px solid #294a63}
.territory-atlas a{cursor:pointer;outline:none}
.territory-atlas polygon{fill:transparent;stroke:transparent;stroke-width:2;vector-effect:non-scaling-stroke;pointer-events:all;transition:fill .12s,stroke .12s}
.territory-atlas a:hover polygon,.territory-atlas a:focus-visible polygon{fill:#ffc16535;stroke:#ffd07a}
.territory-atlas-tooltip{position:fixed;z-index:2147483647;max-width:min(360px,80vw);padding:7px 12px;border:1px solid #ffba48;border-radius:9px;background:#071524f5;color:#ffe0a6;box-shadow:0 4px 18px #0007;font:600 .9rem/1.4 system-ui,sans-serif;pointer-events:none;white-space:pre-line;overflow-wrap:anywhere}
.territory-atlas-tooltip[hidden]{display:none}
.territory-map figcaption{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:10px;color:#a9c7dc;font-size:.8rem;line-height:1.5}
.territory-map figcaption a{color:#ffc165;text-decoration:underline;text-underline-offset:3px}
.catalog-detail-territory .catalog-profile-heading.catalog-territory-heading{display:grid;grid-template-columns:minmax(0,1fr) minmax(280px,.95fr);align-items:center;gap:32px;margin-top:26px}
.catalog-territory-heading>div{min-width:0}
.catalog-territory-heading h2{overflow-wrap:anywhere}
.territory-map-individual{width:100%;max-width:640px;justify-self:end}
.territory-tola-reference{width:100%;max-width:400px;justify-self:end}
.territory-map-tola img{aspect-ratio:auto;max-height:520px;object-fit:contain}
.territory-nonclaimable{display:inline-block;margin:0 0 12px;padding:6px 13px;border:1px solid #7597b3;border-radius:20px;background:#132d43;color:#cae5fa;font-size:.85rem}
.territory-map-dialog{box-sizing:border-box;width:96vw;max-width:1800px;height:94dvh;max-height:94dvh;padding:0;border:1px solid #4c7b9c;border-top:5px solid #ffb946;border-radius:20px;background:#081624;color:#deefff;box-shadow:0 20px 100px #000b;overflow:hidden}
.territory-map-dialog[open]{display:flex;flex-direction:column}
.territory-map-dialog::backdrop{background:#000c;backdrop-filter:blur(4px)}
.territory-map-dialog-header{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:16px 20px;border-bottom:1px solid #294a63;flex:none}
.territory-map-dialog-title{margin:0;font-size:1.15rem;color:#ffc165;overflow-wrap:anywhere}
.territory-map-dialog-actions{display:flex;gap:10px;flex:none}
.territory-map-dialog-actions button{border:1px solid #5683a0;border-radius:12px;padding:9px 15px;background:#132e45;color:#e4f3ff;font:inherit;font-size:.9rem;cursor:pointer}
.territory-map-dialog-actions .territory-map-dialog-close{background:#ffba48;border-color:#ffba48;color:#071321;font-weight:700}
.territory-map-dialog-actions button:focus-visible,.territory-map-dialog-viewport:focus-visible{outline:3px solid #ffc165;outline-offset:-3px}
.territory-map-dialog-viewport{flex:1;min-height:0;overflow:auto;display:flex;align-items:center;justify-content:center;padding:12px;background:#0c1c2d;overscroll-behavior:contain}
.territory-map-dialog .territory-map-dialog-image{display:block;width:auto;height:auto;max-width:100%;max-height:100%;object-fit:contain;flex:none}
.territory-map-dialog .territory-map-dialog-image[hidden]{display:none}
.territory-map-dialog-viewport>.territory-atlas{width:100%;height:100%;min-width:0;min-height:0;flex:1;border:0;border-radius:0;aspect-ratio:auto}
.territory-map-dialog.territory-map-actual-size .territory-map-dialog-viewport>.territory-atlas{width:2980px;height:1880px;max-width:none;max-height:none;flex:none}
.territory-map-dialog.territory-map-actual-size .territory-map-dialog-viewport{display:block}
.territory-map-dialog.territory-map-actual-size .territory-map-dialog-image{max-width:none;max-height:none}
.territory-map-dialog-credit{margin:0;padding:10px 20px;color:#b2d0e5;font-size:.8rem;flex:none;border-top:1px solid #294a63}
@media(max-width:760px){
 .territory-map-overview{padding:18px;border-radius:15px}
 .territory-map-intro{display:block}
 .territory-map-intro>p{margin-top:12px}
 .catalog-detail-territory .catalog-profile-heading.catalog-territory-heading{grid-template-columns:minmax(0,1fr);gap:20px}
 .territory-map-individual{max-width:none;justify-self:stretch}
 .territory-map figcaption{font-size:.75rem}
 .territory-map-dialog-header{align-items:flex-start;flex-direction:column;padding:12px}
 .territory-map-dialog-actions{align-self:flex-end}
 .territory-map-dialog-title{font-size:1rem}
}

/* Ownership tint follows observed server data; only the hovered alliance uses a glow filter. */
.territory-owner-layer,.territory-owner-layer *{pointer-events:none!important}
.territory-owner-layer .territory-owner-group polygon{fill:inherit;stroke:none;fill-opacity:.13;transition:none}
.territory-owner-layer .territory-owner-group.is-highlighted polygon{fill-opacity:1}
.territory-atlas a[data-territory-alliance]:hover polygon,.territory-atlas a[data-territory-alliance]:focus-visible polygon{fill:transparent;stroke:#fff2cf;stroke-width:1.5}
.territory-atlas-tooltip .territory-alliance-crest{float:right;width:52px;height:52px;object-fit:contain;margin:2px 0 5px 12px;border-radius:8px;background:#ffffff0a}
.territory-atlas-tooltip .territory-alliance-holdings{display:block;margin-top:6px;font-size:.78rem;color:#c6def2}
html[data-lcars-theme="klingon"] .territory-map-overview{background:linear-gradient(125deg,#332019,#1c120f);border-color:#8d5b40}
html[data-lcars-theme="klingon"] .territory-atlas-tooltip{background:#24160ff5;border-color:#d9a171;color:#f6dbb8}
html[data-lcars-theme="romulan"] .territory-map-overview{background:linear-gradient(125deg,#142b19,#07130b);border-color:#4c7545}

.territory-atlas-tooltip::after{content:"";display:block;clear:both}

/* The same map artwork sits on a surface supplied by the current display theme. */
:root { --territory-surface:#0d1d30; --territory-edge:#294a63; --territory-chrome:#081624; --territory-ink:#deefff; --territory-label:#b2d0e5; --territory-accent:#ffba48; --territory-button:#132e45; }
html[data-lcars-theme="klingon"] { --territory-surface:#21140f; --territory-edge:#8d5b40; --territory-chrome:#281912; --territory-ink:#f3e0cc; --territory-label:#d0b398; --territory-accent:#e3ae79; --territory-button:#4b2d20; }
html[data-lcars-theme="romulan"] { --territory-surface:#08170d; --territory-edge:#4c7545; --territory-chrome:#0b1c11; --territory-ink:#e2f0d9; --territory-label:#b0c9a5; --territory-accent:#b8de7b; --territory-button:#203c26; }
.territory-atlas, .territory-map-image-link { background:var(--territory-surface); border-color:var(--territory-edge); }
.territory-atlas clipPath polygon { fill:white; stroke:none; pointer-events:none!important; }
.territory-map-dialog, .territory-map-dialog-viewport { background:var(--territory-surface); color:var(--territory-ink); border-color:var(--territory-edge); }
.territory-map-dialog { border-top-color:var(--territory-accent); }
.territory-map-dialog-header, .territory-map-dialog-credit { background:var(--territory-chrome); border-color:var(--territory-edge); }
.territory-map-dialog-title, .territory-map-intro h2, .territory-map figcaption a { color:var(--territory-accent); }
.territory-map figcaption, .territory-map-dialog-credit, .territory-map-intro>p { color:var(--territory-label); }
.territory-map-dialog-actions button { background:var(--territory-button); color:var(--territory-ink); border-color:var(--territory-edge); }
.territory-map-dialog-actions .territory-map-dialog-close { background:var(--territory-accent); color:var(--territory-surface); border-color:var(--territory-accent); }
html[data-lcars-theme="romulan"] .territory-atlas-tooltip { background:#0b1c11f5; border-color:var(--territory-accent); color:var(--territory-ink); }
html[data-lcars-theme="klingon"] .territory-map-intro .eyebrow { color:#d2a180; }
html[data-lcars-theme="romulan"] .territory-map-intro .eyebrow { color:#a7cf8d; }

html:is([data-lcars-theme="klingon"],[data-lcars-theme="romulan"]) :is(.territory-map-overview,.territory-atlas,.territory-map-dialog,.territory-map-dialog-viewport,.territory-map-dialog-header,.territory-map-dialog-credit) {
  background-color:var(--lcars-hull-color,var(--territory-surface));
  background-image:var(--lcars-hull-texture,none);
  background-size:var(--lcars-hull-texture-size,auto);
}
