:root {
    --parchment: #f4f2ec;
    --parchment-dark: #d5dfe8;
    --ink: #14243a;
    --sea: #264c70;
    --sea-deep: #0f2238;
    --gold: #b8892b;
    --wood: #1a3553;
    --error: #9b2c2c;
    --ok: #2f6b3a;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
    height: 100%;
}

body {
    background: linear-gradient(160deg, var(--sea), var(--sea-deep));
    font-family: Georgia, "Times New Roman", serif;
    color: var(--ink);
}

/* ---------- Login ---------- */

.login-screen {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.card {
    width: 100%;
    max-width: 380px;
    background: var(--parchment);
    border: 2px solid var(--gold);
    border-radius: 8px;
    padding: 28px 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

h1 {
    margin: 0 0 4px;
    font-size: 1.6rem;
    text-align: center;
}

.subtitle {
    margin: 0 0 20px;
    text-align: center;
    font-style: italic;
    opacity: 0.75;
}

label {
    display: block;
    margin: 12px 0 4px;
    font-weight: bold;
}

input,
select {
    width: 100%;
    padding: 10px;
    font-size: 1rem;
    border: 1px solid #8ea6bb;
    border-radius: 4px;
    background: #fdfdfb;
}

button {
    font-family: inherit;
    cursor: pointer;
}

.card button {
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    font-size: 1rem;
    font-weight: bold;
    color: var(--parchment);
    background: var(--sea);
    border: none;
    border-radius: 4px;
}

.card button.secondary {
    margin-top: 10px;
    color: var(--ink);
    background: transparent;
    border: 1px solid #8ea6bb;
    font-weight: normal;
}

.card button:disabled {
    opacity: 0.6;
    cursor: wait;
}

select {
    font-family: inherit;
    color: var(--ink);
}

.hint {
    margin: 6px 0 0;
    font-size: 0.85rem;
    font-style: italic;
    opacity: 0.75;
}

.card .link-btn {
    width: auto;
    display: block;
    margin: 14px auto 0;
    padding: 4px;
    font-size: 0.95rem;
    font-weight: normal;
    color: var(--sea);
    background: transparent;
    text-decoration: underline;
}

#status {
    margin-top: 16px;
    min-height: 1.4em;
    font-size: 0.95rem;
    white-space: pre-wrap;
}

.error {
    color: var(--error);
}

.ok {
    color: var(--ok);
}

/* ---------- Game ---------- */

.game-screen {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 16px;
    background: var(--wood);
    border-bottom: 2px solid var(--gold);
    color: var(--parchment);
    flex-wrap: wrap;
}

.brand {
    font-size: 1.15rem;
    font-weight: bold;
    letter-spacing: 0.02em;
}

.build-tag {
    font-size: 0.75rem;
    opacity: 0.55;
}

.spacer {
    flex: 1;
}

.player-name {
    font-style: italic;
}

.hub-status {
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    opacity: 0.9;
}

.hub-status::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #c9a24a;
}

.hub-status[data-state="online"]::before {
    background: #5fb36b;
}

.hub-status[data-state="offline"]::before {
    background: #c75b4a;
}

.topbar-btn {
    padding: 6px 12px;
    color: var(--parchment);
    background: transparent;
    border: 1px solid var(--gold);
    border-radius: 4px;
}

.map-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#mapCanvas {
    display: block;
    touch-action: none;
    cursor: grab;
}

#mapCanvas:active {
    cursor: grabbing;
}

.map-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.map-controls button {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    line-height: 1;
    color: var(--ink);
    background: var(--parchment);
    border: 1px solid var(--gold);
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.hover-info {
    position: absolute;
    left: 12px;
    bottom: 12px;
    padding: 4px 10px;
    font-size: 0.9rem;
    background: rgba(244, 242, 236, 0.92);
    border: 1px solid var(--gold);
    border-radius: 4px;
    pointer-events: none;
}

.hover-info:empty {
    display: none;
}

/* game calendar in the top bar */
.game-date {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 3px 14px 3px 6px;
    border: 1px solid rgba(184, 137, 43, 0.6);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.18);
    cursor: default;
}

.game-date[hidden] {
    display: none;
}

.game-date-season {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex: none;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.15);
}

