:root {
    --bg: #f8f6f1;
    --panel: #fffdf8;
    --ink: #181410;
    --muted: #6e6257;
    --accent: #2d5a4d;
    --accent-soft: #edf4f1;
    --dm-bg: #f5efe3;
    --player-bg: #f2f7ff;
    --other-bg: #f7f4ef;
    --line: rgba(24, 20, 16, 0.1);
    --shadow: 0 20px 50px rgba(34, 27, 20, 0.08);
    font-family: Georgia, "Times New Roman", serif;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: linear-gradient(180deg, #fbf8f2 0%, #ece2d1 100%);
}

.login-card {
    width: min(100%, 28rem);
    border-radius: 24px;
    border: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.98);
    box-shadow: var(--shadow);
    padding: 1.35rem 1.2rem;
    display: grid;
    gap: 0.9rem;
}

.login-form {
    display: grid;
    gap: 0.85rem;
}

.login-form label {
    display: grid;
    gap: 0.35rem;
}

.login-form span,
.top-nav-user {
    font-size: 0.76rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.login-form input {
    width: 100%;
    border-radius: 16px;
    border: 1px solid rgba(24, 20, 16, 0.12);
    background: white;
    padding: 0.8rem 0.9rem;
    font: inherit;
    box-sizing: border-box;
}

.login-form select {
    width: 100%;
    border-radius: 16px;
    border: 1px solid rgba(24, 20, 16, 0.12);
    background: white;
    padding: 0.8rem 0.9rem;
    font: inherit;
    box-sizing: border-box;
}

.login-status {
    margin: 0;
    color: #7c3528;
}

.account-card {
    width: min(100%, 34rem);
}

.account-admin-block {
    display: grid;
    gap: 0.85rem;
    margin-top: 0.5rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--line);
}

