:root {
    --primary-color: #4361ee;
    --primary-light: #4cc9f0;
    --secondary-color: #f0f2ff;
    --dark-color: #2b2d42;
    --light-color: #f8f9fa;
    --success-color: #4ad66d;
    --warning-color: #ffbe0b;
    --danger-color: #ef233c;
    --border-radius: 12px;
    --box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    --transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
    --gradient: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
}

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

body {
    font-family: 'Poppins', 'Roboto', sans-serif;
    background-color: #f9fbfd;
    color: var(--dark-color);
    line-height: 1.7;
    overflow-x: hidden;
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

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

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    animation: fadeIn 0.8s ease-out;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    padding-bottom: 1.5rem;
}

header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 4px;
    background: var(--gradient);
    border-radius: 2px;
}

header h1 {
    font-size: 2.8rem;
    margin-bottom: 0.75rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: inline-block;
    animation: pulse 3s ease-in-out infinite;
}

header p {
    font-size: 1.2rem;
    color: #6c757d;
    max-width: 700px;
    margin: 0 auto;
}

.simulator-container {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 2.5rem;
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid rgba(67, 97, 238, 0.1);
}

.simulator-container:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 28px rgba(67, 97, 238, 0.15);
}

.simulator-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: var(--gradient);
    animation: gradientBG 8s ease infinite;
    background-size: 200% 200%;
}

.input-section {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    justify-content: center;
}

.input-group {
    flex: 1;
    min-width: 220px;
    position: relative;
}

.input-group label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--dark-color);
    font-size: 1.05rem;
}

.input-group input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background-color: #f8f9fa;
    font-weight: 500;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.15);
    transform: translateY(-2px);
}

.btn {
    padding: 1rem 2rem;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #3a56e8 0%, #4895ef 100%);
    z-index: -1;
    opacity: 0;
    transition: var(--transition);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(67, 97, 238, 0.3);
}

.btn:hover::before {
    opacity: 1;
}

.btn:active {
    transform: translateY(1px);
}

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

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

.btn:disabled {
    background: #e9ecef;
    color: #adb5bd;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.controls {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}

.visualization {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.register-display {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.register {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    min-width: 120px;
    text-align: center;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    border: 1px solid rgba(67, 97, 238, 0.1);
    position: relative;
    overflow: hidden;
}

.register:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(67, 97, 238, 0.1);
}

.register::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--gradient);
}

.register-name {
    font-weight: bold;
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.register-value {
    font-family: 'Fira Code', monospace;
    font-size: 1.8rem;
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: var(--transition);
}

.register:hover .register-value {
    background-color: white;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.steps-container {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(67, 97, 238, 0.1);
}

.steps-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.steps-header h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.counter {
    background: var(--gradient);
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.2);
}

.steps {
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    min-height: 200px;
    font-family: 'Fira Code', monospace;
    white-space: pre-wrap;
    line-height: 1.8;
    border: 1px dashed #e9ecef;
    transition: var(--transition);
}

.steps:hover {
    border-color: var(--primary-color);
}

.step {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 8px;
    transition: var(--transition);
    background-color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-left: 3px solid transparent;
}

.step.active {
    background-color: rgba(67, 97, 238, 0.05);
    border-left: 4px solid var(--primary-color);
    padding-left: 1.25rem;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.1);
}

.step.completed {
    color: #6c757d;
    opacity: 0.8;
}

.initial-step {
    color: #6c757d;
    font-style: italic;
    text-align: center;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 1.1rem;
}

.explanation {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 2.5rem;
    box-shadow: var(--box-shadow);
    animation: fadeIn 1s ease-out;
    border: 1px solid rgba(67, 97, 238, 0.1);
}

.explanation h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    position: relative;
    display: inline-block;
}

.explanation h3::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 60px;
    height: 3px;
    background: var(--gradient);
    border-radius: 2px;
}

.explanation h4 {
    margin: 2rem 0 1rem;
    color: var(--primary-color);
    font-size: 1.3rem;
}

.explanation ol, .explanation ul {
    margin-left: 2rem;
}

.explanation li {
    margin-bottom: 0.75rem;
    position: relative;
    padding-left: 1.5rem;
}

.explanation li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.75rem;
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
}

/* Responsive styles */
@media (max-width: 768px) {
    .container {
        padding: 1.5rem 1rem;
    }
    
    header h1 {
        font-size: 2.2rem;
    }
    
    .register-display {
        gap: 1.5rem;
    }
    
    .register {
        min-width: 100px;
        padding: 1.25rem;
    }
    
    .register-value {
        font-size: 1.5rem;
        padding: 0.75rem;
    }
    
    .input-section, .controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .simulator-container {
        padding: 1.5rem;
    }
    
    .explanation {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .register {
        min-width: 80px;
        padding: 1rem;
    }
    
    .register-value {
        font-size: 1.2rem;
    }
    
    .steps {
        padding: 1rem;
        font-size: 0.9rem;
    }
}