.game-date[data-season="spring"] .game-date-season {
    background: radial-gradient(circle at 50% 40%, #c8e39a 0 35%, #6f9a3b 36%);
}

.game-date[data-season="summer"] .game-date-season {
    background: radial-gradient(circle, #ffe08a 0 38%, #e8a23a 39% 60%, #b8892b 61%);
}

.game-date[data-season="autumn"] .game-date-season {
    background: radial-gradient(circle at 45% 40%, #f0b25a 0 30%, #b8562a 31%);
}

.game-date[data-season="winter"] .game-date-season {
    background: radial-gradient(circle at 45% 40%, #ffffff 0 30%, #9fb8cc 31%);
}

.game-date-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.game-date-day {
    font-weight: bold;
    font-size: 0.98rem;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.game-date-sub {
    font-size: 0.72rem;
    font-style: italic;
    opacity: 0.75;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .topbar {
        gap: 10px;
        padding: 8px 12px;
    }

    .brand {
        display: none;
    }
}

/* ---------- Market window (Patrician-style) ---------- */

.market-backdrop {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: rgba(8, 20, 34, 0.55);
    z-index: 10;
}

.market {
    width: 100%;
    max-width: 820px;
    height: 100%;
    max-height: 960px;
    display: flex;
    flex-direction: column;
    background: var(--parchment);
    border: 6px solid var(--wood);
    outline: 2px solid var(--gold);
    outline-offset: -9px;
    border-radius: 6px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.market-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px 10px;
    border-bottom: 2px solid var(--gold);
    background: linear-gradient(180deg, #dde6ed, var(--parchment));
}

.market-title {
    margin: 0;
    font-size: 1.45rem;
}

.market-sub {
    font-style: italic;
    opacity: 0.75;
    font-size: 0.9rem;
}

.market-close {
    width: 34px;
    height: 34px;
    flex: none;
    font-size: 1rem;
    color: var(--parchment);
    background: var(--wood);
    border: 1px solid var(--gold);
    border-radius: 4px;
}

.market-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 18px;
}

.storage-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.storage-tab {
    padding: 5px 12px;
    font-size: 0.92rem;
    color: var(--ink);
    background: #fdfdfb;
    border: 1px solid #8ea6bb;
    border-radius: 4px;
}

.storage-tab.active {
    color: var(--parchment);
    background: var(--sea);
    border-color: var(--sea);
}

.storage-info {
    display: flex;
    gap: 14px;
    font-size: 0.95rem;
}

.storage-info .capacity.over {
    color: var(--error);
    font-weight: bold;
}

.market-table-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    margin: 0 18px;
    border: 1px solid #bccbd8;
    border-radius: 4px;
    background: #f9f8f4;
}

.market-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.market-table th {
    position: sticky;
    top: 0;
    padding: 7px 10px;
    background: #d5dfe8;
    border-bottom: 1px solid #9db0c2;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    white-space: nowrap;
    z-index: 1;
}

.market-table td {
    padding: 4px 10px;
    border-bottom: 1px solid #e0e8ee;
    white-space: nowrap;
}

.market-table tbody tr:nth-child(even) {
    background: rgba(213, 223, 232, 0.25);
}

.market-table tbody tr:hover {
    background: rgba(184, 137, 43, 0.15);
}

.market-table th.col-num,
.market-table td.col-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.market-table .col-good {
    font-weight: bold;
}

.label-short {
    display: none;
}

.market-table .col-actions {
    text-align: center;
}

.market-table .muted {
    opacity: 0.45;
}

.market-table .price {
    font-weight: bold;
    transition: background-color 0.4s;
}

.market-table .price.flash {
    background: rgba(232, 195, 90, 0.45);
}

.market-table .price.profit {
    color: var(--ok);
}

.market-table .price.loss {
    color: var(--error);
}

.trend {
    margin-left: 4px;
    font-size: 0.7rem;
}

.trend.up {
    color: #8a2a1e;
}

.trend.down {
    color: #2f6b3a;
}

.trade-btn {
    min-width: 46px;
    margin: 0 2px;
    padding: 3px 8px;
    font-size: 0.85rem;
    font-weight: bold;
    border-radius: 3px;
    border: 1px solid transparent;
}

.trade-btn.buy {
    color: var(--parchment);
    background: var(--sea);
}

.trade-btn.sell {
    color: var(--parchment);
    background: #7a4a1e;
}

.trade-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.market-transfer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 18px 0;
}

.transfer-label {
    font-weight: bold;
}

/* Office → Seeadler ⇄ */
.xfer-route {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 2px 2px 10px;
    background: #fdfdfb;
    border: 1px solid #8ea6bb;
    border-radius: 4px;
    font-size: 0.92rem;
}

.xfer-end {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: bold;
}

.xfer-arrow {
    color: var(--gold);
    font-weight: bold;
}

.xfer-swap {
    width: 30px;
    height: 28px;
    font-size: 1rem;
    color: var(--ink);
    background: rgba(232, 195, 90, 0.25);
    border: 1px solid #8ea6bb;
    border-radius: 3px;
    cursor: pointer;
}

.xfer-swap:hover {
    background: rgba(232, 195, 90, 0.5);
}

.transfer-input {
    width: 120px;
    padding: 5px 8px;
}

.transfer-input.over {
    border-color: var(--error);
    color: var(--error);
}

.xfer-quick {
    display: flex;
    gap: 4px;
}

.xfer-amount {
    display: flex;
    align-items: center;
    gap: 8px;
}

.transfer-toggle {
    display: none;
}

.xfer-chip {
    padding: 4px 8px;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--ink);
    background: #fdfdfb;
    border: 1px solid #8ea6bb;
    border-radius: 4px;
    cursor: pointer;
}

.xfer-chip:hover {
    background: rgba(232, 195, 90, 0.35);
}

.xfer-chip:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.transfer-btn {
    padding: 5px 12px;
    font-size: 0.9rem;
    color: var(--parchment);
    background: var(--wood);
    border: 1px solid var(--gold);
    border-radius: 4px;
}

.transfer-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* gold in the window header */
.market-titles {
    flex: 1;
    min-width: 0;
}

.purse {
    display: flex;
    gap: 6px;
}

.purse-entry {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 3px 10px;
    border: 1px solid transparent;
    border-radius: 4px;
}

.purse-entry.paying {
    background: rgba(253, 253, 251, 0.7);
    border-color: #8ea6bb;
}

.purse-label {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem;
    font-style: italic;
    opacity: 0.75;
}

.purse-gold {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 1.1rem;
    font-weight: bold;
    color: #7a5a12;
    font-variant-numeric: tabular-nums;
}

.purse-gold::before {
    content: "";
    width: 1.3em;
    height: 1.3em;
    background: url("/game/img/goods/Gold.webp") center / contain no-repeat;
}

.market-status {
    min-height: 2.4em;
    padding: 8px 18px 12px;
    font-size: 0.92rem;
    font-style: italic;
}

.market-status.ok {
    color: var(--ok);
}

.market-status.error {
    color: var(--error);
}

.map-toast {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    padding: 8px 14px;
    background: rgba(244, 242, 236, 0.96);
    border: 1px solid var(--gold);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    font-size: 0.92rem;
    z-index: 5;
}

@media (max-width: 640px) {
    .market-backdrop {
        padding: 0;
    }

    .market {
        max-width: none;
        height: 100%;
        border-radius: 0;
    }

    .market-head,
    .market-bar,
    .market-transfer,
    .market-status {
        padding-left: 12px;
        padding-right: 12px;
    }

    .market-table-wrap {
        margin: 0 12px;
    }

    .market-head {
        gap: 8px;
    }

    .market-title {
        font-size: 1.25rem;
    }

    .purse-entry {
        padding: 2px 6px;
    }

    .purse-label {
        max-width: 72px;
    }

    .purse-gold {
        font-size: 0.98rem;
    }

    .market-table .col-avg {
        display: none;
    }

    .market-table {
        font-size: 0.85rem;
    }

    .market-table td,
    .market-table th {
        padding: 5px 4px;
    }

    .market-table th {
        letter-spacing: 0;
    }

    .label-long {
        display: none;
    }

    .label-short {
        display: inline;
    }

    .trade-btn {
        min-width: 0;
        margin: 0 1px;
        padding: 4px 6px;
        font-size: 0.78rem;
    }

    .trend {
        display: none;
    }
}

/* ---------- Market | Production tabs ---------- */

.view-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 18px 0;
    border-bottom: 2px solid var(--gold);
    background: var(--parchment);
}

.view-tab {
    padding: 7px 18px 6px;
    margin-bottom: -2px;
    font-family: inherit;
    font-size: 0.98rem;
    color: #44607a;
    background: #dae3eb;
    border: 2px solid #bccbd8;
    border-bottom-color: var(--gold);
    border-radius: 6px 6px 0 0;
    cursor: pointer;
}

.view-tab.active {
    color: var(--ink);
    font-weight: bold;
    background: var(--parchment);
    border-color: var(--gold);
    border-bottom-color: var(--parchment);
}

.market-view,
.production-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.production-view {
    overflow: auto;
    padding: 12px 18px;
    gap: 10px;
}

.production-empty {
    margin: 24px 0;
    text-align: center;
    color: #44607a;
    font-style: italic;
}

.production-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 0.9rem;
    color: #44607a;
}

