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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

nav a {
    color: white;
    text-decoration: none;
    margin: 0 1rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    transition: background-color 0.3s;
}

nav a:hover {
    background-color: rgba(255,255,255,0.2);
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

section {
    margin-bottom: 3rem;
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

h2 {
    color: #667eea;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

#patterns-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.pattern-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    aspect-ratio: 3/4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.pattern-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.pattern-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.pattern-card:hover img {
    transform: scale(1.05);
}

.pattern-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
    padding: 2rem 1rem 1rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.pattern-card:hover .pattern-overlay {
    transform: translateY(0);
}

.pattern-overlay h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.circle-card {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.circle-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.circle-card h3 {
    color: #495057;
    margin-bottom: 0.5rem;
}

.pattern-meta, .circle-meta {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.pattern-meta span, .circle-meta span {
    background: #e9ecef;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.9rem;
    color: #495057;
}

.pattern-meta .cost {
    background: linear-gradient(45deg, #28a745, #20c997) !important;
    color: white !important;
    font-weight: 600;
}

.pattern-meta .level {
    background: linear-gradient(45deg, #667eea, #764ba2) !important;
    color: white !important;
}

.difficulty {
    background: linear-gradient(45deg, #ff6b6b, #ffa500) !important;
    color: white !important;
}

.xp {
    background: linear-gradient(45deg, #4ecdc4, #44a08d) !important;
    color: white !important;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    background: linear-gradient(90deg, #f8f9fa, white);
}

.rank {
    font-weight: bold;
    font-size: 1.2rem;
    color: #667eea;
    min-width: 3rem;
}

.name {
    flex: 1;
    font-weight: 600;
    margin-left: 1rem;
}

.level {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.9rem;
    margin-right: 1rem;
}

.xp {
    color: #495057;
    font-weight: 500;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 3% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close:hover {
    background: rgba(255,255,255,1);
    color: #333;
    transform: scale(1.1);
}

.modal-body {
    display: flex;
    flex-direction: row;
    min-height: 500px;
}

.modal-image-section {
    flex: 1;
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border-radius: 12px 0 0 12px;
    padding: 1.5rem;
}

.modal-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 12px 0 0 12px;
}

.modal-info-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.modal-info {
    padding: 2.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.modal-info h2 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.modal-info .description {
    color: #666;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.requirements {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.requirement {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 1.25rem;
    border-radius: 10px;
    border-left: 4px solid #667eea;
    transition: transform 0.2s ease;
}

.requirement:hover {
    transform: translateX(5px);
}

.requirement strong {
    color: #495057;
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    #patterns-list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }

    .pattern-overlay {
        padding: 1.5rem 0.75rem 0.75rem;
    }

    .pattern-overlay h3 {
        font-size: 0.9rem;
    }

    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-width: none;
    }

    .modal-body {
        flex-direction: column;
        min-height: auto;
    }

    .modal-image-section {
        border-radius: 12px 12px 0 0;
        min-height: 250px;
        padding: 1rem;
    }

    .modal-image {
        border-radius: 12px 12px 0 0;
        height: 250px;
        object-fit: contain;
    }

    .modal-info {
        padding: 1.5rem;
    }

    .modal-info h2 {
        font-size: 1.5rem;
    }

    .requirements {
        margin-top: 1rem;
    }

    .requirement {
        padding: 1rem;
    }
}