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

:root {
    --primary-color: #00d4ff;
    --secondary-color: #ff006e;
    --success-color: #00ff88;
    --error-color: #ff4444;
    --warning-color: #ffaa00;
    --bg-color: #1a1a2e;
    --text-color: #e0e0e0;
    --border-color: #333333;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0d1117 0%, #1a1a2e 100%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 10px;
}

/* Header */
header {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 20px;
    animation: slideDown 0.6s ease-out;
    padding: 15px 0;
}

header h1 {
    font-size: 1.8em;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.subtitle {
    font-size: 0.95em;
    opacity: 0.8;
    color: var(--text-color);
}

/* Main Content */
main {
    background: #16213e;
    border-radius: 15px;
    padding: 15px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.6s ease-out;
}

/* Upload Section */
.upload-section {
    margin-bottom: 30px;
}

.upload-box {
    border: 2px dashed var(--primary-color);
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(0, 212, 255, 0.05);
    margin-bottom: 20px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.upload-box:active {
    border-color: var(--secondary-color);
    background: rgba(255, 0, 110, 0.1);
    transform: scale(0.98);
}

.upload-box.dragover {
    border-color: var(--success-color);
    background: rgba(0, 255, 136, 0.1);
}

.upload-icon {
    width: 50px;
    height: 50px;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.upload-box h2 {
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 1.1em;
}

.upload-box p {
    color: var(--text-color);
    font-size: 0.9em;
}

/* Upload Form */
.upload-form {
    background: #0f3460;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.95em;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: #1a1a2e;
    color: var(--text-color);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.2);
}

/* Preview Section */
.preview-section {
    background: #0f3460;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    text-align: center;
}

.preview-section h3 {
    margin-bottom: 12px;
    color: var(--primary-color);
    font-size: 1em;
}

.preview-section img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

#fileInfo {
    color: var(--text-color);
    font-size: 0.85em;
}

/* Buttons */
.btn {
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    min-height: 44px;
    touch-action: manipulation;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: #000;
    width: 100%;
}

.btn-primary:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: #0f3460;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:active {
    background: var(--primary-color);
    color: #000;
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 30px;
}

.loading-spinner p {
    color: var(--primary-color);
    font-size: 0.95em;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Message */
.message {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    animation: slideIn 0.3s ease-out;
    font-size: 0.95em;
}

.message.success {
    background: rgba(0, 255, 136, 0.15);
    color: var(--success-color);
    border-left: 4px solid var(--success-color);
}

.message.error {
    background: rgba(255, 68, 68, 0.15);
    color: var(--error-color);
    border-left: 4px solid var(--error-color);
}

.message.warning {
    background: rgba(255, 170, 0, 0.15);
    color: var(--warning-color);
    border-left: 4px solid var(--warning-color);
}

/* Gallery Section */
.gallery-section {
    margin-top: 30px;
}

.gallery-section h2 {
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 1.2em;
}

.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input,
.sort-select {
    padding: 12px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: #0f3460;
    color: var(--text-color);
    min-height: 44px;
}

.search-input {
    flex: 1;
    min-width: 150px;
}

.search-input:focus,
.sort-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.2);
}

/* Emoji Gallery */
.emoji-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
}

.emoji-card {
    background: #0f3460;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.emoji-card:active {
    transform: scale(0.95);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.emoji-card img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 8px;
    border-radius: 8px;
}

.emoji-card h3 {
    font-size: 0.85em;
    margin-bottom: 4px;
    color: var(--primary-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

.emoji-card .meta {
    font-size: 0.75em;
    color: var(--text-color);
}

.loading-text {
    text-align: center;
    color: var(--text-color);
    padding: 30px;
    grid-column: 1 / -1;
    font-size: 0.95em;
}

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s ease-out;
    overflow-y: auto;
}

.modal-content {
    background: #16213e;
    margin: 10% auto;
    padding: 20px;
    border-radius: 12px;
    width: 95%;
    max-width: 450px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease-out;
}

.close {
    color: var(--text-color);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:active {
    color: var(--primary-color);
}

.modal-body {
    text-align: center;
}

.modal-body img {
    max-width: 100%;
    max-height: 250px;
    border-radius: 10px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}

.modal-body h2 {
    margin-bottom: 10px;
    color: var(--primary-color);
    font-size: 1.2em;
}

.modal-body p {
    color: var(--text-color);
    margin-bottom: 12px;
    font-size: 0.95em;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 15px;
}

.tag {
    background: #0f3460;
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8em;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.modal-actions .btn {
    flex: 1;
}

.upload-info {
    font-size: 0.8em;
    color: var(--text-color);
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

/* Footer */
footer {
    text-align: center;
    color: var(--text-color);
    margin-top: 30px;
    padding: 15px 10px;
    opacity: 0.9;
}

footer p {
    margin: 4px 0;
    font-size: 0.85em;
}

.footer-info {
    font-size: 0.8em;
    opacity: 0.8;
}

.footer-info a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid var(--primary-color);
    transition: all 0.3s ease;
}

.footer-info a:active {
    opacity: 0.7;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.6em;
    }

    main {
        padding: 12px;
    }

    .emoji-gallery {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 10px;
    }

    .filter-bar {
        flex-direction: column;
    }

    .search-input {
        min-width: 100%;
    }

    .modal-content {
        width: 95%;
        margin: 15% auto;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 8px;
    }

    header h1 {
        font-size: 1.4em;
    }

    main {
        padding: 10px;
        border-radius: 12px;
    }

    .upload-box {
        padding: 15px;
        min-height: 100px;
    }

    .emoji-gallery {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
        gap: 8px;
    }

    .emoji-card {
        padding: 10px;
        min-height: 120px;
    }

    .emoji-card img {
        width: 70px;
        height: 70px;
    }

    .modal-actions {
        flex-direction: column;
    }

    .btn {
        padding: 12px 16px;
        font-size: 0.9em;
    }
}