.building-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 10px;
}

.building-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    background: #f9f8f4;
    border: 1px solid #bccbd8;
    border-left: 5px solid #52718c;
    border-radius: 4px;
}

.building-card.mine {
    border-left-color: #264c70;
}

.building-card.other {
    border-left-color: #a8322a;
}

.building-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.building-name {
    margin: 0;
    font-size: 1.08rem;
}

.building-level {
    margin-left: 8px;
    font-size: 0.82rem;
    font-weight: normal;
    color: #44607a;
}

.owner-badge {
    flex-shrink: 0;
    padding: 2px 8px;
    font-size: 0.78rem;
    color: #fdfdfb;
    background: #52718c;
    border-radius: 10px;
}

.owner-badge.mine {
    background: #264c70;
}

.owner-badge.other {
    background: #a8322a;
}

.building-workers {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
}

.workers-label {
    flex-shrink: 0;
    min-width: 110px;
}

.workers-bar {
    flex: 1;
    height: 8px;
    background: #d5dfe8;
    border-radius: 4px;
    overflow: hidden;
}

.workers-fill {
    height: 100%;
    background: linear-gradient(90deg, #b8892b, #e8c35a);
}

.building-flow {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 8px;
}

.flow-arrow {
    align-self: center;
    font-size: 1.2rem;
    color: var(--gold);
}

.goods-title {
    margin-bottom: 2px;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #44607a;
}

.goods-item {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.9rem;
}

.goods-list.consumed .goods-amount {
    color: var(--error);
}

.goods-list.produced .goods-amount {
    color: var(--ok);
}

.building-costs {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 10px;
    margin: 0;
    padding-top: 6px;
    font-size: 0.84rem;
    border-top: 1px dashed #bccbd8;
}

.building-costs dt {
    color: #44607a;
}

.building-costs dd {
    margin: 0;
}

@media (max-width: 640px) {
    .view-tabs,
    .production-view {
        padding-left: 12px;
        padding-right: 12px;
    }

    .building-list {
        grid-template-columns: 1fr;
    }
}

.goods-item.muted {
    color: #6f8aa3;
}

/* ---------- Fleet panel and sailing by map ---------- */

.fleet {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 4;
    width: 250px;
    max-height: calc(100% - 70px);
    display: flex;
    flex-direction: column;
    background: rgba(244, 242, 236, 0.95);
    border: 2px solid var(--wood);
    outline: 1px solid var(--gold);
    outline-offset: -4px;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.fleet-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-family: inherit;
    color: var(--ink);
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
}

.fleet-title {
    flex: 1;
    font-weight: bold;
    font-size: 1rem;
}

.fleet-count {
    min-width: 22px;
    padding: 1px 7px;
    font-size: 0.8rem;
    text-align: center;
    color: var(--parchment);
    background: var(--sea);
    border-radius: 10px;
}

.fleet-chevron {
    color: #44607a;
}

.fleet-list {
    margin: 0;
    padding: 0 6px 6px;
    list-style: none;
    overflow-y: auto;
}

.fleet-ship {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-top: 1px solid #ccd8e2;
    border-radius: 4px;
    cursor: pointer;
}

.fleet-ship:hover {
    background: #f9f8f4;
}

.fleet-ship.selected {
    background: #d9e5ee;
    box-shadow: inset 3px 0 0 var(--gold);
}

.fleet-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.fleet-name {
    font-weight: bold;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fleet-where {
    font-size: 0.8rem;
    color: #44607a;
}

.fleet-ship.at-sea .fleet-where {
    color: var(--sea);
    font-style: italic;
}

.fleet-wave {
    color: var(--sea);
}

.fleet-sail {
    padding: 4px 12px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--parchment);
    background: var(--sea);
    border: 1px solid var(--gold);
    border-radius: 4px;
    cursor: pointer;
}

.fleet-sail:hover {
    background: #1f3f5e;
}

.sail-banner {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 14px;
    width: max-content;
    max-width: min(640px, calc(100% - 32px));
    padding: 10px 16px;
    font-size: 0.95rem;
    color: var(--parchment);
    background: rgba(15, 34, 56, 0.94);
    border: 2px solid var(--gold);
    border-radius: 6px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
}

.sail-banner strong {
    color: #e8c35a;
}

.sail-banner-actions {
    display: flex;
    gap: 8px;
}

.banner-btn {
    padding: 5px 14px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--ink);
    background: #e8c35a;
    border: 1px solid #e8c35a;
    border-radius: 4px;
    cursor: pointer;
}

.banner-btn.ghost {
    font-weight: normal;
    color: var(--parchment);
    background: transparent;
    border-color: rgba(244, 242, 236, 0.5);
}

