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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0a0a0a;
    min-height: 100vh;
    padding: 0;
    color: #e0e0e0;
}

.container {
    width: 100%;
    margin: 0;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

.search-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 100;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    transition: all 0.2s ease;
}

.search-toggle:hover {
    background: #2a2a2a;
    border-color: #667eea;
}

.random-toggle {
    position: fixed;
    top: 70px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 100;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    transition: all 0.2s ease;
}

.random-toggle:hover {
    background: #2a2a2a;
    border-color: #667eea;
    animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-2px, -1px) rotate(-1deg); }
    20% { transform: translate(2px, 1px) rotate(1deg); }
    30% { transform: translate(-1px, 2px) rotate(-1deg); }
    40% { transform: translate(1px, -2px) rotate(1deg); }
    50% { transform: translate(-2px, 1px) rotate(-1deg); }
    60% { transform: translate(2px, -1px) rotate(1deg); }
    70% { transform: translate(-1px, -2px) rotate(-1deg); }
    80% { transform: translate(1px, 2px) rotate(1deg); }
    90% { transform: translate(-2px, -1px) rotate(-1deg); }
}

.search-popup {
    position: fixed;
    top: 20px;
    right: 70px;
    z-index: 99;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.3s ease;
    max-width: 400px;
    width: calc(100vw - 100px);
}

.search-popup.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#searchInput {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    border: none;
    border-radius: 0;
    background: #1a1a1a;
    color: #e0e0e0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    outline: none;
    transition: all 0.3s ease;
    border: 1px solid #2a2a2a;
}

#searchInput::placeholder {
    color: #666;
}

#searchInput:focus {
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.4);
    border-color: #667eea;
    background: #222;
}

.results-info {
    text-align: center;
    color: white;
    margin-bottom: 20px;
    font-size: 1rem;
    opacity: 0.9;
}

.meme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    grid-auto-rows: 200px;
    gap: 0;
    margin-bottom: 0;
    width: 100%;
}

.meme-card {
    background: #1a1a1a;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    border: 1px solid #2a2a2a;
    margin: -1px 0 0 -1px;
}

.meme-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    border-color: #667eea;
}

.image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    background: #0f0f0f;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-wrapper.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.2), transparent);
    animation: shimmer 1.5s infinite;
}

.image-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a1a 0%, #0f0f0f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    font-size: 0.9rem;
}

.image-wrapper.loading .image-placeholder::before {
    content: '⏳';
    font-size: 2rem;
    opacity: 0.5;
}

.image-wrapper.error .image-placeholder::before {
    content: '🖼️';
    font-size: 2rem;
    opacity: 0.5;
}

.meme-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.meme-image.loaded {
    opacity: 1;
}

.meme-image.loaded + .image-placeholder {
    display: none;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
    padding: 8px 10px;
    z-index: 2;
}

.meme-card .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(4px);
    padding: 2px 6px;
    border-radius: 0;
    font-size: 0.7rem;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.empty-state {
    text-align: center;
    color: #e0e0e0;
    font-size: 1.2rem;
    padding: 60px 20px;
    display: none;
    max-width: 500px;
    margin: 0 auto;
}

.empty-state.show {
    display: block;
}

.suggest-text {
    margin-top: 30px;
    font-size: 1rem;
    color: #888;
    font-style: italic;
}

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

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    background: #1a1a1a;
    border-radius: 0;
    padding: 0;
    animation: slideUp 0.3s;
    border: 1px solid #2a2a2a;
}

.modal-image-wrapper {
    position: relative;
    display: inline-block;
}

.modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 0;
    display: block;
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.modal-content img.loaded {
    opacity: 1;
}

.modal-content img:hover {
    opacity: 0.9;
}

.cursor-animation {
    position: fixed;
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transform: translate(-50%, -50%);
}

.cursor-animation.active {
    opacity: 1;
}

.cursor-emoji {
    font-size: 2.5rem;
    transition: transform 0.1s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    animation: float 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
}

.cursor-animation.clicking .cursor-emoji {
    transform: scale(0.7) translateY(5px);
    animation: none;
}

.cursor-animation.clicking::before {
    content: '';
    position: absolute;
    width: 60px;
    height: 60px;
    border: 2px solid rgba(102, 126, 234, 0.6);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: ripple 0.4s ease-out;
}

@keyframes ripple {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

.cursor-text {
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    padding: 8px 14px;
    border: 1px solid #2a2a2a;
    color: #e0e0e0;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-8px) scale(0.9);
    transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cursor-animation.show-text .cursor-text {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.close {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 1.5rem;
    font-weight: bold;
    color: #e0e0e0;
    cursor: pointer;
    z-index: 1001;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-top: none;
    border-right: none;
    transition: all 0.2s;
}

.close:hover {
    background: #2a2a2a;
}


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

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

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .meme-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        grid-auto-rows: 150px;
    }
}

.notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.notification-icon {
    color: #4ade80;
    font-size: 1.2rem;
    font-weight: bold;
}

.notification-text {
    color: #e0e0e0;
    font-size: 0.9rem;
}
