/* The town: a full-height 3D stage with the HUD laid over it. */
.town-stage {
    position: relative;
    height: calc(100vh - 3.25rem - 1.5rem);
    height: calc(100dvh - 3.25rem - 1.5rem);
    min-height: 480px;
    border-radius: 16px;
    overflow: hidden;
    background: #9ddcff;
    box-shadow: 0 6px 24px rgba(20, 40, 80, .18);
}

.site-main:has(.town-stage) {
    max-width: none;
    padding: .75rem;
}

.town-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.town-loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-weight: 700;
    color: #1d4b7a;
}

.town-hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    font-size: .84rem;
    line-height: 1.35;
    color: #2a3442;
}

.town-hud > * {
    pointer-events: auto;
}

.town-hud [hidden] {
    display: none !important;
}

.town-hud h2 {
    margin: .7rem 0 .3rem;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #1d5fd1;
}

.town-hud h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: .6rem 0 .25rem;
    font-size: .78rem;
    font-weight: 800;
    color: #3b2a6b;
}

.town-hud h2:first-child,
.town-hud .town-x + h2 {
    margin-top: 0;
}

.town-hud p {
    margin: 0 0 .4rem;
}

.town-hud button {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.town-hud button:disabled {
    cursor: not-allowed;
}

.town-small {
    font-size: .76rem;
    color: #55606f;
}

.town-small u {
    color: #b3470c;
    text-decoration: none;
}

.town-hud .bad {
    color: #b32121;
}

.town-hud .good {
    color: #1c7a3d;
}

/* ---------- top bar ---------- */
.town-top {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px 12px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100% - 560px);
    padding: 5px 12px;
    background: rgba(255, 255, 255, .95);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(20, 40, 80, .22);
    white-space: nowrap;
}

