html:has(body[data-playing]):not(:has(#territory-entry:not([hidden]))) {overflow:hidden}
body[data-playing] {
    --hud-dark:#142935;
    --hud-ink:#faf7ea;
    --hud-line:#ffffff26;
    --game-menu-width:clamp(10.5rem,13.4vw,13.5rem);
    min-height:0;height:100vh;height:100dvh;overflow:hidden;background:var(--hud-dark);
    grid-template-rows:auto minmax(0,1fr) auto;
}
body:has(#territory-entry:not([hidden])) {height:auto;overflow:visible;background:#f6f2e8}
body:has(#territory-entry:not([hidden])) main {display:block;padding:1rem 0}
main:has(#territory-entry:not([hidden])) > :is(#viewport,#game-nav,#hud,#panel[data-presentation=rail]) {display:none}
body:has(#territory-entry:not([hidden])) :is(#world-footer,#resources) {display:none}

.topbar {min-height:48px;padding-block:.34rem}
body[data-playing] .topbar {
    grid-template-columns:clamp(11rem,19vw,22rem) minmax(0,50rem) minmax(8.5rem,1fr);
    gap:clamp(.55rem,1.8vw,2.15rem);padding:.5rem clamp(.65rem,1.2vw,1.35rem);
    background:linear-gradient(105deg,#102330,#284352 63%,#172e39);
    border-color:#58707a;box-shadow:0 2px 10px #0b192666;color:var(--hud-ink);
}
body[data-playing] :is(.top-center,#connection) {display:none}
body[data-playing] .brand {
    color:var(--hud-ink);letter-spacing:.045em;font-size:clamp(1.34rem,2.08vw,2.12rem);
    gap:.6rem;
}
body[data-playing] .brand:hover:not(:disabled) {color:#ffe6b2;border-color:transparent}
body[data-playing] .brand img {width:clamp(2.3rem,3.4vw,3.5rem);height:auto}
body[data-playing] .brand small {color:#ced8d5;font-size:clamp(.62rem,.9vw,.92rem)}
body[data-playing] .top-status {gap:.46rem;min-width:0}
body[data-playing] .top-status button {
    background:linear-gradient(#314a57,#132b35);color:var(--hud-ink);border-color:var(--hud-line);
    box-shadow:inset 0 1px #ffffff12;padding:.36rem .52rem;
}
body[data-playing] .top-status button:hover {background:#385460;border-color:#d9bf7e}
#quick-settings {height:2.4rem;width:2.4rem;border-radius:50%;flex:none}
.account-control {min-width:0;text-align:left}
.account-control > span {display:grid;min-width:0;line-height:1.2}
.account-control strong {overflow:hidden;text-overflow:ellipsis}
.account-control small {color:#e6ddca;font-size:.71rem;overflow:hidden;text-overflow:ellipsis}
body[data-playing] .account-control .icon {width:1.6rem;height:1.6rem;padding:.21rem;border-radius:50%;background:#dae3e3;color:#213944}

#resources {display:grid;min-width:0;grid-template-columns:minmax(0,1.19fr) minmax(0,1.06fr) repeat(2,minmax(0,.875fr));gap:.35rem}
#resources button {
    display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;justify-items:start;gap:0 .46rem;
    text-align:left;color:var(--hud-ink);min-width:0;
    background:linear-gradient(#304955,#132b36);border:1px solid var(--hud-line);
    border-radius:9px;box-shadow:inset 0 1px #ffffff10,0 2px 5px #15222e64;
    padding:.38rem .48rem;line-height:1.15;
}
#resources button:hover:not(:disabled) {background:#385662;border-color:#ad9a65}
#resources button .icon {grid-row:span 2;width:1.44rem;height:1.44rem;color:#bfd0d1}
#resources button:first-child .icon {color:#f3c663}
#resources button span {font-size:.69rem;color:#c8ded7}
#resources button strong {
    max-width:100%;font-size:clamp(.81rem,1.08vw,1.07rem);font-variant-numeric:tabular-nums;white-space:nowrap;
    overflow:hidden;text-overflow:ellipsis;
}
body[data-playing] :is(.topbar,#game-nav,#scene-chrome,#world-footer) button:focus-visible {
    outline-color:#ffe09a;outline-offset:2px;
}

body[data-playing] main {
    grid-template:"view rail" minmax(0,1fr)/minmax(0,1fr) 0;
    width:100%;min-height:0;min-width:0;
}
body[data-playing] main:has(#hud:not([hidden]),#panel[data-presentation=rail][open]) {
    grid-template-columns:minmax(0,1fr) minmax(300px,366px);
}
body[data-playing] .viewport {grid-area:view;min-width:0;min-height:0;overflow:clip;border:0;background:#668951}
#game-nav {
    grid-area:view;z-index:3;align-self:start;justify-self:end;display:flex;flex-direction:column;gap:.15rem;
    width:var(--game-menu-width);max-height:calc(100% - 5rem);margin:.8rem .7rem 0 0;padding:.37rem;
    overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;
    border:1px solid #ffffff3b;border-radius:11px;background:#263527bd;backdrop-filter:blur(5px);
    box-shadow:0 4px 15px #0c212aa0;
}
#game-nav button {
    flex:none;justify-content:flex-start;gap:.65rem;min-height:clamp(2rem,5.2dvh,3rem);padding:.18rem .65rem;
    white-space:nowrap;text-align:left;
    color:#302919;background:linear-gradient(#fffdf4,#efeadb 55%,#d2cab6);border:1px solid #a7a18c;
    border-radius:6px;box-shadow:inset 0 1px 1px #ffffff8e,0 1px 3px #18202370;
    font-size:clamp(.74rem,.96vw,.96rem);font-weight:740;
}
#game-nav button:hover:not(:disabled) {background:linear-gradient(#fffdf6,#f8e6ac);border-color:#e3c663}
#game-nav button:is([aria-current],[aria-expanded=true],.politics-entry) {
    color:#302012;background:linear-gradient(#fff1ad,#f1d67c 52%,#d1a746);border-color:#e3cb87;
}
#game-nav .politics-entry span {white-space:normal;line-height:1.14}
#game-nav .icon {width:1.22rem;height:1.22rem;color:#544421}
#notice-indicator {
    margin-left:auto;padding:.04rem .29rem;border-radius:1rem;background:#a92830;color:#fff;
    font-size:.66rem;font-variant-numeric:tabular-nums;
}
.town-actions button,#queue-projects {
    padding:.36rem .63rem;border-radius:5px;color:#344931;border:1px solid #d3ccb2;background:#fffdf4;font-size:.79rem;
}
.town-actions button:hover:not(:disabled),#queue-projects:hover:not(:disabled) {border-color:#8ca46e;background:#eef2dc;color:#2c4530}
.town-actions .primary {background:#c9dfa6;border-color:#91ad65;color:#294221}
.town-actions .icon {width:.96rem;height:.96rem}
.candidacy-steps {font-size:.83rem;margin:.15rem 0 .65rem;padding-left:1.25rem;color:var(--muted)}
.candidacy-steps [aria-current=step] {font-weight:750;color:var(--text)}

body[data-playing] .viewport .marker {z-index:1;background:#fff9e3;color:#344831;border-color:#8ba16b;box-shadow:0 2px 4px #425d394d}
body[data-playing] .viewport .marker .icon {color:#557949}
body[data-playing] .viewport .marker:is(:hover,:focus-visible,[data-highlight]) {
    z-index:3;background:#fff3be;color:#374326;border-color:#988749;
}
body[data-playing] .viewport .marker[data-kind=closed] {opacity:.88}
body[data-playing] .viewport .marker[data-life=works] {background:#f8d98d;color:#4f361e;border-color:#a77640}
body[data-playing] .viewport .marker[data-life=planned] {background:#e6efd0;border-color:#7f9950}
body[data-playing] .viewport .marker[data-life=emergency] {background:#f8d4b1;color:#6b251b;border-color:#a34f30}
body[data-playing] .viewport .marker[data-life=outage] {background:#dbf1e7;color:#244b49;border-color:#66918b}
body[data-playing] #markers[data-map] .marker {
    transform:translate(-50%,-50%);width:1.85rem;height:1.85rem;padding:0;justify-content:center;border-radius:50%;
}
#markers[data-map] .marker-name {
    display:none;position:absolute;left:50%;bottom:calc(100% + .3rem);transform:translateX(-50%);
    padding:.31rem .62rem;pointer-events:none;width:max-content;max-width:min(15rem,72vw);
    white-space:normal;line-height:1.24;text-align:center;color:#fff9eb;background:#162c37ed;
    border:1px solid #e5c580;border-radius:5px;box-shadow:0 3px 10px #10242da8;font-size:.85rem;
}
#markers[data-map] .marker[data-align=start] .marker-name {left:0;transform:none}
#markers[data-map] .marker[data-align=end] .marker-name {left:auto;right:0;transform:none}
#markers[data-map] .marker:is(:focus-visible,[data-highlight]) .marker-name {display:block}
@media(any-hover:hover) {
    #markers[data-map] .marker:hover .marker-name {display:block}
}
#markers[data-map] .life-counter {display:none}
body[data-playing] #markers[data-illustrated] .marker:not([data-pin]) {
    background:transparent;border-color:transparent;box-shadow:none;opacity:1;
}
body[data-playing] #markers[data-illustrated] .marker:not([data-pin]) .icon {visibility:hidden}
body[data-playing] #markers[data-illustrated] .marker:focus-visible {outline-color:#ffecab}
body[data-playing] #markers[data-illustrated] .marker[data-pin] {
    width:1.52rem;height:1.52rem;background:#18313bd9;color:#fff8df;border-color:#e9dbc0b8;
}
body[data-playing] #markers[data-illustrated] .marker[data-pin] .icon {color:inherit;width:.83rem;height:.83rem}
body[data-playing] #markers[data-illustrated] .marker[data-pin][data-life=emergency] {background:#a82e30;border-color:#ffcfb5}
body[data-playing] #markers[data-illustrated] .marker[data-pin][data-life=works] {background:#e2b958;color:#432b12;border-color:#fff0bc}
body[data-playing] #markers[data-illustrated] .marker[data-pin][data-life=planned] {background:#426454}
@media(hover:none) {
    body[data-playing] #markers[data-illustrated] .marker:not([data-pin],[data-kind=closed]) {
        background:#193137cc;border-color:#fff8e994;
    }
    body[data-playing] #markers[data-illustrated] .marker:not([data-pin],[data-kind=closed]) .icon {
        visibility:visible;color:#fff8e9;width:.85rem;height:.85rem;
    }
}

.scene-heading {
    position:absolute;top:.85rem;left:clamp(.52rem,1.18vw,1.3rem);
    max-width:calc(100% - var(--game-menu-width) - 2rem);
    display:flex;gap:.38rem;flex-wrap:wrap;align-items:center;
}
#commune-switch {
    pointer-events:auto;min-width:0;gap:.42rem;text-align:left;justify-content:flex-start;
    padding:.42rem .72rem;background:linear-gradient(#274650,#142c37);color:#fff9e9;border-color:#d4ded777;
    box-shadow:0 3px 9px #0b21299c;
}
#commune-switch .icon {color:#b8dc76;width:1.47rem;height:1.47rem}
#commune-switch:hover {border-color:#f3d08b;background:#274a55}
#commune-switch > span {display:grid;line-height:1.2;overflow-wrap:anywhere}
#commune-switch strong {font-size:1.02rem}
#commune-switch small {color:#e3e8da;font-size:.75rem;font-weight:520}
#scene-label {position:static;min-width:0;flex-wrap:wrap;background:#fffbeeef;color:#354731;border-color:#a1b07e}
body[data-scene=map] #scene-label {
    position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);padding:0;border:0;
}
#scene-chrome .scene-label button {background:#fffdf1;color:#354731;border-color:#abb88f}
#scene-chrome .map-tools {
    display:flex;gap:.18rem;top:auto;bottom:.63rem;right:.7rem;padding:.17rem;background:#172d37db;
    border:1px solid #ffffff4d;border-radius:6px;
}
#scene-chrome .map-tools button {
    width:2.06rem;height:2.06rem;background:#23414d;color:#fff9e9;border-color:#b2c1bf4d;box-shadow:none;
}
#scene-chrome .map-tools button:hover {background:#38565e}
#scene-chrome #show-places {width:auto;padding:0 .46rem;gap:.32rem;font-size:.78rem}
#show-places .icon {width:.94rem;height:.94rem}
#places-list {
    position:absolute;right:calc(var(--game-menu-width) + 1rem);bottom:3.4rem;
    width:min(19rem,calc(100% - var(--game-menu-width) - 1.6rem));max-height:66%;
    border:1px solid #a1b07e;border-radius:7px;padding:.42rem;overflow:auto;pointer-events:auto;
    display:grid;gap:.2rem;z-index:4;background:#fffbee;color:#354731;box-shadow:0 5px 20px #10212da0;
}
#places-list button {text-align:start;justify-content:flex-start;padding:.33rem .48rem;font-size:.82rem}
#map-brief {
    position:absolute;pointer-events:auto;left:clamp(.52rem,1.18vw,1.3rem);bottom:.75rem;
    width:min(21rem,calc(100% - 13rem));border:1px solid #9a957c;border-radius:9px;overflow:hidden;
    background:#f2edddf5;color:#302c22;box-shadow:0 4px 13px #142a33a6;
}
#map-brief h2 {
    margin:0;display:flex;align-items:center;gap:.5rem;padding:.49rem .66rem;font-size:.93rem;color:#fff9eb;
    background:linear-gradient(#304b56,#142933);
}
#map-tasks {padding:.25rem .32rem}
.map-task {
    width:100%;min-width:0;display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:.27rem;
    border:0;background:none;text-align:left;padding:.32rem .27rem;font-size:.78rem;line-height:1.2;
}
.map-task span {overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.map-task small {color:#316242;white-space:nowrap;font-size:.69rem}
.map-task .icon {width:.9rem;height:.9rem;color:#58654a}
main:has(#hud:not([hidden]),#panel[data-presentation=rail][open]) #map-brief {display:none}

#world-footer {
    display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.5fr) minmax(0,1fr);gap:.38rem;
    background:linear-gradient(105deg,#132732,#213a46);color:#e8efe9;
    border-color:#5b7077;padding:.28rem clamp(.62rem,1.24vw,1.35rem);min-height:2.1rem;
}
.world-clock,.world-status {display:flex;align-items:center;gap:.48rem;min-width:0;white-space:nowrap}
.world-clock time {overflow:hidden;text-overflow:ellipsis}
.world-status {grid-column:3;justify-self:end}
#world-state {color:#e1eddf;font-size:.78rem}
#world-state[data-tone=error] {color:#ffd2ba}
#world-coordinates {border-left:1px solid #b7c9c24d;padding-left:.48rem;color:#a9bfbe;font-size:.7rem}
#latest-event {
    justify-self:center;min-width:0;max-width:100%;gap:.35rem;background:none;border:0;color:inherit;padding:.12rem;
    font-size:.77rem;
}
#latest-event:hover {color:#ffe2a2}
#latest-event span {min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

#hud,#panel[data-presentation=rail][open] {
    grid-area:rail;min-width:0;min-height:0;max-height:none;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;
    border:1px solid #d8d2b7;border-radius:8px;box-shadow:none;background:#fffdf7;color:#34412f;
}
#hud .activity-heading {
    position:sticky;top:0;z-index:1;display:flex;align-items:center;justify-content:space-between;gap:.55rem;
    padding:.48rem .68rem;background:#edf2db;border-bottom:1px solid #d7dfbd;
}
#activities-title {margin:0;font:700 1.2rem/1.15 Georgia,serif}
#close-activities {padding:.25rem .38rem}
#hud .hud-section {padding:.53rem .68rem}
#hud .hud-section:first-child {border-top:0}
#hud .section-heading {margin-bottom:.29rem}
#hud .section-heading h2 {font:700 1.03rem/1.2 Georgia,serif;color:#3b522e}
#hud .hud-more {border-top:1px solid #e3ddc6}
#hud .hud-more summary {font-size:.83rem;font-weight:700;padding:.43rem .72rem;color:#536447;cursor:pointer}
#hud .hud-nav {grid-template-columns:repeat(auto-fit,minmax(min(100%,185px),1fr))}
#work-preview {display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,230px),1fr));gap:.35rem}
#agenda-preview {display:flex;flex-wrap:wrap;gap:.32rem;align-items:center;margin-top:.44rem}
#agenda-preview h3 {margin:0 .33rem 0 0;font-size:.77rem;color:#596048}
.activity-link {
    display:grid;grid-template-columns:auto minmax(0,1fr);justify-items:start;text-align:left;gap:.1rem .37rem;
    padding:.34rem .48rem;background:#faf4dd;border-color:#e2d6af;color:#3d542f;font-size:.8rem;overflow-wrap:anywhere;
}
.activity-link:hover:not(:disabled) {background:#eef2d9;border-color:#8da66d;color:#344831}
.activity-link small {grid-column:2;color:#5b654e;font-size:.73rem;font-weight:500}
.activity-link .activity-due {font-variant-numeric:tabular-nums;color:#765622}
#agenda-preview .activity-link {padding:.25rem .4rem;background:#f5f7eb;font-size:.73rem}
#agenda-preview .activity-link small {font-size:.65rem}
#panel[data-presentation=rail][open] {
    position:relative;inset:auto;width:100%;height:auto;max-width:none;margin:0;align-self:stretch;
}
#panel[data-presentation=rail] .dialog-head {background:#edf2db;border-color:#d7dfbd;padding:.55rem .72rem}
#panel[data-presentation=rail] .dialog-head h2 {font:700 1.26rem/1.15 Georgia,serif}
#panel[data-presentation=rail] #panel-body {padding:.65rem .72rem}
#panel[data-presentation=rail] .form-grid {grid-template-columns:1fr}
#panel[data-presentation=rail] .facts > div {flex-wrap:wrap}
#panel[data-presentation=rail] .town-actions {display:grid;gap:.34rem}
#panel[data-presentation=rail] .town-actions button {justify-content:flex-start}
@media(max-width:950px) {
    body[data-playing] .topbar {
        grid-template-columns:minmax(0,1fr) auto;gap:.34rem .55rem;padding:.34rem .62rem;
    }
    #resources {grid-column:1/-1;grid-row:2}
    body[data-playing] .top-status {grid-column:2;grid-row:1;max-width:55vw}
    #latest-event {display:none}
    #world-footer {grid-template-columns:minmax(0,1fr) auto}
    .world-status {grid-column:2}
}
@media(max-width:730px) {
    body[data-playing] main {
        grid-template:"view" minmax(0,1fr) "nav" auto/minmax(0,1fr);
    }
    body[data-playing] main:has(#hud:not([hidden]),#panel[data-presentation=rail][open]) {
        grid-template:"view" minmax(0,1fr) "rail" minmax(0,1fr) "nav" auto/minmax(0,1fr);
    }
    #game-nav {
        grid-area:nav;justify-self:stretch;flex-direction:row;width:100%;max-height:none;margin:0;
        border-radius:0;background:#172b35;border-color:#536b73;border-inline:0;padding:.28rem .4rem;
    }
    #game-nav button {min-height:2.2rem;padding:.25rem .57rem;font-size:.76rem;gap:.35rem}
    #game-nav .icon {height:1.04rem;width:1.04rem}
    #resources button {padding:.32rem .22rem;grid-template-columns:minmax(0,1fr);justify-items:center;text-align:center}
    #resources button .icon {display:none}
    #resources button span {font-size:.62rem}
    #resources button strong {font-size:.76rem}
    #quick-settings {width:1.92rem;height:1.92rem;min-width:0}
    body[data-playing] .account-control {gap:.25rem;font-size:.74rem}
    body[data-playing] .account-control .icon {width:1.25rem;height:1.25rem}
    .scene-heading {max-width:calc(100% - 1.3rem);top:.47rem}
    #scene-label {font-size:.78rem;padding:.23rem .38rem}
    #places-list {right:.7rem;width:min(19rem,calc(100% - 1.4rem))}
    #map-brief {display:none}
    #world-footer {font-size:.7rem}
    #world-state {font-size:.69rem}
    #world-coordinates {display:none}
}
@media(max-height:600px) {
    #map-brief {display:none}
}
@media(max-height:400px) {
    body[data-playing] #world-footer {display:none}
    body[data-playing] .brand img {width:1.9rem}
    body[data-playing] .brand small {display:none}
}
@media print {
    body:has(.admin-print) > main {display:block!important}
    body:has(.admin-print) > main > :not(#panel) {display:none!important}
    html:has(.admin-print),body:has(.admin-print) {height:auto!important;overflow:visible!important}
    #panel[data-presentation=rail][open]:has(.admin-print) {position:static;overflow:visible;border:0;background:white}
    #panel[data-presentation=rail] .record.admin-print {background:white;color:black}
}
