* {
    box-sizing: border-box;
}

html,
body,
.app-root,
main,
.game-shell {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    background: #10140f;
    color: #f3efe2;
    font-family: "Segoe UI", system-ui, sans-serif;
}

:root {
    --frame-image: url("/gfx/ui/frames/window-frame-9slice.png");
    --frame-slice: 128;
    --ui-scale: 1;
    --control-size: calc(44px * var(--ui-scale));
    --control-icon-size: calc(30px * var(--ui-scale));
}

a {
    color: inherit;
}

button,
input {
    font: inherit;
}

#worldCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
    touch-action: none;
    background: #1b2517;
}

.top-bar {
    position: fixed;
    top: 12px;
    left: 12px;
    right: 12px;
    min-height: 48px;
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto auto auto auto auto;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border: 12px solid transparent;
    border-radius: 8px;
    border-image: var(--frame-image) var(--frame-slice) / 12px / 3px round;
    background: rgba(16, 20, 15, 0.9);
    background-clip: padding-box;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.top-bar > div {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 7px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.07);
}

.brand {
    font-weight: 800;
    color: #f5c542;
}

.top-menu-button {
    min-width: 64px;
    height: 34px;
    border: 1px solid rgba(243, 239, 226, 0.24);
    border-radius: 8px;
    background: #d7a62a;
    color: #17170e;
    font-weight: 800;
    cursor: pointer;
}

.tool-panel,
.map-controls {
    position: fixed;
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 12px solid transparent;
    border-radius: 8px;
    border-image: var(--frame-image) var(--frame-slice) / 12px / 3px round;
    background: rgba(16, 20, 15, 0.9);
    background-clip: padding-box;
    backdrop-filter: blur(10px);
}

.tool-panel {
    right: 12px;
    bottom: 12px;
    grid-template-columns: repeat(11, var(--control-size));
}

.tool-hint {
    position: absolute;
    right: 8px;
    bottom: calc(100% + 8px);
    width: min(280px, calc(100vw - 24px));
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid rgba(243, 239, 226, 0.22);
    border-radius: 8px;
    background: rgba(16, 20, 15, 0.94);
    color: #c9d2bf;
    font-size: 13px;
    line-height: 1.3;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 120ms ease, transform 120ms ease;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34);
}

.tool-hint.visible {
    opacity: 1;
    transform: translateY(0);
}

.tool-hint strong {
    display: block;
    margin-bottom: 3px;
    color: #f5c542;
}

.map-controls {
    left: 12px;
    bottom: 12px;
    grid-template-columns: repeat(4, var(--control-size));
}

.tool-panel button,
.map-controls button {
    width: var(--control-size);
    height: var(--control-size);
    border: 1px solid rgba(243, 239, 226, 0.22);
    border-radius: 8px;
    background-color: #2b3928;
    background-position: center;
    background-repeat: no-repeat;
    background-size: var(--control-icon-size) var(--control-icon-size);
    color: #f3efe2;
    font-weight: 800;
    cursor: pointer;
}

.tool-panel button.asset-icon,
.map-controls button.asset-icon {
    color: transparent;
    overflow: hidden;
    text-indent: -999px;
}

.tool-panel button.active,
.tool-panel button:hover,
.map-controls button:hover {
    background-color: #d7a62a;
    color: #17170e;
}

.tool-panel button.asset-icon.active,
.tool-panel button.asset-icon:hover,
.map-controls button.asset-icon:hover {
    color: transparent;
}

.tool-panel button:disabled,
.tool-panel button.unavailable {
    cursor: not-allowed;
    filter: grayscale(1);
    opacity: 0.42;
}

.cell-info {
    position: fixed;
    top: 76px;
    right: 12px;
    width: min(320px, calc(100vw - 24px));
    padding: 12px;
    border: 16px solid transparent;
    border-radius: 8px;
    border-image: var(--frame-image) var(--frame-slice) / 16px / 4px round;
    background: rgba(16, 20, 15, 0.9);
    background-clip: padding-box;
    backdrop-filter: blur(10px);
}

.action-panel {
    position: fixed;
    z-index: 5;
    width: min(260px, calc(100vw - 24px));
    padding: 12px;
    border: 16px solid transparent;
    border-radius: 8px;
    border-image: var(--frame-image) var(--frame-slice) / 16px / 4px round;
    background: rgba(16, 20, 15, 0.94);
    background-clip: padding-box;
    backdrop-filter: blur(10px);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.action-panel.hidden {
    display: none;
}

.action-panel h3 {
    margin: 0 0 6px;
    font-size: 15px;
}

.action-panel p {
    margin: 0;
    color: #c9d2bf;
    font-size: 13px;
}

.action-meta {
    display: grid;
    gap: 4px;
    margin-top: 10px;
}

.action-meta-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
}

.action-meta-row span:first-child {
    color: #c9d2bf;
}

.action-select,
.action-textarea {
    width: 100%;
    margin-top: 10px;
    border: 1px solid rgba(243, 239, 226, 0.24);
    border-radius: 8px;
    padding: 10px;
    background: #10140f;
    color: #f3efe2;
}

.action-textarea {
    min-height: 84px;
    resize: vertical;
}

.action-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.action-actions button {
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    background: #d7a62a;
    color: #17170e;
    font-weight: 800;
}

.action-actions button:disabled {
    cursor: not-allowed;
    filter: grayscale(1);
    opacity: 0.5;
}

.action-feedback,
.action-disabled,
.action-status {
    margin-top: 10px;
    font-size: 13px;
}

.action-feedback {
    color: #f5c542;
}

