:root,
:host {
    --cream: #fff8e0;
    --ink: #26342c;
    --deep-green: #244737;
    --forest: #35634a;
    --gold: #f0cb68;
    --brown: #6a431f;
    --sand: #cda66c;
    --panel: #fffdf4;
    --line: #d6c9aa;
    --shadow: 0 12px 32px rgba(37, 52, 44, 0.16);
}

* {
    box-sizing: border-box;
}

.integrated-alpha-builder .builder-header .back-link {
    display: none;
}

html {
    min-width: 320px;
}

body {
    background:
        radial-gradient(circle at 8% 0%, rgba(240, 203, 104, 0.24), transparent 28rem),
        linear-gradient(135deg, #e5eee6, #f5eedb 55%, #dce9df);
    color: var(--ink);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    min-height: 100vh;
}

button,
input,
select {
    font: inherit;
}

button,
select,
input[type="range"] {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
.builder-stage:focus-visible,
a:focus-visible {
    outline: 3px solid #1671c4;
    outline-offset: 2px;
}

.builder-header {
    align-items: center;
    background: rgba(32, 65, 49, 0.96);
    border-bottom: 4px solid var(--gold);
    color: var(--cream);
    display: grid;
    gap: 22px;
    grid-template-columns: auto 1fr auto;
    padding: 14px clamp(16px, 3vw, 40px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.back-link {
    border: 1px solid rgba(255, 248, 224, 0.58);
    border-radius: 999px;
    color: var(--cream);
    font-size: 0.86rem;
    font-weight: 800;
    padding: 9px 14px;
    text-decoration: none;
    white-space: nowrap;
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.12);
}

.brand {
    align-items: center;
    display: flex;
    gap: 13px;
    min-width: 0;
}

.brand h1 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.18rem, 2vw, 1.8rem);
    margin: 0;
}

.brand p {
    font-size: 0.8rem;
    margin: 2px 0 0;
    opacity: 0.82;
}

.alpha-pill {
    background: var(--gold);
    border: 2px solid var(--brown);
    border-radius: 999px;
    color: #38260f;
    flex: 0 0 auto;
    font-size: 0.65rem;
    font-weight: 900;
    letter-spacing: 0.09em;
    padding: 6px 9px;
    text-transform: uppercase;
}

.save-state {
    align-items: center;
    display: flex;
    font-size: 0.78rem;
    font-weight: 700;
    gap: 8px;
    justify-content: flex-end;
    min-width: 150px;
}

.save-indicator {
    background: #e5b753;
    border: 2px solid rgba(255, 255, 255, 0.42);
    border-radius: 50%;
    height: 11px;
    width: 11px;
}

.save-indicator.saved {
    background: #6dd38b;
}

.save-indicator.error {
    background: #ef6b61;
}

.builder-layout {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(230px, 270px) minmax(500px, 1fr) minmax(240px, 285px);
    margin: 18px auto 34px;
    max-width: 1880px;
    padding: 0 18px;
}

.panel,
.workspace-panel {
    background: rgba(255, 253, 244, 0.96);
    border: 1px solid rgba(117, 93, 55, 0.2);
    border-radius: 18px;
    box-shadow: var(--shadow);
    min-width: 0;
}

.panel {
    align-self: start;
    overflow: hidden;
}

.palette-panel,
.inspector-panel {
    max-height: calc(100vh - 104px);
    overflow-y: auto;
    position: sticky;
    top: 90px;
}

.panel-section {
    border-bottom: 1px solid var(--line);
    padding: 18px;
}

.panel-section:last-child {
    border-bottom: 0;
}

.compact-section {
    padding-bottom: 20px;
}

.section-heading {
    align-items: flex-start;
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.section-heading h2,
.compact-section h2 {
    font-size: 0.98rem;
    margin: 0;
}

.section-heading p {
    color: #66736c;
    font-size: 0.73rem;
    line-height: 1.35;
    margin: 3px 0 0;
}

.step-number {
    align-items: center;
    background: var(--deep-green);
    border-radius: 50%;
    color: white;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 0.72rem;
    font-weight: 900;
    height: 25px;
    justify-content: center;
    width: 25px;
}

.field-label,
.toolbar-label {
    color: #57635c;
    display: block;
    font-size: 0.72rem;
    font-weight: 800;
    margin-bottom: 5px;
}

.field-control,
.toolbar-select,
.properties-form input,
.properties-form select {
    background: white;
    border: 1px solid #b9ad91;
    border-radius: 9px;
    color: var(--ink);
    min-height: 38px;
    padding: 7px 9px;
    width: 100%;
}

.level-summary {
    background: #edf4ec;
    border: 1px solid #c8d9c7;
    border-radius: 10px;
    display: grid;
    gap: 2px;
    grid-template-columns: 1fr auto;
    margin-top: 10px;
    padding: 10px 11px;
}

.level-navigation {
    align-items: center;
    background: #233f31;
    border: 1px solid rgba(240, 203, 104, 0.76);
    border-radius: 11px;
    color: var(--cream);
    display: grid;
    gap: 8px;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    margin-bottom: 12px;
    padding: 6px;
}

.level-position {
    color: #ffe69a;
    font-size: 0.76rem;
    text-align: center;
}

.level-nav-button {
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    font-size: 1rem;
    font-weight: 900;
    height: 34px;
    justify-content: center;
    padding: 0;
}

.level-nav-button:hover:not(:disabled) {
    background: var(--gold);
    border-color: var(--brown);
    color: #35220d;
}

.level-nav-button:disabled {
    cursor: not-allowed;
    opacity: 0.32;
}

.level-summary span {
    color: #637267;
    font-size: 0.68rem;
}

.level-summary strong {
    font-size: 0.8rem;
    grid-column: 1 / -1;
}

#level-count {
    grid-column: 2;
    grid-row: 1;
}

.piece-category-tabs {
    display: grid;
    gap: 7px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 12px;
}

.piece-category-tab {
    align-items: center;
    background: #f8f2df;
    border: 1px solid #cdbf9f;
    border-radius: 11px;
    color: #61513b;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    font: inherit;
    font-size: 0.59rem;
    font-weight: 900;
    gap: 3px;
    justify-content: center;
    min-height: 72px;
    padding: 6px 3px;
    position: relative;
    text-align: center;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.piece-category-tab:hover,
.piece-category-tab:focus-visible {
    background: #fff2bf;
    border-color: #92703a;
    outline: none;
    transform: translateY(-1px);
}

.piece-category-tab.active,
.piece-category-tab[aria-selected="true"] {
    background: #28543f;
    border-color: #173b2c;
    box-shadow: inset 0 0 0 2px rgba(246, 205, 100, 0.32);
    color: #fff2bd;
}

.piece-category-icon {
    fill: currentColor;
    height: 27px;
    width: 34px;
}

.category-count {
    align-items: center;
    background: #f1c95f;
    border: 1px solid #8a6427;
    border-radius: 999px;
    color: #3c2a11;
    display: flex;
    font-size: 0.55rem;
    height: 18px;
    justify-content: center;
    line-height: 1;
    min-width: 18px;
    padding: 0 4px;
    position: absolute;
    right: 4px;
    top: 4px;
}

.piece-category-panel[hidden] {
    display: none;
}

.category-help {
    color: #6f685a;
    font-size: 0.65rem;
    line-height: 1.35;
    margin: 7px 0 0;
}

.shared-level-tools {
    border-top: 1px solid #dfd3b8;
    margin-top: 15px;
    padding-top: 1px;
}

.compact-tool-item {
    min-height: 58px;
}

.palette-group-title {
    color: #6f5a3a;
    font-size: 0.7rem;
    letter-spacing: 0.09em;
    margin: 16px 0 7px;
    text-transform: uppercase;
}

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

.single-palette-item {
    grid-template-columns: minmax(0, 1fr);
}

.door-domain-heading {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: space-between;
    margin-top: 16px;
}

.door-domain-heading .palette-group-title {
    margin: 0;
}

.door-domain-badge {
    background: #e8f0e9;
    border: 1px solid #b7cab9;
    border-radius: 999px;
    color: #31533d;
    font-size: 0.59rem;
    font-weight: 900;
    max-width: 110px;
    overflow: hidden;
    padding: 4px 7px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.level-door-palette {
    margin-top: 8px;
}

.door-domain-empty {
    background: #f5f1e5;
    border: 1px dashed #b9aa89;
    border-radius: 9px;
    color: #6f685a;
    font-size: 0.68rem;
    grid-column: 1 / -1;
    line-height: 1.4;
    margin: 0;
    padding: 10px;
}

.palette-item {
    align-items: center;
    background: #fffcf1;
    border: 1px solid #cdbf9f;
    border-radius: 10px;
    color: #4d4436;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    font-size: 0.68rem;
    font-weight: 800;
    gap: 7px;
    justify-content: center;
    min-height: 74px;
    padding: 8px 5px;
    transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.palette-item:hover {
    background: #fff4cf;
    border-color: #8c713f;
    transform: translateY(-1px);
}

.palette-preview {
    display: block;
    position: relative;
}

.platform-preview,
.path-preview {
    background:
        repeating-linear-gradient(90deg, transparent 0 18px, rgba(91, 58, 26, 0.22) 19px 21px),
        linear-gradient(#dfbd80, #a97842);
    border: 2px solid #6b4627;
    border-radius: 4px;
    height: 14px;
}

.platform-preview {
    background: url("../assets/level-pieces/sandstone-ledge.webp") center / 100% 100% no-repeat;
    border: 0;
    border-radius: 0;
    filter: drop-shadow(0 2px 2px rgba(63, 37, 17, 0.32));
    height: 17px;
}

.platform-preview.smart { width: 70px; }

.ladder-preview {
    background: url("../assets/level-pieces/spelling-spire-timber-ladder.webp") center / contain no-repeat;
    filter: drop-shadow(0 2px 2px rgba(63, 37, 17, 0.32));
    height: 48px;
    width: 38px;
}

.architecture-preview {
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    filter: drop-shadow(0 2px 2px rgba(63, 37, 17, 0.32));
    height: 42px;
    width: 78px;
}

.compact-corbel-ledge-preview {
    background-image: url("../assets/level-pieces/sandstone-ledge-compact-corbel.webp");
}

.long-supported-ledge-preview {
    background-image: url("../assets/level-pieces/sandstone-ledge-long-supported.webp");
}

.deep-cantilever-ledge-preview {
    background-image: url("../assets/level-pieces/sandstone-ledge-deep-cantilever.webp");
}

.compact-parapet-balcony-preview {
    background-image: url("../assets/level-pieces/sandstone-balcony-compact-parapet.webp");
}

.wide-balustrade-balcony-preview {
    background-image: url("../assets/level-pieces/sandstone-balcony-wide-balustrade.webp");
}

.arched-gallery-balcony-preview {
    background-image: url("../assets/level-pieces/sandstone-balcony-arched-gallery.webp");
}

.scenery-preview {
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    filter: drop-shadow(0 2px 2px rgba(36, 52, 25, 0.28));
    height: 48px;
    width: 78px;
}

.potted-fern-preview { background-image: url("../assets/scenery/potted-fern.webp"); }
.potted-trailing-ivy-preview { background-image: url("../assets/scenery/potted-trailing-ivy.webp"); }
.potted-flowering-succulent-preview { background-image: url("../assets/scenery/potted-flowering-succulent.webp"); }
.potted-palm-preview { background-image: url("../assets/scenery/potted-palm.webp"); }
.mossy-ledge-strip-preview { background-image: url("../assets/scenery/mossy-ledge-strip.webp"); }
.hanging-ivy-preview { background-image: url("../assets/scenery/hanging-ivy.webp"); }
.moss-ivy-corner-preview { background-image: url("../assets/scenery/moss-ivy-corner.webp"); }
.climbing-ivy-preview { background-image: url("../assets/scenery/climbing-ivy.webp"); }

.window-preview {
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    filter: drop-shadow(0 2px 2px rgba(63, 37, 17, 0.3));
    height: 52px;
    width: 78px;
}

.arrow-slit-window-preview { background-image: url("../assets/windows/sandstone-arrow-slit.webp"); }
.arched-dark-window-preview { background-image: url("../assets/windows/sandstone-arched-dark.webp"); }
.arched-lit-window-preview { background-image: url("../assets/windows/sandstone-arched-lit.webp"); }
.twin-lancet-window-preview { background-image: url("../assets/windows/sandstone-twin-lancet.webp"); }
.barred-window-preview { background-image: url("../assets/windows/sandstone-barred.webp"); }

.path-preview { height: 9px; width: 64px; }

.steps-preview {
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    filter: drop-shadow(0 2px 2px rgba(63, 37, 17, 0.32));
    height: 34px;
    width: 76px;
}

.fixed-compact-steps-preview {
    background-image: url("../assets/level-pieces/sandstone-stairs-compact-3.webp");
}

.fixed-standard-steps-preview {
    background-image: url("../assets/level-pieces/sandstone-stairs-standard-5.webp");
}

.fixed-broad-steps-preview {
    background-image: url("../assets/level-pieces/sandstone-stairs-broad-4.webp");
}

.classic-steps-preview {
    background-image: url("../assets/level-pieces/sandstone-steps-classic.webp");
}

.ramp-preview {
    background: #b58a56;
    height: 22px;
    width: 62px;
}

.ramp-preview.up { clip-path: polygon(0 78%, 100% 0, 100% 100%, 0 100%); }
.ramp-preview.down { clip-path: polygon(0 0, 100% 78%, 100% 100%, 0 100%); }

.door-preview {
    align-items: center;
    background: linear-gradient(90deg, #5d351c, #a15b2a 48%, #6c3b1e);
    border: 3px solid #d6b067;
    border-radius: 18px 18px 3px 3px;
    color: #fff2b5;
    display: flex;
    font-family: Georgia, serif;
    font-size: 21px;
    font-weight: 900;
    height: 38px;
    justify-content: center;
    text-shadow: 0 2px 2px #3b210f;
    width: 27px;
}

.door-preview.has-door-asset {
    background-color: transparent;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    border: 0;
    border-radius: 0;
    filter: drop-shadow(0 3px 3px rgba(43, 31, 18, 0.32));
    height: 54px;
    text-shadow: none;
    width: 44px;
}

.spawn-preview {
    align-items: center;
    background: #2b83bf;
    border: 2px solid white;
    border-radius: 50%;
    color: white;
    display: flex;
    font-size: 0.72rem;
    font-weight: 900;
    height: 31px;
    justify-content: center;
    width: 31px;
}

.inline-fields {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: 90px 1fr;
    margin-top: 10px;
}

.inline-fields label > span {
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.compact-control {
    min-height: 34px;
}

.check-field {
    align-items: center;
    display: flex;
    font-size: 0.76rem;
    font-weight: 700;
    gap: 7px;
    min-height: 34px;
}

.check-field input {
    height: 17px;
    width: 17px;
}

.workspace-panel {
    align-self: start;
    overflow: hidden;
}

.workspace-toolbar {
    align-items: center;
    background: #f5efdf;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    min-height: 58px;
    padding: 9px 12px;
}

.toolbar-group {
    align-items: center;
    display: flex;
    gap: 7px;
}

.toolbar-label {
    margin: 0 0 0 5px;
}

.toolbar-select {
    min-height: 34px;
    padding: 5px 7px;
    width: auto;
}

.tool-button,
.primary-button,
.secondary-button,
.danger-button,
.publish-alpha-button {
    border-radius: 9px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 800;
    min-height: 35px;
    padding: 7px 11px;
}

.tool-button,
.secondary-button {
    background: white;
    border: 1px solid #a99d83;
    color: #4b463b;
}

.tool-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled) {
    background: #fff5d6;
}

.tool-button:disabled,
.secondary-button:disabled,
.danger-button:disabled,
.publish-alpha-button:disabled {
    cursor: not-allowed;
    opacity: 0.42;
}

.preview-button[aria-pressed="true"] {
    background: var(--deep-green);
    border-color: var(--deep-green);
    color: white;
}

#zoom-range {
    accent-color: var(--deep-green);
    max-width: 110px;
}

.zoom-label {
    color: #647069;
    font-size: 0.69rem;
    min-width: 38px;
}

.canvas-viewport {
    background:
        linear-gradient(45deg, rgba(44, 65, 54, 0.055) 25%, transparent 25%, transparent 75%, rgba(44, 65, 54, 0.055) 75%),
        linear-gradient(45deg, rgba(44, 65, 54, 0.055) 25%, transparent 25%, transparent 75%, rgba(44, 65, 54, 0.055) 75%),
        #d8dfd7;
    background-position: 0 0, 12px 12px;
    background-size: 24px 24px;
    min-height: 500px;
    overflow: auto;
    padding: 18px;
}

.stage-frame {
    margin: 0 auto;
    position: relative;
}

.builder-stage {
    background: #78bde5;
    height: 768px;
    overflow: hidden;
    position: absolute;
    touch-action: none;
    transform-origin: top left;
    user-select: none;
    width: 1024px;
}

.scene-background {
    height: 1536px;
    left: 0;
    object-fit: fill;
    pointer-events: none;
    position: absolute;
    top: 0;
    width: 1024px;
    z-index: 0;
}

.scene-shade {
    background: linear-gradient(180deg, rgba(18, 37, 34, 0.04), transparent 52%, rgba(26, 42, 29, 0.08));
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 1;
}

.tower-layer {
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    left: 192px;
    pointer-events: none;
    position: absolute;
    top: 0;
    width: 640px;
    z-index: 2;
}

.tower-middle {
    background-image: url("../assets/tower/sandstone-middle.webp");
    background-position: center bottom;
    background-repeat: repeat-y;
    background-size: 100% auto;
    flex: 1 1 auto;
    margin: 0 auto;
    width: 100%;
}

.tower-base {
    display: block;
    flex: 0 0 auto;
    margin-top: -2px;
    width: 100%;
}

.tower-base[hidden] {
    display: none;
}

.grid-overlay {
    --grid-size: 16px;
    --major-grid-size: 64px;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.13) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.13) 1px, transparent 1px),
        linear-gradient(rgba(31, 67, 48, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31, 67, 48, 0.2) 1px, transparent 1px);
    background-size:
        var(--grid-size) var(--grid-size),
        var(--grid-size) var(--grid-size),
        var(--major-grid-size) var(--major-grid-size),
        var(--major-grid-size) var(--major-grid-size);
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 4;
}

.object-layer {
    inset: 0;
    position: absolute;
    z-index: 5;
}

.builder-object {
    cursor: grab;
    position: absolute;
    transform-origin: center;
}

.builder-object:active {
    cursor: grabbing;
}

.builder-object.selected {
    filter: drop-shadow(0 0 5px white) drop-shadow(0 0 5px #1973c5);
    outline: 3px solid #1973c5;
    outline-offset: 4px;
}

.object-shape {
    height: 100%;
    pointer-events: none;
    position: relative;
    width: 100%;
}

.builder-object.platform .object-shape,
.builder-object.path .object-shape {
    background:
        repeating-linear-gradient(90deg, transparent 0 54px, rgba(94, 59, 27, 0.25) 55px 59px),
        linear-gradient(#e3c187 0 46%, #bc8e54 47% 78%, #8c6239 79% 100%);
    border: 4px solid #6f4b2a;
    border-radius: 8px 8px 5px 5px;
    box-shadow: inset 0 4px 0 rgba(255, 246, 206, 0.5), 0 7px 10px rgba(43, 31, 18, 0.28);
}

.builder-object.platform .object-shape.asset-shape {
    background-color: transparent;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    filter: drop-shadow(0 6px 7px rgba(43, 31, 18, 0.26));
}

.builder-object.scenery .object-shape.asset-shape {
    background-color: transparent;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    border: 0;
    box-shadow: none;
    filter: drop-shadow(0 4px 5px rgba(43, 31, 18, 0.2));
}

.builder-object.scenery .object-shape.modular-ladder-shape {
    background: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ladder-part {
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    display: block;
    flex: 0 0 auto;
    width: 100%;
}

.builder-object.platform .object-shape.smart-ledge-shape {
    background: none;
    display: flex;
    flex-direction: column;
    filter: drop-shadow(0 6px 7px rgba(43, 31, 18, 0.26));
    overflow: hidden;
}

.smart-ledge-course {
    display: block;
    flex: 0 0 auto;
    min-height: 0;
    width: 100%;
}

.smart-ledge-course-top { height: 20px; }
.smart-ledge-course-middle { height: 26px; }
.smart-ledge-course-bottom { height: 12px; }

.smart-ledge-part {
    background-image: var(--smart-ledge-image);
    background-repeat: no-repeat;
    background-size: 100% 58px;
    display: block;
    height: 100%;
    width: 100%;
}

.smart-ledge-course-top .smart-ledge-part { background-position-y: top; }
.smart-ledge-course-middle .smart-ledge-part { background-position-y: -20px; }
.smart-ledge-course-bottom .smart-ledge-part { background-position-y: bottom; }

.builder-object.steps .object-shape.asset-shape {
    background-color: transparent;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    border: 0;
    box-shadow: none;
    clip-path: none;
    filter: drop-shadow(0 6px 7px rgba(43, 31, 18, 0.26));
}

.builder-object.steps .object-shape.smart-stair-shape {
    background: none;
    overflow: hidden;
    position: relative;
}

.smart-stair-shape.climb-left,
.fixed-stair-shape.climb-left {
    transform: scaleX(-1);
}

.smart-stair-module {
    display: block;
    height: 100px;
    overflow: hidden;
    position: absolute;
}

.smart-stair-module-image {
    background-image: var(--smart-stair-image);
    background-position: left top;
    background-repeat: no-repeat;
    background-size: 350px 100px;
    display: block;
    height: 100px;
    width: 350px;
}

.smart-stair-fill {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    z-index: 0;
}

.smart-stair-fill-row {
    background-color: #c88740;
    display: flex;
    flex: 0 0 20px;
    height: 20px;
    width: 100%;
}

.smart-stair-fill-tile {
    background-color: #c88740;
    background-image: var(--smart-stair-image);
    background-repeat: no-repeat;
    background-size: 350px 100px;
    display: block;
    flex: 0 0 70px;
    height: 20px;
}

.smart-stair-module {
    z-index: 1;
}

.builder-object.path .object-shape {
    border-width: 3px;
    border-radius: 999px;
}

.builder-object.steps .object-shape {
    background:
        repeating-linear-gradient(to top right, #9a6e41 0 18px, #c39a63 19px 34px, #e0bd84 35px 39px);
    border-bottom: 4px solid #604026;
    clip-path: polygon(0 100%, 0 78%, 20% 78%, 20% 58%, 40% 58%, 40% 38%, 60% 38%, 60% 18%, 80% 18%, 80% 0, 100% 0, 100% 100%);
    filter: drop-shadow(0 6px 5px rgba(45, 31, 17, 0.3));
}

.builder-object.ramp .object-shape {
    background:
        repeating-linear-gradient(90deg, transparent 0 42px, rgba(90, 55, 25, 0.22) 43px 47px),
        linear-gradient(#dfbd82, #9f7042);
    border-bottom: 5px solid #634127;
    filter: drop-shadow(0 6px 5px rgba(45, 31, 17, 0.3));
}

.builder-object.ramp-up .object-shape {
    clip-path: polygon(0 82%, 100% 0, 100% 100%, 0 100%);
}

.builder-object.ramp-down .object-shape {
    clip-path: polygon(0 0, 100% 82%, 100% 100%, 0 100%);
}

.builder-object.door .object-shape {
    background:
        radial-gradient(circle at 78% 58%, #f1d06e 0 5px, #6c401f 6px 9px, transparent 10px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.08) 0 7px, transparent 8px 18px),
        linear-gradient(90deg, #56301b, #a95f2d 50%, #62351c);
    border: 7px solid #d6b26e;
    border-bottom-width: 10px;
    border-radius: 46% 46% 5px 5px;
    box-shadow: 0 0 0 4px #6d4c2b, inset 0 4px 12px rgba(255,255,255,0.16), 0 8px 12px rgba(38,26,16,0.34);
    overflow: hidden;
    position: relative;
}

.builder-object.door.has-door-art .object-shape.asset-shape {
    background-color: transparent;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    filter: drop-shadow(0 6px 7px rgba(43, 31, 18, 0.3));
    overflow: visible;
}

.builder-object.door-s.has-door-art .object-shape.asset-shape::before {
    content: none;
}

.builder-object.door-s .object-shape::before {
    background: radial-gradient(circle, rgba(255, 240, 167, 0.2), transparent 66%);
    content: "";
    inset: 8px 5px 18px;
    position: absolute;
}

.door-rune {
    align-items: center;
    background: radial-gradient(circle, #6eaf68, #315c36 72%);
    border: 4px solid #f0cb68;
    border-radius: 50%;
    box-shadow: 0 0 0 3px #65441f, 0 4px 8px rgba(27, 20, 12, 0.5);
    color: #fff7c8;
    display: flex;
    font-family: Georgia, serif;
    font-size: 39px;
    font-weight: 900;
    height: 58px;
    justify-content: center;
    left: 50%;
    line-height: 1;
    position: absolute;
    text-shadow: 0 3px 2px #284526;
    top: 28px;
    transform: translateX(-50%);
    width: 58px;
}

.preview-mode .builder-object.door.in-range .object-shape {
    animation: door-ready-pulse 900ms ease-in-out infinite alternate;
}

@keyframes door-ready-pulse {
    from { filter: drop-shadow(0 0 4px rgba(255, 232, 142, 0.4)); }
    to { filter: drop-shadow(0 0 13px rgba(255, 232, 142, 0.95)); }
}

.builder-object.spawn .object-shape {
    align-items: center;
    background: rgba(33, 126, 190, 0.88);
    border: 4px dashed white;
    border-radius: 50% 50% 42% 42%;
    color: white;
    display: flex;
    font-size: 19px;
    font-weight: 900;
    justify-content: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.45);
}

.play-layer {
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 8;
}

.play-layer[hidden] {
    display: none;
}

.play-instructions {
    align-items: center;
    background: rgba(25, 47, 36, 0.9);
    border: 2px solid rgba(240, 203, 104, 0.88);
    border-radius: 10px;
    color: white;
    display: flex;
    font-size: 12px;
    gap: 12px;
    left: 50%;
    padding: 7px 11px;
    position: absolute;
    top: 12px;
    transform: translateX(-50%);
    white-space: nowrap;
}

.play-instructions strong {
    color: #ffe89b;
}

.test-player {
    height: 52px;
    left: 0;
    pointer-events: none;
    position: absolute;
    top: 0;
    transform-origin: center bottom;
    width: 34px;
    z-index: 4;
}


.player-placeholder {
    -webkit-backface-visibility: hidden;
    animation: none;
    backface-visibility: hidden;
    background: url("assets/characters/spelling-spire-boy-walk-cycle-v2.png") -45px 0 / 225px 84px no-repeat;
    bottom: 0;
    display: block;
    filter: drop-shadow(0 3px 2px rgba(28, 29, 24, 0.28));
    height: 84px;
    left: 50%;
    pointer-events: none;
    position: absolute;
    transform: translate3d(-50%, 0, 0) scale3d(0.9, 0.9, 1);
    transform-origin: center bottom;
    will-change: transform, background-position;
    width: 45px;
}

.test-player.running .player-placeholder {
    animation: player-walk-cycle 600ms steps(5) infinite;
}

.test-player.jumping .player-placeholder,
.test-player.landing .player-placeholder {
    animation: none;
    background-image: url("assets/characters/spelling-spire-boy-jump-cycle.png");
    background-position: var(--player-jump-offset, 0px) 0;
    background-size: 315px 84px;
}

.test-player.ladder-climbing .player-placeholder {
    animation: none;
    background-image: url("assets/characters/spelling-spire-boy-ladder-climb-cycle-v1.png");
    background-position: 0 0;
    background-size: 270px 84px;
    filter: drop-shadow(0 3px 2px rgba(28, 29, 24, 0.28));
}

.test-player.ladder-climbing.ladder-moving .player-placeholder {
    animation: player-ladder-climb 720ms steps(6) infinite;
}

.test-player.ladder-climbing.ladder-descending .player-placeholder {
    animation-direction: reverse;
}

.test-player.ceiling-hanging .player-placeholder {
    animation: none;
    background-image: url("assets/characters/spelling-spire-boy-monkey-bar-cycle-v1.png");
    background-position: 0 0;
    background-size: 336px 84px;
    bottom: auto;
    top: 0;
    transform-origin: center top;
    width: 56px;
}

.test-player.ceiling-hanging.ceiling-moving .player-placeholder {
    animation: player-monkey-bar 660ms steps(6) infinite;
}

.test-player.jumping .player-placeholder {
    filter: drop-shadow(0 7px 4px rgba(28, 29, 24, 0.28));
}

.test-player.ladder-climbing.jumping .player-placeholder {
    filter: drop-shadow(0 3px 2px rgba(28, 29, 24, 0.28));
}

@keyframes player-walk-cycle {
    from {
        background-position-x: 0;
    }

    to {
        background-position-x: -225px;
    }
}

@keyframes player-ladder-climb {
    from {
        background-position-x: 0;
    }

    to {
        background-position-x: -270px;
    }
}

@keyframes player-monkey-bar {
    from {
        background-position-x: 0;
    }

    to {
        background-position-x: -336px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .test-player.running .player-placeholder {
        animation: none;
    }

    .test-player.ladder-climbing.ladder-moving .player-placeholder {
        animation: none;
        background-position: -90px 0;
    }

    .test-player.ceiling-hanging.ceiling-moving .player-placeholder {
        animation: none;
        background-position: -112px 0;
    }

    .test-player.jumping .player-placeholder {
        background-position: -180px 0;
    }

    .test-player.landing .player-placeholder {
        background-position: -270px 0;
    }
}

.touch-controls {
    align-items: flex-end;
    bottom: 18px;
    display: flex;
    justify-content: space-between;
    left: 18px;
    pointer-events: none;
    position: absolute;
    right: 18px;
}

.enter-door-button {
    background: linear-gradient(#ffe69a, #e8bd55);
    border: 3px solid #5e3d1d;
    border-radius: 999px;
    bottom: 26px;
    box-shadow: 0 5px 0 #5e3d1d, 0 8px 15px rgba(28, 22, 13, 0.35);
    color: #35230f;
    cursor: pointer;
    font-family: inherit;
    font-size: 16px;
    font-weight: 900;
    left: 50%;
    line-height: 1;
    padding: 12px 20px;
    pointer-events: auto;
    position: absolute;
    transform: translateX(-50%);
    z-index: 6;
}

.enter-door-button:hover,
.enter-door-button:focus-visible {
    background: #fff1b7;
    outline: 4px solid rgba(255, 255, 255, 0.82);
    outline-offset: 2px;
}

.enter-door-button[hidden] {
    display: none;
}

.touch-movement {
    display: flex;
    gap: 10px;
}

.touch-control {
    align-items: center;
    background: rgba(25, 47, 36, 0.8);
    border: 3px solid rgba(255, 255, 255, 0.88);
    border-radius: 50%;
    color: white;
    display: flex;
    font-family: inherit;
    font-size: 27px;
    font-weight: 900;
    height: 62px;
    justify-content: center;
    pointer-events: auto;
    touch-action: none;
    width: 62px;
}

.touch-control:active,
.touch-control.active {
    background: rgba(240, 203, 104, 0.94);
    border-color: #6a431f;
    color: #35220d;
    transform: translateY(2px);
}

.jump-control {
    height: 70px;
    width: 70px;
}

.object-label {
    background: rgba(32, 55, 43, 0.9);
    border: 1px solid rgba(255,255,255,0.62);
    border-radius: 999px;
    bottom: calc(100% + 8px);
    color: white;
    font-size: 12px;
    font-weight: 900;
    left: 50%;
    max-width: 190px;
    overflow: hidden;
    padding: 4px 8px;
    pointer-events: none;
    position: absolute;
    text-overflow: ellipsis;
    transform: translateX(-50%);
    white-space: nowrap;
}

.resize-handle {
    background: #1973c5;
    border: 3px solid white;
    border-radius: 50%;
    bottom: -11px;
    cursor: nwse-resize;
    display: none;
    height: 22px;
    position: absolute;
    right: -11px;
    width: 22px;
    z-index: 2;
}

.builder-object.selected .resize-handle {
    display: block;
}

.stair-run-handle {
    background: #d99b2b;
    border: 3px solid white;
    border-radius: 50%;
    cursor: ew-resize;
    display: none;
    height: 22px;
    position: absolute;
    right: -11px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    z-index: 2;
}

.builder-object.selected .stair-run-handle {
    display: block;
}

.safe-frame {
    border: 4px dashed rgba(255, 255, 255, 0.8);
    bottom: 0;
    box-shadow: 0 0 0 1000px rgba(20, 37, 31, 0.25);
    left: 50%;
    pointer-events: none;
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    width: 100%;
    z-index: 7;
}

.safe-frame span {
    background: rgba(25, 47, 36, 0.82);
    border-radius: 0 0 7px 7px;
    color: white;
    font-size: 12px;
    font-weight: 800;
    left: 50%;
    padding: 5px 9px;
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    white-space: nowrap;
}

.builder-stage.preview-mode .grid-overlay,
.builder-stage.preview-mode .safe-frame,
.builder-stage.preview-mode .resize-handle,
.builder-stage.preview-mode .stair-run-handle,
.builder-stage.preview-mode .object-label {
    display: none;
}

.builder-stage.preview-mode .builder-object {
    cursor: default;
    filter: none;
    outline: 0;
}

.workspace-footer {
    align-items: center;
    background: #f8f4e9;
    border-top: 1px solid var(--line);
    color: #647069;
    display: flex;
    flex-wrap: wrap;
    font-size: 0.69rem;
    gap: 12px;
    justify-content: space-between;
    padding: 9px 13px;
}

.properties-form {
    padding: 0 18px 18px;
}

.inspector-heading {
    border-bottom: 0;
    padding-bottom: 8px;
}

.selected-object-card {
    background: #edf4ec;
    border: 1px solid #c8d9c7;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    margin-bottom: 13px;
    padding: 10px 11px;
}

.selected-type {
    color: #567061;
    font-size: 0.64rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#selected-name {
    font-size: 0.85rem;
    margin-top: 2px;
}

fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

fieldset:disabled {
    opacity: 0.48;
}

.property-grid {
    display: grid;
    gap: 9px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.property-grid label,
.full-field {
    color: #58645d;
    font-size: 0.68rem;
    font-weight: 800;
}

.property-grid label span,
.full-field > span {
    display: block;
    margin-bottom: 4px;
}

.properties-form input,
.properties-form select {
    min-height: 35px;
    padding: 5px 7px;
}

.full-field {
    display: block;
    margin-top: 10px;
}

.full-field small {
    color: #718078;
    display: block;
    font-size: 0.64rem;
    font-weight: 500;
    line-height: 1.35;
    margin-top: 4px;
}

.layer-actions,
.object-actions {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr;
    margin-top: 13px;
}

.layer-actions .secondary-button {
    padding-left: 7px;
    padding-right: 7px;
}

.primary-button {
    background: var(--gold);
    border: 2px solid var(--brown);
    color: #35220d;
}

.danger-button {
    background: #fff4f1;
    border: 1px solid #c66a60;
    color: #8c332c;
}

.danger-button:hover:not(:disabled) {
    background: #ffe2dc;
}

.data-section {
    background: #fbf8ef;
}

.data-actions {
    display: grid;
    gap: 7px;
}

.version-publisher {
    border-top: 1px solid #d8d0bc;
    margin-top: 14px;
    padding-top: 13px;
}

.version-publisher-heading {
    align-items: flex-start;
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.version-publisher-heading h3 {
    color: #2f4b3a;
    font-size: 0.82rem;
    margin: 0 0 3px;
}

.version-publisher-heading p {
    color: #6b675d;
    font-size: 0.64rem;
    line-height: 1.35;
    margin: 0;
}

.small-action-button {
    background: white;
    border: 1px solid #a99d83;
    border-radius: 8px;
    color: #4b463b;
    cursor: pointer;
    font-size: 0.64rem;
    font-weight: 800;
    padding: 6px 8px;
}

.publisher-auth {
    background: #fff3cf;
    border: 1px solid #d5ae45;
    border-radius: 10px;
    color: #674f12;
    display: grid;
    font-size: 0.66rem;
    gap: 6px;
    margin-top: 10px;
    padding: 10px;
}

.publisher-auth[hidden] {
    display: none;
}

.publisher-auth .primary-button {
    display: block;
    text-align: center;
    text-decoration: none;
}

.save-version-form {
    display: grid;
    gap: 5px;
    margin-top: 11px;
}

.save-version-form > label {
    color: #4d5b52;
    font-size: 0.65rem;
    font-weight: 800;
}

.save-version-row {
    display: grid;
    gap: 6px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.save-version-row input {
    border: 1px solid #a99d83;
    border-radius: 8px;
    font: inherit;
    font-size: 0.68rem;
    min-width: 0;
    padding: 7px 8px;
}

.saved-version-list {
    display: grid;
    gap: 8px;
    margin-top: 9px;
}

.saved-version-empty {
    color: #6b675d;
    font-size: 0.66rem;
    margin: 4px 0 0;
}

.saved-version-card {
    background: white;
    border: 1px solid #d5cdb9;
    border-radius: 10px;
    display: grid;
    gap: 7px;
    padding: 9px;
}

.saved-version-card.is-live {
    background: #f0f8ed;
    border-color: #6e9d72;
    box-shadow: inset 3px 0 #3e7b4d;
}

.saved-version-summary {
    display: grid;
    gap: 2px;
}

.saved-version-title-row {
    align-items: center;
    display: flex;
    gap: 6px;
    justify-content: space-between;
}

.saved-version-title {
    color: #2f4537;
    font-size: 0.72rem;
    line-height: 1.25;
}

.live-version-badge {
    background: #2f7244;
    border-radius: 999px;
    color: white;
    font-size: 0.55rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    padding: 3px 6px;
}

.saved-version-meta {
    color: #777164;
    font-size: 0.59rem;
}

.saved-version-actions {
    display: grid;
    gap: 5px;
    grid-template-columns: repeat(3, 1fr);
}

.saved-version-actions button {
    border: 1px solid #a99d83;
    border-radius: 7px;
    cursor: pointer;
    font-size: 0.6rem;
    font-weight: 850;
    min-height: 29px;
    padding: 5px;
}

.preview-version-button {
    background: white;
    color: #4b463b;
}

.make-live-button {
    background: #315f46;
    border-color: #315f46 !important;
    color: white;
}

.delete-version-button {
    background: #fff4f1;
    border-color: #c66a60 !important;
    color: #8c332c;
}

.saved-version-card.is-live .make-live-button,
.saved-version-card.is-live .delete-version-button {
    cursor: not-allowed;
    opacity: 0.45;
}

.publish-alpha-button {
    background: linear-gradient(135deg, #315f46, #203f30);
    border: 2px solid #f0cb68;
    box-shadow: 0 4px 0 #173124;
    color: #fff8d7;
    margin: 5px 0 3px;
}

.publish-alpha-button:hover:not(:disabled) {
    background: #3e7656;
    transform: translateY(-1px);
}

.publish-status {
    background: #eee9da;
    border-radius: 8px;
    color: #635f55;
    font-size: 0.66rem;
    line-height: 1.4;
    margin: 10px 0 0;
    padding: 8px 9px;
}

.publish-status.current {
    background: #e3f1e6;
    color: #2f6140;
}

.publish-status.changed {
    background: #fff2cd;
    color: #795b16;
}

.danger-button.subtle {
    margin-top: 4px;
}

.json-details {
    margin-top: 12px;
}

.json-details summary {
    color: #59665e;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 800;
}

#json-preview {
    background: #24372d;
    border-radius: 9px;
    color: #d9f0df;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.62rem;
    line-height: 1.45;
    max-height: 260px;
    overflow: auto;
    padding: 10px;
    white-space: pre-wrap;
}

.toast {
    background: #203f30;
    border: 2px solid var(--gold);
    border-radius: 12px;
    bottom: 22px;
    color: white;
    font-size: 0.8rem;
    font-weight: 800;
    left: 50%;
    max-width: calc(100% - 30px);
    opacity: 0;
    padding: 11px 16px;
    pointer-events: none;
    position: fixed;
    transform: translate(-50%, 18px);
    transition: opacity 180ms ease, transform 180ms ease;
    z-index: 200;
}

.toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.sr-only {
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

@media (max-width: 1320px) {
    .builder-layout {
        grid-template-columns: 230px minmax(460px, 1fr) 245px;
        padding: 0 10px;
    }

    .canvas-viewport {
        padding: 10px;
    }
}

@media (max-width: 1040px) {
    .builder-header {
        grid-template-columns: auto 1fr;
    }

    .save-state {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .builder-layout {
        grid-template-columns: minmax(220px, 270px) 1fr;
    }

    .inspector-panel {
        grid-column: 1 / -1;
        max-height: none;
        position: static;
    }

    .inspector-panel .properties-form,
    .inspector-panel .data-section {
        display: inline-block;
        vertical-align: top;
        width: 49%;
    }
}

@media (max-width: 760px) {
    .builder-header {
        grid-template-columns: 1fr;
        position: static;
    }

    .brand {
        align-items: flex-start;
    }

    .brand p {
        display: none;
    }

    .back-link {
        width: fit-content;
    }

    .builder-layout {
        display: flex;
        flex-direction: column;
        padding: 0 8px;
    }

    .palette-panel {
        max-height: none;
        position: static;
    }

    .workspace-panel {
        order: -1;
    }

    .canvas-viewport {
        min-height: 390px;
    }

    .workspace-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .inspector-panel .properties-form,
    .inspector-panel .data-section {
        display: block;
        width: 100%;
    }

    .play-instructions {
        align-items: flex-start;
        flex-direction: column;
        gap: 1px;
        left: 10px;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }
}

/* Integrated mode keeps the editable tower as the main view and docks every
   building control in one right-hand tool rail. */
html.integrated-alpha-builder,
html.integrated-alpha-builder body {
    height: 100%;
    min-height: 0;
}

html.integrated-alpha-builder body {
    background: transparent;
    overflow: hidden;
}

.integrated-alpha-builder .builder-header {
    display: none;
}

.integrated-alpha-builder .builder-layout {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) clamp(300px, 24vw, 390px);
    grid-template-rows: minmax(0, 1.25fr) minmax(0, 1fr);
    height: 100%;
    margin: 0;
    max-width: none;
    padding: 10px;
}

.integrated-alpha-builder .workspace-panel {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    grid-column: 1;
    grid-row: 1 / 3;
    min-height: 0;
    order: initial;
}

.integrated-alpha-builder .palette-panel,
.integrated-alpha-builder .inspector-panel {
    align-self: stretch;
    grid-column: 2;
    max-height: none;
    min-height: 0;
    overflow-y: auto;
    position: static;
    top: auto;
}

.integrated-alpha-builder .palette-panel {
    grid-row: 1;
}

.integrated-alpha-builder .inspector-panel {
    grid-row: 2;
}

.integrated-alpha-builder .panel,
.integrated-alpha-builder .workspace-panel {
    backdrop-filter: blur(12px);
    background: rgba(255, 253, 244, 0.94);
    border-radius: 13px;
    box-shadow: 0 8px 24px rgba(20, 38, 29, 0.24);
}

.integrated-alpha-builder .canvas-viewport {
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px;
}

.integrated-alpha-builder .workspace-toolbar,
.integrated-alpha-builder .workspace-footer {
    flex: 0 0 auto;
}

.integrated-alpha-builder .inspector-panel .properties-form,
.integrated-alpha-builder .inspector-panel .data-section {
    display: block;
    width: 100%;
}

@media (max-width: 840px) {
    html.integrated-alpha-builder body {
        overflow: auto;
    }

    .integrated-alpha-builder .builder-layout {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 100%;
    }

    .integrated-alpha-builder .workspace-panel {
        min-height: 540px;
        order: -1;
    }

    .integrated-alpha-builder .palette-panel,
    .integrated-alpha-builder .inspector-panel {
        max-height: none;
        overflow: visible;
    }
}

/* Native Alpha mode runs inside the main tower page's shadow root. It uses a
   dependable three-column editor: blocks, the real Alpha tower, properties. */
:host {
    color: var(--ink);
    display: block;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

:host(.alpha-native-builder) .builder-header {
    display: none;
}

:host(.alpha-native-builder) .builder-layout {
    display: grid;
    gap: 12px;
    grid-template-columns:
        var(--alpha-builder-rail-width, clamp(245px, 18vw, 310px))
        minmax(520px, 1fr)
        var(--alpha-builder-rail-width, clamp(245px, 18vw, 310px));
    height: 100%;
    margin: 0;
    max-width: none;
    min-height: 0;
    padding: 12px;
}

:host(.alpha-native-builder) .workspace-panel {
    align-self: stretch;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    grid-column: 2;
    grid-row: 1;
    height: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

:host(.alpha-native-builder) .palette-panel,
:host(.alpha-native-builder) .inspector-panel {
    align-self: stretch;
    backdrop-filter: blur(14px);
    background: rgba(255, 253, 244, 0.94);
    border: 1px solid rgba(117, 93, 55, 0.28);
    border-radius: 13px;
    box-shadow: 0 8px 24px rgba(20, 38, 29, 0.24);
    grid-row: 1;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overscroll-behavior: contain;
    overflow-y: auto;
    position: relative;
    scrollbar-color: #a98750 rgba(226, 217, 194, 0.48);
    scrollbar-gutter: stable;
    top: auto;
    width: auto;
    z-index: 5;
}

:host(.alpha-native-builder) .palette-panel {
    grid-column: 1;
}

:host(.alpha-native-builder) .inspector-panel {
    grid-column: 3;
}

:host(.alpha-native-builder) .palette-panel::-webkit-scrollbar,
:host(.alpha-native-builder) .inspector-panel::-webkit-scrollbar {
    width: 11px;
}

:host(.alpha-native-builder) .palette-panel::-webkit-scrollbar-thumb,
:host(.alpha-native-builder) .inspector-panel::-webkit-scrollbar-thumb {
    background: #a98750;
    border: 3px solid rgba(255, 253, 244, 0.94);
    border-radius: 999px;
}

:host(.alpha-native-builder) .level-section {
    backdrop-filter: blur(14px);
    background: rgba(255, 253, 244, 0.98);
    box-shadow: 0 7px 14px rgba(53, 66, 57, 0.1);
    padding-top: 66px;
    position: sticky;
    top: 0;
    z-index: 3;
}

:host(.alpha-native-builder) .workspace-toolbar,
:host(.alpha-native-builder) .workspace-footer {
    backdrop-filter: blur(12px);
    background: rgba(255, 253, 244, 0.9);
    border: 1px solid rgba(117, 93, 55, 0.28);
    border-radius: 12px;
    box-shadow: 0 5px 18px rgba(20, 38, 29, 0.18);
    left: 8px;
    position: absolute;
    right: 8px;
    z-index: 4;
}

:host(.alpha-native-builder) .workspace-toolbar {
    top: 8px;
}

:host(.alpha-native-builder) .workspace-footer {
    bottom: 8px;
}

:host(.alpha-native-builder) .canvas-viewport {
    background: transparent;
    inset: 0;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    position: absolute;
}

:host(.alpha-native-builder) .canvas-viewport::before {
    border: 2px solid rgba(255, 248, 224, 0.62);
    border-radius: 15px;
    box-shadow: inset 0 0 0 1px rgba(38, 52, 44, 0.22), 0 10px 28px rgba(20, 38, 29, 0.14);
    content: "";
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 10;
}

/* The Alpha page's real #world tower is the only structure visible while
   editing. This stage supplies coordinates, grid, objects and handles only. */
:host(.alpha-native-builder) .builder-stage {
    background: transparent;
}

:host(.alpha-native-builder) .scene-background,
:host(.alpha-native-builder) .scene-shade,
:host(.alpha-native-builder) .tower-layer {
    display: none !important;
}

:host(.alpha-native-builder) .stage-frame {
    margin: 0;
    position: absolute;
    top: 0;
}

:host(.alpha-native-builder) .inspector-panel .properties-form,
:host(.alpha-native-builder) .inspector-panel .data-section {
    display: block;
    width: 100%;
}

@media (max-width: 1120px) {
    :host(.alpha-native-builder) {
        overflow: auto;
    }

    :host(.alpha-native-builder) .builder-layout {
        display: grid;
        gap: 10px;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(560px, 72vh) minmax(420px, 60vh) minmax(420px, 60vh);
        height: auto;
        min-height: 200vh;
        padding: 8px;
    }

    :host(.alpha-native-builder) .workspace-panel {
        grid-column: 1;
        grid-row: 1;
        height: auto;
        min-height: 540px;
    }

    :host(.alpha-native-builder) .palette-panel,
    :host(.alpha-native-builder) .inspector-panel {
        grid-column: 1;
        height: auto;
        max-height: 60vh;
        overflow-y: auto;
        position: relative;
        width: auto;
    }

    :host(.alpha-native-builder) .palette-panel {
        grid-row: 2;
    }

    :host(.alpha-native-builder) .inspector-panel {
        grid-row: 3;
    }
}

/* Native editor v2 mirrors the complete Alpha playfield. Tooling lives only
   in the green side rails, so every game coordinate remains visible and
   clickable while editing. */
:host(.alpha-native-builder) {
    background: rgba(8, 38, 29, 0.97);
    overflow: hidden;
}

:host(.alpha-native-builder) .builder-layout {
    display: grid;
    gap: 10px;
    grid-template-columns:
        var(--alpha-builder-rail-width, clamp(220px, 18vw, 310px))
        minmax(320px, 1fr)
        var(--alpha-builder-rail-width, clamp(220px, 18vw, 310px));
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
    margin: 0;
    max-width: none;
    min-height: 0;
    padding: 10px;
}

:host(.alpha-native-builder) .workspace-panel {
    display: contents;
}

:host(.alpha-native-builder) .workspace-toolbar {
    align-items: stretch;
    background: rgba(255, 253, 244, 0.96);
    border: 1px solid rgba(117, 93, 55, 0.28);
    border-radius: 13px;
    box-shadow: 0 8px 24px rgba(20, 38, 29, 0.24);
    display: flex;
    flex-direction: column;
    gap: 8px;
    grid-column: 1;
    grid-row: 1;
    left: auto;
    padding: 10px;
    position: relative;
    right: auto;
    top: auto;
    z-index: 6;
}

:host(.alpha-native-builder) .workspace-toolbar .toolbar-group {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    justify-content: flex-start;
    width: 100%;
}

:host(.alpha-native-builder) .workspace-toolbar #zoom-range {
    flex: 1 1 90px;
    min-width: 76px;
}

:host(.alpha-native-builder) .workspace-toolbar .preview-button {
    width: 100%;
}

:host(.alpha-native-builder) .palette-panel,
:host(.alpha-native-builder) .inspector-panel {
    align-self: stretch;
    backdrop-filter: blur(14px);
    background: rgba(255, 253, 244, 0.95);
    border: 1px solid rgba(117, 93, 55, 0.28);
    border-radius: 13px;
    box-shadow: 0 8px 24px rgba(20, 38, 29, 0.24);
    height: auto;
    max-height: none;
    min-height: 0;
    overflow-y: auto;
    position: relative;
    scrollbar-color: #a98750 rgba(226, 217, 194, 0.48);
    scrollbar-gutter: stable;
    top: auto;
    width: auto;
    z-index: 5;
}

:host(.alpha-native-builder) .palette-panel {
    grid-column: 1;
    grid-row: 2 / 4;
}

:host(.alpha-native-builder) .inspector-panel {
    grid-column: 3;
    grid-row: 1 / 3;
}

:host(.alpha-native-builder) .level-section {
    padding-top: 18px;
    position: sticky;
    top: 0;
}

:host(.alpha-native-builder) .inspector-heading {
    padding-top: 62px;
}

:host(.alpha-native-builder) .workspace-footer {
    align-items: flex-start;
    background: rgba(255, 253, 244, 0.96);
    border: 1px solid rgba(117, 93, 55, 0.28);
    border-radius: 13px;
    box-shadow: 0 8px 24px rgba(20, 38, 29, 0.24);
    display: flex;
    flex-direction: column;
    gap: 3px;
    grid-column: 3;
    grid-row: 3;
    left: auto;
    padding: 9px 12px;
    position: relative;
    right: auto;
    z-index: 6;
}

:host(.alpha-native-builder) .canvas-viewport {
    background: transparent;
    grid-column: 2;
    grid-row: 1 / 4;
    inset: auto;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    position: relative;
}

:host(.alpha-native-builder) .canvas-viewport::before {
    content: none;
}

:host(.alpha-native-builder) .stage-frame {
    border-radius: 12px;
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.38);
    margin: 0;
    outline: 2px solid rgba(255, 247, 220, 0.74);
    overflow: hidden;
    position: absolute;
}

:host(.alpha-native-builder) .builder-stage {
    background: #78bde5;
}

:host(.alpha-native-builder) .scene-background,
:host(.alpha-native-builder) .scene-shade,
:host(.alpha-native-builder) .tower-layer {
    display: block !important;
}

:host(.alpha-native-builder) .tower-layer {
    display: flex !important;
}

:host(.alpha-native-builder) .inspector-panel .properties-form,
:host(.alpha-native-builder) .inspector-panel .data-section {
    display: block;
    width: 100%;
}

@media (max-width: 760px) and (orientation: portrait) {
    :host(.alpha-native-builder) {
        -webkit-overflow-scrolling: touch;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        touch-action: pan-y;
    }

    :host(.alpha-native-builder) .builder-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(280px, 46vh) minmax(360px, 72vh) minmax(420px, 62vh) auto;
        height: auto;
        min-height: 230vh;
        padding: 6px;
    }

    :host(.alpha-native-builder) .workspace-toolbar,
    :host(.alpha-native-builder) .canvas-viewport,
    :host(.alpha-native-builder) .palette-panel,
    :host(.alpha-native-builder) .inspector-panel,
    :host(.alpha-native-builder) .workspace-footer {
        grid-column: 1;
    }

    :host(.alpha-native-builder) .workspace-toolbar { grid-row: 1; }
    :host(.alpha-native-builder) .palette-panel { grid-row: 2; }
    :host(.alpha-native-builder) .canvas-viewport { grid-row: 3; }
    :host(.alpha-native-builder) .inspector-panel { grid-row: 4; }
    :host(.alpha-native-builder) .workspace-footer { grid-row: 5; }

    :host(.alpha-native-builder) .palette-panel,
    :host(.alpha-native-builder) .inspector-panel {
        -webkit-overflow-scrolling: touch;
        max-height: 62vh;
        overscroll-behavior-y: contain;
        touch-action: pan-y;
    }

    :host(.alpha-native-builder) .palette-panel {
        max-height: 46vh;
    }

    :host(.alpha-native-builder) .inspector-heading {
        padding-top: 18px;
    }
}

@media (orientation: landscape) and (max-height: 600px) {
    :host(.alpha-native-builder) {
        overflow: hidden;
    }

    :host(.alpha-native-builder) .builder-layout {
        gap: 6px;
        grid-template-columns: clamp(150px, 21vw, 210px) minmax(240px, 1fr) clamp(150px, 21vw, 210px);
        grid-template-rows: auto minmax(0, 1fr);
        height: 100%;
        min-height: 0;
        padding: 6px;
    }

    :host(.alpha-native-builder) .workspace-toolbar {
        gap: 5px;
        grid-column: 1;
        grid-row: 1;
        padding: 6px;
    }

    :host(.alpha-native-builder) .workspace-toolbar .toolbar-group:nth-child(2) {
        display: none;
    }

    :host(.alpha-native-builder) .workspace-toolbar .toolbar-group:first-child {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    :host(.alpha-native-builder) .workspace-toolbar .tool-button {
        min-height: 34px;
        padding: 5px 6px;
    }

    :host(.alpha-native-builder) .palette-panel,
    :host(.alpha-native-builder) .inspector-panel {
        -webkit-overflow-scrolling: touch;
        max-height: none;
        overscroll-behavior-y: contain;
        touch-action: pan-y;
    }

    :host(.alpha-native-builder) .palette-panel {
        grid-column: 1;
        grid-row: 2;
    }

    :host(.alpha-native-builder) .inspector-panel {
        grid-column: 3;
        grid-row: 1 / 3;
    }

    :host(.alpha-native-builder) .canvas-viewport {
        grid-column: 2;
        grid-row: 1 / 3;
    }

    :host(.alpha-native-builder) .workspace-footer {
        display: none;
    }

    :host(.alpha-native-builder) .panel-section {
        padding: 10px;
    }

    :host(.alpha-native-builder) .level-section {
        padding-top: 10px;
    }

    :host(.alpha-native-builder) .level-section .section-heading p,
    :host(.alpha-native-builder) .level-section .field-label,
    :host(.alpha-native-builder) .level-summary,
    :host(.alpha-native-builder) .pieces-section .section-heading p {
        display: none;
    }

    :host(.alpha-native-builder) .level-navigation {
        margin: 8px 0;
    }

    :host(.alpha-native-builder) .palette-group-title {
        margin-top: 10px;
    }

    :host(.alpha-native-builder) .piece-category-tabs {
        gap: 4px;
        margin-top: 7px;
    }

    :host(.alpha-native-builder) .piece-category-tab {
        font-size: 0.5rem;
        min-height: 54px;
        padding: 4px 2px;
    }

    :host(.alpha-native-builder) .piece-category-icon {
        height: 20px;
        width: 27px;
    }

    :host(.alpha-native-builder) .category-count {
        font-size: 0.48rem;
        height: 15px;
        min-width: 15px;
        right: 2px;
        top: 2px;
    }

    :host(.alpha-native-builder) .category-help {
        display: none;
    }

    :host(.alpha-native-builder) .palette-item {
        font-size: 0.6rem;
        gap: 4px;
        min-height: 62px;
        padding: 5px 3px;
    }

    :host(.alpha-native-builder) .architecture-preview {
        height: 34px;
        width: 66px;
    }

    :host(.alpha-native-builder) .steps-preview {
        height: 29px;
        width: 66px;
    }

    :host(.alpha-native-builder) .inspector-heading {
        padding-top: 52px;
    }
}

@media (orientation: landscape) and (max-height: 600px) and (max-width: 700px) {
    :host(.alpha-native-builder) .palette-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}
