* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; 
    position: fixed;  
    touch-action: none; 

}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1; 
    
    background: url("images/bg.png") no-repeat center center;
    background-size: cover; /* Ekranı kapla */
    
    pointer-events: none; 
}

body {
    opacity: 0; 
    transition: opacity 0.5s ease-in-out; 
    font-family: 'Pixelify Sans', sans-serif;
    
    display: flex;
    align-items: center;
    justify-content: center;
}

body.fade-in {
    opacity: 1;
}

.main-layout {
    display: flex;
    background: rgba(255, 243, 184, 0.71);
    padding: 20px;
    padding-bottom: 15px;
    border-radius: 67px;
    box-shadow: 0 10px 40px rgba(126, 87, 194, 0.2);
    gap: 30px;
    max-width: 900px;
    width: 95%;
    height: auto;
}

.sidebar {
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.logo {
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    color:#FE6A86; 
    margin: 0;
    margin-top: 50px; 
    text-align: center;
}

.subtitle {
    text-align: center;
    color: #ff6d00;
    font-size: 15px;
    margin-top: -10px;
}


.flower-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 5px;
    touch-action: pan-x;

}

.flower-grid::-webkit-scrollbar {
    width: 6px;
}
.flower-grid::-webkit-scrollbar-thumb {
    background-color: #FE6A86;
    border-radius: 10px;
}

.flower-item {
    background: #fffbeb;
    border: 2px solid #FFDCE0;
    border-radius: 8px;
    padding: 10px;
    cursor: grab;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s;
}

.flower-item:hover {
    border-color: #FE6A86;
    background: #fffbeb;
    transform: scale(1.05);
}

.flower-item img {
    width: 50px; 
    height: 50px;
    object-fit: contain;
    image-rendering: pixelated;
    pointer-events: none; 
}

.canvas-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.canvas-wrapper {
    position: relative; 
    width: 600px;      
    height: 600px;     
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    background-color: #fffbeb; 
    border: none;
    border-radius: 45px;
    cursor: grab;
    image-rendering: pixelated; 
    width: 100%;
    height: 100%;
}

canvas:active {
    cursor: grabbing;
}

.hint {
    margin-top: 10px;   
    margin-bottom: 0;    
    width: 100%;
    text-align: center;
    font-size: 14px;        
    color: #ff6d00;
    font-family: 'Pixelify Sans', sans-serif;
    opacity: 0.8;
    letter-spacing: 0.5px;
}

.controls {
    position: absolute; 
    bottom: 20px;      
    right: 25px;       
    display: flex;
    flex-direction: row;
    gap: 15px;          
    z-index: 10;        
}

.controls button {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.controls button img {
    width: 35px !important;  
    height: auto !important;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.controls button:hover img {
    transform: scale(1.2) rotate(-5deg);
}

.controls button:active img {
    transform: scale(0.9);
}

.controls button::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    
    background-color: #FE6A86;
    color: white;
    padding: 5px 10px;
    border-radius: 8px;
    font-family: 'Pixelify Sans', sans-serif;
    font-size: 14px;
    white-space: nowrap;
    
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease-in-out;
    pointer-events: none;
}

.controls button::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    border: 6px solid transparent;
    border-top-color: #FE6A86;
    margin-bottom: -10px;
    
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease-in-out;
}

.controls button:hover::after,
.controls button:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-10px);
}

.color-palette {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 5px;
}

.color-btn {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 2px solid #FFDCE0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s;
}

.color-btn:hover {
    transform: scale(1.2);
    border-color: #FE6A86;
}

.modal {
    display: none; 
    position: fixed; 
    z-index: 100; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.5); 
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #fffbeb;
    border: 4px solid #FE6A86;
    border-radius: 20px;
    padding: 20px;
    width: 350px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    font-family: 'Pixelify Sans', sans-serif;
}

.modal-content h2 {
    color: #FE6A86;
    margin-top: 0;
}

.modal-content textarea {
    width: 100%;
    height: 100px;
    border: 2px solid #FFDCE0;
    border-radius: 10px;
    padding: 10px;
    font-family: 'Pixelify Sans', sans-serif;
    font-size: 16px;
    resize: none;
    outline: none;
    background-color: #fff;
}

.modal-content textarea:focus {
    border-color: #FE6A86;
}

.modal-buttons {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
}

.modal-buttons button {
    padding: 8px 20px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Pixelify Sans', sans-serif;
    font-size: 16px;
    transition: transform 0.1s;
}

.modal-buttons button:hover {
    transform: scale(1.05);
}

.add-btn {
    background-color: #FE6A86;
    color: white;
}

.cancel-btn {
    background-color: #ddd;
    color: #555;
}

