/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Prevent selection during drag */
.no-select, .no-select * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Ensure pointer events deliver full move stream on touch */
.drag-handle, .draggable-panel {
    touch-action: none;
}

/* Performance optimization for draggable elements */
.draggable-panel {
    will-change: transform;
    backface-visibility: hidden;
    /* Compose GPU hint with base transform for correct initial layout */
    transform: var(--base-transform, none) translateZ(0);
}

body {
    font-family: 'Kalam', cursive;
    background: #000;
    color: #fff;
    overflow: hidden;
    height: 100vh;
}

/* App container */
.app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

/* Map container */
.map-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    filter: grayscale(100%) invert(1) contrast(1.2);
}

/* Content overlay */
.content-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.content-overlay > * {
    pointer-events: auto;
}

/* Promo Banner */
.promo-banner {
    position: fixed;
    top: -100px; /* hidden initially, slide down to 0 */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    width: min(900px, calc(100vw - 2rem));
    border: 2px solid #A855F7;
    border-radius: 12px;
    background: rgba(90, 0, 150, 0.7);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.6), 0 0 40px rgba(236, 72, 153, 0.3);
    backdrop-filter: blur(6px);
    transition: top 0.6s ease, box-shadow 0.3s ease;
}
.promo-banner.visible {
    top: 0.75rem;
}
.promo-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.6rem 0.8rem;
}
.promo-text {
    color: #E9D5FF;
    font-weight: 800;
    letter-spacing: 0.5px;
}
.promo-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(236,72,153,0.8));
}
.promo-cta {
    margin-left: 0.25rem;
    background: linear-gradient(135deg, #8B5CF6, #EC4899);
    color: #fff;
    text-decoration: none;
    padding: 0.45rem 0.8rem;
    border-radius: 10px;
    font-weight: 800;
    border: 2px solid rgba(255,255,255,0.25);
    box-shadow: 0 6px 18px rgba(236, 72, 153, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.promo-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(236, 72, 153, 0.5);
}
.promo-cta:active {
    transform: translateY(0);
}

/* Mobile promo banner optimization - moved to main mobile section */

/* Input section */
.input-section {
    top: 50%;
    left: 2rem;
    /* Use base transform variable so animations don't override layout */
    --base-transform: translateY(-50%);
    width: 350px;
    padding: 0;
}

.input-container {
    padding: 2rem;
}

.app-title {
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 1.5rem;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.input-wrapper {
    margin-bottom: 1rem;
}

.actions-row {
    display: flex;
    gap: 0.6rem;
}

.suggest-btn {
    background: transparent;
    color: #7CFFA6;
    border: 2px dashed rgba(124, 255, 166, 0.6);
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    font-family: 'Kalam', cursive;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}
.suggest-btn:hover {
    background: rgba(124, 255, 166, 0.12);
    transform: translateY(-1px);
    box-shadow: 0 5px 10px rgba(124, 255, 166, 0.2);
}
.suggest-btn:active {
    transform: translateY(0);
}

#phraseInput {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #fff;
    border-radius: 10px;
    padding: 1rem;
    color: #fff;
    font-family: 'Kalam', cursive;
    font-size: 1rem;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 1rem;
}

#phraseInput::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#phraseInput:focus {
    outline: none;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.generate-btn {
    width: 100%;
    background: #fff;
    color: #000;
    border: none;
    border-radius: 10px;
    padding: 0.8rem 1.5rem;
    font-family: 'Kalam', cursive;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    transform: rotate(-1deg);
}

.generate-btn:hover {
    transform: rotate(0deg) scale(1.05);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.3);
}

.generate-btn:active {
    transform: rotate(1deg) scale(0.95);
}

/* Attention-pulse for Generate button */
.generate-btn.attention {
    animation: btnPulse 1.2s ease-in-out infinite;
    box-shadow: 0 0 0 rgba(255,255,255,0.5);
}

@keyframes btnPulse {
    0% {
        transform: rotate(-1deg) scale(1);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4), 0 0 10px rgba(255,255,255,0.15);
    }
    50% {
        transform: rotate(-1deg) scale(1.05);
        box-shadow: 0 0 0 10px rgba(255, 255, 255, 0), 0 0 20px rgba(255,255,255,0.35);
    }
    100% {
        transform: rotate(-1deg) scale(1);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.0), 0 0 10px rgba(255,255,255,0.15);
    }
}

