:root {
    color-scheme: light;
    --night: #f8f8ec;
    --deep: #f6f2e8;
    --slate: #edf0db;
    --line: #d7d6b9;
    --cyan: #6e9a4c;
    --soft-cyan: #466c35;
    --green: #67954b;
    --amber: #c28a36;
    --red: #a94b41;
    --text: #34412f;
    --muted: #5b654f;
    font: 16px/1.47 "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0;
    min-width: 310px;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    color: var(--text);
    background: var(--deep);
}
button, input, select, textarea { font: inherit; }
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    color: var(--text);
    background: #fffdf4;
    border: 1px solid #cfc9ae;
    border-radius: 7px;
    padding: .57rem .84rem;
    font-weight: 650;
    cursor: pointer;
    transition: background-color .12s, border-color .12s, color .12s;
}
button:hover:not(:disabled) { background: #edf2db; border-color: #92a673; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
    outline: 2px solid var(--soft-cyan);
    outline-offset: 3px;
}
button:disabled { cursor: default; opacity: .52; }
.primary {
    background: #c3dc9b;
    color: #294322;
    border-color: #96b76d;
}
.primary:hover:not(:disabled) { background: #dceabf; color: #294322; border-color: #a9c688; }
.icon { width: 1.08rem; height: 1.08rem; flex: none; display: inline-block; vertical-align: middle; }
.icon-button { min-width: 2.15rem; padding: .43rem; }
.quiet-button { background: #f7f8eb; font-size: .875rem; justify-content: flex-start; }
.eyebrow {
    margin: 0 0 .25rem;
    text-transform: uppercase;
    color: var(--soft-cyan);
    font-size: .77rem;
    letter-spacing: .12em;
    font-weight: 700;
}
.topbar {
    position: relative;
    z-index: 3;
    display: grid;
    grid-template-columns: minmax(235px, 1fr) auto minmax(235px, 1fr);
    align-items: center;
    gap: 1rem;
    padding: .55rem 1.16rem;
    min-height: 65px;
    background: #f8f8ec;
    border-bottom: 1px solid #dad8bd;
}
.brand {
    justify-self: start;
    background: transparent;
    padding: 0;
    border-color: transparent;
    text-align: left;
    letter-spacing: .12em;
    line-height: 1.15;
    font: 700 1.1rem/1.15 Bahnschrift, "Segoe UI", sans-serif;
}
.brand:hover:not(:disabled) { background: transparent; }
.brand small { display: block; color: var(--muted); font: 500 .77rem/1.15 "Segoe UI", sans-serif; letter-spacing: 0; margin-top: .2rem; }
.top-center { color: #5d6554; font-size: .9rem; }
.top-status { justify-content: flex-end; display: flex; align-items: center; gap: .85rem; white-space: nowrap; }
.top-status button { font-size: .875rem; padding: .45rem .65rem; }
.top-date { font-size: .876rem; font-variant-numeric: tabular-nums; color: #5b624d; }
.signal { color: #4c743a; display: inline-flex; align-items: center; gap: .46rem; font-size: .875rem; }
.signal::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--green); }
.signal[data-tone="pending"] { color: #765323; }
.signal[data-tone="pending"]::before { background: var(--amber); }
.signal[data-tone="error"] { color: #8d332c; }
.signal[data-tone="error"]::before { background: var(--red); }
main { display: grid; min-height: 0; }
.viewport {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-height: min(590px, calc(100dvh - 105px));
    background: #8bb568;
}
#world, .map-shade, .marker-layer, #scene-chrome, .welcome { position: absolute; inset: 0; }
#world { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#world.dragging { cursor: grabbing; }
.map-shade {
    z-index: 0;
    pointer-events: none;
    background: none;
}
.marker-layer, #scene-chrome { pointer-events: none; }
.marker-layer { z-index: 1; }
.marker {
    position: absolute;
    transform: translate(-50%, -73%);
    justify-content: flex-start;
    gap: .42rem;
    pointer-events: auto;
    color: #344931;
    background: #fff9e4;
    border-color: #99a977;
    border-radius: 100px;
    white-space: nowrap;
    padding: .34rem .57rem;
    font-size: .84rem;
    box-shadow: 0 3px 8px #0a242d70;
}
.marker .icon { color: #5c794a; width: 1rem; height: 1rem; }
.marker[aria-pressed="true"], .marker:hover:not(:disabled) { color: #344931; background: #e9f0d5; border-color: #9fb37f; }
.marker[aria-pressed="true"] .icon, .marker:hover:not(:disabled) .icon { color: #426b39; }
.marker[data-kind="closed"] {
    background: #f2eddb;
    opacity: .9;
    padding: .27rem .4rem;
    box-shadow: none;
    font-weight: 500;
    color: #5c624d;
}
.marker[data-kind="closed"] .icon { color: #697854; }
.marker[data-kind="person"] { padding: .36rem; border-color: #c2bd85; background: #edf1d5; }
.marker[data-kind="person"] .icon { color: #516743; }
.marker[data-kind="person"]:hover .icon { color: #426a37; }
#scene-chrome { z-index: 2; }
.scene-label, .map-tools, .map-note { position: absolute; }
.scene-label {
    top: 1rem;
    left: 1rem;
    display: flex;
    align-items: center;
    gap: .57rem;
    background: #fffcef;
    border: 1px solid #5f8299;
    border-radius: 8px;
    padding: .35rem .65rem .35rem .36rem;
    box-shadow: 0 6px 20px #0a213e52;
}
.scene-label button, .map-tools button { pointer-events: auto; }
.scene-label button { padding: .31rem .55rem; font-size: .82rem; }
.scene-label span { font-size: .89rem; color: inherit; }
.map-tools { right: 1rem; top: 1rem; display: grid; gap: .38rem; }
.map-tools button { height: 2.45rem; width: 2.45rem; padding: 0; font-size: 1.28rem; box-shadow: 0 3px 9px #0c213655; }
.map-note { bottom: .68rem; right: .92rem; color: #e6f1ef; text-shadow: 0 1px 4px #081826; font-size: .78rem; }
.welcome {
    z-index: 2;
    display: grid;
    align-items: center;
    padding: 2.4rem max(6.5vw, 1.4rem);
    background: linear-gradient(90deg,#fffbee 0%,#f8f5e2ea 29%,#f8f5e278 52%,transparent 78%);
}
.welcome-card { max-width: min(100%, 410px); }
.welcome-mark { margin-bottom: .45rem; }
.welcome h1 {
    margin: 0;
    color: #364d2e;
    font: 760 clamp(2.8rem, 6.2vw, 5rem)/.99 Bahnschrift, "Segoe UI", sans-serif;
    letter-spacing: -.06em;
}
.welcome-sub { color: #4f6141; font-size: clamp(1rem, 1.6vw, 1.45rem); margin: .5rem 0 1.35rem; }
.welcome-menu { display: grid; grid-template-columns: 1fr 1fr; gap: .53rem; }
.welcome-menu button { justify-content: flex-start; padding: .74rem .8rem; min-height: 45px; }
.welcome-note { position: absolute; right: 1.12rem; bottom: .78rem; font-size: .83rem; color: #2d4829; background: #fffbee; padding:.2rem .42rem; border-radius:4px; margin: 0; }
#hud {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-height: 100%;
    overflow: auto;
    background: #fffdf7;
    border-left: 1px solid #ddd7bc;
}
.hud-title { background: #edf1db; padding: 1rem 1rem .85rem; }
.hud-title h1 { margin: .09rem 0 .62rem; letter-spacing: -.03em; font: 700 clamp(1.52rem, 4vw, 1.99rem)/1.02 Bahnschrift, "Segoe UI", sans-serif; overflow-wrap: anywhere; }
.role-chip { display: inline-flex; gap: .35rem; align-items: center; padding: .19rem .56rem; margin: 0; color: #3a5134; border: 1px solid #b9c49a; background: #e9efd6; border-radius: 5px; font-size: .864rem; }
.hud-section { padding: .84rem 1rem; border-top: 1px solid #e3dec7; }
.section-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: .55rem; }
.section-heading h2 { margin: 0; font-size: .98rem; }
.section-heading .icon { color: #718963; }
.facts { margin: 0; }
.facts > div { display: flex; justify-content: space-between; gap: .4rem; align-items: start; margin-bottom: .33rem; }
.facts dt { color: #646d55; font-size: .845rem; }
.facts dd { margin: 0; font-weight: 600; text-align: right; font-size: .87rem; }
.phase { margin: 0 0 .23rem; font-weight: 700; color: #815a27; }
.hud-muted { color: var(--muted); font-size: .86rem; margin: .26rem 0 .65rem; }
.hud-events { display: flex; flex: 1 1 137px; flex-direction: column; min-height: 105px; }
.hud-events .section-heading { margin-bottom: .33rem; }
#event-preview { overflow: auto; scrollbar-width: thin; }
.event-peek { display: grid; grid-template-columns: auto 1fr; gap: .4rem .52rem; margin: .37rem 0; padding: .46rem .47rem; border: 1px solid #dcd5ba; border-radius: 6px; background: #faf6e5; font-size: .83rem; }
.event-peek .icon { margin-top: .13rem; color: #557743; }
.event-peek[data-tone="warning"] .icon { color: #94672f; }
.event-peek time { grid-column: 2; font-size: .75rem; color: #626c54; }
.hud-nav { display: grid; gap: .42rem; margin-top: auto; padding: .73rem 1rem .9rem; border-top: 1px solid #dad6bd; }
.hud-nav button { font-size: .875rem; padding: .45rem .56rem; justify-content: flex-start; }
footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .58rem;
    background: #f8f8ec;
    border-top: 1px solid #d4d9ba;
    padding: .42rem .9rem;
    color: #54634c;
    font-size: .82rem;
}
dialog {
    width: min(955px, calc(100vw - 2rem));
    max-height: min(88dvh, 900px);
    padding: 0;
    background: #fffdf7;
    color: var(--text);
    border: 1px solid #ccd0ac;
    border-radius: 13px;
    box-shadow: 0 18px 100px #45523445;
}
dialog[data-size="compact"] { width: min(512px, calc(100vw - 2rem)); }
dialog::backdrop { background: #39432d54; }
.dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .85rem;
    padding: .9rem 1.2rem;
    position: sticky;
    top: 0;
    z-index: 1;
    background: #edf2dd;
    border-bottom: 1px solid #d1d9b4;
}
.dialog-head h2 { margin: 0; letter-spacing: -.021em; font-size: clamp(1.25rem, 3vw, 1.61rem); }
#panel-body { padding: 1.1rem 1.2rem 1.2rem; }
#panel-body > :first-child { margin-top: 0; }
form { display: grid; gap: .74rem; }
label { display: grid; gap: .3rem; font-size: .91rem; font-weight: 650; }
label.check { display: flex; align-items: start; gap: .54rem; font-weight: 500; }
input:not([type=checkbox]), select, textarea {
    width: 100%; min-width: 0; background: #fffdf5; border: 1px solid #babc9c;
    color: inherit; padding: .57rem .63rem; border-radius: 6px;
}
input[type=checkbox] { width: 1.13rem; height: 1.13rem; accent-color: #6c9d4b; margin-top: .11rem; }
textarea { resize: vertical; min-height: 4.5rem; }
form .grid, .panel-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .72rem; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .72rem; margin-bottom: .62rem; }
.wide-field { grid-column: 1 / -1; }
.check-field { display: flex; gap: .55rem; align-items: start; font-weight: 500; }
.panel-form { margin: .6rem 0 1rem; }
.confirmation { margin: .55rem 0; }
.pager { margin-top: .75rem; }
#panel-body .record { margin-bottom: .48rem; }
#panel-body .facts dd { text-align: right; }
.document .facts dt { color: #455f6c; }
.document button { color: #203344; background: #d7e8e5; border-color: #849e9f; margin-top: .45rem; }
.document button:hover:not(:disabled) { background: #b8d8d6; }
.admin-nav { display: grid; grid-template-columns: repeat(auto-fit,minmax(158px,1fr)); gap: .5rem; margin: 1rem 0; }
.admin-nav button { justify-content: flex-start; }
.marker[data-life="outage"] { background: #daefe8; border-color: #87afac; }
.marker[data-life="damage"], .marker[data-life="works"] { background: #f7e3b4; border-color: #c59c5e; }
.marker[data-life="emergency"] { background: #f9d8ca; border-color: #ba6653; }
.marker[data-life="incident"] { background: #f4dfc7; border-color: #c8935d; }
.marker[data-life="civic"] { background: #e6efd7; border-color: #a7bb8d; }
.life-counter { font-size: .75em; background: #e6edd6; color: #3d5736; border-radius: 5px; padding: .06rem .32rem; }
.life-closures { background: #f4d7cb; color: #732e24; }
.economy-packs { display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:.8rem; }
.economy-packs .record { min-height:135px; margin:0; display:grid; align-content:start; gap:.3rem; }
.economy-packs .record h3 { margin-bottom:.35rem; }
.economy-packs .record button { justify-self:start; }
.shop-link { display:inline-flex; padding:.6rem .9rem; border-radius:7px; text-decoration:none; }
@media (min-width: 900px) {
  .life-incident-facts { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); column-gap: 2rem; }
}
.life-legend { display: flex; gap: .4rem; flex-wrap: wrap; margin: .55rem 0; }
.life-legend span { border: 1px solid #cad2b0; background: #f4f6e5; padding: .22rem .5rem; border-radius: 5px; }
.life-legend .damage { border-color: #c59c5e; }
.life-legend .outage { border-color: #87afac; }
.life-legend .emergency { border-color: #ba6653; }
.life-tag { display: inline-flex; border: 1px solid #c88874; color: #7b3c30; padding: .17rem .5rem; border-radius: 5px; }
.admin-group { margin: .85rem 0 1.1rem; }
.admin-group h3 { margin: .4rem 0 .6rem; }
.admin-disclosure { margin: .7rem 0; }
.admin-disclosure summary { cursor: pointer; font-weight: 670; margin-bottom: .35rem; }
.admin-print > p { white-space: pre-wrap; }
@media print {
    body:has(.admin-print) { height: auto; overflow: visible; background: white; }
    body:has(.admin-print) > :not(dialog), dialog:has(.admin-print) .dialog-head,
    #panel-body:has(.admin-print) > div > :not(.admin-print) { display: none !important; }
    dialog:has(.admin-print) { position: static; width: auto; max-width: none; max-height: none; overflow: visible; margin: 0; border: 0; background: white; }
    dialog:has(.admin-print)::backdrop { background: transparent; }
    .admin-print { color: black; background: white; }
}
.form-actions, .actions { display: flex; flex-wrap: wrap; gap: .47rem; align-items: center; }
.panel-copy { color: var(--muted); margin: .25rem 0 .72rem; }
.catalog-layout { display: grid; grid-template-columns: minmax(0, 1.36fr) minmax(210px, .85fr); gap: 1.12rem; }
.catalog-layout aside { background: #f7f6e8; border: 1px solid #d5d6b7; border-radius: 8px; align-self: start; padding: .72rem; }
.catalog-layout img { display: block; width: 100%; margin-bottom: .63rem; }
.catalog-layout h3 { margin: .3rem 0; font-size: 1rem; }
.catalog-list { padding: 0; margin: .75rem 0; list-style: none; display: grid; gap: .25rem; }
.catalog-list button { width: 100%; justify-content: space-between; text-align: left; padding: .48rem .65rem; }
.catalog-list span:last-child { color: #67765b; font-size: .81rem; }
.catalog-list button[aria-pressed="true"] { border-color: #93ad75; background: #e4edd3; }
.rows { display: grid; gap: .5rem; padding: 0; list-style: none; }
.record { background: #faf7e9; border: 1px solid #e0d9bf; border-radius: 8px; padding: .69rem .82rem; overflow-wrap: anywhere; }
.record h3 { font-size: 1rem; margin: 0 0 .3rem; }
.record p { margin: .27rem 0; }
.record .meta, .small { color: var(--muted); font-size: .81rem; }
.record[data-tone="warning"] { border-left: 3px solid var(--amber); }
.record[data-tone="result"] { border-left: 3px solid var(--green); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: .58rem; margin: .68rem 0; }
.kpis .record strong { display: block; color: #4a6f38; font: 670 1.27rem Bahnschrift, system-ui; }
.vote-bar { display: block; width: 100%; height: .43rem; margin: .36rem 0 .17rem; accent-color: #80a65b; }
.vote-bar::-webkit-progress-value { transition: width .5s ease-out; }
.document { background: #e9f0ed; color: #203344; padding: .98rem 1.1rem; border-radius: 5px; border-top: 4px solid #4e8188; margin: .64rem 0; }
.document .meta { color: #485e6c; }
.document h3 { margin: .05rem 0 .45rem; font-family: Bahnschrift, system-ui; }
.document p { margin: .35rem 0; }
.panel-error { color: #983f31; margin: .55rem 0 0; }
.danger { background: #f8dfd3; border-color: #c8806d; }
#toast {
    z-index: 5;
    position: fixed;
    bottom: .9rem;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 1.6rem);
    padding: .63rem .92rem;
    color: #344b2d;
    border: 1px solid #b4c598;
    background: #f1f6df;
    border-radius: 7px;
    box-shadow: 0 3px 16px #3e51334d;
}
#toast[data-tone="error"] { background: #f8dfd3; border-color: #c98071; }
#hud-time { display: none; }
@media (min-height: 700px) and (min-width: 1100px) {
    body { height: 100vh; height: 100dvh; }
}
@media (max-width: 1100px) {
    .top-center { display: none; }
    .topbar { grid-template-columns: minmax(180px,1fr) auto; }
    .top-date { display: none; }
    #hud-time { display: block; margin-bottom: 0; }
    #hud { max-height: 710px; }
}
@media (max-width: 750px) {
    .topbar { padding: .45rem .6rem; gap: .36rem; grid-template-columns: minmax(140px,1fr) auto; }
    .top-status { gap: .4rem; }
    .top-status .signal { font-size: .76rem; }
    .brand small { display: none; }
    .viewport { min-height: 600px; }
    #hud { max-height: none; }
    .hud-events { flex-basis: auto; min-height: 0; }
    .welcome { padding: 1.05rem; }
    .welcome-menu button { padding: .5rem; }
    footer { flex-wrap: wrap; }
    footer > span:nth-child(2) { display: none; }
    .map-note { font-size: .72rem; }
    .catalog-layout, form .grid, .panel-grid, .form-grid { grid-template-columns: 1fr; }
    .catalog-layout img { max-width: 270px; }
    .marker { font-size: .76rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::after, *::before { transition: none !important; }
}

.character-card { display: grid; grid-template-columns: 80px minmax(0,1fr); gap: 1rem; align-items: start; }
.character-card canvas { border-radius: .6rem; background: #e5edcf; outline: 1px solid #aebf94; }
.character-card .facts { min-width: 0; overflow-wrap: anywhere; }
.lesson-example { margin-block: 1rem; }
.lesson-example h4 { margin: 0; }
.unread-event { border-inline-start: 3px solid #91af6f; }
.welcome-note a { color: inherit; text-underline-offset: .2em; }
.hud-nav [hidden] { display: none; }
@media (max-height: 760px) {
  .welcome-menu { row-gap: .4rem; }
  .welcome-note { margin-bottom: .4rem; }
}
@media (max-width: 540px) {
  .character-card { grid-template-columns: 64px minmax(0,1fr); gap: .7rem; }
  .character-card canvas { width: 64px; height: auto; }
}