.banner-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

@media (max-width: 640px) {
    .fleet {
        width: 200px;
    }

    .sail-banner {
        top: auto;
        bottom: 54px;
    }
}

/* ---------- Construction ---------- */

.production-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.construct-open,
.construct-btn {
    padding: 6px 14px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--parchment);
    background: var(--sea);
    border: 1px solid var(--gold);
    border-radius: 4px;
    cursor: pointer;
}

.construct-open:disabled,
.construct-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.construct-btn.confirming {
    color: var(--ink);
    background: #e8c35a;
}

.construct-back {
    padding: 5px 10px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--ink);
    background: #fdfdfb;
    border: 1px solid #8ea6bb;
    border-radius: 4px;
    cursor: pointer;
}

.construct-funds {
    display: flex;
    gap: 6px;
    font-size: 0.92rem;
    color: #44607a;
}

.construct-funds .gold {
    font-weight: bold;
    color: var(--ink);
}

.construct-hint {
    margin: 0;
    font-size: 0.86rem;
    font-style: italic;
    color: #44607a;
}

.section-title {
    margin: 4px 0 2px;
    font-size: 1rem;
}

.construction-queue {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px 10px;
    background: #eef2f5;
    border: 1px dashed #b8892b;
    border-radius: 4px;
}

.queue-row {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) 2fr auto;
    align-items: center;
    gap: 12px;
}

.queue-text {
    display: flex;
    flex-direction: column;
}

.queue-name {
    font-weight: bold;
}

.queue-owner {
    font-size: 0.8rem;
    color: #44607a;
}

.queue-row.mine .queue-owner {
    color: #264c70;
    font-weight: bold;
}

.queue-bar {
    height: 8px;
    background: #d5dfe8;
    border-radius: 4px;
    overflow: hidden;
}

.queue-fill {
    height: 100%;
    background: repeating-linear-gradient(135deg, #4c6a86 0 6px, #b8892b 6px 12px);
}

.queue-bar.unknown .queue-fill {
    width: 100%;
    opacity: 0.35;
}

.queue-days {
    font-size: 0.88rem;
    white-space: nowrap;
}

.building-card.plan {
    border-left-color: var(--gold);
}

.plan-days {
    font-size: 0.82rem;
    color: #44607a;
}

.plan-needs {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 6px 0 0;
    list-style: none;
    font-size: 0.88rem;
    border-top: 1px dashed #bccbd8;
}

.need {
    display: grid;
    grid-template-columns: 18px 1fr auto;
    align-items: center;
    gap: 6px;
}

.need-name {
    display: flex;
    align-items: center;
    gap: 6px;
}

.need-icon {
    width: 20px;
    height: 20px;
}

.need.ok .need-mark,
.need.ok .need-amount {
    color: var(--ok);
}

.need.missing .need-mark,
.need.missing .need-amount {
    color: var(--error);
    font-weight: bold;
}

.plan-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 6px;
    border-top: 1px dashed #bccbd8;
}

.plan-running {
    font-size: 0.82rem;
    color: #44607a;
}

@media (max-width: 640px) {
    .queue-row {
        grid-template-columns: 1fr auto;
    }

    .queue-bar {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}

.plan-efficiency {
    margin-left: 8px;
    padding: 1px 7px;
    font-size: 0.75rem;
    font-weight: normal;
    color: #44607a;
    background: #e3eaf0;
    border: 1px solid #bccbd8;
    border-radius: 10px;
    white-space: nowrap;
}

.plan-unknown {
    margin: 0;
    font-size: 0.86rem;
    font-style: italic;
    color: #44607a;
}

/* ---------- Production filter ---------- */

.production-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.only-mine {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}

.only-mine input {
    width: auto;
    margin: 0;
    accent-color: #264c70;
}

/* ---------- Citizens tab ---------- */

.citizens-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: auto;
    padding: 14px 18px;
}

.citizens-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 18px;
}

.citizens-pop {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.citizens-pop-num {
    font-size: 2rem;
    font-weight: bold;
    line-height: 1;
}

.citizens-pop-label {
    color: #44607a;
}

.citizens-overall {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1rem;
}

.citizens-split {
    display: flex;
    height: 12px;
    border: 1px solid #bccbd8;
    border-radius: 6px;
    overflow: hidden;
}

.split-part {
    flex-basis: 0;
}

.split-part.poor,
.class-swatch.poor {
    background: #52718c;
}

.split-part.wealthy,
.class-swatch.wealthy {
    background: #b8892b;
}

.split-part.rich,
.class-swatch.rich {
    background: #7a3a7a;
}

.class-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.class-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: #f9f8f4;
    border: 1px solid #bccbd8;
    border-radius: 4px;
}

.class-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.class-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.class-name h3 {
    margin: 0;
    font-size: 1.08rem;
}

.class-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.class-count {
    font-size: 0.92rem;
    color: #44607a;
}

.class-note {
    margin: 0;
    font-size: 0.82rem;
    font-style: italic;
    color: #44607a;
}

.mood-meter {
    height: 10px;
    background: #d5dfe8;
    border-radius: 5px;
    overflow: hidden;
}

.mood-fill {
    height: 100%;
    border-radius: 5px;
}

.mood-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.92rem;
}

.mood-pct {
    margin-left: auto;
    color: #44607a;
}