.town-world-shell {
    width: min(100%, 980px);
    margin: 0 auto;
    padding: 1rem 0.85rem 1.4rem;
    display: grid;
    gap: 1rem;
    min-height: 100vh;
    background: linear-gradient(180deg, #fbf8f2 0%, #ece2d1 100%);
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.top-nav-links,
.top-nav-account {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.top-nav-account {
    margin: 0;
}

.town-world-build-footer {
    width: min(100%, 980px);
    margin: -0.35rem auto 0;
    padding: 0 0.2rem 0.6rem;
    color: var(--muted);
    font-size: 0.82rem;
    display: flex;
    gap: 0.45rem;
    justify-content: flex-end;
}

.town-world-build-footer strong {
    color: var(--ink);
}

.town-world-topbar,
.town-world-card {
    border-radius: 24px;
    border: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.96);
    box-shadow: var(--shadow);
}

.town-world-topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.05rem;
}

.town-world-eyebrow {
    margin: 0;
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.town-world-topbar h1,
.town-world-card h2 {
    margin: 0.25rem 0 0.4rem;
}

.town-world-topbar h1 {
    font-size: clamp(2rem, 4vw, 3.2rem);
    line-height: 1;
}

.town-world-copy {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.town-world-copy--secondary {
    margin-top: 0.55rem;
}

.town-world-topbar-actions,
.town-world-composer {
    display: flex;
    gap: 0.75rem;
}

.town-world-button {
    appearance: none;
    border: 1px solid rgba(45, 90, 77, 0.25);
    border-radius: 999px;
    background: var(--accent);
    color: white;
    padding: 0.7rem 1.1rem;
    font: inherit;
    cursor: pointer;
}

.town-world-button--ghost {
    background: white;
    color: var(--ink);
}

.town-world-layout {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(260px, 320px);
    gap: 1rem;
    align-items: start;
}

.town-world-tabbar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.town-world-tab {
    appearance: none;
    border: 1px solid rgba(24, 20, 16, 0.12);
    border-radius: 999px;
    background: rgba(255, 253, 248, 0.96);
    color: var(--ink);
    padding: 0.7rem 1.1rem;
    font: inherit;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.town-world-tab.is-active {
    background: var(--accent);
    color: white;
    border-color: rgba(45, 90, 77, 0.3);
}

.town-world-panel {
    display: grid;
    gap: 1rem;
    align-content: start;
}

.town-world-card {
    padding: 1rem 1.05rem;
}

.town-world-form-grid,
.town-world-stat-grid,
.town-world-meter-stack,
.town-world-ledger {
    display: grid;
    gap: 0.75rem;
}

.town-world-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.town-world-form-grid label,
.town-world-stat-grid div,
.town-world-meter {
    display: grid;
    gap: 0.35rem;
}

.town-world-form-grid span,
.town-world-stat-grid span,
.town-world-meter span {
    font-size: 0.76rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.town-world-form-grid input,
.town-world-form-grid select,
.town-world-composer input {
    width: 100%;
    border-radius: 16px;
    border: 1px solid rgba(24, 20, 16, 0.12);
    background: white;
    padding: 0.8rem 0.9rem;
    font: inherit;
    box-sizing: border-box;
}

.town-world-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.town-world-meter strong,
.town-world-stat-grid strong {
    font-size: 1.05rem;
}

.town-world-meter-track {
    height: 8px;
    border-radius: 999px;
    background: rgba(24, 20, 16, 0.08);
    overflow: hidden;
}

.town-world-meter-fill {
    height: 100%;
    background: linear-gradient(90deg, #bb7b54 0%, #7c3528 100%);
}

.town-world-meter-fill.is-good {
    background: linear-gradient(90deg, #8ab779 0%, #2d5a4d 100%);
}

.town-world-ledger {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 26rem;
    overflow: auto;
}

.town-world-ledger li {
    display: grid;
    gap: 0.25rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(24, 20, 16, 0.08);
}

.town-world-map-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
    margin-bottom: 1rem;
}

.town-world-scene-card {
    margin-bottom: 0;
}

.town-world-scene-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
}

.town-world-phase {
    min-width: 8rem;
    padding: 0.8rem 0.95rem;
    border-radius: 18px;
    background: rgba(45, 90, 77, 0.08);
    display: grid;
    gap: 0.25rem;
    text-align: right;
}

.town-world-chat-shell,
.town-world-detail-shell {
    display: grid;
    gap: 1rem;
}

.town-world-chat-card {
    min-height: 72vh;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
}

.town-world-map {
    display: grid;
    gap: 0;
    border: 1px solid rgba(24, 20, 16, 0.08);
    border-radius: 24px;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(92, 74, 56, 0.08), rgba(92, 74, 56, 0.02)),
        repeating-linear-gradient(0deg, transparent 0 47px, rgba(24, 20, 16, 0.06) 47px 48px),
        repeating-linear-gradient(90deg, transparent 0 47px, rgba(24, 20, 16, 0.06) 47px 48px),
        #efe5d2;
}

.town-world-tile {
    position: relative;
    min-height: 48px;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.town-world-tile.has-landmark {
    background: rgba(122, 96, 56, 0.18);
}

.town-world-tile.has-citizen {
    background: rgba(51, 97, 176, 0.12);
}

.town-world-tile.is-selected {
    outline: 2px solid rgba(51, 97, 176, 0.6);
    outline-offset: -2px;
}

.town-world-landmark,
.town-world-token {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: 26px;
    height: 26px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.town-world-landmark {
    background: rgba(122, 96, 56, 0.9);
    color: white;
}

.town-world-token {
    background: #234ea1;
    color: white;
    box-shadow: 0 10px 18px rgba(35, 78, 161, 0.26);
}

.town-world-chatlog {
    display: grid;
    gap: 0.75rem;
    max-height: 62vh;
    overflow: auto;
    margin-bottom: 1rem;
}

.town-world-chatline {
    padding: 0.9rem 1rem;
    border-radius: 18px;
    border: 1px solid rgba(24, 20, 16, 0.08);
    background: #f7f2e7;
}

.town-world-chatline.is-player {
    background: #eef5ff;
}

.town-world-chatline.is-dm {
    background: #f6eddc;
}

.town-world-chatline header {
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.town-world-chatline p {
    margin: 0;
    line-height: 1.55;
}

.town-world-feedback-card {
    margin: 0 0 1rem;
    padding: 1rem;
    border: 1px solid rgba(45, 90, 77, 0.18);
    border-radius: 20px;
    background: rgba(247, 252, 249, 0.98);
    display: grid;
    gap: 0.85rem;
}

.town-world-feedback-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
}

.town-world-feedback-head h3 {
    margin: 0.2rem 0 0;
}

.town-world-feedback-quote {
    padding: 0.85rem 0.95rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(24, 20, 16, 0.08);
}

.town-world-feedback-quote p {
    margin: 0.35rem 0 0;
    line-height: 1.5;
}

.town-world-chat-feedback-actions {
    display: flex;
    gap: 0.45rem;
    align-items: center;
    margin-top: 0.8rem;
    flex-wrap: wrap;
}

.town-world-chat-feedback-button,
.town-world-chat-feedback-link {
    appearance: none;
    border: 1px solid rgba(24, 20, 16, 0.12);
    background: rgba(255, 255, 255, 0.85);
    color: var(--ink);
    font: inherit;
}

.town-world-chat-feedback-button {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 999px;
    cursor: pointer;
}

.town-world-chat-feedback-link {
    border-radius: 999px;
    padding: 0.45rem 0.8rem;
    cursor: pointer;
}

.town-world-chat-feedback-button:hover,
.town-world-chat-feedback-link:hover {
    border-color: rgba(45, 90, 77, 0.35);
    background: rgba(247, 252, 249, 1);
}

.town-world-toast {
    position: sticky;
    bottom: 0.75rem;
    z-index: 4;
    margin: 0 0 0.85rem auto;
    width: fit-content;
    max-width: min(100%, 26rem);
    padding: 0.7rem 0.95rem;
    border-radius: 999px;
    border: 1px solid rgba(24, 20, 16, 0.1);
    background: rgba(255, 253, 248, 0.96);
    box-shadow: 0 16px 32px rgba(24, 20, 16, 0.1);
    color: var(--ink);
}

.town-world-toast.is-positive {
    border-color: rgba(45, 90, 77, 0.25);
    background: rgba(237, 244, 241, 0.98);
}

.town-world-form-grid textarea,
.town-world-form-grid select {
    width: 100%;
    border-radius: 16px;
    border: 1px solid rgba(24, 20, 16, 0.12);
    background: white;
    padding: 0.8rem 0.9rem;
    font: inherit;
    box-sizing: border-box;
}

.town-world-form-grid textarea {
    resize: vertical;
    min-height: 5.5rem;
}

.town-world-composer input {
    flex: 1;
}

.town-world-composer--stacked {
    display: grid;
    gap: 0.75rem;
    position: sticky;
    bottom: 0;
    padding-top: 0.5rem;
    background: linear-gradient(180deg, rgba(255, 253, 248, 0), rgba(255, 253, 248, 0.98) 28%);
}

.town-world-composer-actions {
    display: flex;
    justify-content: flex-start;
}

.town-world-response-status {
    padding: 0.15rem 0.2rem 0;
}

.town-world-quick-actions {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.town-world-quick-button {
    appearance: none;
    border: 1px solid rgba(24, 20, 16, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--ink);
    padding: 0.55rem 0.85rem;
    font: inherit;
    cursor: pointer;
}

.town-world-traits {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    margin-top: 0.85rem;
}

.town-world-traits span {
    border-radius: 999px;
    background: rgba(45, 90, 77, 0.08);
    color: var(--accent);
    padding: 0.35rem 0.7rem;
    font-size: 0.88rem;
}

.town-world-notes-block {
    display: grid;
    gap: 0.6rem;
    margin: 0.9rem 0 1rem;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    background: rgba(45, 90, 77, 0.05);
    border: 1px solid rgba(24, 20, 16, 0.06);
}

.town-world-notes-block h3 {
    margin: 0;
    font-size: 1rem;
}

.town-world-notes-block p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

@media (max-width: 1100px) {
    .town-world-topbar,
    .town-world-map-header {
        grid-template-columns: 1fr;
        display: grid;
    }

    .town-world-form-grid,
    .town-world-stat-grid {
        grid-template-columns: 1fr;
    }

    .town-world-scene-row {
        display: grid;
    }

    .town-world-chat-card {
        min-height: auto;
    }

    .town-world-chatlog {
        max-height: 56vh;
    }
}

@media (max-width: 700px) {
    .town-world-shell {
        width: 100%;
        padding: 0.65rem 0.55rem 1rem;
        gap: 0.75rem;
    }

    .town-world-topbar {
        padding: 0.9rem 0.85rem;
        border-radius: 18px;
    }

    .town-world-topbar h1 {
        font-size: clamp(1.65rem, 8vw, 2.3rem);
    }

    .town-world-topbar-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .town-world-tabbar {
        position: sticky;
        top: 0.5rem;
        z-index: 6;
        padding: 0.3rem;
        border-radius: 16px;
        background: rgba(255, 253, 248, 0.92);
        backdrop-filter: blur(10px);
    }

    .town-world-tab {
        flex: 1 1 0;
        text-align: center;
        padding: 0.8rem 0.9rem;
    }

    .town-world-card {
        padding: 0.85rem 0.85rem 0.95rem;
        border-radius: 18px;
    }

    .town-world-scene-row {
        gap: 0.75rem;
    }

    .town-world-phase {
        min-width: 0;
        text-align: left;
    }

    .town-world-chat-card {
        min-height: calc(100vh - 11rem);
    }

    .town-world-chatlog {
        max-height: none;
        min-height: 45vh;
        margin-bottom: 0.75rem;
    }

    .town-world-chatline {
        padding: 0.8rem 0.85rem;
    }

    .town-world-chatline p {
        font-size: 1rem;
        line-height: 1.65;
    }

    .town-world-composer--stacked {
        gap: 0.6rem;
        padding-top: 0.65rem;
    }

    .town-world-composer input {
        min-height: 3.2rem;
        padding: 0.95rem 1rem;
        font-size: 1rem;
    }

    .town-world-composer-actions {
        display: grid;
    }

    .town-world-button {
        width: 100%;
        justify-content: center;
    }

    .town-world-quick-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .town-world-quick-button,
    .town-world-chat-feedback-link,
    .town-world-chat-feedback-button {
        min-height: 2.8rem;
    }

    .town-world-feedback-head {
        display: grid;
    }

    .town-world-feedback-card {
        padding: 0.85rem;
    }

    .town-world-build-footer {
        width: 100%;
        justify-content: center;
        padding-bottom: 0.35rem;
    }
}

.map-workshop-shell {
    width: min(100%, 1800px);
    margin: 0 auto;
    padding: 1.4rem 1.2rem 1.6rem;
    display: grid;
    gap: 1rem;
    min-height: 100vh;
    background:
        radial-gradient(circle at top, rgba(255, 232, 170, calc(0.18 - (var(--world-night-shell, 0.18) * 0.12))) 0%, rgba(255, 232, 170, 0) 42%),
        linear-gradient(180deg,
            rgba(248, 246, 241, calc(0.98 - (var(--world-night-shell, 0.18) * 0.22))) 0%,
            rgba(219, 205, 178, calc(0.88 - (var(--world-night-shell, 0.18) * 0.18))) 100%);
    transition: background 0.45s ease;
}

.map-workshop-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.15rem 1.2rem;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.map-workshop-topbar h1 {
    margin: 0.2rem 0 0.35rem;
    font-size: clamp(2rem, 3.8vw, 3.1rem);
    line-height: 1;
}

.map-workshop-copy,
.map-workshop-card-copy {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.map-workshop-topbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.map-workshop-sim-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.9rem;
}

.map-workshop-speed-row {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.9rem;
}

.map-workshop-speed-row > span {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.map-workshop-speed-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.map-workshop-speed-button {
    width: auto;
    margin-top: 0;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--ink);
    border: 1px solid rgba(24, 20, 16, 0.12);
    box-shadow: none;
}

.map-workshop-speed-button.is-selected {
    background: var(--accent);
    color: white;
    border-color: rgba(45, 90, 77, 0.5);
}

.map-workshop-sim-meta {
    display: grid;
    grid-template-columns: auto auto;
    gap: 0.4rem 0.9rem;
    margin-top: 0.95rem;
    padding: 0.75rem 0.85rem;
    border-radius: 16px;
    background: rgba(45, 90, 77, 0.06);
}

.map-workshop-sim-meta span {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.map-workshop-sim-meta strong {
    justify-self: end;
}

.map-workshop-layout {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(260px, 320px);
    gap: 1rem;
    align-items: start;
}

.map-workshop-panel {
    display: grid;
    gap: 1rem;
    align-content: start;
}

.map-workshop-card {
    padding: 1rem 1.05rem;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.94);
    box-shadow: var(--shadow);
}

.map-workshop-card h2 {
    margin: 0.2rem 0 0.45rem;
    font-size: 1.5rem;
}

.map-workshop-slot-list,
.map-workshop-brushes,
.map-workshop-token-list {
    display: grid;
    gap: 0.75rem;
}

.map-workshop-slot {
    display: grid;
    gap: 0.65rem;
    padding: 0.75rem;
    border-radius: 20px;
    border: 1px solid rgba(24, 20, 16, 0.08);
    background: rgba(255, 255, 255, 0.9);
}

.map-workshop-slot.is-selected,
.map-workshop-brush.is-selected,
.map-workshop-token-chip.is-selected {
    border-color: rgba(39, 70, 144, 0.42);
    box-shadow: 0 0 0 2px rgba(39, 70, 144, 0.12);
}

.map-workshop-slot-select,
.map-workshop-brush,
.map-workshop-token-chip {
    margin-top: 0;
    width: 100%;
    background: transparent;
    color: var(--ink);
    border: 1px solid rgba(24, 20, 16, 0.08);
    box-shadow: none;
}

.map-workshop-slot-select {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem;
    text-align: left;
}

.map-workshop-slot-preview {
    aspect-ratio: 1;
    border-radius: 16px;
    border: 1px dashed rgba(24, 20, 16, 0.16);
    background: linear-gradient(180deg, rgba(255,255,255,0.8), rgba(232,225,210,0.9));
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 0.82rem;
    text-align: center;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.map-workshop-slot-body {
    display: grid;
    gap: 0.2rem;
}

.map-workshop-slot-body span {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.map-workshop-upload {
    display: grid;
    gap: 0.4rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.map-workshop-upload input[type="file"] {
    margin-top: 0;
    padding: 0.75rem;
    border-radius: 14px;
    background: rgba(45, 90, 77, 0.06);
}

.map-workshop-asset-shelf {
    display: grid;
    gap: 0.45rem;
    max-height: 12rem;
    overflow-y: auto;
}

.map-workshop-asset-chip {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 0.6rem;
    align-items: center;
    width: 100%;
    padding: 0.45rem;
    border-radius: 14px;
    border: 1px solid rgba(24, 20, 16, 0.08);
    background: #fff;
    color: var(--ink);
    text-align: left;
}

.map-workshop-asset-chip.is-selected {
    border-color: rgba(39, 70, 144, 0.42);
    box-shadow: 0 0 0 2px rgba(39, 70, 144, 0.12);
}

.map-workshop-asset-thumb {
    aspect-ratio: 1;
    border-radius: 12px;
    border: 1px solid rgba(24, 20, 16, 0.08);
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    background-color: rgba(255,255,255,0.85);
}

.map-workshop-asset-meta {
    display: grid;
    gap: 0.1rem;
    min-width: 0;
}

.map-workshop-asset-meta strong,
.map-workshop-asset-meta small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-workshop-asset-meta small {
    color: var(--muted);
}

.map-workshop-brushes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.map-workshop-brush {
    display: grid;
    justify-items: start;
    gap: 0.55rem;
    padding: 0.7rem;
    border-radius: 18px;
}

.map-workshop-brush-swatch {
    width: 3rem;
    height: 3rem;
    border-radius: 14px;
    border: 1px solid rgba(24, 20, 16, 0.08);
    background: #ebe5d8;
}

.map-workshop-brush-swatch.is-erase {
    background: linear-gradient(135deg, #f7f2e8 0%, #e3d9c6 100%);
}

.map-workshop-brush-swatch.is-floor {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.08), rgba(0,0,0,0.04)),
        url('/assets/map/stone-ground.png');
    background-size: cover, 112px 112px;
}

.map-workshop-brush-swatch.is-wall {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.05), rgba(0,0,0,0.18)),
        url('/assets/map/wall-tiles.png');
    background-size: cover, 112px 112px;
}

.map-workshop-brush-swatch.is-door {
    background: linear-gradient(180deg, #8e6844 0%, #5b3c24 100%);
}

.map-workshop-brush-swatch.is-feature {
    background: linear-gradient(180deg, #d5b456 0%, #977426 100%);
}

.map-workshop-board-card {
    display: grid;
    gap: 1rem;
}

.map-workshop-board-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
}

.map-workshop-board-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.map-workshop-board-wrap {
    overflow: auto;
    border-radius: 22px;
    border: 1px solid var(--line);
    background:
        linear-gradient(180deg,
            rgba(232, 221, 201, calc(0.96 - (var(--world-night-board, 0.12) * 0.3))) 0%,
            rgba(190, 176, 151, calc(0.95 - (var(--world-night-board, 0.12) * 0.12))) 100%);
    padding: 0.5rem;
    min-height: 58rem;
    transition: background 0.45s ease;
}

.map-workshop-board {
    display: grid;
    grid-template-columns: repeat(var(--draft-columns), 56px);
    gap: 0;
    width: max-content;
}

.map-workshop-tile {
    margin-top: 0;
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    border-radius: 0;
    border: 1px solid rgba(24, 20, 16, 0.06);
    border-right-width: 0;
    border-bottom-width: 0;
    box-shadow: none;
    background: #f5efe2;
    background-size: cover;
    background-position: center;
    position: relative;
    padding: 0.2rem;
    overflow: visible;
    isolation: isolate;
}

.map-workshop-tile.has-bubble {
    z-index: 8;
}

.map-workshop-tile::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(243, 205, 102, var(--tile-light-opacity, 0)) 0%, rgba(243, 205, 102, 0) 72%);
    z-index: 0;
    pointer-events: none;
    transition: background 0.45s ease;
}

.map-workshop-tile::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(7, 13, 28, var(--tile-night-opacity, 0));
    z-index: 0;
    pointer-events: none;
    transition: background 0.45s ease;
}

.map-workshop-tile.is-empty {
    background: #f8f4ec;
}

.map-workshop-tile.is-floor {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.42), rgba(0,0,0,0.02)),
        #e7decd;
    background-size: cover;
}

.map-workshop-tile.is-wall {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.14)),
        #6e5842;
    background-size: cover;
}

.map-workshop-tile.is-door {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.2), rgba(0,0,0,0.06)),
        #dbc8a7;
}