.original-phrase {
    margin-top: 1rem;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-style: italic;
    color: rgba(255, 255, 255, 0.9);
    min-height: 40px;
    display: none;
}

/* Draggable panels */
.draggable-panel {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #fff;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
    cursor: move;
    z-index: 10;
    /* Limit transitions to purely visual properties to avoid drag lag */
    transition: box-shadow 0.3s ease, transform 0.3s ease, background 0.3s ease;
}

.draggable-panel:hover {
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.2);
}

.draggable-panel.dragging {
    z-index: 1000;
    /* Avoid scaling to prevent offset calculation issues during drag */
    box-shadow: 0 10px 40px rgba(255, 255, 255, 0.3);
    /* Performance optimizations for smooth dragging */
    will-change: left, top;
}

.drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 13px 13px 0 0;
    cursor: grab;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-dots {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.6);
    transform: rotate(90deg);
}

.drag-text {
    font-family: 'Kalam', cursive;
    font-weight: 400;
}

/* Language chain */
.language-chain {
    top: 2rem;
    right: 2rem;
    width: 300px;
    padding: 0;
}

.language-boxes-container {
    padding: 1rem;
    /* Enable touch dragging for SortableJS */
    touch-action: none;
}

.language-box {
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #fff;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.8rem;
    cursor: grab;
    transition: all 0.3s ease;
    position: relative;
    transform: rotate(0.5deg);
    /* Enable dragging for SortableJS */
    touch-action: none;
}

.language-box:nth-child(even) {
    transform: rotate(-0.5deg);
}

.language-box:hover {
    transform: rotate(0deg) scale(1.02);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.2);
}

.language-box.dragging {
    cursor: grabbing;
    transform: rotate(2deg) scale(1.05);
    z-index: 1000;
}

.language-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.language-flag {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

.language-name {
    font-weight: 700;
    font-size: 1rem;
}

.remove-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.remove-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.language-text {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
    min-height: 20px;
}

/* Add language tile */
.add-language-box {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
    cursor: pointer;
    transform: none;
}
.add-language-box .add-language-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: #fff;
}
.add-language-box .add-language-content span {
    font-size: 0.95rem;
}
.add-language-box:hover {
    transform: scale(1.02);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.2);
}
.add-language-box:active {
    transform: scale(0.98);
}

/* Character counter */
.char-counter {
    text-align: right;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: -0.5rem;
    margin-bottom: 0.5rem;
}

/* Results section */
.results-section {
    bottom: 2rem;
    left: 50%;
    /* Use base transform variable so animations don't override layout */
    --base-transform: translateX(-50%);
    width: 80%;
    max-width: 600px;
    padding: 0;
    display: none;
}

.results-section.active {
    display: block;
}

/* Regenerate indicator */
.regen-indicator {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    display: none;
    align-items: center;
    gap: 0.35rem;
    background: rgba(0, 255, 128, 0.12);
    border: 1px solid rgba(0, 255, 128, 0.4);
    color: #7CFFA6;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,255,128,0.25);
}
.regen-indicator.visible {
    display: inline-flex;
}

.final-result {
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1rem;
    display: none;
    background: none;
    border: none;
    border-radius: 0;
}

.final-result h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: #fff;
}

.final-result p {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    font-style: italic;
}

.translation-steps {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0 0 13px 13px;
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.translation-step {
    margin-bottom: 0.8rem;
    padding: 0.5rem;
    border-left: 3px solid #fff;
    padding-left: 1rem;
}

.step-language {
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.3rem;
}

.step-text {
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: #000;
    border: 3px solid #fff;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 2rem 1rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0; /* Prevent header from shrinking */
}

.modal-header h3 {
    font-size: 1.5rem;
    color: #fff;
}

.close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.language-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    padding: 1rem 2rem 2rem 2rem;
    overflow-y: auto;
    flex: 1; /* Take up remaining space */
}

.language-option {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #fff;
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.language-option:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.language-option .flag {
    font-size: 2rem;
}

.language-option .name {
    font-size: 0.9rem;
    color: #fff;
    font-weight: 700;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    color: #fff;
    font-size: 1.1rem;
    text-align: center;
}

/* Map customizations */
.leaflet-control-container {
    display: none;
}

.custom-pin {
    background: #ff0000;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.8);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 10px rgba(255, 0, 0, 0.8);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 0, 0, 1);
    }
    100% {
        box-shadow: 0 0 10px rgba(255, 0, 0, 0.8);
    }
}