.mood-face {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.mood-word {
    font-weight: bold;
}

.mood-great { color: #2f6b3a; }
.mood-good { color: #5a7a2a; }
.mood-mid { color: #a07a1a; }
.mood-bad { color: #b0561e; }
.mood-awful { color: #9b2c2c; }

.mood-fill.mood-great { background: #2f6b3a; }
.mood-fill.mood-good { background: #6e8f2e; }
.mood-fill.mood-mid { background: #c9962a; }
.mood-fill.mood-bad { background: #c0652a; }
.mood-fill.mood-awful { background: #9b2c2c; }

@media (max-width: 640px) {
    .citizens-view {
        padding-left: 12px;
        padding-right: 12px;
    }

    .production-actions {
        width: 100%;
        justify-content: space-between;
    }
}

/* ---------- Sign-in links ---------- */

.auth-links {
    display: flex;
    justify-content: center;
    gap: 18px;
}

.auth-links .link-btn {
    margin: 14px 0 0;
}

#status.ok {
    color: var(--ok);
}

/* ---------- Sound toggle ---------- */

.sound-btn.off {
    opacity: 0.6;
    text-decoration: line-through;
}

/* Town we're not in: the goods it can produce, as chips above the workshop cards */
.visitor-goods {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: 4px 0 14px;
    padding: 0;
}

.visitor-good {
    padding: 3px 10px;
    border: 1px solid rgba(20, 36, 58, 0.25);
    border-radius: 999px;
    background: rgba(232, 195, 90, 0.18);
    color: #14243a;
    font-size: 13px;
}

/* Units per Buy/Sell click: 1 / 5 / 10 / 25 */
.chunk-picker {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chunk-label {
    margin-right: 4px;
    font-size: 0.82rem;
    font-style: italic;
    color: rgba(20, 36, 58, 0.7);
}

.chunk-btn {
    min-width: 34px;
    padding: 4px 8px;
    font-size: 0.88rem;
    font-weight: bold;
    color: var(--ink);
    background: #fdfdfb;
    border: 1px solid #8ea6bb;
    border-radius: 4px;
    cursor: pointer;
}

.chunk-btn:hover {
    background: rgba(232, 195, 90, 0.35);
}

.chunk-btn.active {
    color: var(--parchment);
    background: var(--sea);
    border-color: var(--sea);
}

.trade-btn {
    white-space: nowrap;
}

/* Found your trading house again (no office or ship on the server) */
.join-backdrop {
    z-index: 20;
}

.join {
    width: 100%;
    max-width: 440px;
    background: var(--parchment);
    border: 6px solid var(--wood);
    outline: 2px solid var(--gold);
    outline-offset: -9px;
    border-radius: 6px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    color: var(--ink);
}

.join-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 20px 20px;
}

.join-text {
    margin: 0;
    font-size: 0.95rem;
    font-style: italic;
    line-height: 1.45;
}

.join-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: bold;
}

.join-input {
    padding: 7px 9px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: normal;
    color: var(--ink);
    background: #fdfdfb;
    border: 1px solid #8ea6bb;
    border-radius: 4px;
}

.join-submit {
    align-self: flex-start;
    padding: 8px 18px;
    font-size: 1rem;
}

.join-submit:disabled {
    opacity: 0.6;
    cursor: wait;
}

.join-status {
    min-height: 1.2em;
    margin: 0;
    font-size: 0.9rem;
}

.join-status.error {
    color: var(--error);
}

.join-status.ok {
    color: var(--ok);
}

/* Load / unload goods between the office and the selected ship */
.market-table:not(.moving) .col-move {
    display: none;
}

.market-table .col-move-actions {
    text-align: center;
}

/* room for the two move columns: the average-paid column steps aside */
.market-table.moving .col-avg {
    display: none;
}

.market-table.moving th,
.market-table.moving td {
    padding-left: 7px;
    padding-right: 7px;
}

.move-btn {
    min-width: 46px;
    margin: 0 2px;
    padding: 3px 8px;
    font-size: 0.82rem;
    font-weight: bold;
    color: var(--ink);
    background: #fdfdfb;
    border: 1px solid #8ea6bb;
    border-radius: 3px;
    white-space: nowrap;
    cursor: pointer;
}

.move-btn:hover:not(:disabled) {
    background: rgba(232, 195, 90, 0.35);
}

.move-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ---------- Auto-trade ---------- */

.fleet-auto {
    margin-right: 6px;
    padding: 4px 9px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--ink);
    background: #fdfdfb;
    border: 1px solid #8ea6bb;
    border-radius: 4px;
    cursor: pointer;
}

.fleet-auto:hover {
    background: rgba(232, 195, 90, 0.35);
}

.fleet-auto.on {
    color: var(--parchment);
    background: var(--ok);
    border-color: var(--gold);
}

.at-backdrop {
    z-index: 15;
}

.at {
    width: 100%;
    max-width: 760px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--parchment);
    border: 6px solid var(--wood);
    outline: 2px solid var(--gold);
    outline-offset: -9px;
    border-radius: 6px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    color: var(--ink);
}

.at-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 18px;
}

.at-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 18px 14px;
    border-top: 1px solid #adc0cf;
}

.at-status {
    flex: 1;
    margin: 0;
    font-size: 0.9rem;
}

.at-status.error {
    color: var(--error);
}

.at-save {
    padding: 8px 18px;
    font-size: 1rem;
}

.at-save:disabled {
    opacity: 0.6;
    cursor: wait;
}

.at-general {
    margin-bottom: 6px;
}

.at-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.92rem;
    font-weight: bold;
}

.at-num {
    width: 76px;
    padding: 4px 6px;
    font-family: inherit;
    font-size: 0.9rem;
    text-align: right;
    color: var(--ink);
    background: #fdfdfb;
    border: 1px solid #8ea6bb;
    border-radius: 3px;
}

.at-num:disabled {
    opacity: 0.4;
}

.at-select {
    padding: 6px 8px;
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--ink);
    background: #fdfdfb;
    border: 1px solid #8ea6bb;
    border-radius: 4px;
}

.at-select.small {
    padding: 3px 6px;
    font-size: 0.85rem;
}

.at-add {
    margin: 4px 0 8px;
}

.at-town {
    margin: 0 0 12px;
    padding: 10px 12px;
    background: #f9f8f4;
    border: 1px solid #adc0cf;
    border-left: 4px solid var(--gold);
    border-radius: 4px;
}

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

.at-town-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--parchment);
    background: var(--sea);
    border-radius: 50%;
}

.at-town-name {
    margin: 0;
    font-size: 1.05rem;
}

.at-here {
    padding: 1px 8px;
    font-size: 0.75rem;
    font-style: italic;
    background: rgba(232, 195, 90, 0.3);
    border-radius: 999px;
}

.at-town-tools {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.at-icon {
    min-width: 26px;
    padding: 2px 6px;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--ink);
    background: #fdfdfb;
    border: 1px solid #8ea6bb;
    border-radius: 3px;
    cursor: pointer;
}

.at-icon:disabled {
    opacity: 0.3;
    cursor: default;
}

.at-gold {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.at-gold-label {
    min-width: 40px;
    font-weight: bold;
}

.at-goods-wrap {
    overflow-x: auto;
}

.at-goods {
    width: 100%;
    margin-bottom: 8px;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.at-goods th {
    padding: 4px 6px;
    font-size: 0.72rem;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    border-bottom: 1px solid #adc0cf;
}

.at-goods td {
    padding: 3px 6px;
    white-space: nowrap;
}

.at-good-name {
    font-weight: bold;
}

.at-move {
    display: flex;
    gap: 4px;
}

.at-move .at-num {
    width: 60px;
}

@media (max-width: 640px) {
    .at-backdrop {
        padding: 0;
    }

    .at {
        height: 100%;
        max-width: none;
        border-radius: 0;
    }

    .at-field {
        flex-direction: column;
        align-items: flex-start;
    }
}

.at-gold .at-select,
.at-add-good,
.at-add .at-select {
    width: auto;
    flex: 0 0 auto;
}

.at-active {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
}

.at-active input {
    width: 18px;
    height: 18px;
    accent-color: var(--ok);
}

/* ---------- Merchants tab ---------- */

.merchants-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: auto;
    padding: 14px 18px;
}

.merch-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.merch-tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    background: #f9f8f4;
    border: 1px solid #adc0cf;
    border-radius: 4px;
}

.merch-tile-num {
    font-size: 1.6rem;
    font-weight: bold;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.merch-tile-label {
    font-size: 0.82rem;
    color: #44607a;
}

.merch-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.85rem;
}

.merch-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.merch-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 2px;
    vertical-align: baseline;
}

