@media (max-width: 1024px) {
    .button-text {
        display: none;
    }

    .action-button {
        min-width: 42px;
        height: 42px;
    }
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
    }

    .main-content {
        flex-direction: column;
        overflow: auto;
    }

    .sidebar,
    .editor-area,
    .preview-area {
        width: 100%;
        max-height: none;
        transition: opacity 0.3s, height 0.3s;
    }

    .sidebar.hidden,
    .editor-area.hidden,
    .preview-area.hidden {
        height: 0;
        overflow: hidden;
        opacity: 0;
        margin: 0;
        padding: 0;
    }

    .components-list-panel,
    .component-palette-panel {
        max-height: none;
        overflow: visible;
    }

    .component-list-panel {
        overflow: hidden;
    }

    .component-item {
        width: calc(50% - 6px);
    }

    .panel-header h3 {
        font-size: 15px;
    }

    .chest-panel {
        transform-origin: top left;
        transform: scale(0.9);
        margin: 10px auto;
    }

    .component-list {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }

    .template-selector-panel {
        width: 100%;
        max-height: none;
        margin-bottom: 60px;
    }

    .template-list {
        grid-template-columns: repeat(2, 1fr);
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 10px;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .header h1 {
        text-align: center;
        font-size: 1.6rem;
    }

    .actions {
        justify-content: center;
    }

    .component-item {
        width: 100%;
    }

    .chest-panel {
        transform: scale(0.75);
    }

    .template-item {
        min-width: unset;
        width: 100%;
    }

    .template-preview {
        width: 90%;
        height: 50px;
    }

    .mobile-nav {
        overflow-x: auto;
        justify-content: flex-start;
    }

    .mobile-nav-button {
        min-width: 80px;
        flex: 0 0 auto;
    }

    .mobile-templates-drawer .template-list {
        grid-template-columns: 1fr;
    }
}

@media (max-height: 700px) {
    .component-list {
        max-height: 150px;
    }

    .component-list-container {
        max-height: 100px;
    }
}

@media (pointer: coarse) {

    .fold-button {
        padding: 12px;
        font-size: 16px;
    }

    input,
    select {
        height: 44px;
        font-size: 16px;
    }

    .property-group {
        padding: 12px;
    }
}

.mobile-component-drawer,
.mobile-templates-drawer,
.mobile-properties-drawer {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(26, 29, 36, 0.97);
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
    max-height: 70vh;
    overflow-y: auto;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.mobile-component-drawer.open,
.mobile-templates-drawer.open,
.mobile-properties-drawer.open {
    transform: translateY(0);
}

.mobile-component-drawer .drawer-header,
.mobile-templates-drawer .drawer-header,
.mobile-properties-drawer .drawer-header {
    background-color: rgba(36, 40, 48, 0.9);
    color: var(--mc-text);
    padding: 12px;
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid #3F4455;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.drawer-close-button {
    background-color: var(--mc-accent);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 14px;
}

.mobile-component-drawer .component-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 12px;
}

.mobile-component-drawer .component-item {
    background-color: #343A46;
    border-radius: 4px;
    padding: 8px;
    display: flex;
    align-items: center;
    cursor: grab;
    height: auto;
}

.mobile-component-drawer .component-item.touch-dragging {
    background-color: inherit;
    transform: none;
    opacity: 1;
}

.editor-component.touch-dragging {
    opacity: 1;
    z-index: 1000;
}

.component-item:active,
.editor-component:active {
    transform: scale(0.95);
}

.mobile-view .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #1A1D24;
    z-index: 1001;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-view .mobile-nav-button {
    flex: 1;
    padding: 10px;
    background-color: #343A46;
    color: var(--mc-text);
    border: none;
    border-right: 1px solid #3F4455;
    cursor: pointer;
}

.mobile-view .mobile-nav-button:last-child {
    border-right: none;
}

.mobile-view .mobile-nav-button.active {
    background-color: var(--mc-accent);
}

.mobile-view .main-content {
    margin-bottom: 50px;
}

.mobile-view .component-container {
    min-height: 200px;
}

.mobile-component-drawer .component-item.selected {
    background-color: var(--mc-accent);
    box-shadow: 0 0 0 2px white;
    position: relative;
}

.mobile-component-drawer .component-item.selected::after {
    content: '✓';
    position: absolute;
    top: 2px;
    right: 5px;
    color: white;
    font-weight: bold;
}

.mobile-placement-instructions {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    z-index: 2000;
    text-align: center;
    animation: pulse 2s infinite;
    pointer-events: none;
}

@keyframes pulse {
    0% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.7;
    }
}

.mobile-templates-drawer .template-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
    max-height: none;
    overflow: visible;
}

