:root {
    --bg-color: #f0f8ff;
    --panel-bg: #ffffff;
    --primary-color: #ff9f43;
    --secondary-color: #54a0ff;
    --accent-color: #ff6b6b;
    --text-color: #2c3e50;
    --border-radius: 20px;
    --shadow: 0 10px 20px rgba(0,0,0,0.1);
}

body {
    font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

header {
    text-align: center;
    margin-bottom: 20px;
    width: 100%;
    max-width: 900px;
}

h1 {
    font-size: 2.5rem;
    color: var(--accent-color);
    text-shadow: 2px 2px 0px #fff;
    margin: 0.5rem 0;
}

.input-group {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

input[type="text"] {
    padding: 15px 20px;
    font-size: 1.2rem;
    border: 3px solid var(--secondary-color);
    border-radius: 50px;
    outline: none;
    font-family: inherit;
    width: 250px;
    transition: transform 0.2s;
}

input[type="text"]:focus {
    transform: scale(1.05);
    border-color: var(--primary-color);
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    transition: transform 0.1s, box-shadow 0.1s;
}

button:active {
    transform: scale(0.95);
}

#generate-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 25px;
    font-size: 1.2rem;
    border-radius: 50px;
    font-weight: bold;
    box-shadow: 0 5px 0 #e67e22;
}

#generate-btn:active {
    box-shadow: 0 2px 0 #e67e22;
    transform: translateY(3px);
}

.app-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    width: 100%;
    max-width: 1000px;
}

.panel {
    background: var(--panel-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 4px solid #eee;
}

h2 {
    margin-top: 0;
    color: var(--secondary-color);
}

.canvas-wrapper {
    position: relative;
    width: 400px;
    height: 400px;
    background-color: white;
    border: 3px dashed #ccc;
    border-radius: 10px;
    overflow: hidden;
    cursor: crosshair;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    touch-action: none; /* Prevent scrolling while drawing */
}

#ghost-canvas {
    pointer-events: none; /* Let clicks pass through to drawing canvas */
    opacity: 0.3;
}

.controls {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    align-items: center;
}

.tools, .colors {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.tool-btn, .action-btn {
    background-color: #f1f2f6;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 1.5rem;
    border: 2px solid transparent;
}

.action-btn {
    font-size: 1rem;
    font-weight: bold;
    background-color: #dfe6e9;
}

#ref-color-toggle {
    margin-top: 15px;
    background-color: #a29bfe;
    color: white;
}

#ref-color-toggle.active {
    background-color: #6c5ce7;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}

.tool-btn.active {
    background-color: #dfe6e9;
    border-color: var(--secondary-color);
    transform: translateY(2px);
}

.color-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.color-btn.selected {
    transform: scale(1.2);
    border-color: var(--text-color);
}

.instruction {
    font-size: 1.1rem;
    color: #7f8c8d;
    margin-top: 10px;
}

@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
        align-items: center;
    }
    
    .canvas-wrapper, canvas {
        width: 300px;
        height: 300px;
    }
}