.map-workshop-tile.is-feature {
    background: linear-gradient(180deg, #d8b862 0%, #a17d2b 100%);
}

.map-workshop-tile.is-selected {
    outline: 3px solid rgba(39, 70, 144, 0.68);
    z-index: 1;
}

.map-workshop-note-pin {
    position: absolute;
    right: 0.2rem;
    top: 0.15rem;
    width: 0.95rem;
    height: 0.95rem;
    border-radius: 50%;
    background: #8f3328;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    line-height: 1;
    z-index: 2;
}

.map-workshop-door-icon {
    position: absolute;
    left: 0.28rem;
    bottom: 0.22rem;
    width: 1rem;
    height: 1rem;
    border-radius: 6px;
    background: rgba(92, 63, 40, 0.92);
    color: #fff7e8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1;
    z-index: 2;
}

.map-workshop-torch-icon {
    position: absolute;
    right: 0.24rem;
    bottom: 0.22rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: rgba(245, 187, 62, 0.95);
    color: #5a2f00;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    line-height: 1;
    z-index: 2;
    box-shadow: 0 0 0 2px rgba(255, 241, 205, 0.55), 0 0 12px rgba(245, 187, 62, 0.45);
}

.map-workshop-resource-pill {
    position: absolute;
    left: 0.22rem;
    top: 0.18rem;
    min-width: 1.4rem;
    padding: 0.12rem 0.28rem;
    border-radius: 999px;
    background: rgba(255, 248, 227, 0.95);
    color: #5d4a0f;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1.1;
    z-index: 2;
}

.map-workshop-token-stack {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    gap: 0.18rem;
    z-index: 9;
}

.map-workshop-token-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.map-workshop-speech-bubble {
    position: absolute;
    bottom: calc(100% + 0.3rem);
    left: 50%;
    transform: translateX(-50%);
    min-width: 3.2rem;
    max-width: 8.5rem;
    padding: 0.22rem 0.4rem;
    border-radius: 999px;
    border: 1px solid rgba(24, 20, 16, 0.12);
    background: rgba(255, 253, 248, 0.98);
    color: var(--ink);
    font-size: 0.62rem;
    line-height: 1.2;
    text-align: center;
    box-shadow: 0 6px 18px rgba(33, 28, 20, 0.12);
    white-space: normal;
    z-index: 12;
}

.map-workshop-speech-bubble::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -0.22rem;
    width: 0.45rem;
    height: 0.45rem;
    background: rgba(255, 253, 248, 0.98);
    border-right: 1px solid rgba(24, 20, 16, 0.12);
    border-bottom: 1px solid rgba(24, 20, 16, 0.12);
    transform: translateX(-50%) rotate(45deg);
}

.map-workshop-token {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.96);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 4px 10px rgba(33, 28, 20, 0.18);
}

.map-workshop-token.is-player {
    background: #274690;
    color: #fff;
}

.map-workshop-token.is-npc {
    background: #edf4f1;
    color: #214439;
}

.map-workshop-token.is-goblin {
    background: #6c7a2b;
    color: #fff8d8;
}

.map-workshop-token-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.map-workshop-needs-list {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.95rem;
}

.map-workshop-needs-card {
    display: grid;
    gap: 0.45rem;
    padding: 0.75rem 0.85rem;
    border-radius: 18px;
    background: rgba(45, 90, 77, 0.06);
}

.map-workshop-event-log {
    display: grid;
    gap: 0.55rem;
    margin-top: 0.95rem;
    max-height: 18rem;
    overflow: auto;
}

.map-workshop-event-log p {
    margin: 0;
    padding: 0.7rem 0.8rem;
    border-radius: 16px;
    background: rgba(45, 90, 77, 0.06);
    color: var(--muted);
    line-height: 1.45;
}

.map-workshop-need-row {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 0.55rem;
    align-items: center;
    color: var(--muted);
    font-size: 0.86rem;
}

.map-workshop-need-track {
    height: 0.7rem;
    border-radius: 999px;
    background: rgba(24, 20, 16, 0.08);
    overflow: hidden;
}

.map-workshop-need-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #d1a06e 0%, #9b5f2e 100%);
}