.mobile-templates-drawer .template-item {
    margin-bottom: 10px;
    transition: transform 0.2s ease, background-color 0.2s ease;
    padding: 12px;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.mobile-templates-drawer .template-item:active,
.mobile-templates-drawer .template-item:hover {
    background-color: var(--mc-button-hover);
}

.mobile-templates-drawer .template-item.template-active {
    background-color: var(--mc-accent);
    transform: scale(0.98);
}

.mobile-templates-drawer .template-item.template-selected {
    background-color: var(--mc-accent);
    animation: flash-selection 0.3s;
}

@keyframes flash-selection {
    0% {
        background-color: var(--mc-accent);
    }

    50% {
        background-color: var(--mc-success);
    }

    100% {
        background-color: var(--mc-accent);
    }
}

.mobile-templates-drawer .template-preview {
    width: 100%;
    height: 60px;
    background-size: cover;
    background-position: center;
}

.mobile-properties-container {
    padding: 12px;
}

.mobile-properties-drawer .property-group {
    margin-bottom: 16px;
    padding: 12px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.mobile-properties-drawer .property {
    margin-bottom: 10px;
}

.mobile-properties-drawer .property:last-child {
    margin-bottom: 0;
}

.mobile-properties-drawer label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.mobile-properties-drawer input[type="number"],
.mobile-properties-drawer input[type="text"],
.mobile-properties-drawer input[type="range"],
.mobile-properties-drawer select {
    width: 100%;
    padding: 10px;
    border-radius: 4px;
    font-size: 16px;
    height: 46px;
}

.mobile-properties-drawer input[type="checkbox"] {
    width: 24px;
    height: 24px;
    margin-right: 8px;
}

.mobile-properties-drawer .color-picker-controls {
    margin-bottom: 8px;
}

.mobile-properties-drawer .color-channels {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-bottom: 6px;
}

.mobile-properties-drawer .color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
}

.mobile-properties-drawer .color-option {
    width: 30px;
    height: 30px;
}

.mobile-properties-drawer {
    z-index: 2000;
}

.mobile-properties-drawer.open {
    display: block;
    transform: translateY(0);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.mobile-view .editor-component.selected {
    outline: 2px solid #7C38D1;
    box-shadow: 0 0 15px rgba(124, 56, 209, 0.6);
    z-index: 10;
}

.mobile-view .editor-component {
    position: absolute;
    cursor: pointer;
}

.mobile-view .editor-component:active {
    outline: 2px solid rgba(124, 56, 209, 0.6);
}

.mobile-properties-drawer .color-picker .color-option {
    width: 35px;
    height: 35px;
    margin: 3px;
}

.mobile-properties-button {
    position: fixed;
    bottom: 60px;
    left: 50%;
    z-index: 1500;
    height: 36px;
    padding: 0 12px;
    border-radius: 18px;
    background-color: var(--mc-accent);
    color: white;
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    transform: translateX(-50%);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    min-width: 160px;
}

.mobile-properties-button:active {
    transform: translateX(-50%) scale(0.95);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
}

.mobile-properties-button i {
    font-size: 14px;
}

.mobile-properties-drawer {
    display: none;
}

.mobile-properties-drawer.open {
    display: block;
}

.mobile-properties-drawer .image-upload-container {
    margin-top: 10px;
    width: 100%;
}

.mobile-properties-drawer .upload-image-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--mc-accent);
    border-radius: 4px;
    border: none;
    color: white;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-properties-drawer .image-preview-container {
    margin-top: 10px;
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.mobile-properties-drawer .custom-image-preview {
    width: 100%;
    height: 100px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    margin-top: 5px;
}

.drawer-delete-button {
    background-color: var(--mc-danger);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.drawer-delete-button i {
    font-size: 14px;
}

.drawer-delete-button:active {
    transform: scale(0.95);
    opacity: 0.9;
}

.mobile-properties-drawer .drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
}

.mobile-properties-drawer .drawer-header span {
    flex: 1;
    text-align: center;
}

.mobile-properties-drawer .drawer-header .drawer-buttons {
    display: flex;
    gap: 8px;
}

.mobile-components-list-drawer {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(26, 29, 36, 0.97);
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
    max-height: 70vh;
    overflow-y: auto;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    padding-bottom: 60px;
}

.mobile-components-list-drawer.open {
    transform: translateY(0);
    display: block;
}

.mobile-components-list-container {
    padding: 8px;
}

.mobile-component-list-item {
    background-color: rgba(52, 58, 70, 0.9);
    margin-bottom: 8px;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-component-list-item.selected {
    background-color: var(--mc-accent);
}

.mobile-component-list-item .item-details {
    flex: 1;
}

.mobile-component-list-item .component-type {
    font-weight: bold;
    font-size: 14px;
    display: block;
}

.mobile-component-list-item .component-info {
    color: #cccccc;
    font-size: 12px;
    display: block;
}

.mobile-component-list-item .component-position {
    color: #999999;
    font-size: 11px;
    display: block;
}

.mobile-component-list-item .item-actions {
    display: flex;
    gap: 6px;
}

.mobile-component-list-item .edit-button,
.mobile-component-list-item .delete-button,
.mobile-component-list-item .up-button,
.mobile-component-list-item .down-button {
    background: none;
    border: 1px solid var(--mc-border);
    border-radius: 4px;
    color: white;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-component-list-item .edit-button {
    background-color: var(--mc-accent);
}

.mobile-component-list-item .delete-button {
    background-color: var(--mc-danger);
}

.mobile-component-list-item .up-button,
.mobile-component-list-item .down-button {
    background-color: var(--mc-button);
}

.mobile-component-list-item .up-button:disabled,
.mobile-component-list-item .down-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mobile-list-button {
    position: fixed;
    bottom: 120px;
    right: 15px;
    width: 50px;
    height: 50px;
    border-radius: 25px;
    background-color: var(--mc-button);
    border: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 900;
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-list-button.active,
.mobile-list-button:active {
    background-color: var(--mc-accent);
}

.mobile-view .editor-canvas .chest-panel,
.mobile-view .preview-canvas .chest-panel {
    margin: 0;
}

.mobile-view .editor-canvas,
.mobile-view .preview-canvas {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    overflow: auto;
    min-height: 250px;
}