body {
    margin: 0;
    padding: 0;
    background: #1e1e1e;
    color: #eaeaea;
    font-family: 'Arial', sans-serif;
    min-height: 100vh;
}

.container {
    display: flex;
    padding: 20px;
    gap: 20px;
    min-height: 100vh;
    box-sizing: border-box;
}

.instructions {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    padding: 15px;
    border-radius: 10px;
    max-width: 90vw;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.instructions p {
    margin: 5px 0;
    font-size: 14px;
    color: #fff;
}

.tools {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 10px;
    width: 250px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

#artCanvas {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

canvas {
    display: block !important;
    background: #2a2a2a;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    touch-action: none;
}

.tool-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.tool-button {
    padding: 8px 16px;
    background: #3a3a3a;
    border: none;
    border-radius: 5px;
    color: #eaeaea;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.tool-button:hover {
    background: #4a4a4a;
    transform: translateY(-2px);
}

.tool-button.active {
    background: #0078d4;
}

.brush-size {
    margin: 15px 0;
}

.size-controls {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.size-button {
    padding: 5px 10px;
    background: #3a3a3a;
    border: none;
    border-radius: 5px;
    color: #eaeaea;
    cursor: pointer;
    transition: background 0.2s;
}

.size-button:hover {
    background: #4a4a4a;
}

.palette-container {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.color-box {
    display: flex;
    gap: 2px;
    padding: 2px;
    background: #1e1e1e;
    border-radius: 5px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.color-box > div {
    width: 25px !important;
    height: 25px !important;
    border-radius: 3px;
}

.palette-item {
    width: 60px;
    height: 60px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    transition: transform 0.2s;
}

.palette-item:hover {
    transform: scale(1.05);
}

/* Mobile-specific styles */
@media screen and (max-width: 768px) {
    .container {
        flex-direction: column;
        padding: 5px;
        gap: 10px;
        height: 100vh;
        overflow: hidden;
    }

    .tools {
        width: auto;
        order: 2;
        padding: 10px;
        max-height: 40vh;
        overflow-y: auto;
        margin-bottom: env(safe-area-inset-bottom, 0px);
    }

    #artCanvas {
        width: 100%;
        order: 1;
        padding: 5px;
        height: 60vh;
        overflow: hidden;
        align-items: center;
    }

    canvas {
        max-width: 100% !important;
        max-height: 100% !important;
        width: auto !important;
        height: auto !important;
        touch-action: none;
    }

    .tool-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }

    .tool-button {
        min-width: 70px;
        padding: 12px 16px;
        font-size: 16px;
    }

    .size-button {
        padding: 8px 15px;
        font-size: 16px;
    }

    .palette-container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
    }

    .color-box {
        margin: 2px;
    }

    .color-box > div {
        width: 30px !important;
        height: 30px !important;
    }

    .edit-controls {
        flex-wrap: wrap;
    }

    body {
        position: fixed;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
}

/* Prevent scrolling/bouncing on iOS */
html {
    position: fixed;
    height: 100%;
    overflow: hidden;
}

.save-load-controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #2a2a2a;
    color: #eaeaea;
    margin: 15% auto;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.modal-section {
    margin: 15px 0;
}

.modal h3 {
    margin: 0 0 15px 0;
    color: #eaeaea;
}

.modal input[type="text"] {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 5px;
    color: #eaeaea;
    font-family: monospace;
}

.modal input[readonly] {
    background: #333;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: #eaeaea;
}

/* Mobile adjustments */
@media screen and (max-width: 768px) {
    .modal-content {
        margin: 30% auto;
        width: 95%;
        padding: 15px;
    }
}

.hamburger-button {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    margin-bottom: 10px;
    transition: transform 0.2s;
}

.hamburger-button:hover {
    transform: scale(1.1);
}

.tools-content {
    display: block;
    transition: max-height 0.3s ease;
}

.tools-content.hidden {
    display: none;
}

.edit-controls {
    margin: 15px 0;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.edit-controls .tool-button {
    min-width: 70px;
    font-size: 0.9em;
    padding: 8px 10px;
    flex-grow: 0;
}

/* Group similar buttons visually */
.edit-controls .tool-button:nth-child(1),
.edit-controls .tool-button:nth-child(5) {
    flex-basis: 60px;
    background: #3a3a3a;
}

.edit-controls .tool-button:nth-child(2),
.edit-controls .tool-button:nth-child(6) {
    background: #444;
}

.edit-controls .tool-button:nth-child(3),
.edit-controls .tool-button:nth-child(7) {
    background: #484848;
}

.edit-controls .tool-button:nth-child(4),
.edit-controls .tool-button:nth-child(8) {
    background: #4c4c4c;
}

/* Mobile-specific adjustments for edit controls */
@media screen and (max-width: 768px) {
    .edit-controls {
        gap: 4px;
    }

    .edit-controls .tool-button {
        min-width: auto;
        padding: 10px 6px;
        flex: 1;
        white-space: nowrap;
        font-size: 0.8em;
        max-width: calc(25% - 4px);
    }
    
    /* Stack undo and redo groups */
    .edit-controls {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }
}

#exportButton {
    background: #2c5282;
}

#exportButton:hover {
    background: #2b6cb0;
}

@media screen and (max-width: 768px) {
    .save-load-controls {
        justify-content: center;
    }
    
    .save-load-controls .tool-button {
        flex: 1;
        min-width: 80px;
        max-width: calc(33.33% - 7px);
    }
}