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

:root {
    --primary-color: #6366f1;
    --primary-hover: #5855eb;
    --success-color: #10b981;
    --success-hover: #059669;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --warning-color: #f59e0b;
    --warning-hover: #d97706;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #475569;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    width: 310px;
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 14px;
    overflow: hidden;
    position: relative;
}

/* Animated background */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(120, 219, 255, 0.1) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-10px) rotate(1deg); }
    66% { transform: translateY(5px) rotate(-1deg); }
}

.container {
    position: relative;
    z-index: 1;
    padding: 30px;
    height: 100%;
}

h2 {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: slideDown 0.6s ease-out;
}

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

.card {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.6s ease-out;
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

h3 {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
    outline: none;
}

input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

input::placeholder {
    color: var(--text-muted);
}

button {
    width: 100%;
    padding: 12px 16px;
    margin: 6px 0;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transform: translateY(0);
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

button:hover:not(:disabled)::before {
    left: 100%;
}

#loginButton {
    background: var(--gradient-primary);
    color: white;
}

#loginButton:hover:not(:disabled) {
    filter: brightness(1.1);
}

.buy-button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.buy-button:hover:not(:disabled) {
    filter: brightness(1.1);
}

#analyzeQuiz {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    font-size: 13px;
    padding: 7px 9px;
}

#analyzeQuiz:hover:not(:disabled) {
    filter: brightness(1.1);
}

#logoutButton {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

#logoutButton:hover:not(:disabled) {
    filter: brightness(1.1);
}

button:disabled {
    background: var(--bg-tertiary) !important;
    color: var(--text-muted) !important;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none !important;
}

.user-info {
    text-align: center;
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

#loggedInUsername {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 15px;
}

#answerDisplay {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    color: var(--text-secondary);
    animation: fadeIn 0.6s ease-out;
}

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

.loading {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.loading::after {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid var(--text-muted);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.error {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    padding: 12px;
    border-radius: 8px;
    margin-top: 8px;
    font-size: 12px;
}

.update-notification {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 12px;
    text-align: center;
    display: none;
    animation: slideDown 0.6s ease-out;
}

.update-notification.mandatory {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border-color: rgba(239, 68, 68, 0.3);
}

.update-notification a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.info-card {
    background: rgba(51, 65, 85, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    margin-top: 16px;
    font-size: 11px;
    color: var(--text-muted);
    animation: slideUp 0.6s ease-out 0.3s both;
}

.info-card a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.info-card a:hover {
    color: var(--primary-hover);
}

.icon {
    width: 18px;
    height: 18px;
    display: inline-block;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive adjustments */
@media (max-width: 320px) {
    .container {
        padding: 16px;
    }
    
    h2 {
        font-size: 20px;
    }
    
    button {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    input {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* Animation delays for staggered effect */
#loginSection { animation-delay: 0.1s; }
#loggedInSection { animation-delay: 0.1s; }
#answerDisplay { animation-delay: 0.2s; }
.info-card { animation-delay: 0.3s; }