* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background-color: #5e75da;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: cover;
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('/static/snowflake_bg.png') repeat;
    background-size: 35%;
    background-position-x: -40px;
    background-position-y: -40px;
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 0;
    padding-bottom: 25px;
    margin-bottom: 25px;
    font-size: 2.5em;
    border-bottom: 2px solid #e0e0e0;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

h1 span {
    color: #8045ba;
}

.tab-buttons {
    display: none; /* Hidden on desktop */
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-button {
    background: #e0e0e0;
    color: #555;
    padding: 10px 30px;
    border: none;
    border-radius: 30px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.tab-button:hover {
    transform: translateY(-2px);
}

h2 {
    color: #555;
    font-size: 1.3em;
    margin-bottom: 10px;
}

.editor-container {
    display: flex;
    gap: 40px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.editor-section, .preview-section {
    flex: 1;
    min-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.instructions {
    color: #666;
    font-size: 0.9em;
    margin-top: 15px;
    line-height: 1.4;
}

canvas {
    border: 2px solid #ddd;
    border-radius: 8px;
    display: block;
    background: #ecf1f3;
    cursor: crosshair;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

canvas#foldedCanvas:hover {
    border-color: #667eea;
}

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

button {
    padding: 10px 20px;
    border: none;
    border-radius: 30px;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

button:disabled {
    background: #ddd;
    color: #aaa;
    cursor: not-allowed;
}

.controls button {
    background: #667eea;
    color: white;
}

.controls button:hover:not(:disabled) {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#clearBtn {
    background: #e74c3c;
}

#clearBtn:hover {
    background: #c0392b;
}

.save-section {
    text-align: center;
    padding: 20px;
    border-top: 2px solid #eee;
    margin-top: 20px;
}

.save-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1.2em;
    padding: 15px 40px;
    box-shadow: 0 4px 15px rgba(155, 169, 232, 0.4);
}

.save-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(167, 179, 230, 0.6);
}

.code-display {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #667eea;
}

.code-display p {
    color: #555;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.code-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

#codeText {
    font-size: 1.8em;
    font-weight: bold;
    color: #667eea;
    font-family: 'Courier New', monospace;
    padding: 10px 20px;
    background: white;
    border-radius: 6px;
    border: 2px solid #667eea;
}

.copy-button {
    background: #27ae60;
    color: white;
    padding: 12px 24px;
}

.copy-button:hover {
    background: #229954;
}

.copy-button.copied {
    background: #2ecc71;
}

@media (max-width: 900px) {
    html {
        background-color: #6177dd;
    }

    body {
        padding: 10px;
        background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
        min-height: unset;
    }
    
    /* Hide background image on mobile */
    body::before {
        display: none;
    }
    
    .container {
        padding: 15px;
        border-radius: 12px;
    }
    
    h1 {
        font-size: 1.5em;
        padding-bottom: 15px;
        margin-bottom: 15px;
    }
    
    h2 {
        font-size: 1.1em;
        margin-bottom: 8px;
    }

    .instructions {
        display: none;
    }
    
    /* Show tab buttons on mobile */
    .tab-buttons {
        display: flex;
    }
    
    .editor-container {
        flex-direction: column;
        margin-bottom: 15px;
        gap: 0;
    }
    
    .editor-section, .preview-section {
        min-width: 100%;
    }
    
    /* Hide preview section by default on mobile */
    .preview-section {
        display: none;
    }
    
    /* Show editor section by default on mobile */
    .editor-section {
        display: flex;
    }
    
    /* Hide inactive sections based on active tab */
    .editor-section.hidden {
        display: none !important;
    }
    
    .preview-section.hidden {
        display: none !important;
    }
    
    /* Show active sections */
    .editor-section:not(.hidden) {
        display: flex !important;
    }
    
    .preview-section:not(.hidden) {
        display: flex !important;
    }
    
    /* Hide section titles on mobile (tabs replace them) */
    .editor-section h2,
    .preview-section h2 {
        display: none;
    }
    
    canvas {
        width: 100%;
        height: auto;
        max-width: 100%;
    }
    
    .instructions {
        font-size: 0.85em;
        margin-top: 10px;
    }
    
    .controls {
        margin-top: 10px;
        justify-content: center;
    }
    
    .save-section {
        padding: 15px 0;
        margin-top: 15px;
    }
    
    .save-button {
        font-size: 1em;
        padding: 12px 30px;
    }
    
    .code-display {
        padding: 15px;
    }
    
    #codeText {
        font-size: 1.4em;
    }
}