.map-workshop-need-fill.is-water {
    background: linear-gradient(90deg, #8fd3ee 0%, #3774a8 100%);
}

.map-workshop-need-fill.is-light {
    background: linear-gradient(90deg, #efe08a 0%, #c39b1d 100%);
}

.map-workshop-need-fill.is-health {
    background: linear-gradient(90deg, #d88888 0%, #9f2d2d 100%);
}

.map-workshop-need-fill.is-sleep {
    background: linear-gradient(90deg, #b9a7e8 0%, #6752a6 100%);
}

.map-workshop-need-thought {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.map-workshop-token-chip {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.8rem;
    border-radius: 18px;
}

.map-workshop-selection-meta {
    display: grid;
    grid-template-columns: auto auto;
    gap: 0.4rem 0.9rem;
    margin-top: 0.9rem;
    padding: 0.75rem 0.85rem;
    border-radius: 16px;
    background: rgba(45, 90, 77, 0.06);
}

.map-workshop-selection-meta span {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.map-workshop-selection-meta strong {
    justify-self: end;
}

.map-workshop-note-input {
    min-height: 12rem;
    resize: vertical;
}

.map-workshop-field {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.8rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.map-workshop-field select,
.map-workshop-field input {
    margin-top: 0;
}

.map-workshop-secondary {
    width: auto;
    margin-top: 0;
    padding: 0.75rem 1rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid rgba(45, 90, 77, 0.2);
    box-shadow: none;
}

@media (max-width: 1100px) {
    .map-workshop-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .map-workshop-panel-right,
    .map-workshop-panel-left {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }

    .map-workshop-board-wrap {
        min-height: 38rem;
    }
}

@media (max-width: 720px) {
    .map-workshop-shell {
        padding: 0.9rem 0.75rem 1.1rem;
    }

    .map-workshop-topbar {
        display: grid;
    }

    .map-workshop-brushes,
    .map-workshop-token-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .map-workshop-board {
        grid-template-columns: repeat(var(--draft-columns), 44px);
    }

    .map-workshop-tile {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: linear-gradient(180deg, #fbfaf7 0%, var(--bg) 100%);
    overflow-x: hidden;
    overflow-y: auto;
}

.app-shell {
    min-height: 100vh;
    overflow: visible;
}

.top-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: 0.7rem;
    padding: 0.9rem 1.25rem 0;
    background: linear-gradient(180deg, rgba(251, 250, 247, 0.95), rgba(251, 250, 247, 0.72));
    backdrop-filter: blur(10px);
}

.top-nav-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    margin-top: 0;
    padding: 0.7rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--muted);
    border: 1px solid var(--line);
    box-shadow: none;
    text-decoration: none;
}

.top-nav-button.active {
    background: var(--accent);
    color: white;
}

.top-nav-button-secondary::after {
    content: "↗";
    margin-left: 0.45rem;
    font-size: 0.8rem;
    opacity: 0.75;
}

button,
textarea,
input {
    width: 100%;
    margin-top: 0.6rem;
    padding: 1rem 1.1rem;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: #fff;
    font: inherit;
}

button {
    cursor: pointer;
    background: var(--accent);
    color: white;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    color: var(--accent);
}

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

.story-app {
    width: min(100%, 1920px);
    margin: 0 auto;
    padding: 1.5rem 1.25rem 1rem;
    min-height: calc(100vh - 4.5rem);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    gap: 1rem;
    overflow: visible;
}

.story-page {
    --scene-top: #fbfaf7;
    --scene-bottom: #f8f6f1;
    min-height: calc(100vh - 4.5rem);
    background: linear-gradient(180deg, var(--scene-top) 0%, var(--scene-bottom) 100%);
    transition: background 0.45s ease;
    overflow: visible;
}

.story-page.scene-white-between {
    --scene-top: #fcfcff;
    --scene-bottom: #eef1f8;
}

.story-page.scene-town {
    --scene-top: #faf4ea;
    --scene-bottom: #efe3cf;
}

.story-page.scene-hollow {
    --scene-top: #eef1e7;
    --scene-bottom: #d8dfcf;
}

.story-page.scene-dawnspire {
    --scene-top: #f9f3de;
    --scene-bottom: #ead9a8;
}

.story-header {
    margin-bottom: 0;
}

.reset-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.story-columns {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(320px, 420px) minmax(0, 1.6fr) minmax(280px, 360px);
    gap: 1rem;
    align-items: start;
}

.story-columns.map-expanded .story-panel-chat,
.story-columns.map-expanded .story-panel-sidebar {
    opacity: 0.18;
    pointer-events: none;
}

.story-panel {
    min-height: 0;
    display: grid;
    align-content: start;
}

.story-panel-sidebar {
    gap: 1rem;
}

.story-panel-chat {
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
    overflow: visible;
}

.story-panel-controls {
    grid-template-rows: auto;
    align-content: start;
    gap: 0.85rem;
}

.story-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.story-header-actions {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.story-header h1 {
    margin: 0.25rem 0 0.4rem;
    font-size: clamp(2rem, 4vw, 3.4rem);
    line-height: 1;
}

.story-subtitle {
    max-width: 42rem;
    margin: 0;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.6;
}

.loading-card {
    width: min(100%, 40rem);
    margin: 8vh auto 0;
    padding: 1.4rem 1.4rem 1.2rem;
    border-radius: 28px;
    background: rgba(255, 253, 248, 0.9);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.loading-card h1 {
    margin: 0.2rem 0 0.45rem;
    font-size: clamp(1.8rem, 5vw, 2.8rem);
}

.loading-copy {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.loading-track {
    margin-top: 1rem;
    height: 14px;
    border-radius: 999px;
    background: rgba(45, 90, 77, 0.12);
    overflow: hidden;
}

.loading-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #b6d4cb 0%, var(--accent) 100%);
    transition: width 0.25s ease;
}

.loading-percent {
    margin: 0.55rem 0 0;
    color: var(--accent);
    font-size: 0.95rem;
    font-weight: 600;
}

.loading-error {
    margin: 0.85rem 0 0;
    color: #8f3328;
    line-height: 1.55;
}

.tab-warning {
    padding: 0.95rem 1rem;
    border-radius: 20px;
    border: 1px solid rgba(138, 60, 34, 0.18);
    background: #fff4ef;
    box-shadow: var(--shadow);
}

.tab-warning-copy {
    margin: 0.2rem 0 0;
    color: #7d4a36;
    line-height: 1.55;
}

.mobile-panel-tabs {
    display: none;
    gap: 0.6rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mobile-panel-tab {
    margin-top: 0;
    padding: 0.75rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--muted);
    border: 1px solid var(--line);
    box-shadow: none;
}

.mobile-panel-tab.active {
    background: var(--accent);
    color: white;
}

.panel-load-card {
    display: grid;
    gap: 0.45rem;
    padding: 0.75rem 0.9rem 0.85rem;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: none;
}

.panel-load-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.panel-load-percent {
    color: var(--accent);
    font-size: 0.86rem;
    font-weight: 600;
}

.panel-load-copy {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
    font-size: 0.92rem;
}

.panel-load-track {
    height: 9px;
    border-radius: 999px;
    background: rgba(45, 90, 77, 0.12);
    overflow: hidden;
}

.panel-load-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #b6d4cb 0%, var(--accent) 100%);
    transition: width 0.25s ease;
}

.panel-load-card.is-ready .panel-load-fill {
    background: linear-gradient(90deg, #b6d4cb 0%, #4f8f78 100%);
}

.panel-load-card.is-error {
    border-color: rgba(138, 60, 34, 0.22);
    background: #fff4ef;
}

.panel-load-card.is-error .panel-load-percent,
.panel-load-card.is-error .panel-load-copy {
    color: #8a3c22;
}

.panel-load-card.is-error .panel-load-fill {
    background: linear-gradient(90deg, #e7b0a1 0%, #b35c43 100%);
}

.rulebook-panel {
    margin-bottom: 1.2rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.rulebook-copy,
.rulebook-status,
.rulebook-list span {
    color: var(--muted);
}

.rulebook-copy,
.rulebook-status {
    margin: 0.35rem 0 0;
}

.rulebook-list {
    margin: 0.8rem 0 0;
    padding-left: 1.1rem;
}

.library-tabs {
    display: flex;
    gap: 0.7rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.library-tab {
    width: auto;
    margin-top: 0;
    padding: 0.7rem 0.95rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--muted);
    border: 1px solid var(--line);
    box-shadow: none;
}

.admin-page {
    gap: 1.25rem;
}

.admin-grid {
    display: grid;
    gap: 1rem;
}

.admin-card-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.85rem;
}

.admin-card,
.admin-panel {
    background: rgba(255, 253, 248, 0.92);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.world2d-shell {
    display: grid;
    gap: 1rem;
    width: min(100%, 1920px);
    margin: 0 auto;
    padding: 1.5rem 1.25rem 1.25rem;
}

.world2d-loading {
    width: min(100%, 42rem);
    margin: 10vh auto 0;
    padding: 1.5rem;
    border-radius: 28px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.world2d-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.2rem;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.world2d-topbar h1 {
    margin: 0.2rem 0 0.35rem;
    font-size: clamp(2rem, 3vw, 3.1rem);
    line-height: 1;
}

.world2d-subtitle,
.world2d-map-copy {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.world2d-topbar-actions,
.world2d-command-actions,
.world2d-chip-list,
.world2d-legend,
.world2d-token-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.world2d-stage {
    display: grid;
    grid-template-columns: minmax(220px, 290px) minmax(0, 1fr) minmax(220px, 270px);
    gap: 1rem;
    align-items: start;
}

.world2d-sidebar,
.world2d-main {
    display: grid;
    gap: 1rem;
    align-content: start;
}

.world2d-main {
    min-width: 0;
}

.world2d-card {
    padding: 1rem 1.05rem;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.world2d-sidebar .world2d-card {
    padding: 0.95rem 0.95rem;
}

.world2d-card h2 {
    margin: 0.2rem 0 0.45rem;
    font-size: 1.55rem;
}

.world2d-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.world2d-stat-grid div {
    padding: 0.75rem 0.85rem;
    border-radius: 18px;
    background: rgba(45, 90, 77, 0.06);
}

.world2d-stat-grid span {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.world2d-log {
    max-height: 52vh;
    overflow: auto;
    opacity: 0.92;
}

.world2d-log-entry + .world2d-log-entry {
    margin-top: 0.9rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--line);
}

.world2d-log-entry strong {
    display: block;
    margin-bottom: 0.3rem;
}

.world2d-log-entry p {
    margin: 0;
    line-height: 1.5;
}

.world2d-draft-card-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.world2d-palette-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.world2d-palette-brush {
    margin-top: 0;
    padding: 0.7rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.86);
    color: var(--ink);
    border: 1px solid var(--line);
    display: grid;
    justify-items: start;
    gap: 0.45rem;
}

.world2d-palette-brush.selected {
    border-color: rgba(39, 70, 144, 0.45);
    box-shadow: 0 0 0 2px rgba(39, 70, 144, 0.12);
}

.world2d-palette-swatch {
    width: 3rem;
    height: 3rem;
    border-radius: 12px;
    border: 1px solid rgba(24, 20, 16, 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.world2d-palette-swatch.is-floor {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.08), rgba(0,0,0,0.04)),
        url('/assets/map/stone-ground.png');
    background-size: cover, 112px 112px;
}

.world2d-palette-swatch.is-wall {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.05), rgba(0,0,0,0.18)),
        url('/assets/map/wall-tiles.png');
    background-size: cover, 112px 112px;
}

.world2d-palette-swatch.is-feature {
    background: linear-gradient(180deg, rgba(244, 222, 159, 0.28), rgba(168, 134, 46, 0.22));
}

.world2d-palette-swatch.is-void {
    background: linear-gradient(180deg, #5b6570 0%, #2e343d 100%);
}

.world2d-map-card {
    display: grid;
    gap: 1rem;
    padding-bottom: 1.2rem;
}

.world2d-map-header {
    display: grid;
    gap: 0.35rem;
}

.world2d-map-wrap {
    overflow: auto;
    border-radius: 22px;
    border: 1px solid var(--line);
    background:
        linear-gradient(rgba(107, 93, 70, 0.14) 1px, transparent 1px),
        linear-gradient(90deg, rgba(107, 93, 70, 0.14) 1px, transparent 1px),
        url('/assets/map/stone-ground.png'),
        radial-gradient(circle at top, rgba(255,255,255,0.8), rgba(255,255,255,0.2)),
        linear-gradient(180deg, #f4efe3 0%, #e9dfc8 100%);
    background-size: 56px 56px, 56px 56px, 112px 112px, auto, auto;
    background-repeat: repeat, repeat, repeat, no-repeat, no-repeat;
    padding: 0.85rem;
    min-height: 48rem;
}

.world2d-map-grid {
    display: grid;
    grid-template-columns: repeat(var(--map-columns), minmax(42px, 1fr));
    gap: 0;
    width: max-content;
    min-width: 100%;
}

.world2d-cell {
    margin-top: 0;
    aspect-ratio: 1;
    width: 56px;
    min-width: 56px;
    min-height: 56px;
    padding: 0.2rem;
    border-radius: 0;
    border: 1px solid rgba(24, 20, 16, 0.08);
    border-right-width: 0;
    border-bottom-width: 0;
    background: transparent;
    color: var(--ink);
    display: grid;
    align-content: space-between;
    justify-items: start;
    text-align: left;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
    transition: transform 0.12s ease, box-shadow 0.12s ease, outline-color 0.12s ease;
    position: relative;
    overflow: hidden;
}

.world2d-cell:hover {
    transform: translateY(-1px);
    box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0.08), 0 4px 10px rgba(39, 33, 25, 0.08);
}

.world2d-cell.is-floor {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.08), rgba(0,0,0,0.04));
}

.world2d-cell.is-wall {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.05), rgba(0,0,0,0.18)),
        url('/assets/map/wall-tiles.png');
    background-size: cover, 112px 112px;
    color: #fff;
}

.world2d-cell.is-feature {
    background:
        linear-gradient(180deg, rgba(244, 222, 159, 0.28), rgba(168, 134, 46, 0.22));
}

.world2d-cell.is-void {
    background: linear-gradient(180deg, #5b6570 0%, #2e343d 100%);
    color: #fff;
}

.world2d-cell.selected {
    outline: 3px solid rgba(39, 70, 144, 0.62);
    box-shadow: 0 8px 18px rgba(39, 70, 144, 0.2), inset 0 0 0 999px rgba(255,255,255,0.08);
}

.world2d-cell.in-range:not(.selected) {
    outline: 2px solid rgba(67, 112, 197, 0.22);
    box-shadow: inset 0 0 0 2px rgba(67, 112, 197, 0.12);
}

.world2d-cell-label {
    display: none;
}

.world2d-cell-coord {
    position: absolute;
    left: 0.32rem;
    top: 0.28rem;
    color: rgba(36, 29, 21, 0.5);
    font-size: 0.52rem;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.world2d-cell:hover .world2d-cell-coord,
.world2d-cell.selected .world2d-cell-coord {
    opacity: 1;
}

.world2d-cell-marker {
    justify-self: end;
    align-self: start;
    min-width: 1.5rem;
    padding: 0.18rem 0.32rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    color: #241d15;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
}

.world2d-cell-marker.is-player-marker {
    background: #274690;
    color: #fff;
}

.world2d-cell-marker.is-landmark-marker {
    background: rgba(255, 248, 227, 0.92);
    color: transparent;
    width: 1.75rem;
    height: 1.75rem;
    min-width: 1.75rem;
    padding: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 1.1rem 1.1rem;
    border: 1px solid rgba(88, 65, 6, 0.22);
}

.world2d-cell-marker.is-void-marker {
    background: rgba(255, 255, 255, 0.9);
    color: #1f2732;
}

.world2d-note-pin {
    position: absolute;
    right: 0.32rem;
    bottom: 0.28rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: #8f3328;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    line-height: 1;
}

.world2d-cell-marker.landmark-shrine {
    background-image: url('/assets/map/props.png');
    background-size: 512px 512px;
    background-position: -431px -6px;
}

.world2d-cell-marker.landmark-bell {
    background-image: url('/assets/map/props.png');
    background-size: 512px 512px;
    background-position: -7px -123px;
}

.world2d-cell-marker.landmark-gate {
    background-image: url('/assets/map/struct.png');
    background-size: 512px 512px;
    background-position: -384px 0;
}

.world2d-cell-marker.landmark-inn {
    background-image: url('/assets/map/props.png');
    background-size: 512px 512px;
    background-position: -58px -58px;
}

.world2d-cell-marker.landmark-market {
    background-image: url('/assets/map/props.png');
    background-size: 512px 512px;
    background-position: -118px -123px;
}

.world2d-cell-marker.landmark-teleport,
.world2d-cell-marker.landmark-generic {
    background-image: url('/assets/map/props.png');
    background-size: 512px 512px;
    background-position: -359px -247px;
}

.world2d-token {
    width: auto;
    margin-top: 0;
    padding: 0;
    width: 1.8rem;
    height: 1.8rem;
    min-width: 1.8rem;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.92);
    color: #17324a;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 9px rgba(33, 28, 20, 0.18);
}

.world2d-token-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.world2d-token.is-player {
    background: #274690;
    color: #fff;
}

.world2d-token.is-npc {
    background: #edf4f1;
    color: #214439;
}

.world2d-legend {
    color: var(--muted);
    font-size: 0.88rem;
}

.world2d-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.world2d-legend i {
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 4px;
    display: inline-block;
}

.legend-floor { background: #bfb6a3; }
.legend-wall { background: #6c5c44; }
.legend-feature { background: #a8862e; }
.legend-void { background: #2e343d; }
.legend-player { background: #274690; }
.legend-range { background: #8db4ff; }

.world2d-target span {
    display: block;
    margin-bottom: 0.35rem;
}

.world2d-target select,
.world2d-input {
    margin-top: 0;
}

.world2d-commandbar {
    display: grid;
    gap: 0.85rem;
}

.world2d-sidebar-right .world2d-card:first-child {
    position: sticky;
    top: 5.5rem;
}

.world2d-selection-meta {
    display: grid;
    grid-template-columns: auto auto;
    gap: 0.4rem 0.9rem;
    margin: 0.9rem 0 0.4rem;
    padding: 0.75rem 0.85rem;
    border-radius: 16px;
    background: rgba(45, 90, 77, 0.06);
}

.world2d-selection-meta span {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.world2d-selection-meta strong {
    justify-self: end;
}

.world2d-note-editor textarea {
    min-height: 7rem;
    resize: vertical;
}

.world2d-submit,
.world2d-action,
.world2d-action-secondary,
.world2d-chip {
    width: auto;
    margin-top: 0;
    padding: 0.75rem 1rem;
    border-radius: 999px;
}

.world2d-action-secondary,
.world2d-chip {
    background: rgba(255, 255, 255, 0.86);
    color: var(--accent);
    border: 1px solid rgba(45, 90, 77, 0.18);
}

@media (max-width: 1180px) {
    .world2d-stage {
        grid-template-columns: minmax(0, 1fr);
    }

    .world2d-sidebar {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    }
}

@media (max-width: 720px) {
    .world2d-shell {
        padding: 1rem 0.85rem 1.25rem;
    }

    .world2d-topbar {
        grid-template-columns: minmax(0, 1fr);
        display: grid;
    }

    .world2d-topbar-actions,
    .world2d-command-actions {
        width: 100%;
    }

    .world2d-map-grid {
        grid-template-columns: repeat(var(--map-columns), minmax(42px, 1fr));
    }

    .world2d-cell {
        width: 42px;
        min-width: 42px;
        min-height: 42px;
    }

    .world2d-cell-marker {
        min-width: 1.15rem;
        font-size: 0.62rem;
    }

    .world2d-cell-coord {
        display: none;
    }
}

.admin-card {
    padding: 1rem 1.1rem;
    display: grid;
    gap: 0.35rem;
}

.admin-card strong {
    font-size: 1.35rem;
}

.admin-card span {
    color: var(--muted);
    line-height: 1.5;
}

.admin-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
    gap: 1rem;
}

.admin-panel {
    padding: 1rem 1.1rem;
    min-height: 0;
}

.admin-panel h2 {
    margin: 0.15rem 0 0.8rem;
}

.admin-panel-wide {
    min-width: 0;
}

.admin-stream {
    display: grid;
    gap: 0.8rem;
    max-height: 34rem;
    overflow: auto;
    padding-right: 0.15rem;
}

.admin-transcript {
    max-height: 42rem;
}

.admin-stream-card {
    padding: 0.9rem 1rem;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.75);
    display: grid;
    gap: 0.25rem;
}

.admin-stream-card strong {
    font-size: 1rem;
}

.admin-stream-card span,
.admin-meta,
.admin-note {
    color: var(--muted);
}

.admin-stream-card p,
.admin-note {
    margin: 0;
    line-height: 1.55;
}

.admin-tick-chart {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18px, 1fr));
    align-items: end;
    gap: 0.45rem;
    min-height: 8rem;
    padding-top: 0.5rem;
}

.admin-tick-bar-wrap {
    display: grid;
    justify-items: center;
    gap: 0.35rem;
}

.admin-tick-bar-wrap span {
    color: var(--muted);
    font-size: 0.72rem;
}

.admin-tick-bar {
    width: 100%;
    min-height: 10px;
    border-radius: 999px 999px 6px 6px;
    background: #b8cec7;
}

.admin-tick-bar.on-time {
    background: linear-gradient(180deg, #b8d9ce 0%, #4f8f78 100%);
}

.admin-tick-bar.slight-delay {
    background: linear-gradient(180deg, #e5d399 0%, #bc9650 100%);
}

.admin-tick-bar.late {
    background: linear-gradient(180deg, #e7b0a1 0%, #b35c43 100%);
}

.library-tab.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: rgba(45, 90, 77, 0.24);
}

.library-grid,
.wiki-grid {
    display: grid;
    grid-template-columns: 0.95fr 1.4fr;
    gap: 1rem;
}

.wiki-option-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 1rem 0;
}

.wiki-toolbar,
.wiki-summary-grid {
    display: grid;
    gap: 1rem;
    margin: 1rem 0;
}

.wiki-toolbar {
    grid-template-columns: 1.6fr 0.9fr;
    align-items: end;
}

.wiki-summary-grid {
    grid-template-columns: repeat(3, 1fr);
}

.wiki-toolbar-field label {
    display: block;
    margin-bottom: 0.2rem;
}

.wiki-summary-card {
    padding: 0.95rem 1rem;
    border-radius: 18px;
    background: #fcfaf5;
    border: 1px solid var(--line);
}

.wiki-summary-card strong {
    display: block;
    margin-top: 0.2rem;
    font-size: 1.8rem;
}

.wiki-summary-card p {
    margin: 0.35rem 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.wiki-grid {
    grid-template-columns: repeat(3, 1fr);
}

.library-column,
.wiki-card {
    min-width: 0;
}

.document-button {
    display: block;
    text-align: left;
    margin-top: 0;
    margin-bottom: 0.65rem;
    background: #fff;
    color: var(--ink);
}

.document-button span {
    display: block;
    margin-top: 0.25rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.chunk-list,
.job-list {
    display: grid;
    gap: 0.8rem;
}

.chunk-card,
.job-card,
.wiki-card {
    padding: 0.95rem 1rem;
    border-radius: 18px;
    background: #fff;
    border: 1px solid var(--line);
}

.chunk-card span,
.job-header span,
.wiki-card p {
    color: var(--muted);
}

.chunk-card p,
.wiki-card p {
    line-height: 1.65;
}

.wiki-section-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.9rem;
}

.wiki-section-header h3 {
    margin: 0.2rem 0 0;
    font-size: 1.3rem;
}

.wiki-card .rulebook-list li + li {
    margin-top: 0.55rem;
}

.library-inline-button {
    width: auto;
    margin-top: 0.8rem;
    padding: 0.7rem 0.95rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--accent);
    border: 1px solid rgba(45, 90, 77, 0.18);
    box-shadow: none;
}

.library-inline-actions {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    margin: 0.8rem 0 0.4rem;
}

.library-inline-actions .library-inline-button {
    margin-top: 0;
}

.library-inline-button.danger {
    color: #8a2f2f;
    border-color: rgba(138, 47, 47, 0.22);
    background: rgba(255, 246, 246, 0.92);
}

.job-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.progress-track {
    height: 10px;
    margin-top: 0.8rem;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(45, 90, 77, 0.12);
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #9ec7ba 0%, var(--accent) 100%);
}

.compact-sheet {
    margin-bottom: 0;
}

.character-sheet {
    margin-bottom: 0;
    padding: 1.2rem 1.2rem 1rem;
    border: 1px solid var(--line);
    border-radius: 26px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.quick-nav {
    margin-bottom: 0;
    padding: 0.95rem 1rem 1rem;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow);
}

.quick-nav-buttons {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.quick-nav-button {
    width: auto;
    margin-top: 0.5rem;
    padding: 0.72rem 0.95rem;
    border-radius: 999px;
    background: #fff;
    color: var(--accent);
    border: 1px solid rgba(45, 90, 77, 0.18);
    box-shadow: none;
}

.world-map-card {
    margin-bottom: 0;
    padding: 1rem;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.76);
    box-shadow: var(--shadow);
}

.world-map-card.is-expanded {
    position: fixed;
    inset: 1rem;
    z-index: 50;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    gap: 0.9rem;
    padding: 1.15rem;
    background: rgba(255, 252, 247, 0.985);
}

.world-map-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 0.85rem;
}

.world-map-head-actions {
    display: grid;
    justify-items: end;
    gap: 0.7rem;
}

.world-map-head h3 {
    margin: 0.15rem 0 0;
    font-size: 1.2rem;
}

.world-map-focus {
    margin: 0;
    color: var(--muted);
    text-align: right;
}

.world-map-grid {
    position: relative;
    min-height: 20rem;
    border-radius: 20px;
    border: 1px solid var(--line);
    background:
        linear-gradient(rgba(24, 20, 16, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(24, 20, 16, 0.05) 1px, transparent 1px),
        linear-gradient(180deg, rgba(248, 246, 241, 0.9), rgba(242, 235, 222, 0.95));
    background-size: 12.5% 12.5%, 12.5% 12.5%, 100% 100%;
    overflow: hidden;
}

.world-map-forecast {
    margin: 0.75rem 0 0.85rem;
    padding: 0.75rem 0.9rem;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.78);
}

.world-map-forecast-copy {
    margin: 0.25rem 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.world-map-selection-panel {
    margin: 0 0 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.world-map-selection-copy {
    color: var(--muted);
    font-size: 0.94rem;
    line-height: 1.5;
}

.world-map-selection-clear {
    width: auto;
    margin-top: 0;
    white-space: nowrap;
}

.world-map-heat {
    position: absolute;
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
}

.world-map-heat.heat-low {
    background: rgba(86, 141, 117, 0.18);
}

.world-map-heat.heat-medium {
    background: rgba(201, 154, 63, 0.22);
}

.world-map-heat.heat-high {
    background: rgba(166, 72, 44, 0.28);
}

.world-map-card.is-expanded .world-map-grid {
    min-height: 0;
    height: 100%;
}

.map-area-inn {
    background:
        linear-gradient(rgba(70, 45, 24, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(70, 45, 24, 0.08) 1px, transparent 1px),
        linear-gradient(180deg, #f4ead8, #e7d8bf);
    background-size: 12.5% 12.5%, 12.5% 12.5%, 100% 100%;
}

.map-area-market {
    background:
        linear-gradient(rgba(102, 73, 36, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(102, 73, 36, 0.07) 1px, transparent 1px),
        linear-gradient(180deg, #efe2c7, #dcc7a3);
    background-size: 12.5% 12.5%, 12.5% 12.5%, 100% 100%;
}

.map-area-shrine {
    background:
        linear-gradient(rgba(90, 83, 55, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(90, 83, 55, 0.06) 1px, transparent 1px),
        linear-gradient(180deg, #f3efe5, #e3d8c3);
    background-size: 12.5% 12.5%, 12.5% 12.5%, 100% 100%;
}

.map-area-descent,
.map-area-dungeon {
    background:
        linear-gradient(rgba(38, 46, 37, 0.09) 1px, transparent 1px),
        linear-gradient(90deg, rgba(38, 46, 37, 0.09) 1px, transparent 1px),
        linear-gradient(180deg, #dfe5d8, #b9c2b0);
    background-size: 12.5% 12.5%, 12.5% 12.5%, 100% 100%;
}

.map-area-tower,
.map-area-tower-floor {
    background:
        linear-gradient(rgba(74, 67, 40, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 67, 40, 0.08) 1px, transparent 1px),
        linear-gradient(180deg, #f4edd8, #decd9f);
    background-size: 12.5% 12.5%, 12.5% 12.5%, 100% 100%;
}

.map-area-white {
    background:
        linear-gradient(rgba(116, 124, 150, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(116, 124, 150, 0.07) 1px, transparent 1px),
        linear-gradient(180deg, #f8fbff, #e9eef9);
    background-size: 12.5% 12.5%, 12.5% 12.5%, 100% 100%;
}

.map-area-square {
    background:
        linear-gradient(rgba(97, 74, 48, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(97, 74, 48, 0.06) 1px, transparent 1px),
        linear-gradient(180deg, #f6eddc, #e5d4b4);
    background-size: 12.5% 12.5%, 12.5% 12.5%, 100% 100%;
}

.world-map-object {
    position: absolute;
    pointer-events: none;
}

.world-map-object.map-layer-floor {
    z-index: 1;
}

.world-map-selection {
    position: absolute;
    z-index: 5;
    border: 2px dashed rgba(31, 46, 87, 0.7);
    background: rgba(31, 46, 87, 0.12);
    border-radius: 12px;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.world-map-object.map-layer-blocker {
    z-index: 2;
}

.world-map-object.map-layer-furnishing {
    z-index: 3;
}

.map-object-boundary {
    border: 3px solid rgba(49, 41, 32, 0.48);
    background: rgba(255, 255, 255, 0.16);
}

.map-object-boundary-room,
.map-object-boundary-court {
    border-radius: 1.3rem;
}

.map-object-boundary-street {
    border-radius: 1.8rem;
}

.map-object-boundary-cavern {
    border-radius: 42% 58% 51% 49% / 34% 45% 55% 66%;
    border-style: dashed;
}

.map-object-counter {
    border-radius: 999px;
    background: rgba(104, 71, 36, 0.75);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.map-object-table,
.map-object-crate,
.map-object-stall {
    background: rgba(118, 87, 48, 0.75);
    border: 1px solid rgba(73, 54, 31, 0.35);
    border-radius: 1rem;
}

.map-object-stall {
    background: linear-gradient(180deg, rgba(149, 106, 57, 0.8), rgba(118, 87, 48, 0.88));
}

.map-object-lane {
    background: rgba(95, 82, 58, 0.22);
    border-radius: 999px;
}

.map-object-lane-ragged {
    border-radius: 2rem;
    box-shadow: 0 0 0 2px rgba(70, 78, 63, 0.12);
}

.map-object-bell,
.map-object-lantern,
.map-object-circle,
.map-object-winch,
.map-object-stairs,
.map-object-arch,
.map-object-pool,
.map-object-ring,
.map-object-focus {
    border-radius: 1.2rem;
}

.map-object-bell {
    background: radial-gradient(circle at 50% 35%, rgba(244, 222, 137, 0.95), rgba(170, 122, 48, 0.9));
}

.map-object-lantern,
.map-object-candle {
    background: radial-gradient(circle, rgba(255, 240, 182, 0.98), rgba(221, 176, 93, 0.78));
    border-radius: 999px;
}

.map-object-circle,
.map-object-ring {
    border: 3px solid rgba(124, 108, 72, 0.55);
    background: rgba(255, 255, 255, 0.12);
}

.map-object-winch {
    background: radial-gradient(circle at 50% 50%, rgba(96, 90, 73, 0.92), rgba(54, 50, 42, 0.92));
}

.map-object-stairs {
    background:
        repeating-linear-gradient(180deg, rgba(59, 63, 61, 0.9) 0, rgba(59, 63, 61, 0.9) 10%, rgba(103, 109, 105, 0.82) 10%, rgba(103, 109, 105, 0.82) 20%);
}

.map-object-arch {
    border: 3px solid rgba(108, 95, 66, 0.62);
    background: rgba(255, 255, 255, 0.12);
}

.map-object-pool {
    background: radial-gradient(circle at 35% 35%, rgba(74, 103, 117, 0.82), rgba(31, 52, 62, 0.9));
}

.map-object-focus {
    background: rgba(45, 90, 77, 0.26);
    border: 2px solid rgba(45, 90, 77, 0.45);
}

.map-object-door {
    background: rgba(79, 52, 30, 0.82);
    border-radius: 0.6rem;
}

.world-map-path {
    position: absolute;
    background: rgba(120, 101, 66, 0.14);
    border-radius: 999px;
    pointer-events: none;
}

.world-map-path-market {
    left: 27%;
    top: 34%;
    width: 33%;
    height: 0.55rem;
    transform: rotate(-18deg);
}

.world-map-path-inn {
    left: 31%;
    top: 45%;
    width: 18%;
    height: 0.55rem;
    transform: rotate(10deg);
}

.world-map-path-descent {
    left: 15%;
    top: 58%;
    width: 24%;
    height: 0.55rem;
    transform: rotate(24deg);
}

.world-map-path-tower {
    right: 14%;
    top: 28%;
    width: 24%;
    height: 0.55rem;
    transform: rotate(-28deg);
}

.world-map-pin,
.world-map-player {
    position: absolute;
    width: 2rem;
    height: 2rem;
    margin-top: 0;
}

.world-map-pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 999px;
    background: rgba(45, 90, 77, 0.92);
    border: 2px solid rgba(255, 255, 255, 0.9);
    color: white;
    font-size: 0.72rem;
    box-shadow: 0 8px 20px rgba(45, 90, 77, 0.2);
}

.world-map-pin.is-current {
    background: #9b5a2e;
}

.world-map-player {
    border-radius: 999px;
    background: #1f2e57;
    border: 3px solid white;
    box-shadow: 0 0 0 4px rgba(31, 46, 87, 0.16);
    cursor: grab;
    z-index: 6;
    padding: 0;
}

.world-map-player::after {
    content: "";
    position: absolute;
    inset: 0.35rem;
    border-radius: 999px;
    background: white;
}

.world-map-player:active {
    cursor: grabbing;
}

.world-map-npc {
    position: absolute;
    z-index: 7;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 18px rgba(31, 24, 20, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
}

.world-map-npc.is-curious {
    animation: mapTokenBob 2.3s ease-in-out infinite;
}

.world-map-npc.is-alarmed {
    animation: mapTokenShake 0.55s ease-in-out infinite;
}

.world-map-npc.is-warm {
    box-shadow: 0 0 0 4px rgba(45, 90, 77, 0.14), 0 8px 18px rgba(31, 24, 20, 0.18);
}

.world-map-npc.is-person {
    background: #8b5c33;
}

.world-map-npc.is-creature {
    background: #6b3a32;
}

.world-map-bubble {
    position: absolute;
    z-index: 8;
    max-width: 11rem;
    padding: 0.45rem 0.6rem;
    border-radius: 14px;
    border: 1px solid rgba(45, 90, 77, 0.18);
    background: rgba(255, 255, 255, 0.95);
    color: var(--ink);
    font-size: 0.74rem;
    line-height: 1.35;
    box-shadow: 0 10px 24px rgba(31, 24, 20, 0.12);
    transform: translateX(-50%);
    pointer-events: none;
}

.world-map-bubble::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -0.42rem;
    width: 0.7rem;
    height: 0.7rem;
    background: rgba(255, 255, 255, 0.95);
    border-right: 1px solid rgba(45, 90, 77, 0.18);
    border-bottom: 1px solid rgba(45, 90, 77, 0.18);
    transform: translateX(-50%) rotate(45deg);
}

.world-map-reaction {
    position: absolute;
    left: 50%;
    top: -0.95rem;
    transform: translateX(-50%);
    min-width: 1.35rem;
    padding: 0.08rem 0.26rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(45, 90, 77, 0.22);
    color: var(--ink);
    font-size: 0.58rem;
    line-height: 1;
    text-align: center;
    box-shadow: 0 6px 14px rgba(31, 24, 20, 0.16);
    pointer-events: none;
}

.world-map-reaction.is-alarmed {
    background: #fff2ee;
    color: #8f3328;
}

.world-map-reaction.is-curious {
    background: #f7f4ea;
    color: #765229;
}

.world-map-reaction.is-warm {
    background: #eff8f3;
    color: #2d5a4d;
}

.world-map-help {
    margin: 0.7rem 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.world-map-legend {
    display: grid;
    gap: 0.6rem;
    margin-top: 0.9rem;
}

.world-map-legend-item {
    display: block;
    text-align: left;
    margin-top: 0;
    padding: 0.8rem 0.9rem;
    border-radius: 18px;
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
    box-shadow: none;
}

.world-map-legend-item strong {
    display: block;
    margin-bottom: 0.2rem;
}

.world-map-legend-item span {
    color: var(--muted);
    line-height: 1.5;
}

.world-map-legend-item.is-current {
    border-color: rgba(155, 90, 46, 0.28);
    background: #fff7f0;
}

.sheet-topline {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

@media (max-width: 960px) {
    .world-map-grid {
        min-height: 13rem;
    }

    .world-map-card.is-expanded {
        inset: 0.45rem;
        border-radius: 20px;
    }
}

@keyframes mapTokenShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-1px) rotate(-4deg); }
    40% { transform: translateX(1px) rotate(4deg); }
    60% { transform: translateX(-1px) rotate(-3deg); }
    80% { transform: translateX(1px) rotate(3deg); }
}

@keyframes mapTokenBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

.sheet-topline h2 {
    margin: 0.2rem 0 0;
    font-size: 1.45rem;
}

.sheet-location {
    margin: 0;
    color: var(--muted);
}

.sheet-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.sheet-stat {
    padding: 0.8rem 0.85rem;
    border-radius: 18px;
    background: #fcfaf5;
    border: 1px solid var(--line);
}

.sheet-label {
    display: block;
    margin-bottom: 0.28rem;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.sheet-sections {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 0.9rem;
}

.sheet-panel {
    padding: 0.95rem 1rem;
    border-radius: 20px;
    background: #fff;
    border: 1px solid var(--line);
}

.sheet-list {
    margin: 0;
    padding-left: 1.1rem;
}

.sheet-list li + li {
    margin-top: 0.55rem;
}

.sheet-list span,
.sheet-persona,
.sheet-empty {
    color: var(--muted);
}

.sheet-appearance {
    margin: 0.9rem 0 0;
    color: var(--ink);
    line-height: 1.65;
}

.conversation {
    display: grid;
    align-content: start;
    gap: 0.9rem;
    margin-bottom: 0;
    padding-right: 0.45rem;
    padding-bottom: 0.5rem;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    outline: none;
}

.story-chat-shell {
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 0.85rem;
    overflow: visible;
}

.scene-actions-bar {
    display: grid;
    gap: 0.85rem;
    padding: 0.95rem 1rem 1rem;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.scene-banner,
.target-chooser {
    display: grid;
    gap: 0.45rem;
    padding: 0.95rem 1rem 1rem;
    border-radius: 22px;
    background: rgba(255, 253, 248, 0.9);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.scene-banner h3 {
    margin: 0;
    font-size: 1.1rem;
}

.scene-banner-copy,
.target-chooser-copy {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.target-chooser-buttons {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.merchant-panel {
    display: grid;
    gap: 0.75rem;
    padding: 0.95rem 1rem 1rem;
    border-radius: 22px;
    background: rgba(255, 253, 248, 0.9);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.merchant-card {
    padding: 0.85rem 0.9rem;
    border-radius: 18px;
    background: #fff;
    border: 1px solid var(--line);
}

.merchant-copy {
    margin: 0.35rem 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.merchant-stock-list {
    margin: 0.7rem 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0.45rem;
}

.merchant-stock-list li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.95rem;
}

.scene-actions-group {
    display: grid;
    gap: 0.45rem;
}

.scene-actions-chips {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.scene-chip {
    width: auto;
    margin-top: 0;
    padding: 0.68rem 0.9rem;
    border-radius: 999px;
    background: #fff;
    color: var(--accent);
    border: 1px solid rgba(45, 90, 77, 0.18);
    box-shadow: none;
}

.scene-chip-response {
    color: var(--ink);
    border-color: rgba(24, 20, 16, 0.12);
}

.conversation:focus-visible {
    border-radius: 22px;
    box-shadow: inset 0 0 0 2px rgba(45, 90, 77, 0.18);
}

.conversation-frame {
    display: grid;
    min-height: 0;
    min-block-size: 24rem;
    max-block-size: min(62vh, 52rem);
    padding: 0.8rem;
    border-radius: 28px;
    border: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.78);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.message-row {
    display: flex;
}

.message-row-player {
    justify-content: flex-end;
}

.message-row-dm,
.message-row-other {
    justify-content: flex-start;
}

.message {
    position: relative;
    max-width: min(46rem, 82%);
    padding: 1rem 1.15rem;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: var(--other-bg);
    box-shadow: var(--shadow);
}

.message-player {
    background: var(--player-bg);
    border-bottom-right-radius: 10px;
}

.message-player::after {
    content: "";
    position: absolute;
    right: -10px;
    bottom: 0;
    width: 18px;
    height: 18px;
    background: var(--player-bg);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-bottom-right-radius: 6px;
    clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.message-dm {
    background: var(--dm-bg);
    border-bottom-left-radius: 10px;
}

.message-dm::after {
    content: "";
    position: absolute;
    left: -10px;
    bottom: 0;
    width: 18px;
    height: 18px;
    background: var(--dm-bg);
    border-left: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-bottom-left-radius: 6px;
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.message-other {
    background: var(--other-bg);
    border-bottom-left-radius: 10px;
}

.message-other::after {
    content: "";
    position: absolute;
    left: -10px;
    bottom: 0;
    width: 18px;
    height: 18px;
    background: var(--other-bg);
    border-left: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-bottom-left-radius: 6px;
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.message-meta {
    margin-bottom: 0.35rem;
}

.message-name {
    font-size: 0.82rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
}

.message-behavior {
    margin: 0 0 0.5rem;
    color: var(--muted);
    font-style: italic;
    line-height: 1.55;
}

.message-content {
    margin: 0 0 0.55rem;
    font-size: 1.12rem;
    line-height: 1.75;
}

.message-thinking {
    opacity: 0.94;
}

.message-content-thinking {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0;
}

.message-resolution {
    margin: 0.75rem 0 0;
    color: var(--ink);
    line-height: 1.7;
    padding: 0.85rem 0.95rem;
    border-radius: 16px;
    background: rgba(45, 90, 77, 0.08);
    border: 1px solid rgba(45, 90, 77, 0.14);
}

.explain-button {
    width: auto;
    margin-top: 0.15rem;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    background: transparent;
    color: var(--accent);
    border: 1px solid rgba(45, 90, 77, 0.18);
    font-size: 0.88rem;
}

.reset-button {
    width: auto;
    margin-top: 0;
    padding: 0.65rem 0.95rem;
    border-radius: 999px;
    background: #fff6f3;
    color: #8a3c22;
    border: 1px solid rgba(138, 60, 34, 0.2);
    box-shadow: none;
}

.sheet-button {
    width: auto;
    margin-top: 0;
    padding: 0.65rem 0.95rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid rgba(45, 90, 77, 0.2);
    box-shadow: none;
}

.reset-button:disabled {
    opacity: 0.7;
    cursor: wait;
}

.story-page[data-duplicate-tab="true"] .conversation-frame {
    border-color: rgba(138, 60, 34, 0.22);
}

.single-tab-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.composer {
    position: relative;
    padding-top: 0.75rem;
    padding-bottom: 0.2rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0), color-mix(in srgb, var(--scene-bottom) 92%, white 8%) 20%);
}

.composer-chat {
    padding: 0.85rem 0 0.2rem;
    border-top: 1px solid rgba(24, 20, 16, 0.08);
}

.composer-form {
    display: grid;
    gap: 0.2rem;
}

.composer-target {
    display: block;
    margin-bottom: 0.45rem;
}

.composer-select {
    width: 100%;
    margin-top: 0.45rem;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fff;
    font: inherit;
}

.story-side-tools {
    display: grid;
    gap: 0.85rem;
    align-content: start;
}

.feedback-panel {
    margin-bottom: 0.85rem;
    padding: 0.95rem 1rem 1rem;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.tester-feedback {
    margin-top: 0.85rem;
    padding: 0.95rem 1rem 1rem;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.feedback-copy {
    margin: 0.25rem 0 0.1rem;
    color: var(--muted);
    line-height: 1.55;
}

.feedback-button {
    margin-top: 0.75rem;
    background: #f4efe4;
    color: #5f4a1b;
    border: 1px solid rgba(95, 74, 27, 0.16);
    box-shadow: none;
}

.gift-form {
    margin: 0 0 0.75rem;
}

.gift-button {
    margin-top: 0;
    margin-bottom: 0;
    background: linear-gradient(135deg, #b1873f 0%, #8f6528 100%);
    border: 1px solid rgba(102, 69, 19, 0.2);
    color: #fff8ea;
    box-shadow: 0 14px 30px rgba(122, 84, 28, 0.18);
}

.composer-input {
    min-height: 88px;
    resize: vertical;
}

.composer-input-single {
    min-height: 0;
}

.composer-button {
    margin-top: 0.8rem;
    font-weight: 600;
}

.composer-feedback {
    min-height: 1.2rem;
    margin: 0.45rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.composer-status {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-top: 0.85rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.loading-dots span {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    background: var(--accent);
    opacity: 0.35;
    animation: composer-pulse 1.2s infinite ease-in-out;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

.composer-input:disabled,
.composer-button:disabled {
    opacity: 0.72;
    cursor: wait;
}

.composer-form[data-busy="true"] .composer-input {
    opacity: 0.82;
}

@keyframes composer-pulse {
    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.3;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 900px) {
    .story-app {
        width: 100%;
        padding: 0.9rem 0.7rem 0.8rem;
        min-height: 0;
        grid-template-rows: auto auto;
    }

    .story-header-bar {
        align-items: flex-start;
        flex-direction: column;
    }

    .sheet-topline,
    .sheet-sections,
    .library-grid,
    .wiki-toolbar,
    .wiki-summary-grid,
    .wiki-option-grid,
    .wiki-grid {
        width: 100%;
        flex-direction: column;
        grid-template-columns: 1fr;
    }

    .story-header-actions {
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .story-columns {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "chat"
            "sidebar"
            "controls";
        gap: 0.8rem;
        overflow: visible;
    }

    .mobile-panel-tabs {
        display: grid;
    }

    .story-panel-chat {
        grid-area: chat;
        min-height: 0;
    }

    .story-panel-controls {
        grid-area: controls;
    }

    .story-panel-sidebar {
        grid-area: sidebar;
    }

    .story-columns.panel-active-chat .story-panel-sidebar,
    .story-columns.panel-active-chat .story-panel-controls,
    .story-columns.panel-active-sheet .story-panel-chat,
    .story-columns.panel-active-sheet .story-panel-controls,
    .story-columns.panel-active-nav .story-panel-chat,
    .story-columns.panel-active-nav .story-panel-sidebar {
        display: none;
    }

    .story-chat-shell {
        grid-template-rows: auto auto auto;
    }

    .conversation-frame {
        min-block-size: 18rem;
        max-block-size: 48vh;
        padding: 0.55rem;
        border-radius: 20px;
    }

    .conversation {
        padding-right: 0.25rem;
    }

    .message {
        max-width: 94%;
        padding: 0.9rem 0.95rem;
    }

    .message-content {
        font-size: 1rem;
        line-height: 1.6;
    }

    .character-sheet {
        padding: 0.95rem;
    }

    .sheet-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem;
    }

    .sheet-stat {
        padding: 0.65rem 0.7rem;
    }

    .sheet-label {
        font-size: 0.72rem;
    }

    .sheet-sections {
        gap: 0.65rem;
    }

    .admin-card-grid,
    .admin-columns {
        grid-template-columns: minmax(0, 1fr);
    }

    .admin-stream,
    .admin-transcript {
        max-height: none;
    }

    .quick-actions-panel,
    .feedback-panel,
    .quick-nav,
    .tester-feedback {
        padding: 0.8rem 0.85rem 0.9rem;
        border-radius: 18px;
    }

    .composer-chat {
        padding-top: 0.65rem;
    }

    .story-header h1 {
        font-size: clamp(1.5rem, 9vw, 2.2rem);
    }

    .story-subtitle {
        font-size: 0.96rem;
        line-height: 1.45;
    }
}

@media (min-width: 1180px) {
    .story-app {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        gap: 1rem;
        align-items: start;
    }

    .story-header {
        margin-bottom: 0;
    }

    .conversation {
        min-height: 0;
    }

    .message {
        max-width: min(60rem, 78%);
    }
}

@media (max-width: 1280px) {
    .admin-card-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Play page shell rebuild: keep chat, sheet, and world stable and independently scrollable. */
.story-app {
    width: min(100%, 1800px);
    padding: 1rem 1rem 1.25rem;
    min-height: calc(100vh - 4.5rem);
    align-content: start;
}

.story-header {
    display: grid;
    gap: 0.9rem;
}

.story-columns {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(300px, 380px);
    gap: 1rem;
    align-items: start;
}

.story-panel {
    min-width: 0;
}

.story-panel-sidebar,
.story-panel-controls {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 8.75rem);
    overflow: auto;
    padding-right: 0.2rem;
}

.story-panel-chat {
    min-width: 0;
    min-height: 0;
}

.story-chat-shell {
    display: grid;
    gap: 1rem;
    min-height: 0;
}

.scene-banner,
.conversation-frame,
.character-sheet,
.quick-nav,
.world-map-card,
.merchant-panel,
.voxel-card,
.feedback-panel,
.tester-feedback,
.target-chooser {
    background: rgba(255, 253, 248, 0.92);
}

.voxel-card {
    margin-bottom: 0;
    padding: 1rem;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--shadow);
}

.voxel-card.is-expanded {
    position: fixed;
    inset: 1rem;
    z-index: 45;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 0.9rem;
    padding: 1.15rem;
    background: rgba(255, 252, 247, 0.985);
}

.voxel-view {
    position: relative;
    min-height: 18rem;
    border-radius: 20px;
    border: 1px solid var(--line);
    overflow: hidden;
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.95), rgba(234, 225, 209, 0.9) 55%, rgba(209, 197, 177, 0.92) 100%);
}

.voxel-card.is-expanded .voxel-view {
    min-height: 0;
    height: 100%;
}

.voxel-view canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.world3d-shell {
    min-height: calc(100vh - 4.5rem);
    padding: 1rem;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 1rem;
    background: radial-gradient(circle at top, #f2ece1 0%, #dcccb4 52%, #c9b79d 100%);
}

.world3d-loading {
    width: min(100%, 34rem);
    margin: 8vh auto 0;
    padding: 1.5rem;
    border-radius: 24px;
    background: rgba(255, 252, 247, 0.9);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.world3d-loading h1 {
    margin: 0.2rem 0 0.6rem;
}

.world3d-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    border-radius: 24px;
    border: 1px solid rgba(24, 20, 16, 0.1);
    background: rgba(255, 252, 247, 0.82);
    box-shadow: var(--shadow);
}

.world3d-topbar h1 {
    margin: 0.2rem 0 0.35rem;
    font-size: clamp(1.8rem, 3vw, 3rem);
}

.world3d-subtitle {
    margin: 0;
    color: var(--muted);
    max-width: 44rem;
    line-height: 1.55;
}

.world3d-topbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.6rem;
}

.world3d-action,
.world3d-chip,
.world3d-submit {
    width: auto;
    margin-top: 0;
    padding: 0.75rem 1rem;
    border-radius: 999px;
}

.world3d-stage {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(250px, 320px) minmax(720px, 1fr) minmax(250px, 320px);
    grid-template-areas: "left viewport right";
    gap: 1rem;
    align-items: stretch;
}

.world3d-viewport {
    grid-area: viewport;
    min-height: 52vh;
    min-width: 0;
    aspect-ratio: 16 / 10;
    border-radius: 28px;
    border: 1px solid rgba(24, 20, 16, 0.12);
    background: linear-gradient(180deg, rgba(255,255,255,0.58), rgba(234,225,209,0.75));
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.world3d-viewport canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.world3d-renderer-status {
    position: absolute;
    left: 1rem;
    top: 1rem;
    z-index: 2;
    max-width: min(24rem, calc(100% - 2rem));
    padding: 0.8rem 1rem;
    border-radius: 18px;
    border: 1px solid rgba(24, 20, 16, 0.12);
    background: rgba(250, 246, 238, 0.92);
    box-shadow: 0 16px 30px rgba(24, 20, 16, 0.08);
}

.world3d-renderer-status strong {
    display: block;
    margin-top: 0.25rem;
    font-size: 1rem;
}

.world3d-renderer-status p:last-child {
    margin: 0.35rem 0 0;
}

.world3d-renderer-status-error {
    border-color: rgba(145, 49, 49, 0.28);
    background: rgba(255, 243, 240, 0.95);
}

.world3d-viewport-hint {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    z-index: 2;
    max-width: min(26rem, calc(100% - 2rem));
    padding: 0.65rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(24, 20, 16, 0.12);
    background: rgba(250, 246, 238, 0.88);
    color: var(--muted);
    font-size: 0.92rem;
    box-shadow: 0 12px 24px rgba(24, 20, 16, 0.08);
}

.world3d-hud {
    min-height: 0;
    display: grid;
    gap: 1rem;
    align-content: start;
}

.world3d-hud-left {
    grid-area: left;
}

.world3d-hud-right {
    grid-area: right;
}

.world3d-card {
    padding: 1rem 1.05rem;
    border-radius: 22px;
    border: 1px solid rgba(24, 20, 16, 0.1);
    background: rgba(255, 252, 247, 0.9);
    box-shadow: var(--shadow);
}

.world3d-card h2 {
    margin: 0.2rem 0 0.45rem;
}

.world3d-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 0.9rem;
}

.world3d-stat-grid div {
    padding: 0.75rem 0.8rem;
    border-radius: 16px;
    background: rgba(45, 90, 77, 0.08);
    display: grid;
    gap: 0.2rem;
}

.world3d-stat-grid span {
    color: var(--muted);
    font-size: 0.82rem;
}

.world3d-log {
    max-height: 42vh;
    overflow: auto;
}

.world3d-log-entry {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(24, 20, 16, 0.08);
}

.world3d-log-entry:last-child {
    border-bottom: 0;
}

.world3d-log-entry p {
    margin: 0.3rem 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.world3d-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.world3d-chip {
    background: rgba(45, 90, 77, 0.12);
    color: var(--accent);
    border: 1px solid rgba(45, 90, 77, 0.16);
}

.world3d-commandbar {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) auto;
    gap: 0.8rem;
    padding: 0.95rem 1rem;
    border-radius: 24px;
    border: 1px solid rgba(24, 20, 16, 0.1);
    background: rgba(255, 252, 247, 0.88);
    box-shadow: var(--shadow);
}

.world3d-target {
    display: grid;
    gap: 0.3rem;
}

.world3d-target select,
.world3d-input {
    width: 100%;
    margin-top: 0;
    padding: 0.95rem 1rem;
    border-radius: 18px;
    border: 1px solid rgba(24, 20, 16, 0.12);
    background: rgba(255, 255, 255, 0.92);
    font: inherit;
}

.world3d-submit {
    min-width: 10rem;
}

@media (max-width: 1100px) {
    .world3d-stage {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "viewport"
            "left"
            "right";
    }

    .world3d-hud-left,
    .world3d-hud-right {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }

    .world3d-commandbar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .world3d-shell {
        padding: 0.75rem;
    }

    .world3d-topbar {
        grid-template-columns: minmax(0, 1fr);
        display: grid;
    }

    .world3d-topbar-actions {
        justify-content: flex-start;
    }

    .world3d-viewport {
        min-height: 40vh;
    }
}

.conversation-frame {
    min-block-size: 24rem;
    max-block-size: calc(100vh - 22rem);
}

.conversation {
    height: 100%;
    overflow: auto;
    padding-right: 0.35rem;
}

.asset-workshop-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.asset-workshop-grid {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 1rem;
}

.asset-column {
    display: grid;
    gap: 1rem;
    align-content: start;
}

.asset-column-wide {
    min-width: 0;
}

.asset-job-button,
.asset-approved-card {
    width: 100%;
    display: grid;
    gap: 0.2rem;
    text-align: left;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    border: 1px solid rgba(24, 20, 16, 0.1);
    background: rgba(255, 252, 247, 0.9);
    box-shadow: var(--shadow);
}

.asset-job-button.active {
    border-color: rgba(45, 90, 77, 0.28);
    background: rgba(232, 245, 239, 0.94);
}

.asset-job-button span,
.asset-approved-card span {
    color: var(--muted);
    font-size: 0.92rem;
}

.asset-meta-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.8rem;
    margin: 1rem 0;
}

.asset-meta-grid div {
    padding: 0.8rem 0.9rem;
    border-radius: 16px;
    background: rgba(45, 90, 77, 0.08);
    display: grid;
    gap: 0.2rem;
}

.asset-meta-grid span {
    color: var(--muted);
    font-size: 0.82rem;
}

.asset-preview-stack {
    display: grid;
    gap: 1rem;
}

.asset-layer-card {
    padding: 0.9rem 1rem;
    border-radius: 18px;
    border: 1px solid rgba(24, 20, 16, 0.1);
    background: rgba(255, 252, 247, 0.82);
}

.asset-layer-heading {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.75rem;
}

.asset-layer-heading span {
    color: var(--muted);
    font-size: 0.92rem;
}

.asset-voxel-grid {
    display: grid;
    gap: 0.22rem;
}

.asset-voxel-cell {
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    border: 1px solid rgba(24, 20, 16, 0.08);
}

.asset-voxel-cell.empty {
    background: rgba(255, 255, 255, 0.5);
}

@media (max-width: 960px) {
    .asset-workshop-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .asset-meta-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.composer {
    padding-top: 0;
    padding-bottom: 0;
    background: none;
}

.composer-chat {
    padding: 0;
    border-top: 0;
}

.composer-form {
    gap: 0.75rem;
    padding: 1rem 1.05rem 1.05rem;
    border-radius: 24px;
    background: rgba(255, 253, 248, 0.92);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.composer-target {
    margin-bottom: 0;
}

.composer-input-single,
.composer-select {
    margin-top: 0.35rem;
}

.story-header-actions {
    flex-wrap: wrap;
}

.world-map-card {
    max-height: calc(100vh - 8.75rem);
    overflow: auto;
}

.world-map-card.is-expanded {
    position: fixed;
    inset: 1.25rem;
    z-index: 30;
    max-height: none;
    overflow: hidden;
}

.world-map-card.is-expanded .world-map-grid {
    min-height: min(72vh, 900px);
}

@media (min-width: 901px) {
    .mobile-panel-tabs {
        display: none !important;
    }

    .story-panel-sidebar,
    .story-panel-chat,
    .story-panel-controls {
        display: grid !important;
    }
}

@media (max-width: 900px) {
    .story-app {
        padding: 0.85rem 0.75rem 1rem;
        min-height: 0;
    }

    .mobile-panel-tabs {
        display: grid;
        position: sticky;
        top: 0.75rem;
        z-index: 8;
        padding: 0.35rem;
        border-radius: 18px;
        background: rgba(251, 250, 247, 0.92);
        backdrop-filter: blur(10px);
    }

    .story-columns {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.9rem;
    }

    .story-panel-sidebar,
    .story-panel-controls,
    .story-panel-chat {
        position: static;
        top: auto;
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .story-columns.panel-active-chat .story-panel-sidebar,
    .story-columns.panel-active-chat .story-panel-controls,
    .story-columns.panel-active-sheet .story-panel-chat,
    .story-columns.panel-active-sheet .story-panel-controls,
    .story-columns.panel-active-nav .story-panel-chat,
    .story-columns.panel-active-nav .story-panel-sidebar {
        display: none !important;
    }

    .conversation-frame {
        min-block-size: 18rem;
        max-block-size: 48vh;
        padding: 0.6rem;
    }

    .composer-form,
    .world-map-card,
    .character-sheet,
    .quick-nav,
    .merchant-panel,
    .feedback-panel,
    .tester-feedback,
    .target-chooser {
        border-radius: 20px;
    }
}

@media (min-width: 1520px) {
    .story-columns {
        grid-template-columns: minmax(340px, 440px) minmax(0, 1.8fr) minmax(320px, 420px);
    }
}

.app-build-badge {
    position: fixed;
    right: 0.9rem;
    bottom: 0.9rem;
    z-index: 80;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: rgba(17, 24, 22, 0.88);
    color: #f8f4eb;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

.app-build-badge strong {
    color: #b9e0d5;
    font-size: 0.74rem;
    text-transform: uppercase;
}

.app-build-badge span {
    white-space: nowrap;
}

@media (max-width: 640px) {
    .app-build-badge {
        right: 0.6rem;
        bottom: 0.6rem;
        padding: 0.4rem 0.6rem;
        font-size: 0.72rem;
    }
}
