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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #2D3748;
    color: white;
    overflow-x: hidden;
}

.app-container {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, #1A202C, #2D3748);
    padding: 1.5rem 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.app-title {
    font-size: 2.5rem;
    font-weight: 800;
    text-align: center;
    color: #4299E1;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.subtitle {
    text-align: center;
    color: #CBD5E0;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.nav-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-tab {
    background: rgba(66, 153, 225, 0.1);
    border: 2px solid #4299E1;
    color: #4299E1;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.nav-tab:hover, .nav-tab.active {
    background: #4299E1;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(66, 153, 225, 0.4);
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 250px 1fr 280px;
    gap: 1rem;
    padding: 1rem;
    min-height: 0;
}

/* Info Panel */
.info-panel {
    background: rgba(26, 32, 44, 0.8);
    border-radius: 15px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(66, 153, 225, 0.2);
}

.info-section h3, .pattern-thumbnails h4 {
    color: #4299E1;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.info-content p {
    line-height: 1.6;
    color: #CBD5E0;
    font-size: 0.9rem;
}

.thumbnail-grid {
    display: grid;
    gap: 0.5rem;
}

.thumbnail {
    background: rgba(66, 153, 225, 0.1);
    border: 1px solid rgba(66, 153, 225, 0.3);
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.thumbnail:hover {
    background: rgba(66, 153, 225, 0.2);
    border-color: #4299E1;
    transform: scale(1.02);
}

/* Canvas Area */
.canvas-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background: rgba(26, 32, 44, 0.8);
    border-radius: 15px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(66, 153, 225, 0.2);
}

.canvas-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.zoom-btn, .reset-btn {
    background: #4299E1;
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.reset-btn {
    width: auto;
    padding: 0 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

.zoom-btn:hover, .reset-btn:hover {
    background: #3182CE;
    transform: scale(1.1);
}

#canvas {
    border: 3px solid #4299E1;
    border-radius: 10px;
    background: white;
    cursor: crosshair;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    max-width: 100%;
    height: auto;
}

.canvas-info {
    background: rgba(0, 0, 0, 0.6);
    padding: 0.5rem 1rem;
    border-radius: 15px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #4299E1;
}

/* Control Panel */
.control-panel {
    background: rgba(26, 32, 44, 0.8);
    border-radius: 15px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(66, 153, 225, 0.2);
    overflow-y: auto;
}

.control-section {
    margin-bottom: 2rem;
}

.control-section h3 {
    color: #4299E1;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    border-bottom: 2px solid rgba(66, 153, 225, 0.3);
    padding-bottom: 0.5rem;
}

.control-section label {
    display: block;
    margin: 1rem 0 0.5rem 0;
    color: #E2E8F0;
    font-weight: 500;
    font-size: 0.9rem;
}

.control-section select, .control-section input[type="range"] {
    width: 100%;
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid rgba(66, 153, 225, 0.3);
    background: rgba(45, 55, 72, 0.8);
    color: white;
    font-size: 0.9rem;
}

.control-section select:focus, .control-section input:focus {
    outline: none;
    border-color: #4299E1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
}

.color-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: end;
}

.color-controls label {
    margin: 0;
}

input[type="color"] {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    transform: scale(1.2);
    accent-color: #4299E1;
}

.direction-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 1rem;
}

.direction-btn {
    background: rgba(66, 153, 225, 0.1);
    border: 1px solid rgba(66, 153, 225, 0.3);
    color: #4299E1;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.direction-btn:hover, .direction-btn.active {
    background: #4299E1;
    color: white;
}

/* Action Bar */
.action-bar {
    background: rgba(26, 32, 44, 0.9);
    padding: 1rem 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(66, 153, 225, 0.2);
    flex-wrap: wrap;
}

.action-btn {
    background: linear-gradient(135deg, #4299E1, #3182CE);
    border: none;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(66, 153, 225, 0.3);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(66, 153, 225, 0.4);
}

.action-btn.surprise {
    background: linear-gradient(135deg, #ED8936, #DD6B20);
    box-shadow: 0 4px 15px rgba(237, 137, 54, 0.3);
}

.action-btn.surprise:hover {
    box-shadow: 0 6px 20px rgba(237, 137, 54, 0.4);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #2D3748;
    padding: 2rem;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    border: 2px solid #4299E1;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
    color: #4299E1;
    margin-bottom: 1rem;
    text-align: center;
}

.modal-content input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(66, 153, 225, 0.3);
    border-radius: 8px;
    background: rgba(45, 55, 72, 0.8);
    color: white;
    font-family: 'Courier New', monospace;
}

.modal-content button {
    background: #4299E1;
    border: none;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    margin: 0 0.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.modal-content button:hover {
    background: #3182CE;
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .info-panel {
        order: 3;
    }
    
    .control-panel {
        order: 2;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }
    
    .app-title {
        font-size: 2rem;
    }
    
    .nav-tabs {
        gap: 0.5rem;
    }
    
    .nav-tab {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .main-content {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    #canvas {
        max-width: 100%;
        height: 300px;
    }
    
    .action-bar {
        padding: 1rem;
    }
    
    .action-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .color-controls {
        grid-template-columns: 1fr;
    }
    
    .direction-controls {
        grid-template-columns: 1fr;
    }
    
    .canvas-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(45, 55, 72, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #4299E1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3182CE;
}

/* Animation for loading states */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid #4299E1;
    outline-offset: 2px;
}