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

:root {
    --primary: #6C63FF;
    --primary-dark: #5A52CC;
    --secondary: #FF6B6B;
    --success: #51CF66;
    --warning: #FFD93D;
    --danger: #FF6B6B;
    --bg-light: #F5F7FA;
    --bg-dark: #0F0F1E;
    --text-dark: #1A1A2E;
    --text-light: #FFFFFF;
    --border-color: #E0E0E0;
    --card-bg: #FFFFFF;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-dark);
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 40px;
    animation: slideDown 0.6s ease-out;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-light);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 25px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 600;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-5px);
}

.header h1 {
    font-size: 3em;
    font-weight: 800;
    margin-bottom: 10px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.header p {
    font-size: 1.1em;
    opacity: 0.95;
    font-weight: 300;
}

/* Content */
.content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 40px;
}

/* Joke Section */
.joke-section {
    animation: fadeIn 0.8s ease-out 0.2s backwards;
}

.joke-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    margin-bottom: 25px;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.joke-card:hover {
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
    transform: translateY(-5px);
}

.joke-content {
    text-align: center;
    width: 100%;
}

.joke-setup {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 20px;
    line-height: 1.6;
    animation: slideUp 0.5s ease-out;
}

.joke-punchline {
    font-size: 1.3em;
    color: var(--primary);
    font-weight: 700;
    font-style: italic;
    padding: 20px;
    background: rgba(108, 99, 255, 0.1);
    border-left: 4px solid var(--primary);
    animation: fadeIn 0.5s ease-out;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 99, 255, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #FF5252;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.3);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
}

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-light);
    font-size: 1.1em;
}

/* Messages */
.error-message,
.success-message {
    padding: 15px 20px;
    border-radius: 8px;
    margin-top: 15px;
    font-weight: 600;
    animation: slideUp 0.4s ease-out;
}

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

.success-message {
    background: rgba(81, 207, 102, 0.15);
    color: var(--success);
    border-left: 4px solid var(--success);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* History Section */
.history-section {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    animation: fadeIn 0.8s ease-out 0.4s backwards;
    max-height: 600px;
    overflow-y: auto;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.history-header h2 {
    font-size: 1.3em;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.clear-btn {
    padding: 8px 16px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.clear-btn:hover {
    background: #FF5252;
    transform: scale(1.05);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    padding: 15px;
    background: var(--bg-light);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 4px solid var(--primary);
    animation: slideUp 0.4s ease-out;
}

.history-item:hover {
    background: rgba(108, 99, 255, 0.1);
    transform: translateX(5px);
}

.history-item-text {
    font-size: 0.95em;
    color: var(--text-dark);
    line-height: 1.5;
    margin-bottom: 8px;
}

.history-item-time {
    font-size: 0.8em;
    color: #999;
}

.empty-message {
    text-align: center;
    color: #999;
    padding: 30px 20px;
    font-style: italic;
}

/* Footer */
.footer {
    text-align: center;
    color: var(--text-light);
    font-size: 0.95em;
    opacity: 0.9;
}

.footer a {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

.footer a:hover {
    border-bottom-color: var(--text-light);
}

.footer i {
    color: var(--secondary);
}

/* 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 fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.history-section::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 10px;
}

.history-section::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.history-section::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Responsive Design */
@media (max-width: 768px) {
    .content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .header h1 {
        font-size: 2em;
    }

    .header p {
        font-size: 1em;
    }

    .joke-card {
        padding: 25px;
        min-height: 200px;
    }

    .joke-setup {
        font-size: 1.2em;
    }

    .joke-punchline {
        font-size: 1.1em;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .history-section {
        max-height: 400px;
    }
}

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

    .header h1 {
        font-size: 1.5em;
    }

    .joke-card {
        padding: 20px;
    }

    .joke-setup {
        font-size: 1em;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.9em;
    }
}