.connection-line {
    stroke: #00ffff;
    stroke-width: 3;
    fill: none;
    filter: drop-shadow(0 0 5px #00ffff);
    animation: glow 3s ease-in-out infinite alternate;
}

@keyframes glow {
    0% {
        filter: drop-shadow(0 0 5px #00ffff);
    }
    100% {
        filter: drop-shadow(0 0 15px #00ffff);
    }
}

/* Sortable.js ghost styling */
.sortable-ghost {
    opacity: 0.4;
    transform: rotate(5deg) scale(1.05) !important;
    box-shadow: 0 10px 25px rgba(255, 255, 255, 0.3) !important;
    z-index: 1000 !important;
    /* Ensure visibility during drag */
    visibility: visible !important;
}

.sortable-chosen {
    cursor: grabbing !important;
    /* Ensure the chosen element is visible during drag */
    opacity: 0.8;
    transform: scale(1.02) !important;
}

.sortable-drag {
    /* Additional styling for the dragged element */
    box-shadow: 0 15px 30px rgba(255, 255, 255, 0.4) !important;
    z-index: 1001 !important;
}

/* Additional animations */
@keyframes slideInFromLeft {
    0% {
        transform: var(--base-transform, none) translateX(-100px);
        opacity: 0;
    }
    100% {
        transform: var(--base-transform, none) translateX(0);
        opacity: 1;
    }
}

@keyframes slideInFromRight {
    0% {
        transform: var(--base-transform, none) translateX(100px);
        opacity: 0;
    }
    100% {
        transform: var(--base-transform, none) translateX(0);
        opacity: 1;
    }
}

@keyframes fadeInUp {
    0% {
        transform: var(--base-transform, none) translateY(30px);
        opacity: 0;
    }
    100% {
        transform: var(--base-transform, none) translateY(0);
        opacity: 1;
    }
}

.input-section {
    animation: slideInFromLeft 0.8s ease-out;
}

.language-chain {
    animation: slideInFromRight 0.8s ease-out;
}

.results-section {
    animation: fadeInUp 0.6s ease-out;
}

/* Typewriter effect for final result */
.typewriter {
    overflow: hidden;
    border-right: 3px solid #fff;
    white-space: nowrap;
    animation: typing 2s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: #fff; }
}

/* Reset animation */
.draggable-panel.resetting {
    animation: resetPulse 0.3s ease-out;
}

@keyframes resetPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Draggable panel improvements */
.draggable-panel .input-container,
.draggable-panel .language-boxes-container {
    background: none;
    border: none;
    border-radius: 0;
    backdrop-filter: none;
    box-shadow: none;
}

/* Reset button for panels */
.reset-position-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 100;
}

.reset-position-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Improved drag handle visibility */
.drag-handle {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.drag-handle:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
}

/* Responsive design */
@media (max-width: 768px) {
    /* Allow scrolling on mobile */
    body {
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
    }
    
    .app-container {
        height: auto;
        min-height: 100vh;
    }
    
    .content-overlay {
        position: relative;
        width: 100%;
        height: auto;
        min-height: 100vh;
        padding: 1rem;
        padding-top: 4rem; /* Space for promo banner */
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Reset draggable positioning on mobile */
    .draggable-panel {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        transform: none !important;
        --base-transform: none !important;
        width: 100% !important;
        max-width: none !important;
        cursor: default;
        margin: 0;
    }
    
    /* Disable dragging on mobile */
    .drag-handle {
        cursor: default;
        padding: 0.6rem 1rem;
    }
    
    .drag-handle:active {
        cursor: default;
    }
    
    /* Hide "Drag to move" headers on mobile, but keep language chain header */
    .input-section .drag-handle,
    .results-section .drag-handle {
        display: none;
    }
    
    /* Keep the language chain drag handle visible for instructions */
    .language-chain .drag-handle {
        display: flex;
    }
    
    /* Stack panels vertically with proper spacing */
    .input-section {
        order: 1;
        margin-bottom: 0;
    }
    
    .language-chain {
        order: 2;
        margin-bottom: 0;
    }
    
    .results-section {
        order: 3;
        margin-bottom: 2rem;
    }
    
    /* Adjust panel content for mobile */
    .input-container {
        padding: 1.5rem;
    }
    
    .language-boxes-container {
        padding: 1rem;
        /* Enable touch dragging for SortableJS */
        touch-action: none;
    }
    
    .app-title {
        font-size: 1.6rem;
        margin-bottom: 1.5rem;
        line-height: 1.3;
    }
    
    .drag-text {
        font-size: 0.8rem;
        line-height: 1.2;
    }
    
    .drag-handle {
        padding: 0.7rem 1rem;
        font-size: 0.8rem;
        line-height: 1.2;
    }
    
    /* Improve text readability */
    .original-phrase {
        font-size: 0.95rem;
        line-height: 1.4;
        padding: 1rem;
    }
    
    .final-result h3 {
        font-size: 1.4rem;
        line-height: 1.3;
        margin-bottom: 1.2rem;
    }
    
    .final-result p {
        font-size: 1.1rem;
        line-height: 1.4;
    }
    
    .char-counter {
        font-size: 0.85rem;
        margin-top: -0.3rem;
        margin-bottom: 0.7rem;
    }
    
    /* Better spacing for mobile */
    .input-wrapper {
        margin-bottom: 1.2rem;
    }
    
    #phraseInput {
        padding: 1.2rem;
        line-height: 1.4;
        margin-bottom: 0.5rem;
    }
    
    #phraseInput::placeholder {
        font-size: 0.95rem;
    }
    
    /* Improve input sizing on mobile */
    #phraseInput {
        font-size: 1rem; /* Prevent zoom on iOS */
        min-height: 60px;
    }
    
    /* Better button layouts on mobile */
    .actions-row {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .suggest-btn, .generate-btn {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        min-height: 48px; /* Apple recommended touch target size */
        border-radius: 12px;
    }
    
    /* Improve touch targets for remove buttons */
    .remove-btn {
        width: 35px;
        height: 35px;
        font-size: 1.1rem;
        border-radius: 50%;
        margin: -5px; /* Expand touch area */
    }
    
    /* Better touch targets for language boxes */
    .language-box {
        min-height: 60px;
        padding: 1.2rem;
        cursor: grab; /* Keep grab cursor for drag functionality */
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
        /* Enable touch dragging for SortableJS */
        touch-action: none;
    }
    
    .add-language-box {
        min-height: 60px;
        padding: 1rem;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    }
    
    /* Improve modal close button touch target */
    .close-btn {
        width: 40px;
        height: 40px;
        font-size: 1.8rem;
        margin: -5px;
    }
    
    /* Better touch feedback */
    .suggest-btn:active, .generate-btn:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Remove conflicting active transform for language boxes to allow SortableJS to handle dragging */
    .language-box:active:not(.sortable-chosen):not(.sortable-ghost) {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Improve language boxes on mobile */
    .language-box {
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    .language-name {
        font-size: 0.95rem;
    }
    
    .language-text {
        font-size: 0.85rem;
    }
    
    /* Modal improvements for mobile */
    .modal-content {
        max-height: 85vh;
        margin: 1rem;
        width: calc(100vw - 2rem);
    }
    
    .modal-header {
        padding: 1.5rem 1.5rem 1rem 1.5rem;
    }
    
    .language-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.8rem;
        padding: 1rem 1.5rem 1.5rem 1.5rem;
    }
    
    .language-option {
        padding: 0.8rem;
    }
    
    .language-option .flag {
        font-size: 1.5rem;
    }
    
    .language-option .name {
        font-size: 0.8rem;
    }
    
    /* Hide reset buttons on mobile since dragging is disabled */
    .reset-position-btn {
        display: none;
    }
    
    /* Ensure map stays in background on mobile */
    .map-container {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: 1;
    }
    
    /* Optimize promo banner for mobile */
    .promo-banner {
        position: fixed;
        top: -100px;
        left: 1rem;
        right: 1rem;
        width: auto;
        transform: none;
        z-index: 1100;
        margin: 0;
    }
    
    .promo-banner.visible {
        top: 0.5rem;
    }
    
    .promo-inner {
        padding: 0.5rem 0.7rem;
        gap: 0.5rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .promo-text {
        font-size: 0.8rem;
        font-weight: 700;
        text-align: center;
        flex: 1;
        min-width: 120px;
    }
    
    .promo-logo {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }
    
    .promo-cta {
        padding: 0.35rem 0.6rem;
        font-size: 0.8rem;
        font-weight: 700;
        flex-shrink: 0;
        white-space: nowrap;
    }
}