.town-name {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.town-name b {
    color: #3b2a6b;
    font-size: .95rem;
}

.town-name span,
.town-clock span {
    font-size: .7rem;
    font-weight: 700;
    color: #1d5fd1;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.town-res b {
    font-variant-numeric: tabular-nums;
}

.town-res i {
    font-style: normal;
    font-size: .74rem;
    color: #6b7482;
}

.town-res.warn b {
    color: #b32121;
}

.town-clock {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.town-speed {
    display: flex;
    gap: 2px;
}

.town-speed button {
    min-width: 30px;
    padding: 3px 6px;
    border: 2px solid #c9d2e0;
    border-radius: 7px;
    background: #f1f4f9;
    font-weight: 700;
}

.town-speed button.on {
    border-color: #1d5fd1;
    background: #1d5fd1;
    color: #fff;
}

/* ---------- left: tools and designer ---------- */
.town-left {
    position: absolute;
    top: 10px;
    left: 10px;
    bottom: 10px;
    width: 232px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.town-left > * {
    pointer-events: auto;
}

.town-tools,
.town-design,
.town-right {
    padding: 10px;
    background: rgba(255, 255, 255, .95);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(20, 40, 80, .22);
    overflow-y: auto;
    scrollbar-width: thin;
}

.town-tools {
    flex: 0 1 auto;
    min-height: 120px;
}

.town-design {
    flex: 0 0 auto;
    max-height: 58%;
    border: 2px solid #1d5fd1;
}

.town-tools button {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    margin-bottom: 2px;
    padding: 3px 7px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: #f1f4f9;
    font-weight: 600;
    text-align: left;
}

.town-tools button span:nth-child(2) {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.town-tools button i {
    font-style: normal;
    font-size: .72rem;
    color: #55606f;
    white-space: nowrap;
}

.town-tools button:hover {
    background: #e2eaf7;
}

.town-tools button.on {
    border-color: #1d5fd1;
    background: #dfeaff;
}

/* Christmas mode, the switch under Look & select */
.town-tools button.town-xmas .town-swatch { background: none; border: 0; font-size: 14px; line-height: 15px; text-align: center; }
.town-tools button.town-xmas.on { border-color: #c8102e; background: linear-gradient(90deg, #ffecef, #e8f8ee); }
.town-tools button.town-xmas.on i { color: #c8102e; font-weight: 800; }

.town-tools button.locked {
    color: #7b8492;
    background: #f6f7f9;
}

.town-tools button.locked .town-swatch {
    opacity: .4;
}

.town-swatch {
    flex: none;
    width: 15px;
    height: 15px;
    border-radius: 4px;
    border: 2px solid rgba(0, 0, 0, .28);
}

.town-swatch.round {
    border-radius: 50%;
}

.town-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.town-opt > label {
    flex: none;
    width: 58px;
    font-size: .74rem;
    font-weight: 700;
    color: #55606f;
}

.town-opt select {
    flex: 1;
    min-width: 0;
    padding: 2px 4px;
    font: inherit;
    border: 2px solid #c9d2e0;
    border-radius: 7px;
    background: #fff;
}

.town-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.town-chips button {
    padding: 1px 8px;
    border: 2px solid #c9d2e0;
    border-radius: 999px;
    background: #fff;
    font-weight: 600;
}

.town-chips button.on {
    border-color: #1d5fd1;
    background: #1d5fd1;
    color: #fff;
}

.town-chips.mini {
    display: inline-flex;
    margin-left: 6px;
    text-transform: none;
    letter-spacing: 0;
    font-size: .72rem;
}

.town-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.town-dot {
    width: 19px;
    height: 19px;
    padding: 0;
    border: 2px solid rgba(0, 0, 0, .25);
    border-radius: 50%;
}

.town-dot.on {
    border-color: #1a2233;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1d5fd1;
}

.town-cost {
    margin-top: .5rem !important;
    padding: 4px 8px;
    border-radius: 8px;
    background: #fff4d6;
}

.town-hud kbd {
    padding: 0 4px;
    border: 1px solid #aab3c2;
    border-bottom-width: 2px;
    border-radius: 4px;
    background: #fff;
    font: inherit;
    font-size: .72rem;
    font-weight: 700;
}

.town-link {
    padding: 0;
    border: 0;
    background: none;
    color: #1d5fd1 !important;
    font-weight: 700 !important;
    text-align: left;
}

.town-link:hover {
    text-decoration: underline;
}

.town-link small {
    display: block;
    font-weight: 400;
    color: #55606f;
}

h2 .town-link {
    margin-left: 6px;
    font-size: .7rem;
    text-transform: none;
    letter-spacing: 0;
}

/* ---------- right: inspector and tabs ---------- */
.town-right {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 300px;
    max-height: calc(100% - 20px);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.town-inspect {
    position: relative;
    flex: 0 0 auto;
    max-height: 44vh;
    padding: 10px;
    overflow-y: auto;
    scrollbar-width: thin;
    background: #fffaf0;
    border-bottom: 2px solid #ffd23f;
}

.town-x {
    position: absolute;
    top: 4px;
    right: 6px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    background: none;
    font-size: 1.1rem;
    line-height: 1;
}

.town-x:hover {
    background: #f0e3bf;
}

.town-tabs {
    display: flex;
    flex: none;
    background: #3b2a6b;
}

.town-tabs button {
    flex: 1;
    padding: 6px 0;
    border: 0;
    background: none;
    color: #d9d0f2;
    font-size: .78rem;
    font-weight: 700;
}

.town-tabs button:hover {
    color: #fff;
}

.town-tabs button.on {
    background: #fff;
    color: #3b2a6b;
    border-radius: 8px 8px 0 0;
}

.town-pane {
    flex: 0 1 auto;
    min-height: 120px;
    padding: 10px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.town-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: .4rem 0;
}

.town-btns button,
.town-event button,
.town-dialog button {
    padding: 3px 10px;
    border: 2px solid #1d5fd1;
    border-radius: 8px;
    background: #fff;
    color: #1d5fd1;
    font-weight: 700;
}

.town-btns button:hover:not(:disabled),
.town-event button:hover:not(:disabled),
.town-dialog button:hover:not(:disabled) {
    background: #dfeaff;
}

.town-btns button.on {
    background: #1d5fd1;
    color: #fff;
}

.town-btns button.danger {
    border-color: #c2470a;
    color: #c2470a;
}

.town-btns button.danger[data-armed] {
    background: #c2470a;
    color: #fff;
}

.town-hud button:disabled {
    border-color: #c5ccd8;
    background: #eceff4;
    color: #7b8492;
}

.town-bar {
    height: 8px;
    margin: 2px 0 6px;
    background: #dfe6ee;
    border-radius: 4px;
    overflow: hidden;
}

.town-bar div {
    height: 100%;
    background: linear-gradient(90deg, #ff8a3d, #ffd23f);
    transition: width .3s;
}

.town-bar.red div {
    background: #d9534f;
}

.town-bar.blue div {
    background: linear-gradient(90deg, #4aa8f0, #63cfa4);
}

.town-goal {
    margin-bottom: .5rem;
    padding: 6px 9px;
    border-radius: 9px;
    background: #fff4d6;
    border-left: 4px solid #ffb800;
}

.town-goal b {
    display: block;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #8a5a00;
}

.town-goal i {
    display: block;
    font-size: .74rem;
    color: #6b5a2a;
}

.town-notes,
.town-diary,
.town-why {
    margin: 0 0 .5rem;
    padding: 0;
    list-style: none;
}

.town-notes li {
    padding: 2px 0 2px 14px;
    position: relative;
}

.town-notes li::before {
    content: "•";
    position: absolute;
    left: 2px;
}

.town-diary li {
    padding: 3px 0;
    border-bottom: 1px solid #e6eaf0;
    font-size: .78rem;
}

.town-diary li i {
    font-style: normal;
    font-size: .68rem;
    color: #7b8492;
    margin-right: 4px;
}

.town-diary li.tip {
    color: #55606f;
}

.town-why li {
    display: flex;
    justify-content: space-between;
    font-size: .76rem;
    color: #3d4856;
}

.town-row {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    margin-bottom: 2px;
    padding: 2px 6px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: #f4f6fa;
    text-align: left;
}

.town-row:hover {
    background: #e2eaf7;
}

.town-row.on {
    border-color: #ffb800;
    background: #fff4d6;
}

.town-row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.town-row-main small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .72rem;
    color: #55606f;
}

.town-line {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 4px;
}

.town-line .grow,
.town-hud .grow {
    flex: 1;
    min-width: 0;
}

.town-step {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: none;
}

.town-step b {
    min-width: 30px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.town-step button,
.town-mini {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 2px solid #1d5fd1;
    border-radius: 7px;
    background: #fff;
    color: #1d5fd1 !important;
    font-weight: 800 !important;
    line-height: 1;
}

.town-step button:disabled {
    color: #7b8492 !important;
}

.town-mini {
    border-color: #c9d2e0;
    filter: grayscale(1);
}

.town-mini.on {
    border-color: #ffb800;
    background: #fff4d6;
    filter: none;
}

.town-check {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 4px 0 8px;
    font-size: .78rem;
    cursor: pointer;
}

.town-team {
    margin-bottom: 8px;
    padding: 6px 8px;
    border-left: 5px solid #ffc928;
    border-radius: 8px;
    background: #f4f6fa;
}

.town-team .town-check {
    margin-bottom: 0;
}

.town-site {
    margin-bottom: 4px;
}

.town-pill {
    display: inline-block;
    padding: 0 7px;
    border-radius: 999px;
    background: #fff4d6;
    color: #6b4a00;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: 0;
    white-space: nowrap;
}

.town-tech {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0 6px;
    width: 100%;
    margin-bottom: 4px;
    padding: 5px 8px;
    border: 2px solid #c9d2e0;
    border-radius: 9px;
    background: #fff;
    text-align: left;
}

.town-tech em,
.town-tech small {
    grid-column: 1 / -1;
    font-size: .74rem;
}

.town-tech em {
    color: #6b7482;
}

.town-tech small {
    color: #2a3442;
}

.town-tech.ready {
    border-color: #2e9e57;
    background: #eafaf0;
}

.town-tech.ready:hover {
    background: #d5f5e0;
}

.town-tech.known {
    border-color: #b8a8e8 !important;
    background: #f1ecff !important;
    color: #3b2a6b !important;
    cursor: default !important;
}

.town-tech.locked {
    opacity: .62;
}

.town-event {
    margin-bottom: 6px;
    padding: 6px 8px;
    border-radius: 9px;
    background: #f4f6fa;
}

.town-event.off b {
    color: #55606f;
}

/* ---------- messages ---------- */
.town-log {
    position: absolute;
    left: 254px;
    bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: flex-start;
    max-width: min(30rem, calc(100% - 580px));
    pointer-events: none;
}

.town-log div {
    padding: 2px 10px;
    border-radius: 9px;
    background: rgba(255, 255, 255, .9);
    color: #2a3442;
    font-size: .78rem;
    box-shadow: 0 1px 4px rgba(20, 40, 80, .18);
}

.town-log div.good {
    border-left: 4px solid #2e9e57;
}

.town-log div.bad {
    border-left: 4px solid #d9534f;
}

.town-log div.tip {
    border-left: 4px solid #ffb800;
}

.town-toast {
    position: absolute;
    left: 50%;
    top: 64px;
    transform: translateX(-50%);
    max-width: min(32rem, calc(100% - 24px));
    padding: 6px 16px;
    border-radius: 999px;
    background: #3b2a6b;
    color: #fff;
    font-weight: 700;
    text-align: center;
    opacity: 0;
    transition: opacity .25s;
    pointer-events: none;
}

.town-toast.show {
    opacity: 1;
}

.town-tip,
.town-label {
    position: absolute;
    padding: 1px 8px;
    border-radius: 7px;
    background: rgba(30, 24, 60, .88);
    color: #fff;
    font-size: .76rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}

.town-label {
    transform: translate(-50%, -100%);
    background: #ffd23f;
    color: #3b2a6b;
    font-weight: 800;
}

.town-modal {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(20, 16, 44, .45);
}

.town-dialog {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: min(26rem, calc(100% - 32px));
    padding: 18px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
    font-size: .92rem;
}

.town-dialog h2 {
    font-size: 1.05rem;
    letter-spacing: 0;
    text-transform: none;
    color: #3b2a6b;
}

.town-dialog button {
    padding: 6px 12px;
    text-align: left;
}

@media (max-width: 980px) {
    .town-left {
        width: 170px;
    }

    .town-right {
        width: 236px;
    }

    .town-top {
        max-width: calc(100% - 436px);
        font-size: .76rem;
        gap: 2px 8px;
    }

    .town-log {
        left: 190px;
        max-width: calc(100% - 440px);
    }
}

@media (max-width: 700px) {
    .town-top {
        position: static;
        transform: none;
        max-width: none;
        margin: 6px;
        border-radius: 10px;
    }

    .town-left {
        top: auto;
        height: 42%;
        width: 150px;
        font-size: .74rem;
    }

    .town-right {
        top: auto;
        bottom: 10px;
        max-height: 46%;
        width: calc(100% - 180px);
        font-size: .76rem;
    }

    .town-log {
        display: none;
    }

    .town-toast {
        top: auto;
        bottom: 48%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .town-toast, .town-bar div { transition: none; }
}

/* ---------- sound ---------- */
.town-sndbtn {
    width: 32px;
    height: 30px;
    padding: 0;
    border: 2px solid #c9d2e0;
    border-radius: 7px;
    background: #f1f4f9;
    font-size: 1rem;
    line-height: 1;
}

.town-sndbtn:hover {
    background: #e2eaf7;
}

/* the desktop (itch.io) build's full-screen toggle, beside the sound button (js/desktop.js draws the icon) */
.town-fullbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #3b4a66;
}

.town-fullbtn svg {
    width: 18px;
    height: 18px;
}

.town-fullbtn.on {
    color: #1d5fd1;
}

.town-sound {
    position: absolute;
    top: 66px;
    left: 50%;
    transform: translateX(-50%);
    width: 270px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, .97);
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(20, 40, 80, .3);
    z-index: 5;
}

.town-sound input[type=range] {
    width: 100%;
    margin: 0 0 6px;
    accent-color: #1d5fd1;
}

.town-sound select {
    flex: 1;
    min-width: 0;
    padding: 2px 4px;
    font: inherit;
    border: 2px solid #c9d2e0;
    border-radius: 7px;
    background: #fff;
}

.town-tog {
    padding: 1px 10px;
    border: 2px solid #c9d2e0;
    border-radius: 999px;
    background: #fff;
    font-weight: 700 !important;
    font-size: .76rem;
}

.town-tog.on {
    border-color: #1d5fd1;
    background: #1d5fd1;
    color: #fff !important;
}

/* ---------- be the cat ---------- */
.town-becat-panel {
    position: absolute;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    width: min(37rem, calc(100% - 24px));
    padding: 8px 12px;
    border-radius: 14px;
    background: rgba(30, 22, 58, .9);
    color: #fff;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
    text-align: center;
    z-index: 4;
}

.town-becat-panel .town-small {
    color: #d9d0f2;
    margin: 4px 0 0;
}

.town-becat-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: .92rem;
}

.town-becat-title b {
    color: #ffd23f;
}

.town-becat-title button {
    padding: 2px 10px;
    border: 2px solid #ffd23f;
    border-radius: 999px;
    background: transparent;
    color: #ffd23f !important;
    font-weight: 700;
    font-size: .78rem;
}

.town-becat-title button.stop {
    border-color: #ff9d7a;
    color: #ff9d7a !important;
}

.town-becat-moves {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 6px;
}

.town-becat-moves button {
    position: relative;
    width: 44px;
    height: 40px;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, .25);
    border-radius: 10px;
    background: rgba(255, 255, 255, .1);
    font-size: 1.25rem;
    line-height: 1;
}

.town-becat-moves button:hover {
    background: rgba(255, 210, 63, .25);
    border-color: #ffd23f;
}

.town-becat-moves i {
    position: absolute;
    right: 3px;
    bottom: 1px;
    font-style: normal;
    font-size: .62rem;
    font-weight: 800;
    color: #ffd23f;
}

.town-becat {
    border-color: #ff8a3d !important;
    background: #ff8a3d !important;
    color: #fff !important;
}

/* ---------- welcome banner ---------- */
.town-welcome {
    position: absolute;
    left: 50%;
    top: 74px;
    transform: translate(-50%, -12px) scale(.96);
    width: min(30rem, calc(100% - 24px));
    padding: 10px 16px 12px;
    border-radius: 16px;
    border: 3px solid #ffd23f;
    background: linear-gradient(135deg, #3b2a6b, #5a3fa0);
    color: #fff;
    text-align: center;
    box-shadow: 0 8px 28px rgba(30, 20, 70, .45);
    opacity: 0;
    transition: opacity .35s, transform .35s;
    z-index: 6;
}

.town-welcome.show {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
}

.town-welcome-flag {
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #ffd23f;
}

.town-welcome-more {
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(255, 210, 63, .2);
    letter-spacing: 0;
}

.town-welcome-title {
    margin: 2px 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.town-welcome-title b {
    color: #ffd23f;
}

.town-welcome-sub {
    font-size: .8rem;
    color: #e4dcff;
}

.town-welcome-btns {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
}

.town-welcome-btns button {
    padding: 3px 12px;
    border: 2px solid #ffd23f;
    border-radius: 999px;
    background: #ffd23f;
    color: #3b2a6b !important;
    font-weight: 800 !important;
}

.town-welcome-btns button.quiet {
    background: transparent;
    color: #ffd23f !important;
}

@media (prefers-reduced-motion: reduce) {
    .town-welcome { transition: none; }
}

/* ---------- the town map (js/town/map.js): a parchment map laid on a starry night-blue table ---------- */
.town-tools button.town-mapbtn .town-swatch { background: none; border: 0; font-size: 14px; line-height: 15px; text-align: center; }
.town-tools button.town-mapbtn { background: linear-gradient(90deg, #fbf1d6, #f1f4f9); }
.town-tools button.town-mapbtn:hover { border-color: #b98a55; background: #fbecc4; }
.town-tools button.town-mapbtn i { font-weight: 800; color: #8a6237; }
.town-tools button.town-backupbtn { background: linear-gradient(90deg, #e6f4ea, #f1f4f9); }
.town-tools button.town-backupbtn:hover { border-color: #3f8f5a; background: #d7efdf; }
.town-tools button.town-backupbtn i { color: #2f7a48; }

/* the Backups dialog (ui.js showBackup) */
.town-dialog.town-backup { width: min(30rem, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto; }
.town-backup h3 { margin: .5rem 0 0; }
.town-backup p { margin: 0; }
.town-warn {
    padding: 8px 10px;
    border: 2px solid #e0a325;
    border-radius: 10px;
    background: #fff6dc;
    color: #5c3d00;
}
.town-hud .town-filebtn {
    display: block;
    padding: 6px 12px;
    border: 2px solid #1d5fd1;
    border-radius: 8px;
    background: #fff;
    color: #1d5fd1;
    font-weight: 700;
    cursor: pointer;
}
.town-hud .town-filebtn:hover,
.town-hud .town-filebtn:focus-within { background: #dfeaff; }
.town-dialog button.town-danger { border-color: #c2470a; background: #c2470a; color: #fff; }
.town-dialog button.town-danger:hover:not(:disabled) { background: #a33a06; }

.tmap {
    --tmap-ink: #4a3523;
    --tmap-paper: #fbf1d6;
    position: fixed;
    inset: 0;
    z-index: 2000;
    overflow: hidden;
    outline: none;
    color: var(--tmap-ink);
    font-family: Georgia, "Palatino Linotype", "Book Antiqua", serif;
    font-size: 14px;
    user-select: none;
    background:
        radial-gradient(1.5px 1.5px at 23px 41px, #fff9 50%, transparent),
        radial-gradient(1px 1px at 97px 13px, #fff8 50%, transparent),
        radial-gradient(1px 1px at 151px 88px, #ffe9a8aa 50%, transparent),
        radial-gradient(1.5px 1.5px at 61px 133px, #fff7 50%, transparent),
        radial-gradient(1px 1px at 183px 161px, #fff8 50%, transparent),
        radial-gradient(ellipse at 50% 40%, #33306a 0%, #1d1b42 55%, #0f0e24 100%);
    background-size: 200px 180px, 200px 180px, 200px 180px, 200px 180px, 200px 180px, 100% 100%;
}

.tmap[hidden] { display: none; }
.tmap.opening .tmap-canvas { animation: tmap-unroll .5s cubic-bezier(.2, .8, .25, 1); }
.tmap.opening { animation: tmap-fade .25s ease-out; }
.tmap.closing { animation: tmap-fade .22s ease-in reverse forwards; }

@keyframes tmap-unroll {
    from { clip-path: inset(0 0 100% 0); transform: scale(.97) translateY(-12px); }
    to { clip-path: inset(0 0 0 0); transform: none; }
}

@keyframes tmap-fade { from { opacity: 0; } to { opacity: 1; } }

.tmap-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    /* a little red paw for a pointer */
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 32 32'%3E%3Cg fill='%23c0392b' stroke='%23fff' stroke-width='1.6'%3E%3Cellipse cx='16' cy='20' rx='7' ry='5.6'/%3E%3Cellipse cx='8.5' cy='12.5' rx='2.6' ry='3.3'/%3E%3Cellipse cx='13' cy='8.5' rx='2.6' ry='3.3'/%3E%3Cellipse cx='19' cy='8.5' rx='2.6' ry='3.3'/%3E%3Cellipse cx='23.5' cy='12.5' rx='2.6' ry='3.3'/%3E%3C/g%3E%3C/svg%3E") 14 14, grab;
}

.tmap.pointing .tmap-canvas { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 32 32'%3E%3Cg fill='%23e8b520' stroke='%234a3523' stroke-width='1.6'%3E%3Cellipse cx='16' cy='20' rx='7' ry='5.6'/%3E%3Cellipse cx='8.5' cy='12.5' rx='2.6' ry='3.3'/%3E%3Cellipse cx='13' cy='8.5' rx='2.6' ry='3.3'/%3E%3Cellipse cx='19' cy='8.5' rx='2.6' ry='3.3'/%3E%3Cellipse cx='23.5' cy='12.5' rx='2.6' ry='3.3'/%3E%3C/g%3E%3C/svg%3E") 14 14, pointer; }
.tmap.dragging .tmap-canvas { cursor: grabbing; }

.tmap button {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

/* the bar along the top, with cat ears */
.tmap-bar {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 24px);
    padding: 7px 8px 7px 16px;
    border: 2px solid var(--tmap-ink);
    border-radius: 18px;
    background: linear-gradient(#fdf6e2, #efddb3);
    box-shadow: 0 4px 0 rgba(74, 53, 35, .45), 0 12px 30px rgba(0, 0, 0, .45);
    white-space: nowrap;
}

.tmap-ear {
    position: absolute;
    top: -20px;
    left: 34px;
    width: 32px;
    height: 22px;
    background: var(--tmap-ink);
    clip-path: polygon(0 100%, 28% 0, 100% 100%);
    z-index: -1;
}

.tmap-ear::after {
    content: '';
    position: absolute;
    left: 8px;
    bottom: 0;
    width: 15px;
    height: 13px;
    background: #f2b3bf;
    clip-path: polygon(0 100%, 30% 0, 100% 100%);
}

.tmap-ear.r { left: auto; right: 34px; transform: scaleX(-1); }

.tmap-title {
    margin-right: 6px;
    font-size: 15px;
    font-style: italic;
}

.tmap-title b { font-size: 17px; color: #5a2e1a; }

.tmap-btn {
    padding: 5px 12px;
    border: 2px solid var(--tmap-ink);
    border-radius: 999px;
    background: #fff8e6;
    font-weight: 600;
    transition: background .12s, transform .12s;
}

.tmap-btn:hover,
.tmap-btn:focus-visible { background: #ffe7a8; transform: translateY(-1px); }
.tmap-btn.on { background: var(--tmap-ink); color: #fff3d6; }

.tmap-close {
    width: 34px;
    height: 34px;
    border: 2px solid var(--tmap-ink);
    border-radius: 50%;
    background: #c0392b;
    color: #fff !important;
    font-weight: 900;
    line-height: 1;
}

.tmap-close:hover,
.tmap-close:focus-visible { background: #e04a3a; }

.tmap-save { position: relative; }

.tmap-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    display: flex;
    flex-direction: column;
    min-width: 220px;
    padding: 6px;
    border: 2px solid var(--tmap-ink);
    border-radius: 14px;
    background: var(--tmap-paper);
    box-shadow: 0 10px 26px rgba(0, 0, 0, .4);
}

.tmap-menu[hidden] { display: none; }

.tmap-menu button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 6px 10px;
    border: 0;
    border-radius: 9px;
    background: none;
    font-weight: 700;
    text-align: left;
}

.tmap-menu button i { font-size: 12px; font-weight: 400; opacity: .75; }
.tmap-menu button:hover,
.tmap-menu button:focus-visible { background: #ffe7a8; }

/* zoom: two pink toe beans and a ball of yarn on a thread */
.tmap-zoom {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    border: 2px solid var(--tmap-ink);
    border-radius: 999px;
    background: linear-gradient(90deg, #fdf6e2, #efddb3);
    box-shadow: 0 10px 26px rgba(0, 0, 0, .4);
}

.tmap-bean {
    width: 36px;
    height: 32px;
    border: 2px solid #9c4a5e;
    border-radius: 50% 50% 46% 46%;
    background: radial-gradient(circle at 40% 35%, #ffd0db, #f39bb2);
    color: #6b2236 !important;
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
    transition: transform .1s;
}

.tmap-bean:hover,
.tmap-bean:focus-visible { transform: scale(1.1); }
.tmap-bean:active { transform: scale(.94); }

.tmap-track {
    position: relative;
    width: 26px;
    height: 150px;
    cursor: pointer;
    touch-action: none;
}

.tmap-track::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 2px dashed #d9466e;
}

.tmap-thumb {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 22px;
    line-height: 1;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35));
    pointer-events: none;
}

.tmap-where,
.tmap-hint {
    position: absolute;
    bottom: 16px;
    padding: 5px 12px;
    border: 1.5px solid rgba(74, 53, 35, .6);
    border-radius: 999px;
    background: rgba(251, 241, 214, .9);
    font-size: 13px;
    font-style: italic;
    pointer-events: none;
}

.tmap-where { left: 16px; }
.tmap-where[hidden] { display: none; }
.tmap-hint { left: 50%; transform: translateX(-50%); white-space: nowrap; transition: opacity 1s; }
.tmap-hint.gone { opacity: 0; }

.tmap-tip {
    position: absolute;
    padding: 3px 10px;
    border-radius: 8px;
    background: rgba(59, 38, 20, .92);
    color: #fff3d6;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}

.tmap-tip[hidden],
.tmap-card[hidden],
.tmap-busy[hidden] { display: none; }

/* the card for a place you clicked */
.tmap-card {
    position: absolute;
    width: 270px;
    padding: 12px 14px;
    border: 2px solid var(--tmap-ink);
    border-radius: 16px;
    background: linear-gradient(#fdf6e2, #f1e0b8);
    box-shadow: 0 4px 0 rgba(74, 53, 35, .4), 0 14px 30px rgba(0, 0, 0, .45);
    animation: tmap-pop .18s ease-out;
}

.tmap-card::before {
    content: '🐾';
    position: absolute;
    top: -13px;
    left: 14px;
    font-size: 18px;
    transform: rotate(-15deg);
}

.tmap-card h3 { margin: 0 24px 2px 0; font-size: 18px; font-style: italic; color: #5a2e1a; }
.tmap-card-sub { margin-bottom: 6px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; opacity: .75; }
.tmap-card p { margin: 0 0 6px; font-size: 13.5px; line-height: 1.35; }
.tmap-go { margin-top: 4px; }

.tmap-card-x {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    background: rgba(74, 53, 35, .12);
    font-weight: 900;
    line-height: 1;
}

@keyframes tmap-pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }

/* a paw print where you click */
.tmap-paw {
    position: absolute;
    width: 26px;
    height: 26px;
    margin: -13px 0 0 -13px;
    pointer-events: none;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cg fill='%23c0392b'%3E%3Cellipse cx='16' cy='20' rx='7' ry='5.6'/%3E%3Cellipse cx='8.5' cy='12.5' rx='2.6' ry='3.3'/%3E%3Cellipse cx='13' cy='8.5' rx='2.6' ry='3.3'/%3E%3Cellipse cx='19' cy='8.5' rx='2.6' ry='3.3'/%3E%3Cellipse cx='23.5' cy='12.5' rx='2.6' ry='3.3'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
    animation: tmap-paw .9s ease-out forwards;
}

@keyframes tmap-paw {
    0% { opacity: 0; transform: rotate(var(--a)) scale(1.6); }
    15% { opacity: .75; transform: rotate(var(--a)) scale(1); }
    100% { opacity: 0; transform: rotate(var(--a)) scale(1); }
}

/* saving a picture */
.tmap-busy {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(15, 14, 36, .45);
}

.tmap-busy > div {
    padding: 16px 22px;
    border: 2px solid var(--tmap-ink);
    border-radius: 16px;
    background: var(--tmap-paper);
    font-size: 16px;
    font-style: italic;
    text-align: center;
}

.tmap-busy-paws { display: block; margin-bottom: 6px; font-size: 22px; font-style: normal; }
.tmap-busy-paws i { display: inline-block; font-style: normal; opacity: 0; animation: tmap-step 1.2s infinite; }
.tmap-busy-paws i:nth-child(2) { animation-delay: .3s; }
.tmap-busy-paws i:nth-child(3) { animation-delay: .6s; }

@keyframes tmap-step { 0%, 100% { opacity: 0; } 30%, 60% { opacity: 1; } }

@media (max-width: 760px) {
    .tmap-title { display: none; }
    .tmap-btn { padding: 4px 8px; font-size: 12px; }
    .tmap-hint { display: none; }
    .tmap-zoom { right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    .tmap.opening .tmap-canvas, .tmap.opening, .tmap.closing, .tmap-card, .tmap-paw { animation: none; }
}
