:root {
    --toolbar-width-landscape: 80px;
    --toolbar-height-portrait: 70px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    height: 100vh;
    margin: 0;
    background-color: #f0f0f0;
    overflow: hidden; /* Prevent pull-to-refresh */
}

.container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    max-width: 1800px; /* Max width for large screens */
    margin: 0 auto; /* Center the container */
    box-shadow: 0 0 20px rgba(0,0,0,0.15); /* Add a subtle shadow */
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
}

#toolbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    background-color: #fff;
    border-right: 1px solid #ccc;
    width: var(--toolbar-width-landscape);
    box-sizing: border-box;
}

#toolbar input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    padding: 0;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    margin-bottom: 15px;
}

#toolbar input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

#toolbar input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

#toolbar button {
    font-size: 1.8rem;
    border: none;
    background: none;
    cursor: pointer;
    padding: 8px;
    margin-bottom: 10px;
    border-radius: 10px;
    transition: background-color 0.2s;
}

#toolbar button:hover, #toolbar button:active {
    background-color: #e0e0e0;
}

#canvas-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    height: 100%;
}

#coloringCanvas {
    cursor: pointer;
    touch-action: none; /* Prevent scrolling/zooming on canvas */
}

.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 10px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#imageLibrary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
}

#imageLibrary img {
    width: 100%;
    cursor: pointer;
    border: 1px solid #ccc;
    border-radius: 5px;
}

#deleteModal .modal-content {
    text-align: center;
}

#deleteModal button {
    padding: 10px 20px;
    margin: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#confirmDeleteBtn {
    background-color: #dc3545;
    color: white;
}

#cancelDeleteBtn {
    background-color: #ccc;
}

.tutorial-overlay {
    display: flex;
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
}

.tutorial-overlay.hidden {
    display: none;
}

.tutorial-content {
    background-color: white;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.tutorial-content h1 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.2rem;
}

.tutorial-section {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    text-align: left;
}

.tutorial-icon {
    font-size: 2rem;
    margin-right: 10px;
    min-width: 40px;
}

.tutorial-section div {
    color: #666;
    font-size: 0.9rem;
}

.tutorial-instruction {
    margin: 15px 0 10px 0;
    font-weight: bold;
    color: #333;
}

.tutorial-ok-btn {
    margin-top: 20px;
    padding: 10px 30px;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
}

/* Mobile and Tablet Styles */
@media (max-width: 768px) {
    .container {
        flex-direction: column-reverse; /* Toolbar at the bottom */
    }

    #toolbar {
        flex-direction: row;
        justify-content: space-around;
        border-right: none;
        border-top: 1px solid #ccc;
        width: 100%;
        height: var(--toolbar-height-portrait);
        padding: 5px;
        position: fixed;
        bottom: 0;
        left: 0;
        background-color: #ffffff;
        z-index: 10;
    }

    #toolbar input[type="color"] {
        margin-bottom: 0;
        margin-right: 10px;
        width: 35px;
        height: 35px;
    }

    #toolbar button {
        margin-bottom: 0;
        margin-right: 5px;
        font-size: 1.5rem;
    }

    #canvas-container {
        height: calc(100% - var(--toolbar-height-portrait));
        width: 100%;
    }

    .modal-content {
        margin: 20% auto;
    }
}

@media (orientation: portrait) {
    .container {
        flex-direction: column; /* Toolbar at the top */
    }

    #toolbar {
        flex-direction: row;
        justify-content: space-around;
        border-right: none;
        border-bottom: 1px solid #ccc;
        width: 100%;
        height: var(--toolbar-height-portrait);
        padding: 5px;
        position: static; /* remove fixed positioning */
    }

    #toolbar input[type="color"] {
        margin-bottom: 0;
        margin-right: 10px;
        width: 35px;
        height: 35px;
    }

    #toolbar button {
        margin-bottom: 0;
        margin-right: 5px;
        font-size: 1.5rem;
    }

    #canvas-container {
        height: calc(100% - var(--toolbar-height-portrait));
        width: 100%;
    }
}

