.wrap {
    overflow: visible;
}

.meme-container {
    position: relative;
    max-width: 480px;
    margin: auto;
    text-align: center;
    overflow: visible;
}

.bottom-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 8px 13px;
}

.action-buttons {
    display: flex;
    gap: 6px;
}

.action-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color);
    transition: none;
}

.action-btn:hover,
.action-btn:active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn:disabled:hover {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-color);
}

.meme-text {
    position: absolute;
    font-size: 32px;
    font-weight: 800;
    color: white;
    text-shadow:
        1.41px 1.41px black,
        2px 0 black,
        1.41px -1.41px black,
        0 -2px black,
        -1.41px -1.41px black,
        -2px 0 black,
        -1.41px 1.41px black,
        0 2px black;
    padding: 5px;
    cursor: move;
    user-select: none;
    letter-spacing: 6%;
    min-width: max-content;
    max-width: 100%;
    width: fit-content;
    box-sizing: border-box;
}

.meme-text.black-text {
    color: black;
    text-shadow:
        1.41px 1.41px white,
        2px 0 white,
        1.41px -1.41px white,
        0 -2px white,
        -1.41px -1.41px white,
        -2px 0 white,
        -1.41px 1.41px white,
        0 2px white;
}

.meme-text.no-shadow {
    text-shadow: none !important;
}


#top-text {
    top: 10px;
    text-align: center;
}

#bottom-text {
    top: calc(100% - 60px);
    text-align: center;
}


img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: auto;
}

button {
    margin-top: 20px;
    font-size: 16px;
    cursor: pointer;
}

.template-select {
    margin-bottom: 20px;
    font-size: 16px;
}

#memeImg {
  pointer-events: none;
}

.download-meme {
    border: 0;
    background-color: var(--accent-color);
    color: white;
    margin: 13px;
    border-radius: 6px;
    border-color: transparent;
    transition: none;
    justify-self: stretch;
}

.download-meme:hover {
    background-color: #d99c00;
}

.text-control-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 10px;
    border: 1px solid var(--border-color);
}

.text-control-item h2{
    margin-block-end: 0px;
    font-weight: 600;
    font-size: 14px;
}

.text-controls {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 16px;
}

.text-align label{
    margin-bottom: 6px;
}

.waterm {
  position: absolute;
  bottom: 12px;
  right: 12px;
  color: white;
  font-size: 14px;
  text-shadow:
    -1px -1px 0 black,
     1px -1px 0 black,
    -1px  1px 0 black,
     1px  1px 0 black;
  opacity: 0.6; /* регулируй прозрачность */
  pointer-events: none;
  user-select: none;
  z-index: 2000;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    margin-right: 13px;
    margin-left: 13px;
    margin-bottom: 8px;
}

.align-buttons-wrap {
    display: flex;
    flex-direction: row;
    gap: 32px;
}

.text-align {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.text-size {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 100%;
    justify-content: space-between;
}

.text-color-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: space-between;
}


.text-size input{
    height: 24px;
}

/* Обеспечиваем правильный скролл */
body {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Мобильные улучшения */
@media (max-width: 768px) {
    .meme-container {
        max-width: 100%;
        margin: 0 10px;
    }
    
    .controls {
        margin: 8px 10px;
        gap: 8px;
    }
    
    .text-controls {
        flex-direction: column;
        gap: 12px;
    }
    
    .align-buttons-wrap {
        gap: 16px;
        justify-content: center;
    }
    
    .text-size input {
        height: 40px;
        -webkit-appearance: none;
        background: var(--bg-secondary);
        border-radius: 20px;
        outline: none;
    }
    
    .text-size input::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 24px;
        height: 24px;
        background: var(--accent-color);
        border-radius: 50%;
        cursor: pointer;
    }
    
    .text-size input::-moz-range-thumb {
        width: 24px;
        height: 24px;
        background: var(--accent-color);
        border-radius: 50%;
        cursor: pointer;
        border: none;
    }
    
    .align-btn {
        min-width: 56px;
        min-height: 56px;
        padding: 16px;
        border-radius: 12px;
        background: var(--bg-secondary);
        border: 2px solid var(--border-color);
        transition: none;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .align-btn:hover,
    .align-btn:active,
    .align-btn.active {
        background: var(--accent-color);
        border-color: var(--accent-color);
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    }
    
    .align-btn svg {
        width: 28px;
        height: 28px;
    }
    
    /* Улучшенные кнопки цветов */
    .text-color-buttons .align-btn {
        min-width: 60px;
        min-height: 60px;
    }
    
    .text-color-buttons .align-btn svg {
        width: 32px;
        height: 32px;
    }
    
    .download-meme {
        height: 56px;
        font-size: 18px;
        font-weight: 600;
        margin: 20px 10px;
        border-radius: 12px;
    }
    
    .meme-text {
        font-size: 28px;
        padding: 8px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .text-control-item h2 {
        font-size: 20px;
        margin-bottom: 8px;
    }
    
    .text-size label,
    .text-color-buttons label,
    .text-align label {
        font-size: 16px;
        font-weight: 500;
        margin-bottom: 8px;
    }
    
    
    /* Улучшенный мобильный layout */
    .wrap {
        padding-bottom: 20px;
    }
    
    .wrap h1 {
        font-size: 20px;
        margin: 16px 10px;
        padding: 0;
    }
    
    /* Компактные контролы на мобильных */
    .text-control-item {
        background: var(--bg-secondary);
        border-radius: 8px;
        padding: 10px;
        margin-bottom: 8px;
        border: 1px solid var(--border-color);
    }
    
    .text-control-item h2 {
        margin-bottom: 8px;
        padding-bottom: 4px;
        border-bottom: 1px solid var(--border-color);
        font-size: 16px;
    }
    
    /* Мобильные стили для кнопок действий */
    .bottom-buttons {
        flex-direction: column;
        gap: 12px;
    }
    
    .action-buttons {
        justify-content: center;
    }
    
    .action-btn {
        width: 44px;
        height: 44px;
    }
    
    .download-meme {
        width: 100%;
    }
    
    
    /* Мобильные стили для управления текстом */
    .text-management {
        margin: 16px 10px;
        padding: 12px;
        flex-direction: column;
        gap: 12px;
    }
    
    .text-counter {
        font-size: 16px;
        text-align: center;
    }
    
    .text-actions {
        justify-content: center;
    }
    
    .text-action-btn {
        width: 40px;
        height: 40px;
    }
}

.accent-txt{
    color: var(--accent-color)
}


/* Управление текстовыми элементами */
.text-management {
    margin: 12px 13px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.text-counter {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-color);
}

.text-actions {
    display: flex;
    gap: 6px;
}

.text-action-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color);
    transition: none;
}

.text-action-btn:hover,
.text-action-btn:active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.text-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.text-action-btn:disabled:hover {
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}