.merch-legend-item .merch-swatch {
    margin-right: 0;
}

.merch-goods {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.merch-good {
    display: grid;
    grid-template-columns: 150px 1fr 64px;
    align-items: center;
    gap: 10px;
}

.merch-good-label {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.merch-good-name {
    font-weight: bold;
}

.merch-good-total {
    font-size: 0.78rem;
    color: #44607a;
}

.merch-bar {
    display: flex;
    gap: 2px;
    height: 16px;
    padding: 0;
    background: transparent;
}

.merch-seg {
    min-width: 3px;
    height: 100%;
}

.merch-seg:first-child {
    border-radius: 4px 0 0 4px;
}

.merch-seg:last-child {
    border-radius: 0 4px 4px 0;
}

.merch-seg:only-child {
    border-radius: 4px;
}

.merch-seg.idle {
    flex-grow: 1;
    background: repeating-linear-gradient(45deg, #d5dfe8 0 4px, #f4f2ec 4px 8px);
}

.merch-good-mine {
    font-size: 0.85rem;
    font-weight: bold;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.merch-good-mine.muted {
    opacity: 0.45;
}

.merch-table-wrap {
    margin: 0;
    flex: none;
}

.merch-table tr.merch-me td {
    background: rgba(42, 120, 214, 0.1);
    font-weight: bold;
}

.merch-wealth {
    font-weight: bold;
}

@media (max-width: 640px) {
    .merchants-view {
        padding-left: 12px;
        padding-right: 12px;
    }

    .merch-tiles {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px;
    }

    .merch-tile-num {
        font-size: 1.2rem;
    }

    .merch-good {
        grid-template-columns: 96px 1fr 52px;
        gap: 6px;
    }

    .merch-hide-sm {
        display: none;
    }
}

/* four tabs must fit a phone: the tab row scrolls instead of widening the window */
.view-tabs {
    overflow-x: auto;
    scrollbar-width: none;
}

.view-tab {
    flex: none;
    white-space: nowrap;
}

.merch-good-mine {
    white-space: nowrap;
}

@media (max-width: 640px) {
    .view-tab {
        padding: 6px 11px 5px;
        font-size: 0.9rem;
    }
}

/* merchants table: up to 100 rows, scrolls in its own box under a sticky header */
.merch-table-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.merch-search {
    width: 200px;
    padding: 5px 9px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--ink);
    background: #fdfdfb;
    border: 1px solid #8ea6bb;
    border-radius: 4px;
}

.merch-table-wrap {
    max-height: 380px;
    overflow: auto;
}

.merch-none {
    padding: 10px !important;
    font-style: italic;
    text-align: center;
}

@media (max-width: 640px) {
    .merch-search {
        width: 140px;
    }

    .merch-table-wrap {
        max-height: 60vh;
    }
}

.merch-table-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.merch-findme {
    padding: 5px 10px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--parchment);
    background: #2a78d6;
    border: 1px solid #1d5ba8;
    border-radius: 4px;
    white-space: nowrap;
    cursor: pointer;
}

/* fleet: a ship at sea, opened (data read from the server on open) */
.fleet-ship.at-sea {
    flex-wrap: wrap;
}

.fleet-ship.at-sea.open {
    background: #f9f8f4;
    box-shadow: inset 3px 0 0 var(--sea);
}

.fleet-details {
    flex-basis: 100%;
    padding: 6px 2px 2px;
    border-top: 1px dashed #bccbd8;
    font-size: 0.82rem;
    cursor: default;
}

.fleet-details-note {
    margin: 2px 0;
    font-style: italic;
    color: #44607a;
}

.fleet-details-note.error {
    color: var(--error);
}

.fleet-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 10px;
    margin: 0 0 4px;
}

.fleet-facts dt {
    color: #44607a;
}

.fleet-facts dd {
    margin: 0;
    font-weight: bold;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.fleet-cargo {
    margin: 0;
    padding: 4px 0 0;
    list-style: none;
    border-top: 1px solid #d5dfe8;
}

.fleet-cargo li {
    display: flex;
    justify-content: space-between;
    padding: 1px 0;
}

.fleet-cargo-qty {
    font-variant-numeric: tabular-nums;
}

/* Population: beggars and the census (growth vs yesterday / last month / last year) */
.citizens-beggars {
    color: #44607a;
    font-size: 0.92rem;
}

.census .section-title {
    margin: 0 0 6px;
}

.census-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    font-variant-numeric: tabular-nums;
    background: #f9f8f4;
    border: 1px solid #bccbd8;
    border-radius: 4px;
}

.census-table th,
.census-table td {
    padding: 5px 10px;
    border-bottom: 1px solid #d5dfe8;
}

.census-table th {
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #44607a;
    background: #dde6ed;
}

.census-table .col-num {
    text-align: right;
    white-space: nowrap;
}

.census-class {
    text-align: left;
    white-space: nowrap;
}

.census-class .class-swatch {
    display: inline-block;
    margin-right: 7px;
    vertical-align: -1px;
}

.census-total td {
    font-weight: bold;
    border-top: 2px solid #bccbd8;
}

.census-delta.up {
    color: var(--ok);
}

.census-delta.down {
    color: var(--error);
}

.census-delta.flat {
    color: #607b94;
}

.census-arrow {
    margin-right: 3px;
    font-size: 0.7em;
}

.census-pct {
    font-size: 0.85em;
    opacity: 0.8;
}

@media (max-width: 640px) {
    .census-table th,
    .census-table td {
        padding: 5px 6px;
    }

    .census-pct {
        display: none;
    }
}

/* goods icons (market table, ship cargo) */
.good-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.good-icon {
    flex: none;
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.market-table .good-label {
    vertical-align: middle;
    margin: -3px 0;
}

.fleet-cargo .good-icon {
    width: 20px;
    height: 20px;
}

.fleet-cargo li {
    align-items: center;
}

@media (max-width: 640px) {
    .market-table .good-icon {
        width: 22px;
        height: 22px;
    }

    .market-table .good-label {
        gap: 5px;
    }
}

.fleet-facts .fleet-gold {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.fleet-facts .fleet-gold::before {
    content: "";
    width: 16px;
    height: 16px;
    margin: -3px 0;
    background: url("/game/img/goods/Gold.webp") center / contain no-repeat;
}

/* ---------- Housing tab ---------- */

.house-meter {
    height: 8px;
    border: 1px solid #bccbd8;
    border-radius: 4px;
    background: #dde6ed;
    overflow: hidden;
}

.house-fill {
    height: 100%;
    border-radius: 4px;
}

.house-fill.poor {
    background: #52718c;
}

.house-fill.wealthy {
    background: #b8892b;
}

.house-fill.rich {
    background: #7a3a7a;
}

.house-fill.full {
    background: var(--error);
}

.house-facts {
    margin: 2px 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.88rem;
}

.house-fact {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 0;
    border-bottom: 1px dashed #d5dfe8;
}

.house-fact-label {
    color: #44607a;
}

.house-fact-value {
    font-weight: bold;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.house-fact.full .house-fact-value {
    color: var(--error);
}

.house-plan .class-note {
    margin: -2px 0 2px;
}


/* Population tab: headline with Build a house; class cards join people and homes */
.pop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 18px;
}

.pop-head-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pop-head-sub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 0.95rem;
}

.pop-head-beds {
    color: #44607a;
    font-size: 0.9rem;
}

.class-card .class-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.class-stat-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.class-stat-label {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #44607a;
}

.class-stat-value {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

.class-stat-value.full {
    color: var(--error);
}

.class-stat-value .mood-pct {
    font-weight: normal;
    color: #44607a;
}

.class-card .house-facts {
    margin-top: 2px;
}

.owner-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 2px;
}

.owner-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 3px 2px 9px;
    font-size: 0.8rem;
    border-radius: 999px;
    color: #fff;
    background: #607b94;
}

.owner-chip.town {
    background: #52718c;
}

.owner-chip.mine {
    background: #264c70;
}

.owner-chip.other {
    background: #a8322a;
}

.owner-chip-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.owner-chip-count {
    min-width: 20px;
    padding: 0 6px;
    font-weight: bold;
    text-align: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.25);
}