.action-disabled {
    color: #ffb0a3;
}

.action-status {
    color: #f5c542;
}

.world-panel {
    position: fixed;
    top: 76px;
    left: 12px;
    width: min(280px, calc(100vw - 24px));
    max-height: calc(100vh - 164px);
    overflow: auto;
    padding: 12px;
    border: 16px solid transparent;
    border-radius: 8px;
    border-image: var(--frame-image) var(--frame-slice) / 16px / 4px round;
    background: rgba(16, 20, 15, 0.9);
    background-clip: padding-box;
    backdrop-filter: blur(10px);
}

.world-panel h2 {
    margin: 0 0 8px;
    font-size: 15px;
}

.world-panel ol {
    margin: 0 0 14px 20px;
    padding: 0;
}

.activity-item {
    margin-bottom: 8px;
    color: #c9d2bf;
    font-size: 13px;
}

.admin-shell {
    min-height: 100vh;
    padding: 20px;
    background: #10140f;
}

.admin-header {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}

.admin-header h1,
.admin-grid h2 {
    margin: 0;
}

.admin-header button,
.admin-form button,
.admin-row button {
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    background: #d7a62a;
    color: #17170e;
    font-weight: 800;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.admin-grid section {
    padding: 14px;
    border: 16px solid transparent;
    border-radius: 8px;
    border-image: var(--frame-image) var(--frame-slice) / 16px / 4px round;
    background: rgba(255, 255, 255, 0.06);
    background-clip: padding-box;
}

.admin-form {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.admin-form input {
    min-width: 0;
    border: 1px solid rgba(243, 239, 226, 0.24);
    border-radius: 8px;
    padding: 10px;
    background: #10140f;
    color: #f3efe2;
}

.admin-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.admin-row {
    display: grid;
    gap: 4px;
    padding: 8px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.admin-row code {
    overflow-wrap: anywhere;
    color: #c9d2bf;
}

#adminStatus {
    white-space: pre-wrap;
    margin-top: 16px;
    color: #c9d2bf;
}

.cell-info h2 {
    margin: 0 0 8px;
    font-size: 16px;
}

.cell-info dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    margin: 0;
}

.cell-info dt {
    color: #c9d2bf;
}

.cell-info dd {
    margin: 0;
    text-align: right;
}

.muted {
    color: #c9d2bf;
}

.join-dialog {
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-rows: auto auto;
    place-items: center;
    align-content: center;
    gap: 14px;
    padding: 24px;
    background: linear-gradient(rgba(5, 8, 4, 0.58), rgba(5, 8, 4, 0.72));
}

.join-dialog.hidden {
    display: none;
}

.main-menu-logo {
    display: block;
    width: min(460px, 86vw);
    max-height: min(220px, 28vh);
    object-fit: contain;
    filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.45));
}

.join-panel {
    width: min(420px, 100%);
    padding: 24px;
    border: 24px solid transparent;
    border-radius: 8px;
    border-image: var(--frame-image) var(--frame-slice) / 24px / 6px round;
    background: rgba(20, 25, 18, 0.94);
    background-clip: padding-box;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.main-menu {
    display: grid;
    gap: 14px;
}

.join-panel h1 {
    margin: 0;
    font-size: 32px;
    color: #f5c542;
}

.join-panel p {
    margin: -8px 0 4px;
    color: #c9d2bf;
}

.menu-primary,
.menu-actions a {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(243, 239, 226, 0.22);
    border-radius: 8px;
    background: #2b3928;
    color: #f3efe2;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.menu-actions {
    display: grid;
    gap: 8px;
}

.menu-setting {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
    color: #c9d2bf;
    font-weight: 700;
}

.menu-setting input {
    width: 100%;
    accent-color: #d7a62a;
}

.asset-progress {
    display: grid;
    gap: 8px;
}

.asset-progress-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #c9d2bf;
    font-size: 13px;
    font-weight: 700;
}

.asset-progress-track {
    height: 10px;
    overflow: hidden;
    border: 1px solid rgba(243, 239, 226, 0.22);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.32);
}

.asset-progress-bar {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: #d7a62a;
    transition: width 160ms ease;
}

.hidden {
    display: none !important;
}

#joinForm {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

#joinForm input {
    min-width: 0;
    border: 1px solid rgba(243, 239, 226, 0.24);
    border-radius: 8px;
    padding: 12px;
    background: #10140f;
    color: #f3efe2;
}

#joinForm button {
    border: 0;
    border-radius: 8px;
    padding: 0 18px;
    background: #d7a62a;
    color: #17170e;
    font-weight: 800;
}

#joinError {
    min-height: 20px;
    margin-top: 10px;
    color: #ffb0a3;
}

@media (max-width: 760px) {
    .top-bar {
        grid-template-columns: 1fr 1fr;
        font-size: 13px;
    }

    .brand,
    .top-menu-button {
        grid-column: span 2;
    }

    .cell-info {
        top: auto;
        right: 12px;
        bottom: 76px;
        left: 12px;
        width: auto;
    }

    .action-panel {
        top: auto !important;
        right: 12px !important;
        bottom: 216px;
        left: 12px !important;
        width: auto;
    }

    .tool-panel {
        left: 12px;
        right: 12px;
        grid-template-columns: repeat(11, minmax(28px, 1fr));
    }

    .tool-hint {
        right: 0;
        bottom: calc(100% + 8px);
        width: 100%;
    }

    .tool-panel button,
    .map-controls button {
        width: 100%;
    }

    .map-controls {
        bottom: 76px;
    }
}

