#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f4f7f9;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

#preloader img {
    width: 80px;
    margin-bottom: 20px;
}

body {
    background-color: #f4f7f9;
    color: #333;
    font-family: 'Poppins', sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100vw;
    margin: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.main-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    flex-grow: 1;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

.app-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    width: 100%;
}

.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.controls-panel button {
    background-color: #fff;
    color: #333;
    border: 1px solid #ddd;
    padding: 10px 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.controls-panel button:hover {
    background-color: #f4f7f9;
    border-color: #ccc;
}

.controls-panel button.active {
    background-color: #007aff;
    color: #fff;
    border-color: #007aff;
}

#code-input {
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    width: 100%;
}

.code-input-container {
    display: flex;
    gap: 5px;
}

#code-send-btn {
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 0 15px;
    cursor: pointer;
    background-color: #fff;
}

header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    padding: 20px 0;
}

#menu-btn {
    position: absolute;
    left: 20px;
    background: none;
    border: none;
    color: #333;
    font-size: 1.5em;
    cursor: pointer;
}

.menu {
    position: absolute;
    left: 20px;
    top: 50px;
    background: #fff;
    border-radius: 10px;
    padding: 10px;
    display: none;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.menu.show {
    display: flex;
}

.menu a {
    color: #333;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.menu a:hover {
    background-color: #f4f7f9;
}

.container {
    display: flex;
    gap: 50px;
    margin-bottom: 20px;
}

.phone-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 300px;
    height: 600px;
    background-color: #fff;
    border-radius: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 15px;
    box-sizing: border-box;
    transition: all 0.3s ease-in-out;
}

.phone-container:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.screen {
    background: #f4f7f9;
    height: 100%;
    border-radius: 20px;
    overflow-y: auto;
    border: 1px solid #e6e6e6;
    transition: all 0.3s ease-in-out;
}

.screen.dragover {
    border: 2px dashed #4fd1c5;
    background: rgba(79, 209, 197, 0.2);
}

.image-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 10px;
}

.image-gallery img {
    width: 100%;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}

.image-gallery img:hover {
    transform: scale(1.05);
}

.image-gallery img.selected {
    border: 3px solid #007aff;
    box-shadow: 0 0 15px rgba(0, 122, 255, 0.5);
    transform: scale(1.05);
    transition: all 0.3s ease-in-out;
}

@keyframes liftAnimation {
    0% { transform: translateY(0) scale(1.15); }
    100% { transform: translateY(-50px) scale(1.2); }
}

.lifting {
    animation: liftAnimation 0.5s ease-out forwards;
}

@keyframes dropAnimation {
    0% { transform: translateY(-100px) scale(0.5); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.dropping {
    animation: dropAnimation 0.5s ease-in-out forwards;
}


.upload-btn {
    background-color: #007aff;
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    display: block;
    margin: 20px auto;
    transition: background-color 0.2s;
}

.upload-btn:hover {
    background-color: #0056b3;
}

.instructions {
    margin-top: 20px;
    font-style: italic;
    color: #8892b0;
}

footer {
    margin-top: 20px;
    font-size: 0.8em;
    color: #aaa;
}

#qr-container {
    text-align: center;
    margin-top: 20px;
}

#qrcode {
    display: inline-block;
    background-color: #fff;
    padding: 10px;
    border-radius: 10px;
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#history-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80vw;
    max-width: 500px;
    background: rgba(11, 18, 32, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 10px 10px 20px #060910, -10px -10px 20px #101b30;
    z-index: 100;
}

#history-list {
    list-style: none;
    padding: 0;
    max-height: 60vh;
    overflow-y: auto;
}

#history-list li {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    font-size: 0.9em;
}

#instructions-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80vw;
    max-width: 500px;
    background: rgba(11, 18, 32, 0.95);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 10px 10px 30px #060910, -10px -10px 30px #101b30;
    z-index: 200;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#instructions-container h2 {
    text-align: center;
    color: #4fd1c5;
}

#instructions-container ul {
    list-style: none;
    padding: 0;
}

#instructions-container li {
    margin-bottom: 15px;
    line-height: 1.6;
}

#code-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80vw;
    max-width: 400px;
    background: rgba(11, 18, 32, 0.95);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 10px 10px 30px #060910, -10px -10px 30px #101b30;
    z-index: 200;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#code-display {
    font-size: 2em;
    font-weight: 600;
    color: #4fd1c5;
    letter-spacing: 5px;
    margin: 20px 0;
}

#close-code-modal-btn {
    display: block;
    margin: 20px auto 0;
    background-color: #0b1220;
    color: #4fd1c5;
    border: 1px solid #4fd1c5;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 5px 5px 10px #060910, -5px -5px 10px #101b30;
    transition: all 0.2s ease-in-out;
}

#close-code-modal-btn:hover {
    color: #0b1220;
    background-color: #4fd1c5;
    box-shadow: inset 5px 5px 10px #3aa99e, inset -5px -5px 10px #64f7ec;
}

#close-instructions-btn {
    display: block;
    margin: 20px auto 0;
    background-color: #0b1220;
    color: #4fd1c5;
    border: 1px solid #4fd1c5;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 5px 5px 10px #060910, -5px -5px 10px #101b30;
    transition: all 0.2s ease-in-out;
}

#close-instructions-btn:hover {
    color: #0b1220;
    background-color: #4fd1c5;
    box-shadow: inset 5px 5px 10px #3aa99e, inset -5px -5px 10px #64f7ec;
}

@media (max-width: 768px) {
    .app-body {
        flex-direction: column;
    }

    #console-container {
        height: 30vh; /* Taller on mobile */
    }

    .container {
        flex-direction: column;
        gap: 20px;
    }

    .phone-container {
        width: 90vw;
        height: 70vh;
    }

    header h1 {
        font-size: 1.5em;
    }
}