/* the tab scrolls as a whole: its blocks keep their height */
.citizens-view > * {
    flex-shrink: 0;
}

.pop-head-sep {
    width: 1px;
    height: 1.1em;
    background: #bccbd8;
}

strong.class-count {
    font-size: 1.05rem;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.pop-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pop-section > .section-title {
    margin: 4px 0 0;
}

.mood-card {
    gap: 8px;
}

/* Move gold on phones: one folded line; opened, a stacked panel with big touch targets */
@media (max-width: 640px) {
    .market-transfer {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 8px 12px 0;
    }

    .market-transfer .transfer-label {
        display: none;
    }

    .transfer-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        min-height: 40px;
        padding: 6px 12px;
        font-family: inherit;
        font-size: 0.95rem;
        color: var(--ink);
        background: #fdfdfb;
        border: 1px solid #8ea6bb;
        border-radius: 6px;
        cursor: pointer;
    }

    .transfer-toggle-label {
        font-weight: bold;
    }

    .transfer-toggle-route {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        text-align: left;
        font-style: italic;
        color: #44607a;
    }

    .transfer-toggle-chevron {
        transition: transform 0.15s;
    }

    .market-transfer.open .transfer-toggle-chevron {
        transform: rotate(180deg);
    }

    .market-transfer:not(.open) > :not(.transfer-toggle) {
        display: none;
    }

    .market-transfer .xfer-route {
        justify-content: space-between;
        min-height: 40px;
    }

    .market-transfer .xfer-end {
        max-width: none;
        flex: 1;
    }

    .market-transfer .xfer-swap {
        width: 40px;
        height: 34px;
    }

    .xfer-amount {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .market-transfer .transfer-input {
        width: 100%;
        min-height: 40px;
        font-size: 16px;   /* no zoom-in on focus (iOS) */
    }

    .xfer-quick {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    .xfer-chip {
        min-height: 38px;
        font-size: 0.92rem;
    }

    .market-transfer .transfer-btn {
        width: 100%;
        min-height: 42px;
        font-size: 1rem;
    }
}

/* Politics tab: placeholder */
.politics-view {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 18px;
}

.coming-soon {
    margin: 0;
    font-style: italic;
    color: #44607a;
}

/* registration: agreeing to the terms */
.card .agree {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 16px;
    font-weight: normal;
    font-size: 0.92rem;
    line-height: 1.4;
    cursor: pointer;
}

.card .agree input {
    width: auto;
    margin: 3px 0 0;
    flex: none;
    accent-color: var(--sea);
}

.card .agree a,
.legal-links a {
    color: var(--sea);
}

.legal-links {
    margin: 18px 0 0;
    font-size: 0.82rem;
    text-align: center;
    color: #44607a;
}

/* ---------- Harbor tab (shipyard) ---------- */

.harbor-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 18px;
    overflow: auto;
}

.shipyard-queue .queue-row.waiting .queue-bar {
    opacity: 0.45;
}

.shipyard-queue .queue-row.waiting .queue-days {
    font-style: italic;
    color: #607b94;
}

.ship-plan .building-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ship-plan-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex: none;
}