.custom-toast {
    position: fixed;
    bottom: 30px;            
    left: 50%;              
    transform: translateX(-50%);
    background-color: #FE6A86; 
    color: #fff;             
    padding: 12px 24px;
    border-radius: 50px;    
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    font-family: sans-serif;
    font-size: 14px;
    z-index: 9999;           
    
    opacity: 1;
    transition: opacity 0.5s ease, bottom 0.5s ease;
    animation: slideUp 0.5s ease-out;
}

.custom-toast.hide {
    opacity: 0;
    bottom: 10px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        bottom: 10px;
    }
    to {
        opacity: 1;
        bottom: 30px;
    }
}

#view-only-header {
    display: none;
}

body.view-mode {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #fdf6f8;
    margin: 0;
    overflow: hidden;
}

body.view-mode .sidebar,
body.view-mode .controls,
body.view-mode .hint {
    display: none !important;
}

body.view-mode .main-layout {
    width: auto;
    display: block;
}

body.view-mode .canvas-wrapper {
    position: relative; 
    border-radius: 12px;
    overflow: hidden; 
}

body.view-mode #view-only-header {
    display: block;
    position: absolute;       
    top: 25px;              
    right: 10px;
    z-index: 10;              
    text-align: center;
    width: 100%;
    pointer-events: none; 
}

body.view-mode .logo {
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    color: #FE6A86;
    margin: 0;

}

body.view-mode .subtitle {
    font-family: 'Pixelify Sans', sans-serif;
    font-size: 14px;
    color: #FE6A86;
    margin-top: 5px;
    font-weight: 800;
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
}

@media screen and (max-width: 900px) {
    body::-webkit-scrollbar {
        display: none; 
    }

    body {
        padding: 10px;
        box-sizing: border-box;
        background-position: center center;

    }

    .main-layout {
        flex-direction: column-reverse; 
        width: 95%;
        height: 75%;
        gap: 20px;
        align-items: center;
        justify-content: center;
        position: relative;
        padding-top: 50px; 
        padding-bottom: 20px;
    }

    .sidebar {
        width: 100%;
        gap: 10px;
    }

    .logo {
        position: absolute;
        top: 20px;         
        left: 0;
        right: 0;
        text-align: center;
        margin: 0;
        z-index: 5;         
        font-size: 24px;    
    }

    .subtitle {
        position: absolute;
        top: 50px;          
        left: 0;
        right: 0;
        text-align: center;
        margin: 0;
        z-index: 5;
        font-size: 12px;
    }

    .flower-grid {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        max-height: auto;
        padding-bottom: 10px;
        gap: 15px;
        width: 100%;
        -webkit-overflow-scrolling: touch; 
    }

    .flower-grid::-webkit-scrollbar {
        height: 4px;
        background: transparent;
    }
    .flower-grid::-webkit-scrollbar-thumb {
        background-color: #FE6A86;
        border-radius: 10px;
    }

    .flower-item {
        min-width: 60px;
        height: 60px;
        flex-shrink: 0; 
    }

    .color-section {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    .color-section .subtitle {
        position: static; 
        margin-top: 10px;
        width: 100%;
        text-align: center;
    }

    .canvas-container {
        width: 100%;
    }

    .canvas-wrapper {
        width: 100%;
        max-width: 600px;
        height: auto;
        aspect-ratio: 1 / 1;
    }

    .controls {
        right: 10px;
        bottom: 10px;
        gap: 8px;
    }
    
    .controls button img {
        width: 30px !important;
    }

    body.view-mode {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    body.view-mode .main-layout {
        height: 45% !important;      
        width: 85% !important;    
        margin: auto !important;   
        padding: 30px 20px !important;
        background: rgba(255, 243, 184, 0.71);
        border-radius: 50px;
        text-align: center; 
    }

    body.view-mode #view-only-header {
        top: -20px;
        display: flex;
        flex-direction: column;

    }

    body.view-mode .logo {
        font-size: 20px !important;
        margin-bottom: 5px !important;
    }

    body.view-mode .subtitle {
        font-size: 12px !important;
    }

    body.view-mode .canvas-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        aspect-ratio: 1/1 !important;
        margin: 0 auto !important; 
        display: block; 
    }

    body.view-mode .sidebar,
    body.view-mode .controls,
    body.view-mode .hint,
    body.view-mode .flower-grid, 
    body.view-mode .color-section {
    display: none !important;
    }
}

@media screen and (max-width: 380px) {
    body::-webkit-scrollbar {
        display: none; 
    }

    .main-layout {
        padding-top: 70px; 
    }
    .logo {
        top: 20px;
        font-size: 20px;
    }
    .subtitle {
        top: 45px;
    }
}