.ship-plan.locked {
    opacity: 0.6;
    border-left-color: #adc0cf;
}

.ship-plan.locked .plan-running {
    font-style: italic;
}

/* ---------- Discord links ---------- */

.discord-icon {
    width: 1.1em;
    height: 1.1em;
    flex: none;
}

.discord-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 18px 0 0;
    padding: 9px 12px;
    font-size: 0.95rem;
    font-weight: bold;
    color: #fff;
    background: #5865f2;
    border: 1px solid #4752c4;
    border-radius: 4px;
    text-decoration: none;
}

.discord-link:hover {
    background: #4752c4;
}

.discord-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: #fff;
    background: #5865f2;
    border: 1px solid #5865f2;
    border-radius: 50%;
}

.discord-btn .discord-icon {
    width: 18px;
    height: 18px;
}

.discord-btn:hover {
    background: #4752c4;
}

/* ---------- World chat (bottom right of the map) ---------- */

.chat {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 4;
    width: 270px;
    display: flex;
    flex-direction: column;
    background: rgba(244, 242, 236, 0.96);
    border: 2px solid var(--wood);
    outline: 1px solid var(--gold);
    outline-offset: -4px;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-family: inherit;
    color: var(--ink);
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
}

.chat-title {
    flex: 1;
    font-weight: bold;
    font-size: 0.92rem;
}

.chat-badge {
    min-width: 22px;
    padding: 1px 7px;
    font-size: 0.8rem;
    text-align: center;
    color: #fff;
    background: #a8322a;
    border-radius: 10px;
}

.chat-badge[hidden] {
    display: none;
}

.chat-chevron {
    color: #44607a;
}

.chat-body {
    display: flex;
    flex-direction: column;
    padding: 0 8px 8px;
}

.chat-body[hidden] {
    display: none;
}

.chat-list {
    height: 170px;
    margin: 0;
    padding: 4px 4px 0;
    overflow-y: auto;
    list-style: none;
    border-top: 1px solid #ccd8e2;
}

.chat-empty {
    margin: 0;
    padding: 8px 4px;
    font-size: 0.85rem;
    font-style: italic;
    color: #44607a;
}

.chat-empty[hidden] {
    display: none;
}

.chat-msg {
    padding: 4px 2px;
    border-bottom: 1px dashed #d5dfe8;
}

.chat-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.chat-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: bold;
    font-size: 0.85rem;
    color: var(--sea);
}

.chat-msg.mine .chat-name {
    color: #264c70;
}

.chat-time {
    flex: none;
    font-size: 0.72rem;
    color: #607b94;
}

.chat-text {
    margin: 1px 0 0;
    font-size: 0.85rem;
    line-height: 1.35;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-form {
    margin-top: 8px;
}

.chat-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.chat-input {
    flex: 1;
    min-height: 30px;
    max-height: 100px;
    padding: 5px 8px;
    font-family: inherit;
    font-size: 0.88rem;
    line-height: 1.3;
    color: var(--ink);
    background: #fdfdfb;
    border: 1px solid #8ea6bb;
    border-radius: 4px;
    resize: none;
}

.chat-send {
    height: 30px;
    padding: 0 10px;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--parchment);
    background: var(--sea);
    border: none;
    border-radius: 4px;
}

.chat-send:disabled {
    opacity: 0.45;
    cursor: default;
}

.chat-counter {
    display: block;
    margin-top: 3px;
    font-size: 0.75rem;
    text-align: right;
    color: #44607a;
}

.chat-counter[hidden] {
    display: none;
}

.chat-counter.full {
    color: var(--error);
    font-weight: bold;
}

.chat-error {
    margin: 4px 0 0;
    font-size: 0.82rem;
    color: var(--error);
}

.chat-error[hidden] {
    display: none;
}

@media (max-width: 640px) {
    .chat {
        left: 12px;
        right: 12px;
        width: auto;
    }

    .chat:not(.open) {
        left: auto;
        width: 120px;
    }

    .chat-list {
        height: 130px;
    }

    .chat-input {
        font-size: 16px;   /* no zoom-in on focus (iOS) */
    }
}

/* the office's last weekly bill, under its gold in the town window header */
.purse-bill {
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.purse-bill.cost {
    color: var(--error);
}

.purse-bill.gain {
    color: var(--ok);
}

/* notice popup (weekly bill) */
.notice-backdrop {
    z-index: 12;
}

.notice {
    max-width: 320px;
}

.notice .market-head {
    padding: 10px 14px 8px;
}

.notice .market-title {
    font-size: 1.1rem;
}

.notice .join-form {
    gap: 8px;
    padding: 12px 14px 14px;
}

.notice .join-text {
    font-size: 0.68rem;
    line-height: 1.35;
    text-align: center;
}

.notice-figure {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 0;
    font-size: 1.4rem;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

.notice-gold {
    width: 22px;
    height: 22px;
}

.notice-figure.cost {
    color: var(--error);
}

.notice-figure.gain {
    color: var(--ok);
}

.notice .join-submit {
    align-self: center;
    min-width: 72px;
    padding: 4px 12px;
    font-size: 0.82rem;
}
